If actor overlaps or collides for 5 sec's trigger action

skippyskippy Member Posts: 106
edited November -1 in Working with GS (Mac)
Can you make an actor do something if it has collided for a certain amount of time like if two actor's come together and stay together for 5 seconds for example then 1 actor gets destroyed
but then if they seperate before 5 seconds the time resets untill they collide again, i'm just not sure how to put this in a rule.

Comments

  • VoidedSkyVoidedSky Member Posts: 1,095
    --Rule; when overlaps or collide with XXX
    ---Timer; after 5 seconds, Destroy

    That should be all you need.
  • skippyskippy Member Posts: 106
    Thanks but I tried that Cowtech if they just overlap or collide then after 5 sec one actor destroys that works fine but i don't want it to, i want an actor to destroy when its "been touching" the other actor for 5 seconds if you know what i mean
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I would do it like this:

    Create an integer attribute called 'isTouching'.
    Leave it set to 0.

    Then two Rules, like this:

    Rule
    When all conditions are valid:
    Actor overlaps or collides with Actor of Type [whatever]
    -----Timer Every 1 second
    ----------Change Attribute: self.isTouching To: self.isTouching + 1
    otherwise
    -----Change Attribute: self.isTouching To: 0

    Rule
    When all conditions are valid:
    self.isTouching = 5
    -----[do something]

    Don't use run to completion on the Timer.
    That should do the trick!
  • juzcookjuzcook Member Posts: 259
    Did you try unticking "run to completion"?

    EDIT: ahh FireMaple beat me
  • skippyskippy Member Posts: 106
    Thanks all and Fmg that works perfectly :)
  • VoidedSkyVoidedSky Member Posts: 1,095
    I'm doing the same thing as FMG shows, but opposite, if the actor isn't in the area, then it counts. But if the actor moves around in the area, sometimes it triggers that it isn't in the collide-able area, when it really is. Any ideas???
Sign In or Register to comment.