# Position prediction

## Recommended Posts

Hi.

Im trying to predict some element position in future ( after 1 second).

Gta returns velocity in meters per 1/50 seconds, so i need ot confirm my calculation.

Is this right way?

x, y, z = getElementPosition ( element )

sX, sY, sZ = getElementVelocity ( element )

-- Find predicted position after 1 second

-- rich velocity in meters pre second ( not 1/50 second )

sX = sX * 50

sY = sY * 50

sZ = sZ * 50

-- predicted position. "1" is 1 second here, added it just to show

predictedX = x + sX * 1

predictedY = y + sY * 1

predictedZ = Z + sZ * 1

Is this correct way to find element position after 1 second?

Thanks!

I did a little test, and seems more or less right.

Appears its not not exactly 1/50 maybe.

The calculated position was off by about 0.7 units.

I did a little test, and seems more or less right.

Appears its not not exactly 1/50 maybe.

The calculated position was off by about 0.7 units.

Show code of test please. Wich speed did u give to element in test?

It was just setting the speed to 0.2 in a render function, checking the position twice with 1 second delay.

## Create an account

Register a new account