Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Null reference exception on start (do not disable scene reload *solved)
#1
hi everyone I have a very weird problem that I have trouble figuring out. 

I have imported obi rope 6.2 into a 2021.1.19f1 vr hdrp project I am working on and when I try to start a scene with a rope or rod all I get is a null ref exception in ObiConstraints.cs 

actor.solverBatchOffsets[constraintType].Clear();

explicitly solverBatchOffsets is what is null. 
Backend used doesn't matter 

My testscene is empty except for camera, directional light and obi rope and obi solver. The blueprint is also unaltered straight from create asset.

In a completely new project (same unity version, hdrp, steam vr too) the issue does not appear. 


Why could this go wrong? Is there a way I can hotfix this?

---
I suspect that either Awake isn't called correctly on ObiActor or that solverBatchOffsets is not serialized. In any case when I check if solverbatchOffsets is null in ObiActor.OnEnable it does return null as well. Initializing it in OnEnable prevents the error but breaks the simulation.

--- figured it out ---
Awake isn't called (and I guess on many other important components too) when you have Scene reload disabled Rodar ojos Astuto (I am stupid, hopefulyl this spares someone else the hours to find out)
Reply
#2
(10-09-2021, 01:21 PM)fleity Wrote: hi everyone I have a very weird problem that I have trouble figuring out. 

I have imported obi rope 6.2 into a 2021.1.19f1 vr hdrp project I am working on and when I try to start a scene with a rope or rod all I get is a null ref exception in ObiConstraints.cs 

actor.solverBatchOffsets[constraintType].Clear();

explicitly solverBatchOffsets is what is null. 
Backend used doesn't matter 

My testscene is empty except for camera, directional light and obi rope and obi solver. The blueprint is also unaltered straight from create asset.

In a completely new project (same unity version, hdrp, steam vr too) the issue does not appear. 


Why could this go wrong? Is there a way I can hotfix this?

---
I suspect that either Awake isn't called correctly on ObiActor or that solverBatchOffsets is not serialized. In any case when I check if solverbatchOffsets is null in ObiActor.OnEnable it does return null as well. Initializing it in OnEnable prevents the error but breaks the simulation.

--- figured it out ---
Awake isn't called (and I guess on many other important components too) when you have Scene reload disabled Rodar ojos Astuto (I am stupid, hopefulyl this spares someone else the hours to find out)


It did spare me the hours to find! Thank you for including the solution  Sonrisa

-bump-
Reply
#3
Bumping this old thread since it is still relevant and have been trying to find a reason why Obi Particle Attachments (in my case) fail (they're not attached properly) when scene is reloaded, and since I feel there's a lack of direct info on how to resolve it, I'm attaching a screenshot from Project Settings inside the Unity Editor.

[Image: Screenshot-2024-10-17-at-12-31-58.png]
Reply