• 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 How to check for an unobstructed path.

hans

Member
Hello, is there a way to see if an instance has an unobstructed path to a specific instance. I'm currently trying to implement an enemy spawner that first checks to see if the enemies it's spawning are able to travel to the player before spawning enemies.
 

Rob

Member
It depends on how you're doing the path. if it's a straight line you can use something like collision_line.

Code:
obstacle = collision_line(fill in the entries)
Obstacle would hold either an instance ID or noone.
 

hans

Member
Not exactly, i'm trying to see if a path is possible from the spawner object to the player object, and if there is no possible path to not spawn enemies. This would have to be able to circumnavigate a maze like structure.
 
C

Catastrophe

Guest
Basically, set up an mp_grid, and then use mp_grid_path. If it returns false, you've got no path. An alternate is an A* extension.

Sidenote: If you're using this method, you may as well use it for your actual pathfinding as well.

But yeah pathfinding a maze will require a bit of setup like this.
 
Last edited by a moderator:
Top