Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Game Maker: Game crashing when collision happens.

  • 09-10-2016 9:17pm
    #1
    Registered Users Posts: 101 ✭✭


    Hey, I'm trying to make it so that when 2 objects collide, one gets destroyed while the other remains. I've almost done that, but as soon as the objects collide, the game crashes. I am unsure why, and I haven't experienced this before. So if someone could even just point me in a good direction, that would be appreciated.

    This is the collision event on one object ("EnemySpaceship"), and ties to the other object ("Spaceship1"). I have a drag and drop action to "Destroy the Instance", and then another action of code which is:

    EnemySpawn.dead = true;

    Then I have an object called "EnemySpawn" which sorts the spawning for the enemy. It has a Create event with the code:

    instance_create(x,y, EnemySpaceship)

    It also has an Alarm event with the code:

    instance_create(x, y, EnemySpaceship);

    And finally it has a Step event with the code:

    if dead = true
    {
    alarm[0] = 60
    dead = false
    }

    The error that comes up says:

    "FATAL ERROR in
    action number 2
    of Step EventSpaceship1
    for object EnemySpaceship:

    Unable to find any instance for object index '2' name 'EnemySpawn'
    at gml_Object_EnemySpaceship_CollisionEvent_0_2 (line 1) - EnemySpawn.dead = true;"

    I think that's all I can supply for it, Thanks for taking the time to look at it.


Comments

  • Moderators, Category Moderators, Computer Games Moderators Posts: 50,776 CMod ✭✭✭✭Retr0gamer


    What's happening is you are destroying the object but the code running after that event is now looking for that object that isn't there anymore. That's causing the crash. You need to stop that code after the destroy event.


Advertisement