H
Hepero
Guest
So when i click play (f5) and start walking in my platformer game and kill enemy the game maker studio 2 runner freezes and i have to close it with task manager.
I got 2 "whiles" in enemy object (step event)My first thought: infinite loop.
Check your "for" and "while" loops, particularly in any collision code with the enemy object.
If you still can't find it, I recommend posting your code.
i dont know. How do i check that?You likely have an infinite loop. Do you have any loops that run when you kill the enemy?
So this is my Enemy Object step event:Post the code.
and no there is no issue when enemy is walking, only when i kill enemySo the problem does not occur until you kill the enemy, correct? When the enemy is idly walking around, there is no issue?
Please post the code that gets executed when you kill the enemy object, and if applicable, the enemy's Destroy Event.
yeah i use 2 objects for enemy. One is oEnemy that is just walking around and then when i kill it it changes to oDead (oDead has 2 sprites)So are you changing sprites when the enemy dies or are you changing to a different object that uses a different Sprite than the one the enemy normally uses? if so, it sounds like your origin-to-bounds measurements are not equal, so when you kill the enemy it's turning into a Sprite that is automatically putting it into the ground. This forces an endless loop because if either of your speeds are 0, it can't move outside of the collision.
Thought:
Remove the code that changes the enemy into oDead upon death, and instead just destroy the instance (for now.)
If this removes the freezing problem, then the problem code is in the oDead object. If it does not, then the problem is elsewhere in the oEnemy code.
im not sure how to remove that bcs im newbie in coding and game developing, but im following the youtube tutorial from Shaun Spalding, maybe that will help you or smthThought:
Remove the code that changes the enemy into oDead upon death, and instead just destroy the instance (for now.)
If this removes the freezing problem, then the problem code is in the oDead object. If it does not, then the problem is elsewhere in the oEnemy code.
Ok so it worked but how do i make the death object?It's your sprites. Your dead object sprite is set up in such a way that it is forcing a collision. Set the dead object's sprite to <No Sprite> and see if that makes the freeze go away.
Whitch info? You mean like size or what ?Post the Sprite info for all of the sprites that the dead object uses and Sprite that the enemy uses.
Ok i have this codeThought:
Remove the code that changes the enemy into oDead upon death, and instead just destroy the instance (for now.)
If this removes the freezing problem, then the problem code is in the oDead object. If it does not, then the problem is elsewhere in the oEnemy code.