Fix aiming animation and mesh rotation

This commit is contained in:
Jens Pitkänen 2020-08-10 02:42:55 +03:00
parent 9d491d34de
commit 68eab14326
6 changed files with 11 additions and 4 deletions

View File

@ -23,7 +23,10 @@ namespace NeonTea.Quakeball.Animation {
private Animator Animator;
private Transform BehindHand;
private Transform FrontHand;
private Transform Head;
private Transform Torso;
private float VisualYaw;
private float VisualPitch;
private void Awake() {
foreach (Animator animator in Soldiers) {
@ -31,7 +34,8 @@ namespace NeonTea.Quakeball.Animation {
}
Animator = Soldiers[(int)Model].GetComponent<Animator>();
Animator.gameObject.SetActive(true);
HeadCollider.parent = Head = TransformUtil.FindChildWithName(Animator.transform, "HEAD");
HeadCollider.parent = TransformUtil.FindChildWithName(Animator.transform, "HEAD");
Torso = TransformUtil.FindChildWithName(Animator.transform, "RIBS");
BehindHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.R");
FrontHand = TransformUtil.FindChildWithName(Animator.transform, "HAND.L");
if (GunGluedToHand) {
@ -47,8 +51,11 @@ namespace NeonTea.Quakeball.Animation {
}
private void LateUpdate() {
transform.localEulerAngles = new Vector3(0, Player.Yaw, 0);
Head.localEulerAngles = new Vector3(Player.Pitch, 0, 0);
VisualYaw = Mathf.Lerp(VisualYaw, Player.Yaw, 10f * Time.deltaTime);
VisualPitch = Mathf.Lerp(VisualPitch, -Player.Pitch, 10f * Time.deltaTime);
transform.localEulerAngles = new Vector3(0, VisualYaw, 0);
Torso.localEulerAngles = new Vector3(VisualPitch, 0, 0);
if (GunGluedToHand) {
Vector3 GunOffset = GunHandle.position - Gun.position;

Binary file not shown.

Binary file not shown.