Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Lost solver parameter from rope
#5
(01-09-2020, 11:38 AM)josemendez Wrote: Hi,

I'm unable to reproduce any problems when doing this. I've added a public ObiRope variable to a custom script, placed the script onto a prefab with solver+rope, dragged the rope to the variable slot in the inspector. Then I instantiated the prefab at runtime using Instantiate() and the reference is kept. Anyway, this is all handled automatically by Unity, Obi does not use any custom serialization/prefab system of any kind.

Make sure you're not referencing anything that's outside the prefab (as the reference will be lost).

PS: make sure that the null reference is not taking place because of m_ActualRope, but because of m_ActualRope.solver.  The solver can be null if the actor instance hasn't been yet added to a solver, so if you try to access it in your scripts Awake() (which may be called before the rope's Awake() method, since the order in which methods are called for different components is undefined in Unity), the reference to the solver may as well be null. That's what Start() is for, so try subscribing in Start() instead of Awake().
Yes srry, That's exactly what is happening. I explained myself really bad. The m_actualRope.solver is what is null. I will try your approach, thank you!

PD: Solved! Using Start method for init solves the issue.
Reply


Messages In This Thread
Lost solver parameter from rope - by flaurens - 01-09-2020, 11:17 AM
RE: Lost solver parameter from rope - by flaurens - 01-09-2020, 11:25 AM
RE: Lost solver parameter from rope - by flaurens - 01-09-2020, 11:44 AM