playMaker

Author Topic: using OnDestroy() from PlayMaker  (Read 2609 times)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
using OnDestroy() from PlayMaker
« on: April 14, 2018, 03:36:54 AM »
Is there a way to run some actions/events when the object going to be destroyed?
Similar to the OnDestroy() that can be used from the C#?


I write a Script that send event to fsm
void OnDestroy() { fsm.SendEvent("Die"); }
but unfortunately it does not work. I can send event onUpdate, for example, but can't see a result OnDestroy  :(
« Last Edit: April 14, 2018, 04:10:02 AM by nFighter »
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: using OnDestroy() from PlayMaker
« Reply #1 on: April 14, 2018, 03:08:56 PM »
How are the objects destoyed?

with playmaker actions or from other scripts?

if playmaker you could intead of destroying.
send an event (set a global transition for it so it can be called anytime)  do what you need to do then destroy self.

if from script you could prevent destroy and send an event from the script to the fsm and do the same as above.

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: using OnDestroy() from PlayMaker
« Reply #2 on: April 14, 2018, 04:58:15 PM »
It could be destroyed from different scripts, and I actually don't know what scripts exactly and how they working. I'm trying to hook in the complex working system with some playmaker tweaks. I don't have access to the script that actually send destroy event, but I have an object that must be destroyed and I want to make some actions on his death.

For now the only working way for me - checking every frame is object exist or not. Not the optimal way, to be honest  :-[
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: using OnDestroy() from PlayMaker
« Reply #3 on: April 14, 2018, 05:00:29 PM »
Is it some technical restriction with Playmaker to handle a OnDestoy() event?
I found some topics where people discuss it but don't see any simple solution
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: using OnDestroy() from PlayMaker
« Reply #4 on: April 14, 2018, 09:41:42 PM »
There’s no technical restriction, it just hasn’t been exposed to actions yet. I’ll add it in the next update...

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: using OnDestroy() from PlayMaker
« Reply #5 on: April 14, 2018, 09:50:36 PM »
Great to know! Thank you  ;D
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: using OnDestroy() from PlayMaker
« Reply #6 on: April 15, 2018, 05:53:49 PM »
Quick question: Do you specifically need OnDestroy or would an OnDisable event suffice? OnDisable is also called when an object is destroyed. So wondering if it's useful to add both OnDisable and OnDestroy events, or if OnDisable is enough...

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: using OnDestroy() from PlayMaker
« Reply #7 on: April 15, 2018, 06:28:57 PM »
If I understand right, I'll be fine with anything that will help me to catch the dying object. I think that OnDisable is even better  ;D
indie developer of multiplayer adult fighting
http://nakedfighter3d.com