TargetPosition of leg spring stuck at 80
hello everyone, I state that I am really new on unity, and for a while I am having a problem that I am too stupid to understand why it happens and how to solve it ... https://imgur.com/UzGE9ZP
as shown in this video: https://streamable.com/9tyauc the right leg of this ragdoll, for some reason, the moment the game start, gets stuck and does not want to move at all ... if i remove i remove the "reverse" option the leg unlocks and moves, but obviously not good because it makes the same movement of the other leg ...
this is the script:
[code=CSharp]using System.Collections; using System.Collections.Generic; using UnityEngine; public class PernMov : MonoBehaviour { public HingeJoint hj; public Transform objective; public bool invert; void Start () {
JointSpring spr = hj.spring;
spr.targetPosition = 0;
hj.spring = spr;
}
void Update ()
{
JointSpring js = hj.spring;
js.targetPosition = objective.localEulerAngles.x;
if(js.targetPosition > 180)
js.targetPosition = js.targetPosition - 360;
js.targetPosition = Mathf.Clamp(js.targetPosition, hj.limits.min + 5, hj.limits.max - 5);
if (invert)
{
js.targetPosition = js.targetPosition * -1;
}
hj.spring = js;
}
}[/code]
[1]: https://imgur.com/a/RG4pNNS
Your answer
Follow this Question
Related Questions
C# - JS problem. 1 Answer
Making an enemy ship chase player in unity3d. 1 Answer
Replace dead npc with ragdoll ? 0 Answers
Respawn Script Is Not Functioning 0 Answers