• 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!

GameMaker Navigating a simple 'house map'

D

DukeMeister

Guest
Hi all. I'm wondering if there's way to have a character automatically navigate a fixed map (e.g. like a normal house, with about 60 interconnected rooms) without using the built-in pathfinding? So, knowing just which rooms adjoin other rooms, is there a simple way of doing this in GML? Thanks.

edit:
Just to clarify, I don't need the characters to visibly move on the map, in real time. Just to be able to work out 'what is the (minimum) list of rooms to get from room 11 to room 27, say?' e.g. "12, 15, 16, 21, 27"

It seems clear I'd need to create a data structure that describes for each room, each exit and to which room it leads. Although a bit of drudge work I can do this, and have started on that. In theory that's all you'd need, but how the algorithm would look in GML, I'm not sure.

update:
So I'm thinking something like this, which I've got partially working:

Basically work backwards from the destination room.

For each exit from that room
Visit the room it exits to, except:
  • Ignore rooms that have already been visited
  • Ignore the exit back to the previous room
For each exit from that room...
etc.
Continue until the Origin room is encountered
OR
The only exit is back to the previous room (bad path)
OR
Number of rooms visited is > the shortest path already found
Something like that anyway. This definitely seems to beg for a recursive solution, but initially I might just do it procedurally. The hard part is to just keep track of everything.
 
Last edited by a moderator:
D

DukeMeister

Guest
Happy to share any code/knowledge of how I got this done if anyone needs it. I'm a newb to GML so it took me longer that it should've and I might've done things weirdly.. but it works.

(PS did the links show up? It looks fine to me but I have a warning about adding links due to < 5 posts.)
 
Top