phent_addvellocal

Posted By: demiGod

phent_addvellocal - 11/18/06 17:32

Someone please can explain to me why using the code below the ball receives random velocities and not a constant "kick"?

The direction vector seems to work properly but the speed sometimes its forwards and sometimes backwards or upwards at random values.
Thanks in advance.

Code:

function testVelocities()
{
var speedVector[3];
var angleVector[3] = 45,0,0;
vec_set(speedVector, vector(10000,0,0));
vec_rotate(speedVector,angleVector);
phent_addvellocal(ball,speedVector,vector(20,0,0));
}


Posted By: jcl

Re: phent_addvellocal - 11/20/06 15:35

Speeds are measured in units per tick, so the value of your speed vector doesn't make sense. 50 or 100 are realistic values.

You'll find an example for kicking a physics ball in the latest AUM issue.
Posted By: demiGod

Re: phent_addvellocal - 11/20/06 15:54

Thanks for answering jcl,

Unfortanly i have serious problems with physics questions, however i am trying to learn and search for some support. If we search this forums for "phent_addvellocal" it appears 3 results with a few information on that matter.

Anyway, thanks for your reply. I will check the AUM issue.

Btw, one more question. Should i use phent_addvellocal to kick an object like a ball and give it some effects like a kick with lateral curvature or "banana curvature" depending on vector* pos values? Or should i use other function?

Thanks.

Edit:
You see, the problem is that i had to scale up the world several times because of collision detection problems with the ball at high velocities.
So i have to apply higher velocities to the objects. With phent_addvelcentral it works ok, but with vellocal the ball has random movements.
Posted By: jcl

Re: phent_addvellocal - 11/21/06 12:07

Yes, but even in a scaled up world, 10000 seems far too high. At that speed your ball would be out of the whole level in half a second. But in your case, the problem is not even the linear speed of the ball but the rotation speed that you give it by a non-central kick. Such a speed would cause a spin of several thousand rotations per second, which is certainly a higher rotation speed than a physics engine can manage. A real ball would explode at such a spin.

Reduce the speed, and make the kick less central. This shifts the ball spin into more reasonable ranges. Also, increasing the physics frame rate gives a higher accuracy at the price of a lower overall frame rate.
© 2023 lite-C Forums