GameSalad

Howdy, Stranger!

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

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 Posts: 11,861Member, Sous Chef, PRO, Senior Sous-Chef

    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 Posts: 11,861Member, Sous Chef, PRO, Senior Sous-Chef
    edited September 5

    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.