- Home /
Extremly long space journey via time stamp
Hi Guys,
I have to time stamps. One for starting time (now minus 1000 seconds) and another for the arrival time (now plus 1000 seconds). At the same time I have two Vector3 providing the position where the starting time should have started and where the ending time should arrive. I actually want to travel from one Vector3 (start) to the other (arival).
The best way I can imagine is to calculate the position in every update-step.
The formular would be like this
Upate() {
nowPos = startPos + (endPos-startPos) * (nowTime-startTime)/(endTime-startTime)
}
Although it works, but the spacefighter sometimes jumps forward a little and forth instead of sliding...
I guess it has to do with double/float inaccurate calculations.
Someone has another way to approach this?
Kind regards
You timebase will need to be scaled to 0->1
Undertaking any large movement will result in large jumps if you do it quickly, naturally, whether you move manually or by Lerp.
yeah thats what i though aswell thats why i created waypoints for smaller distances ... but that cant be the best solution..
Applying a sin-in-out curve to your Lerp will help smooth out the extents. Check out the Animation Curve for an easy way to do this. There is also the mathfx library floating around out there which has some more efficient and interesting smoothing functions. Either way, you'd want to derive the time value of your Lerp by either evaluating a curve or by first passing it into a mathfx smoothing function. Then your ship will smoothly start and end it's journey. A curve will allow fine, visual, control but is slightly slower then the pure math functions.
Your answer
Follow this Question
Related Questions
C# CS0266 error for multiplying by a decimal 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
summing up items price in runtime 1 Answer
Ok, going to try to reach out on this issue one more time. 3 Answers