SA-MP Forums Archive
Simple Maths - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Simple Maths (/showthread.php?tid=324163)



Simple Maths - MP2 - 08.03.2012

Hi.

I have two points. I am going to use the new 0.3e InterpolateCameraPos function to move the camera between these points. I want to move it at a speed of, for example, 3 units per second. How would I go about doing that? I know I need to use GetDistanceBetweenPoints, I'm just stuck on the simple maths part. The 'speed' parameter in the function is in miliseconds, so how do I convert the distance to those miliseconds?

Any help is appreciated.


Re: Simple Maths - wups - 08.03.2012

time = distance / velocity(speed).

Lets say speed is 1, and distance is 10. So you get 10seconds. Multiply that by 1000 and you'll have your miliseconds.

EDIT: Oh I see. There is no speed value. I think it's the same as with MoveObject.
If the time parameter means time needed for the camera to reach the destination, then you have to use proportion.
Ex: You want to move one unit per half a second
Код:
1 unit - 500 ms
10 units - x ms
x = 500ms*10units/1unit



Re: Simple Maths - MP2 - 08.03.2012

The parameter is the amount of time it should take to complete the move. I still don't understand though, could you give me an example?


Re: Simple Maths - wups - 08.03.2012

Quote:
Originally Posted by MP2
Посмотреть сообщение
The parameter is the amount of time it should take to complete the move. I still don't understand though, could you give me an example?
pawn Код:
new Float:Distance = GetDistanceBetweenPoints();
new const TimeForUnit = 500;
new Time = floatround(TimeForUnit*Distance);
I don't know how to explain more simply than that.


Re: Simple Maths - MP2 - 08.03.2012

I will give that a go, thanks.