Player Animations

-Configured the human avatar and avatar masks
-Added aiming animation
-Added Idle animation
This commit is contained in:
juliuse98
2021-10-25 08:32:50 +02:00
parent e59f509df6
commit 8c2c3e10db
19 changed files with 685 additions and 129 deletions

View File

@@ -34,6 +34,11 @@ public class PlayerController : MonoBehaviour
[SerializeField] private float groundDistance = 0.4f;
[SerializeField] private LayerMask groundMask;
[Header("Animations")]
[SerializeField]private Animator playerAnimator;
private float animationVal = 0.0f;
float f = 0.5f;
public bool isGrounded;
private float viewPitch = 0f;
private float velocityY = 0.0f;
@@ -49,6 +54,7 @@ public class PlayerController : MonoBehaviour
private void Start()
{
playerAnimator = GetComponentInChildren<Animator>();
controller = GetComponent<CharacterController>();
if (lockCursor)
{
@@ -57,11 +63,15 @@ public class PlayerController : MonoBehaviour
}
//Position the camera at the height of the neck (set by the neckLength)
neckLength = Vector3.Distance(playerCamera.position, playerNeck.position);
playerCamera.position = playerNeck.position;
playerCamera.position += playerNeck.up * neckLength;
}
private void Update()
{
f = (viewPitch + 90f) / 180f;
playerAnimator.SetFloat("Time", 1-f);
UpdateMouseLook();
Grounded();
UpdateMovement();