Godot Version
4.3
Question
my character turns in the direction of the look vector when the animation is turned off but not when it’s turned on. does anybody have any Idea of how to fix this? this is my code
internal override void Tilt_Bone(Player player, int bone, float dt)
{
Vector2 currentRotation = Char_Parent.Inputs.Inputvec;
Vector2 lastRotation = Char_Parent.Inputs.Inputvec_Interp;
float deltaRotation = Mathf.Wrap(currentRotation.Angle() - lastRotation.Angle(), -Mathf.Pi, Mathf.Pi);
float Roll = deltaRotation < -0.01f ? Char_Parent.Inputs.Inputvec.Dot(Char_Parent.Inputs.Inputvec_Interp) : deltaRotation > 0.01f ? Char_Parent.Inputs.Inputvec.Dot(Char_Parent.Inputs.Inputvec_Interp) * -1: 0 ;
float Max_Roll = 85;
//Quaternion newquat = new Quaternion(Mathf.DegToRad(Skeleton.GetBonePose(bone).Basis.GetRotationQuaternion().X), Mathf.DegToRad(Skeleton.GetBonePose(bone).Basis.GetRotationQuaternion().Y), Mathf.DegToRad(Skeleton.GetBonePose(bone).Basis.GetRotationQuaternion().Z), Skeleton.GetBonePose(bone).Basis.GetRotationQuaternion().W);
//Quaternion newquat = Skeleton.GetBonePoseRotation(bone);
if (currentRotation.Length() > 0 && lastRotation.Length() > 0)
{
if (deltaRotation > 0.01f)
{
GD.Print("Turning Right " + Roll);
}
else if (deltaRotation < -0.01f)
{
GD.Print("Turning Left " + Roll);
}
}
//new Transform3D(new Basis(newquat), Skeleton.GetBonePose(bone).Origin)
Char_Parent.Skeleton.SetBonePoseRotation(bone,new Quaternion(Char_Parent.Skeleton.GetBonePoseRotation(bone).X,Mathf.DegToRad( Mathf.Clamp(-deltaRotation * 30,-Max_Roll,Max_Roll) ),Char_Parent.Skeleton.GetBonePoseRotation(bone).Z,Char_Parent.Skeleton.GetBonePoseRotation(bone).W));
//Transform3D pose = Char_Parent.Skeleton.GetBoneGlobalPose(bone);
//pose.Basis = new Basis(pose.Basis.X,pose.Basis.Y, pose.Basis.Z * new Vector3(1.4f,1,1)); // Your custom rotation
//Char_Parent.Skeleton.SetBoneGlobalPoseOverride(bone, pose, 1.0f, true);
//Char_Parent.Skeleton.ClearBonesGlobalPoseOverride();
}