Opposite Leg Joint Rotation Using Unity Joint Simulation

18 Views Asked by At

I've created a simple leg joint structure in Unity, using a cube as the hip with free movement and rotation for self-balancing. Two rectangular prisms represent the right and left legs, and they are completely symmetrical. I'm driving their movement using targetRotation for stepping. However, I've encountered an issue: when I rotate the right leg and it encounters ground obstruction, the right leg can't rotate, and the left leg rotates in the opposite direction. Conversely, when I rotate the left leg and it hits the ground, the left leg can lift the ragdoll, and the right leg's rotation remains unaffected. Why is this happening?

The joint configurations, rotations, and positions of both legs are completely symmetrical in my setup, and I'm puzzled about why this is happening. How can I resolve this issue? This video is just a simplified example, but I'm facing the same problem in my actual application: when the character's right foot steps on the ground, the left foot lifts up.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class RagDollControlTest : MonoBehaviour
{
    [Header("---RightLeg---")]
    public ConfigurableJoint rightLeg;
 
    public Vector3 rightLegIdleEuler = new Vector3(0, 0, 0);
 
    [Header("---LeftLeg---")]
    public ConfigurableJoint leftLeg;
   
    public Vector3 leftLegIdleEuler = new Vector3(0, 0, 0);
   
 
 
   
    private void FixedUpdate()
    {
       
        var leftLegTargetRotation = Quaternion.Euler(leftLegIdleEuler);
        leftLeg.targetRotation = leftLegTargetRotation;
       
       var rightLegTargetRotation = Quaternion.Euler(rightLegIdleEuler);
       rightLeg.targetRotation = rightLegTargetRotation;
 
     
    }
}

When the right leg touches the ground, the left leg lifts up. When the left leg touches the ground, the right leg does not respond, and the left leg can support the entire joint structure.

I believe the behavior of the left leg is normal, and the behavior of the right leg is erroneous. However, in different versions of Unity, across various projects, they all demonstrate the same behavior: the right leg affects the left leg, but the left leg doesn’t affect the right leg. I think under normal circumstances, either both legs should influence each other to the same degree or they should not affect each other at all. How can I address this issue?

Thanks in advance!

0

There are 0 best solutions below