playMaker

Author Topic: Send an Event when using Destroy Object?  (Read 107 times)

wirejaw

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Send an Event when using Destroy Object?
« on: November 20, 2020, 05:10:52 PM »
I'm using Destroy Object to destroy a bomb that is thrown by my player character.  Is there a way to send an event when the object is destroyed?  I want to add other things like a particle explosion and a screen shake when the bomb explodes.  Thanks for any help.
« Last Edit: November 20, 2020, 05:45:15 PM by wirejaw »

Broken Stylus

  • Sr. Member
  • ****
  • Posts: 475
    • View Profile
Re: Send an Event when using Destroy Object?
« Reply #1 on: November 21, 2020, 04:36:26 AM »
In a FSM you can use a System Event event that's called DISABLE which lets you throw some functions within the object's last frame of activity before going off (as it receives the order to deactivate itself from Unity. Don't use any action that would last longer and, generally, make it short no matter what.

For particles there's also an option called Stop Action in the main settings that allows you to disable or destroy the object once the particle effect is finished.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 5567
    • View Profile
    • jinxtergames
Re: Send an Event when using Destroy Object?
« Reply #2 on: November 21, 2020, 07:58:58 AM »
Hi.
On the 'Bomb' when you Create it (store the object when you create), you can use a 'Set Fsm Gameobject' and set the 'player' gameobject  (on the bomb Game object/fsm).

Now just before destroying the bomb you can use a Send Event By Name to  the 'player'

Here are some videos that might help :



wirejaw

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Send an Event when using Destroy Object?
« Reply #3 on: November 21, 2020, 06:30:59 PM »
Thank you both for your replies and suggestions.  I will give these ideas a try.

Broken Stylus

  • Sr. Member
  • ****
  • Posts: 475
    • View Profile
Re: Send an Event when using Destroy Object?
« Reply #4 on: November 22, 2020, 04:17:57 AM »
When the bomb blows up, maybe you'd want to spawn (or pick from a pool) an instance of a prefab that receives the last coordinates of the bomb. Set the instance's parent in some logical "folder" I would say so you can let the bomb game object be destroyed or repooled without worrying about it waiting for some particles effect to complete, because the particles effect would be on a different object. You would essentially be swapping objects here within the same frame, before the graphic rendering phase.