movement anim
This commit is contained in:
parent
b7562d53ae
commit
5776d5e889
4 changed files with 114 additions and 54 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class Entity : MonoBehaviour
|
||||
|
|
@ -10,6 +11,7 @@ public class Entity : MonoBehaviour
|
|||
[Header("Movement")]
|
||||
public int maxMovement;
|
||||
public TileObject currentTile;
|
||||
public float moveAnimSpeed;
|
||||
|
||||
[Header("Flags")]
|
||||
public bool canMove = true;
|
||||
|
|
@ -34,4 +36,22 @@ public class Entity : MonoBehaviour
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual IEnumerator MoveToLocation(TileObject[] pathToMove)
|
||||
{
|
||||
float currentState = 0;
|
||||
int currentTileList = 0;
|
||||
while (currentTileList < pathToMove.Length)
|
||||
{
|
||||
currentState += Time.deltaTime * moveAnimSpeed;
|
||||
transform.position = Vector2.Lerp(currentTile.transform.position, pathToMove[currentTileList].transform.position, currentState);
|
||||
if (currentState > 1)
|
||||
{
|
||||
currentTile = pathToMove[currentTileList];
|
||||
currentState = 0;
|
||||
currentTileList++;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue