Problem with Actors Colliding/Overlapping
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
Nas
Best Answers
-
Chobbiface Posts: 491
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 -
MotherHoose Posts: 2,456
@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 & destroyMH
Answers
When 'actor receives event' overlaps/collides with character actor:
Drag timer behaviour in: after X seconds, trigger whatever behaviour you wish (e.g. bomb to blow up).
Is that what you mean?