12.10.2011, 19:13
(
Последний раз редактировалось uPeppe; 13.11.2011 в 07:16.
)
I made a Pool Script and I move balls' position with this code (done every 20ms):
That's a small code that works perfectly, but I have a problem with ball rotation (that with SetObjectRot). Here's how I did it:
So I realized that this isn't the right way to rotate a ball..
Who can tell me the right algorithm to rotate a ball that's moving, knowing the angle of direction and the moving's speed?
PS: Note that "a" is the angle of ball's direction.
Код:
GetObjectPos(PoolBall[i][bObject], x1, y1, z); x1 += ((PoolBall[i][bSpeed]/50) * floatsin(-a, degrees)); y1 += ((PoolBall[i][bSpeed]/50) * floatcos(-a, degrees)); SetObjectPos(PoolBall[i][bObject], x1, y1, z);
Код:
GetObjectRot(PoolBall[i][bObject], rx, ry, rz); rx -= ((20.0 * PoolBall[i][bSpeed]) * floatcos(-a, degrees)); ry += ((20.0 * PoolBall[i][bSpeed]) * floatsin(-a, degrees)); SetObjectRot(PoolBall[i][bObject], rx, ry, rz);
Who can tell me the right algorithm to rotate a ball that's moving, knowing the angle of direction and the moving's speed?
PS: Note that "a" is the angle of ball's direction.