playMaker

Author Topic: Collision Enter/Exit/Stay help[SOLVED]  (Read 2528 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Collision Enter/Exit/Stay help[SOLVED]
« on: November 10, 2013, 10:50:29 AM »
Hi,
I know Collision Stay is not recommended, so can someone help me out with an alternative?
Basically, I have 2 objects, player and enemy. I have 2 FSM's on the ememy that deal with chasing and collision.
I have the chasing FSM working OK, but the collision FSM is where I need help.
I have a Collision Enter > setting a collision bool to true > updating some variables > then I want it to loop back if the collision is still true.  Problem is, I dont know how to set the bool to false inside the loop, as that can only be done after a Collision Exit.
Can someone help me work this out?
« Last Edit: November 11, 2013, 11:21:51 PM by jeanfabre »

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Collision Enter/Exit/Stay help
« Reply #1 on: November 10, 2013, 11:46:14 AM »
In your case here is what you can do:
You can use collision enter and use wait action with some minimum wait float such as 0.01 and loop back to collision state. You don't have to use bool value, you can just create something similar to this example on attached image.
In Not colliding state you have collision event and waiting for collision, after that object collide with certain object for example Player it will fire deal damage event and in that state you can add amount to health or any other variable by adding minimum value and in that state you have action that waits for collision exit and just use wait action to wait some small amount of time like 0.1 and proceed with finished and loop back to damage. This way you can have same effect like with collision stay because damage will loop until you exit from collider.
Is this ok for you?

Cheers!

Splankton

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Re: Collision Enter/Exit/Stay help
« Reply #2 on: November 10, 2013, 12:25:47 PM »
Thanks a lot I'll give it a go.  Instead of using the wait action, using next frame event is better imo.  Are those global events called from the same FSM?

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
    • View Profile
Re: Collision Enter/Exit/Stay help
« Reply #3 on: November 10, 2013, 12:43:05 PM »
No problem ;)
You can use next frame event ofc but In this case you can use the wait cause you have more control over your damage / heal or what ever in a way that you can set how frequent damage can be.
Anyhow result is similar.

Those events are not global, that is just global transition, I prefer that over branching sometimes and it looks better organized and much cooler :), you can use that by clicking on any state with your right mouse and instead of add transition you use add global transition ;)

Cheers!

Splankton

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Re: Collision Enter/Exit/Stay help
« Reply #4 on: November 11, 2013, 08:42:44 AM »
Works perfect, thanks a lot!