Pathing problem - enemy won't recognize randomly spawned walls

Stamos22

Member
Hello,

Thanks to the help of the fine people on this forum I've managed to get some pathfinding going! My enemy object will navigate objects that I've placed in the room using the mp_grid functions and it's all pretty neat for someone brand new to game making.

However, I've hit a problem that I've been trying to sort out all day to no avail.

When I use a spawner to place random walls in the room, the pathfinding doesn't work. The enemy just ignores any walls placed via the spawner. I can't figure it out. The pathing avoids the walls when I place them by hand, so something is lost in translation when they get spawned by the object, I'm just not sure what. I've tried messing around with the order in which the objects are created etc but that hasn't seemed to help.

If anyone has any ideas I'd greatly appreciate them.

Thanks for any help!
 

Stamos22

Member
Of course I finally figure it out after posting... sigh.

In case anyone else has this problem, the solution for me was to have my spawner spawn the grid and the enemy object instead of having the grid placed in the room at creation. I guess it was just a matter of having the objects places before the grid was drawn? I just didn't realize how to do that until now. Derp.
 

Nidoking

Member
You should be able to have the grid there, as long as you add the newly-created walls to the grid before calculating the path.
 
Top