Animation.Stop

Switch to Manual

Declaration

public void Stop();

Description

Stops all playing animations that were started with this Animation.

Stopping an animation also Rewinds it to the Start.

using UnityEngine;

public class ExampleScript : MonoBehaviour { Animation anim;

void Start() { anim = GetComponent<Animation>(); }

void Update() { if (Input.GetButtonDown("Jump") && anim.isPlaying) { anim.Stop(); } } }

Declaration

public void Stop(string name);

Description

Stops an animation named name.

Stopping an animation also Rewinds it to the Start.

using UnityEngine;

public class ExampleScript : MonoBehaviour { Animation anim;

void Start() { anim = GetComponent<Animation>(); }

void Update() { if (Input.GetButtonDown("Jump") && anim.isPlaying) { anim.Stop("CubeJump"); } } }

Did you find this page useful? Please give it a rating: