60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class PlayerAnimationController : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField]
|
||
|
private Animator animController;
|
||
|
[SerializeField]
|
||
|
private string runningParameter;
|
||
|
[SerializeField]
|
||
|
private string runningSpeedParameter;
|
||
|
[SerializeField]
|
||
|
private string sideStepSpeedParameter;
|
||
|
|
||
|
private float runningSpeed;
|
||
|
private float sideStepSpeed;
|
||
|
|
||
|
private bool isRunning;
|
||
|
private bool movementInterrupt = false;
|
||
|
[SerializeField]
|
||
|
private PlayerInteractionHandler interactionHandler;
|
||
|
|
||
|
|
||
|
public void Animate(Vector2 movement,bool jump,bool isMoving)
|
||
|
{
|
||
|
animController.SetFloat(runningSpeedParameter, movement.magnitude);
|
||
|
animController.SetBool(runningParameter,isMoving);
|
||
|
//animController.SetFloat(sideStepSpeedParameter, movement.x);
|
||
|
|
||
|
}
|
||
|
public void Animate(PlayerQuickAnimationType animation)
|
||
|
{
|
||
|
switch(animation)
|
||
|
{
|
||
|
case PlayerQuickAnimationType.Grab:
|
||
|
print("grabbing...");
|
||
|
break;
|
||
|
case PlayerQuickAnimationType.Shoot:
|
||
|
print("shooting...");
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
// Start is called before the first frame update
|
||
|
void Start()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
animController.SetBool("IsCarrying", interactionHandler.IsCarrying);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public enum PlayerAnimationType {Movement,Action}
|
||
|
public enum PlayerQuickAnimationType { Grab,Shoot}
|