Hello, i’m trying to make a script that would retarget a legacy animation to an other boneset at runtime by making a script that is applied to all bones that would adjust their rotations depending on the boneset that is animated but actually, the model is making weird moves (the model moves its arms upward when the original model move its arms downward, the model runs by moving its legs in the reversed axis (it like it broke its legs) and things like this)
this is my current script
targetbone is the bone that has the animation applied and basebone is the same bone but without animation applied to get the original rotation values to adjust to the current boneset
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
public class AnimationRetarget : MonoBehaviour
{
private float BaseRotationX;
private float BaseRotationY;
private float BaseRotationZ;
public Transform targetbone;
public Transform basebone;
public void Start()
{
BaseRotationX = gameObject.transform.localEulerAngles.x;
BaseRotationY = gameObject.transform.localEulerAngles.y;
BaseRotationZ = gameObject.transform.localEulerAngles.z;
angle = new Vector3(0, 0, 0);
}
Vector3 angle;
public void Update()
{
angle.x = BaseRotationX + (targetbone.localEulerAngles.x - basebone.localEulerAngles.x);
angle.y = BaseRotationY + (targetbone.localEulerAngles.y - basebone.localEulerAngles.y);
angle.z = BaseRotationZ + (targetbone.localEulerAngles.z - basebone.localEulerAngles.z);
gameObject.transform.localEulerAngles = angle;
}
}
what should i fix in this code ?