added: new maru model and downed animation
This commit is contained in:
44
Assets/Scripts/Units/UnitAnimation.cs
Normal file
44
Assets/Scripts/Units/UnitAnimation.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reset.Units{
|
||||
public class UnitAnimation : UnitComponent{
|
||||
public Animator modelAnimator;
|
||||
|
||||
// Temporary
|
||||
private float inputMagnitude;
|
||||
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
void Update(){
|
||||
try {
|
||||
// Temporary
|
||||
inputMagnitude = Mathf.MoveTowards(inputMagnitude, GetComponent<PlayerControls>().rawMoveInput.magnitude * 2f, 6f * Time.deltaTime);
|
||||
|
||||
modelAnimator.SetFloat("Move Direction X", Unit.Movement.GetResolvedDirectionLocal().x * inputMagnitude);
|
||||
modelAnimator.SetFloat("Move Direction Y", Unit.Movement.GetResolvedDirectionLocal().y * inputMagnitude);
|
||||
} catch (Exception e) {
|
||||
Debug.LogError($"Failed in setting X and Y move direction floats: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public void SendTriggerToAnimator(string trigger){
|
||||
if (!modelAnimator) {
|
||||
Debug.LogError($"There is no animator set to recieve the trigger '{trigger}' on unit {name}.", gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
modelAnimator.SetTrigger(trigger);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Failed to send trigger to Animator: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user