Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Adding pin constraints to a rope at runtime
#9
(18-03-2018, 06:04 PM)Gieve Wrote:
Code:
NullReferenceException: Object reference not set to an instance of an object
Obi.RopeMaker.AddPendulum (Obi.ObiCollider pendulum, Vector3 offSet)
(at Assets/Scripts/RopeMaker.cs:65)
RopeSetup.MakeRopes () (at Assets/Scripts/RopeSetup.cs:58)
RopeMakerEditor.OnInspectorGUI () (at Assets/Editor/RopeMakerEditor.cs:14)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex,
Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext,
UnityEngine.Rect& importedObjectBarRect)
(at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1253)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
The Full Error read out, 

points at line 65 the AddConstraint function call, and then refers back to all referencing code.

Are you waiting for the rope to be fully initialized before calling AddPendulum? There will be no pin constraint batches (or constraints of any kind, for that matter) before the initialization coroutine  (MakeRope()) has finished... this is explained in the comments to that function:

Quote:/// MakeRope and AddPendulum may NOT be called on the same frame.
/// You must wait for the MakeRope coroutine to finish first.
/// Just adds a pendulum to the rope on the un-anchored end.
Reply


Messages In This Thread
RE: Adding pin constraints to a rope at runtime - by josemendez - 18-03-2018, 06:12 PM