Page 1 of 1

Path following - like on rails

Posted: Wed Dec 09, 2015 6:53 pm
by Klobo
HI all,

I'm new here and new in game development. I'm looking for a way to make shapes (objects) follow a curved path and turn at the same time.

To make it more simple, I have a square grid with defined nodes. I already implemented the code that makes the object follow waypoints but they cannot turn while moving - the object reaches the node, stops, turns on the spot to to the next waypoint and starts moving again.

I tried to change the offset of the ocject and play with the coordinates to make a fake pivot for the turn and it works. The main problem is that it seems to be dependent on the initial conditions.

Example: the object is facing north and then all the right turns work, but when I start the scenario with the object facing say east then the turns are all messed up (it will still turn right but during the turn it will be "teleported" to another position)

Any advice or any alternative method/solution to make an object turn "like on rails"

Thanks!

Re: Path following - like on rails

Posted: Wed Dec 09, 2015 8:47 pm
by Ref
Maybe something like this.
Left click and drag to change path.

Re: Path following - like on rails

Posted: Wed Dec 09, 2015 10:34 pm
by Klobo
I solved my problem... there were some rounding errors but yes thank you for the small program it is exactly what I was looking for

Thanks again!