- Home /
how to move object while following spline path?
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.
Answer by JI-Kim · Jun 12, 2021 at 01:55 AM
I set up one object follows path, and add my character to this object as children. hope it is helpful answer for someone
Answer by berkun5 · Aug 09, 2021 at 08:03 AM
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: https://assetstore.unity.com/packages/tools/utilities/b-zier-path-creator-136082
Your answer
Follow this Question
Related Questions
Camera path with user entry stops 0 Answers
Dynamically Add Points to Spline 1 Answer
Recommendations for a script/plugin for creating set, curved paths 2 Answers
How to make objects running by Curve? 0 Answers
object follow a spline path 1 Answer