✅ [Resolved] [Unity] Procedural animation for a crab with Rigging animation & Inverse kinematic

I work on unity, I have to completely change my script which allows to do procedural animation in reverse kinematic, in fact to explain to you I have a crab with 8 legs, each with 4 pivot points, and I want to do so that when the crab moves the legs also, via procedural animation. I have already created a script to do all this, however sometimes the point remains in place, impossible to reset it, even with checks, whether in the calculation, out of the calculation, and even by forcing with Tasks etc.. So I would like to know if some here could help me fix this bug, or completely redo everything to start from a good base. Here is my full script.
8 Replies
Maxime66410
Maxime66410OP2y ago
Maxime66410
Maxime66410OP2y ago
Maxime66410
Maxime66410OP2y ago
My bug
Maxime66410
Maxime66410OP2y ago
As you can see, sometimes the red cube remains frozen.
anita
anita2y ago
maybe ask on the unity discord server $unity
Maxime66410
Maxime66410OP2y ago
ok thanks Found, there is a calculation error in my code, I am calculating in world when I have to calculate locally. Delete the task present in the script, it will be useless and it is not done in the right way.
public void FixDistanceLeg()
{
for (int i = 0; i < singleLegs.Count; i++)
{
var distanceIKtoLegLocal = Vector3.Distance(singleLegs[i].transform.localPosition, singleLegsIK[i].transform.localPosition);

if (distanceIKtoLegLocal > distanceToFixStep)
{
//singleLegs[i].transform.position = singleLegsIK[i].transform.position;
singleLegs[i].transform.position = Vector3.Lerp(singleLegs[i].transform.position, singleLegsIK[i].transform.position, Time.deltaTime * speedSyncLegs);
singleLegsTarget[i] = singleLegsIK[i].transform.position;
singleLocalTarget[i] = singleLegsIK[i].transform.position;
}
}
}
public void FixDistanceLeg()
{
for (int i = 0; i < singleLegs.Count; i++)
{
var distanceIKtoLegLocal = Vector3.Distance(singleLegs[i].transform.localPosition, singleLegsIK[i].transform.localPosition);

if (distanceIKtoLegLocal > distanceToFixStep)
{
//singleLegs[i].transform.position = singleLegsIK[i].transform.position;
singleLegs[i].transform.position = Vector3.Lerp(singleLegs[i].transform.position, singleLegsIK[i].transform.position, Time.deltaTime * speedSyncLegs);
singleLegsTarget[i] = singleLegsIK[i].transform.position;
singleLocalTarget[i] = singleLegsIK[i].transform.position;
}
}
}
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server