UUUUUUUUUUUUUUUUH
This commit is contained in:
1 parent
e8393a28ad
commit
f0bb83c869
110 files changed
+55065
-21232
No files matched your search
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using KinematicCharacterController;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.Player
|
||||
{
|
||||
public class PlayerAnimator : MonoBehaviour
|
||||
{
|
||||
private static readonly int VelocityForward = Animator.StringToHash("VelocityForward");
|
||||
private static readonly int VelocityRight = Animator.StringToHash("VelocityRight");
|
||||
|
||||
private KinematicCharacterMotor _motor;
|
||||
private Animator _animator;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_motor = GetComponent<KinematicCharacterMotor>();
|
||||
_animator = GetComponentInChildren<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var forwardVelocity =
|
||||
Vector3.Project(_motor.Velocity, transform.right).magnitude;
|
||||
_animator.SetFloat(VelocityForward, forwardVelocity);
|
||||
|
||||
var rightVelocity =
|
||||
Vector3.Project(_motor.Velocity, transform.forward).magnitude;
|
||||
_animator.SetFloat(VelocityRight, rightVelocity);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user