15-05-2023, 01:20 PM
(This post was last modified: 15-05-2023, 01:30 PM by natko1412.
Edit Reason: more info
)
Thanks for your reply!
I tried moving that part of code to the Start method. Now I get NullReferenceException in this line in my code (in Editor):
In debugger it shows that actor is good, but solverIndices is null. Seems like actor is not initialized all the way when I try to work with it inside my Start() method.
This is the whole codeblock I use - it loads positions and velocities from json file and should set them to the rope:
Actually, while debugging - drom actor I see that solver's initialized flag is false
I tried moving that part of code to the Start method. Now I get NullReferenceException in this line in my code (in Editor):
Code:
int solverIndex = actor.solverIndices[i];
In debugger it shows that actor is good, but solverIndices is null. Seems like actor is not initialized all the way when I try to work with it inside my Start() method.
This is the whole codeblock I use - it loads positions and velocities from json file and should set them to the rope:
Code:
var positions = reader.Read<List<Vector3>>("tether_positions");
var velocities = reader.Read<List<Vector3>>("tether_velocities");
for (int i = 0; i < positions.Count; ++i)
{
int solverIndex = actor.solverIndices[i];
actor.solver.positions[solverIndex] = positions[i];
actor.solver.velocities[solverIndex] = velocities[i];
}
cursor.ChangeLength(reader.Read<float>("tether_length"));
Actually, while debugging - drom actor I see that solver's initialized flag is false