I'm trying to make a tile-based movement, and in order to handle collisions before the player moves off the grid, I need to check if there is a "solid" object in front of them. My current solution is to assign the boolean variable "walkable" to an object and then compare against it, but I've hit a roadblock; all the functions I can find innate to GameMaker need you to specify a discreet instance of an object to compare against. How can I check fo any potential object that might occupy an area on the screen?
For completeness, here is my current code. I'm using "any_object" as a placeholder for what I want to do, though if you have a solution which gets around this then I'm happy to hear it.
For completeness, here is my current code. I'm using "any_object" as a placeholder for what I want to do, though if you have a solution which gets around this then I'm happy to hear it.
GML:
//Right
if (position_meeting(x+96,y,"any_object")) && (instance_position(x+96,y,"any_object").walkable)
{
if (keyboard_check(ord("D"))) && (!moving)
{
moving = true;
target_x += 96;
sprite_index = spr_playerright;
}
} else { sprite_index = spr_playerright; }