GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

If actor is destroyed are all behaviour following it destroyed too?

helpingtogrowhelpingtogrow Posts: 60Member, PRO

I have a number of behaviours to do after an actor is destroyed. What happens to
these behaviors if the destroy actor is implemented before they happen?
Thanks

Comments

  • MetalloMetallo Posts: 82Member, PRO

    They won't happen.

  • bob loblawbob loblaw Posts: 181Member, PRO

    bahaviours first, then destroy.

    gs does do this weird thing sometimes though where it will carry over the behaviour of one actor instance to an instance on a fresh new scene.

  • MetalloMetallo Posts: 82Member, PRO

    I had a big problem in my game for exactly this, and the behaviours after the death didn't happen at all. GameSalad is procedural, it runs the commands as written and if the object is destroyed everything after the event is ignored.

  • Two.ETwo.E Posts: 523Member

    You are correct @Metallo.

    If a destroy behaviour occurs, any remaining behaviours / rules will not be activated since the actor no longer exists.

    GS behaviours and rules are triggered from top to bottom in an actors logic in the one frame. So if a behaviour changes a rule that will come next, that rule will be applied in the same frame. If that rule is before, the rule will be applied on the next frame.

    Each actor's logic is done based on Bottom to Top in the Layer.

    This information is very helpful in making sure rules are placed in the correct order as needed.

    Hope it Helps,

    Two.E

  • tatiangtatiang Posts: 11,636Member, Sous Chef, PRO, Senior Sous-Chef

    If you need something to happen when an actor is destroyed:

    When [actor should be destroyed]
         Spawn actor [DoStuff]
         Destroy actor

    Then put all of the rules you want to happen in the DoStuff actor.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • helpingtogrowhelpingtogrow Posts: 60Member, PRO

    My game is not changing scenes after I destroy an actor. I tried the DoStuff suggestion above but to no avail.

  • IceboxIcebox Posts: 1,476Member

    Another way is to add a timer

    When the condition is true
    - put your code here
    - Timer After 0.03 seconds
    destroy actor

    Your code will have time to run before the actor gets destroyed, and its instant so it wont affect the gameplay

  • bob loblawbob loblaw Posts: 181Member, PRO

    @helpingtogrow said:
    My game is not changing scenes after I destroy an actor. I tried the DoStuff suggestion above but to no avail.

    are your change scene and destroy behaviours in the same actor? that would possibly be the issue.

    lots of ways you can go. the way i go is to have a game state variable. default setting to 0. then for example, change to 1 when play starts, 2 for level fail, 3 for level pass and 4 for pause (don't need this but helps if using a reset function on a pause screen).

    all your actors/behaviours work based on the above states. eg. if you have a score tile to display scores and other stuff when the level is complete, you'd have a behaviour that says if game state = 3, do a bunch of stuff, maybe including a button that changes scenes when pressed. within your actor you'd have a rule that checks the same condition but a destroy behaviour.

Sign In or Register to comment.