chunk 1: core gameplay scripts scenes runtime assets
This commit is contained in:
39
Assets/Scripts/Behaviours/Player/PlayerAnimationBehaviour.cs
Normal file
39
Assets/Scripts/Behaviours/Player/PlayerAnimationBehaviour.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerAnimationBehaviour : MonoBehaviour
|
||||
{
|
||||
[Header("Component References")]
|
||||
public Animator playerAnimator;
|
||||
|
||||
//Animation String IDs
|
||||
private int playerMovementAnimationID;
|
||||
private int playerAttackAnimationID;
|
||||
|
||||
public void SetupBehaviour()
|
||||
{
|
||||
SetupAnimationIDs();
|
||||
}
|
||||
|
||||
void SetupAnimationIDs()
|
||||
{
|
||||
playerMovementAnimationID = Animator.StringToHash("Movement");
|
||||
playerAttackAnimationID = Animator.StringToHash("Attack");
|
||||
}
|
||||
|
||||
public void UpdateMovementAnimation(float movementBlendValue)
|
||||
{
|
||||
playerAnimator.SetFloat(playerMovementAnimationID, movementBlendValue);
|
||||
}
|
||||
|
||||
public void PlayAttackAnimation()
|
||||
{
|
||||
// If the unified input-to-animation system is present, avoid double-triggering
|
||||
if (GetComponent<InputToAnimation>() != null)
|
||||
return;
|
||||
playerAnimator.SetTrigger(playerAttackAnimationID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user