April 1st, 2012, 05:05 AM
How would I move an object smooth and fast?
So lets say I have unit vector 'a' as direction.
To move an object to the direction I would use
object.Position=object.Position + a*speed, right?
If the speed would be something like 5 it would just teleport 5 units towards the direction..
I could use some loops to move it and keep the speed under 1 unit..But..
That's slow since the smallest sleep would be the time from frame to another frame.
I can't get an object to move smooth and fast...
April 1st, 2012, 08:32 AM
To get something smooth, you should have at least 30 frames per second (fps) and higher is better.
You say you want to move it fast with 5 unit in speed, but speed is defined by the distance over a specific time.
You have to ask if the speed should be 5 unit/frames directly or 5 unit/second.
If you want to work with seconds, you will then have to calculate the unit/frames, depending at the fps.
e.g. 5 unit/second with 30 fps will have the actual frame speed at 0,16 unit.
April 2nd, 2012, 12:32 PM
Originally Posted by MrFujin
Some-kind of a loop with smallest sleep and;
position = position+direction*0.16
April 2nd, 2012, 01:31 PM
Try it and see how it looks.
But if you only have that calculation in a loop, it will go much faster than the "5 unit/second".
For example, in my test, it takes about 5 milliseconds to get from 0 to 5 with a step at 0.16 while it prints out "Hello World". (tested with Java)
But this is of course without any use of sleep "cheating"