Turning collide on/off

I have an actor that is shot towards a wall. When it hits the wall it bounces off. All is well. The wall has small slots in it. I want to fill these slots with another actor, that toggles collision.

Essentially I want to touch the actor to turn on the image and the collide behavior, then click it again to turn off the image and have no colliding. How do I do this?

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I would suggest using a boolean attribute and placing your collide behavior inside a rule that says

    When self.attribute is true
    --Collide with actor

    Then just turn the attribute back and forth between true and false for when you want the collisions on or not.
  • rrosario007rrosario007 Member, PRO Posts: 15
    I'm still having the same problem.

    Either collide works with an image with alpha=1 or alpha=0
    Or collide does not work with image alpha=1 or alpha=0

    Let me clarify more.

    Actor-ball is the moving object it has collide with actor-walls
    Actor-slot is an actor that will fill the slots in the walls.
    I have a boolean attribute called SlotFilled

    By default Actor-slot is set to color.alpha=0
    Behavior-ACTOR DOES NOT COLLIDE WITH SLOT
    game.Attribute-SlotFilled=false

    I want a rule for Actor Slot
    when touch is pressed
    change attribute-game.SlotFilled=true
    change attribute: self.color.alpha=1
    Behavior-Collide: with actor of type Actor-ball

    Then an additional rule that says when touch is pressed
    and Attribute-game.SlotFilled=True
    change attribute-game.SlotFilled=false
    change attribute: self.color.alpha=0
    Behavior-Actor-ball DOES NOT COLLIDE WITH SLOT
Sign In or Register to comment.