Created
October 24, 2021 06:54
-
-
Save itspacchu/8f837ea56c4e9726eb0a8fa0c6abaf09 to your computer and use it in GitHub Desktop.
Walking animation between two positions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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