Destroy happening next frame?

fmarkusfmarkus Member Posts: 42
edited April 2012 in Working with GS (Mac)
Hi all,
I was wondering... When you use 'destroy' to remove an object, is that object removed from the scene immediately and any further script is stopped or... does the destroy happen next frame and the scripts are still going on?
I have a bug that makes me think that destroy is the frame after the call and scripts keep going on until the next frame too...

Answers

  • GreenHavenGamesGreenHavenGames Member Posts: 62
    Put a debug behavior after the destroy behavior and see if it fires off.
  • GreenHavenGamesGreenHavenGames Member Posts: 62
    Log debugging statement behavior to be precise.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    In my experience, it's best to assume a destroy statement will remove the actor AND stop its scripts immediately but best to also assume that that may not be the case. I've seen actors' rules where the destroy statement halted the rules and I've seen actors' rules where the behaviors after the destroy statement continue to run. My guess is that because behaviors are running parallel to each other, a rule such as

    When game.over is true
    destroy this actor
    log debugging statement "still alive!"

    May destroy the actor at the same time it logs the statement. So to be save, try to avoid a situation where a behavior is running parallel to a destroy behavior.
Sign In or Register to comment.