How can I make a rule or option where an actor will destroy if another actor has also been destroyed

If I have a touch event that destroys an actor how can I make it so that actor 2 if touched will only destroy if actor 1 has been destroyed?

Comments

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

    That's what game attributes are for. Make a boolean attribute called game.actor1dead.

    Actor 1:
    When touch is pressed
         Change attribute game.actor1dead to true
         Destroy actor

    Actor 2:
    When touch is pressed and attribute game.actor1dead is true (set rule conditions to ALL instead of ANY)
         Destroy actor

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited September 2019

    Or you can nest your rules:

    Actor 1:
    When touch is pressed
         Change attribute game.actor1dead to true
         Destroy actor

    Actor 2:
    When touch is pressed
    When attribute game.actor1dead is true
         Destroy actor
    Otherwise
         [do something when actor 2 is touched but actor 1 is still alive]

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

Sign In or Register to comment.