04-02-2021, 01:52 PM
(This post was last modified: 04-02-2021, 02:01 PM by josemendez.)
There's two things in line 67 that can be null: "pinConstraints" or "newBatch". Since you're just created newBatch and AddBatch() is a nop if you pass null to it, it's safe to say that it is pinConstraints that's null.
A quite probable cause for this is that you're getting it in Awake(), which Unity calls in no specific order for all objects in the scene. The rope's own Awake() might not have been called by the time you grab the reference to the pin constraints, so you get an uninitialized reference to the pin constraints (null). The usual Unity way to work around this is to use Start(), its intended use is to get references to other object's stuff once they've been all initialized in Awake(). Moving your Awake() code to Start() should solve this.
A quite probable cause for this is that you're getting it in Awake(), which Unity calls in no specific order for all objects in the scene. The rope's own Awake() might not have been called by the time you grab the reference to the pin constraints, so you get an uninitialized reference to the pin constraints (null). The usual Unity way to work around this is to use Start(), its intended use is to get references to other object's stuff once they've been all initialized in Awake(). Moving your Awake() code to Start() should solve this.