playMaker

Author Topic: How to call a function on colliding game object  (Read 1370 times)

Karmic

  • Playmaker Newbie
  • *
  • Posts: 3
How to call a function on colliding game object
« on: April 25, 2018, 02:51:46 AM »
i am going through documentation but cant find solution for a specific problem. I want to call a method on a colliding game object.

Is there a builtin functionality for this. How can i achieve this

I have pooled projectiles. And when enemy or player is hit bynprojectiles, i want to call method on player/enemy to decrease their health.
« Last Edit: April 25, 2018, 03:12:01 AM by Karmic »

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: How to call a function on colliding game object
« Reply #1 on: April 25, 2018, 04:52:29 AM »
On the projectile itself, have a FSM. Use the action "Collision Event". Use the store collider variable. Filter the collision by tag (probably "player"). Then when it hits the player the store collider variable will populate with whatever it hit (anything with the player tag).

In the next state, use the action "Send Event". The target of that event should be "store collider variable".  Make sure the event is global.

On your player, or any other things you want hit, setup that event. Following the event, you can setup whatever "method" (aka string of states), you want triggered.

Karmic

  • Playmaker Newbie
  • *
  • Posts: 3
Re: How to call a function on colliding game object
« Reply #2 on: April 25, 2018, 05:31:25 AM »
Thanks for the quick response. Will try it out