13-02-2020, 12:18 PM
I have a coiled rope that unwinds nicely when the rope is enabled. I want to have the rope reset to it's starting coiled shape every time I activate it. How to I reset the rope to it's original shape?
(13-02-2020, 12:18 PM)basilisk Wrote: [ -> ]I have a coiled rope that unwinds nicely when the rope is enabled. I want to have the rope reset to it's starting coiled shape every time I activate it. How to I reset the rope to it's original shape?
void Reset(ObiActor actor)
{
if (actor.isLoaded)
{
Matrix4x4 l2sTransform = actor.actorLocalToSolverMatrix;
Quaternion l2sRotation = l2sTransform.rotation;
for (int i = 0; i < actor.particleCount; ++i)
{
int solverIndex = actor.solverIndices[i];
actor.solver.positions[solverIndex] = l2sTransform.MultiplyPoint3x4(actor.blueprint.positions[i]);
actor.solver.velocities[solverIndex] = l2sTransform.MultiplyVector(actor.blueprint.velocities[i]);
if (actor.usesOrientedParticles)
{
actor.solver.orientations[solverIndex] = l2sRotation * actor.blueprint.orientations[i];
actor.solver.angularVelocities[solverIndex] = l2sTransform.MultiplyVector(actor.blueprint.angularVelocities[i]);
}
}
}
}
NullReferenceException: Object reference not set to an instance of an object
if (actor.isLoaded)
void Reset(ObiActor actor)
(13-02-2020, 02:54 PM)basilisk Wrote: [ -> ]Thank you, this works. But oddly, I am getting an error...
Code:NullReferenceException: Object reference not set to an instance of an object
error at the line:
Code:if (actor.isLoaded)
The rope shape is still being reset like I want even with this null error, so it works but I'd like to eliminate the error.
They way I've set it up is a public ObiActor myRope variable where I assign the rope GameObject in the editor, and when I want the rope to reset reset I pass myRope into...
Code:void Reset(ObiActor actor)
Any idea why this null error is happening?
if (actor.isLoaded)
if (actor != null && actor.isLoaded)