- Home /
Move object through set of points
I'm making 3D runner game and need to move Player along the "road". Road is built at runtime, it can turn left or right(like arc) and also move down (with turn or not). In result it seems like curve road from mountain. I'm generate many central points with small distance between it to make something like curve, after i create a set of supporting points (left/right road point, left/right terrain point etc) with ±x/yOffset from central to generate meshes. How i can move player along central points?
I already tried to use Vector3.Lerp - it's works bad, because at some point, when moveSpeed is really great, T parametr (which would be between 0 and 1) momentally becomes >1 for example: lerpT = moveSpeed * Time.deltaTime
- if moveSpeed > 100 then product of moveSpeed and Time.deltaTime always > 1 and movement appears like jumps from one point to another.
P.S.: Sorry for my bad english, i'm from Belarus =)
maybe set a few different speeds. Fast, medium and slow and test the distance from the end point to deter$$anonymous$$e the speed. When the character gets close enough to the central points make the next central point the target and therefore T will never be more than 1.
This:
Vector2.Lerp( startPos, targetPos, Time.deltaTime * speed );
is what I'm using at the moment and I also have multiple targets. I have managed to control the jittery/jumps by changing the speed depending on the character's proximity to the targets.
Hope this helps
Your answer
