If actor "x" is destroyed then actor "y" is destroyed as well

lowskilowski Member Posts: 25
edited November -1 in Working with GS (Mac)
How do I do this?

Step by step please, I am a noob :)

Comments

  • butterbeanbutterbean Member Posts: 4,315
    There are probably many ways to do this, but one could be:

    Create a global game attribute: Call it ActorXDestroyed, set by default to false

    Within Actor X, Create a Rule that states when the actor is destroyed:

    ie: Rule: When actor overlaps with enemy:

    Change attribute ActorXDestroyed to true

    Timer: After 0.1 seconds: Destroy this actor

    Then in Actor Y Create a rule that says:

    When game.ActorXDestroyed is true:

    Destroy this actor

    Hope this helps!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Also make sure that your "destroy" Rule isn't in the Prototype, only in the Instance ( the one on screen)!

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • firemaplegamesfiremaplegames Member Posts: 3,211
    @gyroscope: make sure NO code is in any the instances!!! Make sure ALL code is only in the Prototypes when you are starting out...
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    OK, thanks firemaplegames. I was thinking that if actor "x" and actor "y" were Instances of the same Prototype, then asking the Prototype to destroy itself would destroy both Instances?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Once you drag an instance of the prototype out into the Scene, it becomes it's own entity. One instance does not affect another.

    The Rules and behaviors of an instance only apply to that instance.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Sure thing, thanks; that's why I suggested to make sure the destroy "me" in the Rules of actor "x" was in its Instance, if actor "y" was another instance of the same Prototype. But that last bit I didn't mention, in my post to lowski...so sorry to have mislead you as to what I meant!

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • lowskilowski Member Posts: 25
    butterbean said:
    There are probably many ways to do this, but one could be:

    Create a global game attribute: Call it ActorXDestroyed, set by default to false

    Within Actor X, Create a Rule that states when the actor is destroyed:

    ie: Rule: When actor overlaps with enemy:

    Change attribute ActorXDestroyed to true

    Timer: After 0.1 seconds: Destroy this actor

    Then in Actor Y Create a rule that says:

    When game.ActorXDestroyed is true:

    Destroy this actor

    Hope this helps!

    Worked wonderfully. Thanks a bunch!

    Thanks for the other clarifications as well :)
  • NaweeNawee Member Posts: 7
    Sorry, I needed the same help however I don't understand how to create a Global Game Attribute. Please help, thanks!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Nawee, very straightforward. Go to the Scene Editor (any scene); there's the Inspector on the left hand side; Two buttons, Game and Scene, make sure it's in Game; 3 buttons underneath, 2nd button is Attributes; just click the + like you do adding to Scene or Actor attributes.

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • NaweeNawee Member Posts: 7
    Thanks, Great help!
  • NaweeNawee Member Posts: 7
    Sorry to bother you, one more question, what attribute type do I pick?
    Thanks, Nawee
  • NaweeNawee Member Posts: 7
    Never Mind!
Sign In or Register to comment.