42 lines
1000 B
C#
42 lines
1000 B
C#
namespace Gameplay.Vehicle
|
|
{
|
|
using UnityEngine;
|
|
|
|
public class VehicleAnim
|
|
{
|
|
|
|
public BaseVehicle owner;
|
|
|
|
public readonly Animator rawAnim;
|
|
|
|
public string currentAnim { get; private set; }
|
|
public string targetAnim;
|
|
|
|
public VehicleAnim(BaseVehicle owner)
|
|
{
|
|
this.owner = owner;
|
|
var rootObj = owner.Node.GameObject;
|
|
var animTrans = rootObj.transform.GetChild(0).GetChild(0);
|
|
rawAnim = animTrans.GetComponent<Animator>();
|
|
}
|
|
|
|
public void ViewUpdate(float dt)
|
|
{
|
|
if (rawAnim == null) return;
|
|
if (currentAnim != targetAnim)
|
|
{
|
|
if (currentAnim == null)
|
|
{
|
|
rawAnim.Play(targetAnim);
|
|
}
|
|
else
|
|
{
|
|
rawAnim.CrossFade(targetAnim, 0.1f);
|
|
}
|
|
currentAnim = targetAnim;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|