• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

RPG/Tactics style movement with an MP grid?

Dr_Nomz

Member
I've been able to have AI on an NPC to move around an environment for awhile now, but can I apply that to a tactics/RPG style of grid movement? So I can have NPCs move one grid space at a time?

I usually use mp_grid_path to plan out where my NPC will go, can that work for grid based stuff?
 

woods

Member
mp_grid_path

With this function you can create a path that will navigate from a start point to a finish point using an mp_grid that you have previously defined, avoiding any obstacles that have already been added into the grid.

its almost as if it was designed to be used that way ;o)
 

Vusur

Member
I link myself for some useful links :)

Simple grid movement is mp_grid_path, I mean... it's in the name ;)
Just tell the mp_grid valid and invalid cells, and set the allowdiag argument to false.
For more complex grid movement, i.e. terrain cost, range preview and so on, you need your own pathfinding. A* or atleast Dijkstra. Maybe you get away with Flood Fields, if terrain cost is not important. It sounds hard, is not that trivial (depending on your programming level), but it's also not rocket science and actually fun to do. Imho built-in motion planning is quite limited.
 

Dr_Nomz

Member
Wow, I didn't know Refresher Towel made such cool tutorials. Thanks for the tip.

I'll get into studying that for the next week or so, I'll be back later if I have questions.
 

Vusur

Member
Always worth checking the profile posts from time to time here right side. Found it by accident :)
I would probably start with Red Blob Games due his interactive graphics. The A* post builds up from the easiest one to a full A*. While the code is python(?), it's still easy to understand. Sure, we can't copy that, but it's about the algorithm.
RefresherTowel is nice afterwards, when the algorithm is more clear. But thats me and I'm a little paranoid and somehow assum, people would just copy&paste code. No offense :)
The question is, do you need A* or is Dijkstra, maybe even FloodField/Breadth First Search enough. All these algorithms are also just the start for pathing. They make a useable grid. The pathing itself needs still work. Each Cell? Waypoints? For this, Red Blob Games is your source again.
But I'm sure you'll figure it out what you need.

happy coding!
 
Top