how to move object while following spline path?

example video

Hi. I’m trying to do make run game like video up there.

My goal is my character will be running on curved roads and roads will pre-set up pass by specific points. user only can controll left and right direction. character will run forward automatically with following road line.

First I had tried to use curved shader, and it was not fit with my goal. It was for infinite run, infinite world.

so I thought I need to make roads that pass by specific points.

So I made roads with spline curve.
And Now I can make follow the spline curve to my character.

But problem is I have no idea how to move my character while it is following spline curve. I wanna move my character left or right on roads like that video.

Is there any idea to move object while it is running on spline curve?
Or is it wrong to use spline path to this?
I would be very thankful if someone give me hint or advise.

Thanks for reading it.

I set up one object follows path, and add my character to this object as children.
hope it is helpful answer for someone

Hi, I think you can move your character in forward direction constantly, and get the rotation of the next closest normal’s rotation on the curve. So it will rotate along the path while moving forward.
So don’t really make your character follow the road but make it rotate along the road while constantly moving forward.

While this is happening on update, it should be easy to just use vector3.right to move it right and left directions.


PS. there is also a really cool free asset called “Bezier Path Creator” that you can use for this kind of thing: