Simple Maths
#1

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.
Reply
#2

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
Reply
#3

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?
Reply
#4

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.
Reply
#5

I will give that a go, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)