Skip to content

Instantly share code, notes, and snippets.

@itspacchu
Created October 24, 2021 06:54
Show Gist options
  • Save itspacchu/8f837ea56c4e9726eb0a8fa0c6abaf09 to your computer and use it in GitHub Desktop.
Save itspacchu/8f837ea56c4e9726eb0a8fa0c6abaf09 to your computer and use it in GitHub Desktop.
Walking animation between two positions
IEnumerator Walk(Vector3 target, Transform tgt)
{
float t = 0;
Vector3 start = tgt.position;
while(t < 1)
{
LegMoving = true;
t += Time.deltaTime*LegMoveSpeed;
tgt.position = Vector3.Lerp(start, target, t) + Vector3.up * 1.3f*Mathf.Sin(t * Mathf.PI);
yield return null;
}
LegState = (LegState + 1) % 2;
LegMoving = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment