Touch Managing

VmlwebVmlweb Member Posts: 427
edited November -1 in Working with GS (Mac)
Hey,

I have a actor called zombie.
Is there any way to get how many zombie actors are touching an object at once?

Thanks,
Victor

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    you would need a global attribute called zombieTouches or something like that.

    In the zombie actor, add two boolean attributes called:
    isTouchingObject
    hasAddedToZombieTouches

    Add a rule that says:

    When Actor touches or collides with Actor of type (your object here)
    Change Attribute: self.isTouchingObject to TRUE
    Otherwise
    Change Attribute: self.isTouchingObject to FALSE

    Another rule that says:

    ALL
    When self.isTouchingObject is TRUE
    When self.hasAddedToZombieTouches is FALSE
    Change Attribute: game.zombieTouches = game.zombieTouches + 1;
    Change Attribute:self.hasAddedToZombieTouches to TRUE

    And another rule that says:

    ALL
    When self.isTouchingObject is FALSE
    When self.hasAddedToZombieTouches is TRUE
    Change Attribute: game.zombieTouches = game.zombieTouches - 1;
    Change Attribute:self.hasAddedToZombieTouches to FALSE

    Hope this helps!
    Joe
  • VmlwebVmlweb Member Posts: 427
    works great,
    thanks
Sign In or Register to comment.