playMaker

Author Topic: "Destroy object" too slow  (Read 1803 times)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
"Destroy object" too slow
« on: February 24, 2020, 09:55:46 PM »
I have two states. In the first state I "Destroy object" (the children object) in the second state I check "Game Object Has Children". And seems like I check for children faster than children really can be destroyed, so I have the response "true". But if I wait for let's say .5 seconds and then check if children exist - I got the correct answer "false".

Is it how Unity suppose to work or something goes wrong?

I tested with "Next Frame" event and it doesn't help. I believe that using "wait 0.5 sec" is the worst solution ever so what should I actually do?
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: "Destroy object" too slow
« Reply #1 on: February 25, 2020, 02:15:39 AM »
Hi,

 yes, objects are truly destroyed at the end of the frame, next frame should work actually

https://docs.unity3d.com/ScriptReference/Object.Destroy.html

Quote
Actual object destruction is always delayed until after the current Update loop, but is always done before rendering.

Please, debug your logic once again with the next frame, if that still doesn't work, let me know.

Bye,

 Jean

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: "Destroy object" too slow
« Reply #2 on: February 25, 2020, 03:41:08 PM »
Please, debug your logic once again with the next frame, if that still doesn't work, let me know.

Checked once again, Next Frame didn't help. It just stuck on "NoCharacters?" state if I didn't use wait before.
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

GonerGames

  • Junior Playmaker
  • **
  • Posts: 53
Re: "Destroy object" too slow
« Reply #3 on: February 25, 2020, 11:07:15 PM »
Couple of options would be:
1. Break apart your destroy object and next frame event into 2 seperate states. This way the destroy object will complete in one state, move to the next state then wait for next frame and finally move to "NoCharacters?" state.

2. Leave all on one state, remove the next frame event. Use a IsGameObject Null check every frame to check if CharacterGO is now null. If true goto "NoCharacters?" state.

Either way this should remove the need for the wait timer.

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: "Destroy object" too slow
« Reply #4 on: February 26, 2020, 03:29:21 PM »
Couple of options would be:
1. Break apart your destroy object and next frame event into 2 seperate states. This way the destroy object will complete in one state, move to the next state then wait for next frame and finally move to "NoCharacters?" state.
Actually, I did it this way from the very beginning. It doesn't work (I believe because of the same reason as Next Frame didn't help)


2. Leave all on one state, remove the next frame event. Use a IsGameObject Null check every frame to check if CharacterGO is now null. If true goto "NoCharacters?" state.
Well, this looks like a good move! Thanks, i'm gonna try!

indie developer of multiplayer adult fighting
http://nakedfighter3d.com