Hi, based on mouse input from the user, I’m tilting a parent object around its X and Z axis. This object has a child object attached to it (see diagram). As the parent object tilts, I’m ascertaining the greatest axis that it’s moved (so it’s X or Z). Based on this, I’m restricting the axis the child object can move by using configurable joints. So the child object can never move diagonally, only left/right or up/down. This is the code I’m using in FIXEDUPDATE
tiltVector = Iceberg.ReturnTilt();
if (Mathf.Abs(tiltVector.x) >= Mathf.Abs(tiltVector.z))
{
print("Locking Z Motion");
referenceToJoint.zMotion = ConfigurableJointMotion.Locked;
referenceToJoint.xMotion = ConfigurableJointMotion.Free;
}
else
{
print("Locking X Motion");
referenceToJoint.xMotion = ConfigurableJointMotion.Locked;
referenceToJoint.zMotion = ConfigurableJointMotion.Free;
}
The issue I’m having is the code above - sometimes when it enters the code within the ‘if’ statement and locks one axis while freeing another, the object ‘pops’ up vertically.
Any reasons why?
Thanks in advance for any help
