Problem with Actors Colliding/Overlapping

slinky1988slinky1988 Member, PRO Posts: 89
edited June 2012 in Working with GS (Mac)
I've been whacking my brains out over the last couple hours trying to sort out this problem, I'm sure the solution is pretty simple but I'm probably over complicating it and getting lost (kinda like when you lose your keys and realise later that it was in your pockets all along). But basically I have a character actor that when colliding with another actor (bomb) it will change the state (or activate) the actor, and then when the actor leaves it it will trigger an event. In this instance the character collides with the bomb but nothing happens yet, only when the character leaves a countdown is started for the bomb to blow up. I hope I've explained this clearly. Any help would be greatly appreciated. Thanks!

Nas

Best Answers

  • ChobbifaceChobbiface Posts: 491
    edited June 2012 Accepted Answer
    Oh I see what you mean now. I'm guessing the tricky part is the point at which your character (especially if you use several different characters) loses contact with the bomb, since this could be variable (depending on bounce/restitution settings etc.)

    1. You could still use the timer (which gives a more static approach), you'd just have to make the timer longer to compensate for the 1 sec or so it takes for the character to lose contact.

    2. Use magnitude to determine the distance between your character and the bomb, gives you precise control in pixels (but requires constraining)
    - Make 2 game (real) attributes e.g. characterX & characterY.
    - In your 'character' actor, use constrain behaviour and constrain your character actor's self position X and self position Y to the attributes above respectively.
    - Make another real attribute e.g. distance.
    - In your 'bomb' actor, constrain the attribute 'distance' to magnitude (self.position.X-game.characterX, self.position.Y-game.characterY)

    Now you can detect the distance between the character and bomb. Use rules to trigger off your behaviours e.g. when attribute 'distance' <10, start timer for bomb etc.


    3. Maybe there is actually a simpler way (and my keys are actually in my pocket as well )

    :P
  • MotherHooseMotherHoose Posts: 2,456
    Accepted Answer
    @NAS-M

    on bombActor:
    Rule: when
    Event: overlaps or collides with actor type: characterActor
    --changeAttribute: self.Tags To: active
    Otherwise:
    Rule: when
    Attribute: self.Tags is active
    --do timed stuff & destroy

    image MH

Answers

Sign In or Register to comment.