M
mall0c
Guest
I have found some weird behavior in GameMaker during the making of my current game and need some advise on how to fix this.
I was able to reproduce it for a very simple case:
Consider a 2D topdown game where a player object can move through the room. Also, there are some tree objects.
Because I want my player to be able to pass before and behind the trees, I set the player's depth to -y every step and the trees' depth to -y on create. Everything works fine so far. But now I also call the "instance_destroy" function on some of the trees to remove them from the room after they have been created. When I move my player to the y position of a tree I have destroyed, the sprite will disappear. If I move one pixel up or down, it reappears. This happens every time I use a function like "instance_destroy" or "instance_deactivate...".
Do you have any idea why that happens and how I can fix it?
EDIT: Also, this only happens when the player moves upwards.
I was able to reproduce it for a very simple case:
Consider a 2D topdown game where a player object can move through the room. Also, there are some tree objects.
Because I want my player to be able to pass before and behind the trees, I set the player's depth to -y every step and the trees' depth to -y on create. Everything works fine so far. But now I also call the "instance_destroy" function on some of the trees to remove them from the room after they have been created. When I move my player to the y position of a tree I have destroyed, the sprite will disappear. If I move one pixel up or down, it reappears. This happens every time I use a function like "instance_destroy" or "instance_deactivate...".
Do you have any idea why that happens and how I can fix it?
EDIT: Also, this only happens when the player moves upwards.