- Home /
The question is answered, right answer was accepted
2DHingeJoints not flipping with characters localScale C# unity ragdoll
So i made a script that activates enemy ragdoll on impact. I have skeleton on the enemy and attached 2DhingeJoints on the bones.
The issue is when i flip the characters localScale on the parent object the hingeJoints are not flipping properly, so i made method trying to flip them.
void FlipHingeJointLimits(float localScaleX)
{
if (localScaleX < 0 && !isFlipped)
{
for (int i = 0; i < hingeJoints.Length; ++i)
{
JointAngleLimits2D jointLimits = hingeJoints[i].limits;
jointLimits.min = -jointOgLimits[i].min;
jointLimits.max = -jointOgLimits[i].max;
hingeJoints[i].limits = jointLimits;
}
isFlipped = true;
}
}
The other part of the method just flips them back and is working so i didn't include it here.
The rotations are so confusing to work with and i don't know why negative of the original angles are not working
Anyone have any advice how i could make this work?
,Answer by helsipk · Jul 24, 2020 at 09:38 AM
Okay i solved it. I had fixed joint connected from the Rigs spine to the characters container to keep it from falling off when i simulate bones rigidbodies.
Somehow it interfered with the 2DhingeJoints after i flip the character.
Its weird in the editor the hinge joints limits seem to point wrong way, but now flipping the hingejoints seem to work properly after i disabled the fixed joint on the spine
Follow this Question
Related Questions
Weird Rotation Issue 0 Answers
My Algorithm for checking whole tiles didint work 0 Answers
Values not moving to Game Over screen or the Game over doesn't somehow work. 0 Answers
Make Object move a distance from a center. 1 Answer
Scaling unity apps 1 Answer