Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Destroying GameObjects immediately is not permitted during physics trigger/contact
#4
(17-09-2024, 01:37 PM)Alexander34 Wrote: The death event can be triggered by a collision with a dangerous object or trigger, it switches the player's state to death and does the above with the rope

Right, but you can't do this operation on a collision/trigger callback. As explained, the correct way to do this is to store some indication that the rope must be attached, then do the actual AttachRope() call outside of the trigger callback.

This is similar to what you'd do for reacting for input on FixedUpdate(): you can't read input on FixedUpdate() since it may not be called every frame and you'd be missing keystrokes, so you read input in Update(), store input indicators (booleans, enums, etc) and then react to it during FixedUpdate().

(17-09-2024, 01:37 PM)Alexander34 Wrote: if I change the method to Destroy() instead of DestroyImmediately(), the burst starts complaining that it loses references to objects while executing jobs.

You can't do this, since Destroy() defers destruction until the end of the frame which is too late in this case. We use DestroyImmediate() instead for a reason.
Reply


Messages In This Thread
RE: Destroying GameObjects immediately is not permitted during physics trigger/contact - by josemendez - 17-09-2024, 02:02 PM