Path following - like on rails

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Klobo
Prole
Posts: 4
Joined: Wed Dec 09, 2015 6:38 pm

Path following - like on rails

Post 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!
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Path following - like on rails

Post by Ref »

Maybe something like this.
Left click and drag to change path.
Attachments
fly.love
spline path
(172.51 KiB) Downloaded 197 times
Klobo
Prole
Posts: 4
Joined: Wed Dec 09, 2015 6:38 pm

Re: Path following - like on rails

Post 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!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests