holopy3/Assets/Plugins/RootMotion/FinalIK/_DEMOS/FBBIK/Scripts/SoccerDemo.cs

39 lines
851 B
C#
Raw Permalink Normal View History

2020-12-10 14:25:12 +00:00
using UnityEngine;
using System.Collections;
namespace RootMotion.Demos {
[RequireComponent(typeof(Animator))]
public class SoccerDemo : MonoBehaviour {
private Animator animator;
private Vector3 defaultPosition;
private Quaternion defaultRotation;
void Start () {
animator = GetComponent<Animator>();
// Remember the default position and rotation of the character
defaultPosition = transform.position;
defaultRotation = transform.rotation;
StartCoroutine(ResetDelayed());
}
// Reset the character after some time and restart the animation
private IEnumerator ResetDelayed() {
while (true) {
yield return new WaitForSeconds(3f);
transform.position = defaultPosition;
transform.rotation = defaultRotation;
animator.CrossFade("SoccerKick", 0f, 0, 0f);
yield return null;
}
}
}
}