Following a predefined path, advice

Im having a hard time figuring out the best way to add an object to my game and get it to follow a predefined path.

Im not sure if i need to create a bezier cure or if i can use waypoints or path finding. I thought about waypoints but its going to be difficult because of how my map is and its not really a tile map. Pathfinding will also be difficult because I cant set borders on the path because of the curved paths. So i think the only way will be bezier curve but i have no idea how to get this set up correctly. I have tried http://developer.coronalabs.com/code/bezier-curve-corona-sdk but I find if i switch devices the paths in a different position on the map, the object also moves very slow on the bends using this

Anybody have any suggestions? An example of the type of map im using is attached

I’d recommend pathfinding based on a grid.

Your map isn’t a grid? Doesn’t have to be – you can lay one down “underneath” the actual map. Your objects can use the underlying grid to determine where to go.

Here’s an example in Tiled – I took your picture, grabbed a tileset (I just needed the one tile) and laid out a grid of “walkable” areas:

plutobasemapexample.png

If you wanted more control you could decrease the size of the tiles from 32x32 to 16x16, or even 8x8 to get into all the nooks and crannies of the map.

What I’d do next is turn off the Image Layer and then export that map and use it as the base for the Jumper pathfinding library which you can find here:

https://github.com/Yonaba/Jumper

That is an awesome library. And yes, it’s grid-based, and your maps aren’t, but you can lay a grid underneath and nobody but you will ever know.

Hopefully that is a workable idea for you and I’ve given you enough info to get started (if you choose this method).

 Jay

Thank you this is helpful, i didn’t think of that. Only issue is im using million tile engine already to load my map mainly for the screen bounds and scrolling / zooming, so I would need to work out how they can interact with each other

I’d recommend pathfinding based on a grid.

Your map isn’t a grid? Doesn’t have to be – you can lay one down “underneath” the actual map. Your objects can use the underlying grid to determine where to go.

Here’s an example in Tiled – I took your picture, grabbed a tileset (I just needed the one tile) and laid out a grid of “walkable” areas:

plutobasemapexample.png

If you wanted more control you could decrease the size of the tiles from 32x32 to 16x16, or even 8x8 to get into all the nooks and crannies of the map.

What I’d do next is turn off the Image Layer and then export that map and use it as the base for the Jumper pathfinding library which you can find here:

https://github.com/Yonaba/Jumper

That is an awesome library. And yes, it’s grid-based, and your maps aren’t, but you can lay a grid underneath and nobody but you will ever know.

Hopefully that is a workable idea for you and I’ve given you enough info to get started (if you choose this method).

 Jay

Thank you this is helpful, i didn’t think of that. Only issue is im using million tile engine already to load my map mainly for the screen bounds and scrolling / zooming, so I would need to work out how they can interact with each other