Animation will not stop playing? Help needed


Ok now for anyone ready to help me here –

This is a 2d game and javascript MY Animation will not stop playing , I have so far

1 checked all loops OFF

2 checked for wrap modes set all to “once”

3 Checked and made sure it is not my default animation

Please help

heres my script below

var animator : Animator;
	 var pow: AudioClip;
	 var fingersslap: AnimationClip;

	function Start () {
		animator = GetComponent("Animator");
		animation.clip = fingersslap;
	audio.clip = pow;
	//function Update () {	
		//if(Input.GetButtonDown("Fire1")) {
		function OnCollisionEnter2D(coll : Collision2D) {
         if (coll.gameObject.tag == "Player") {
    //animator.SetBool("dead", true);
             Debug.Log("whyyy collision detected");
			animator.SetBool("Fire1", true);
		else {
			animator.SetBool("Fire1", false);
	function SetFire1(value: boolean) {
		  Fire1 = value;
		animator.SetBool("Fire1", value);

alt text

This looks like expected behaviour to me.

1.) Let’s assume you start in the “fingidle” state, with “Fire1” bool set to false.
2.) A collision is detected with the player. This sets “Fire1” to true (line 22 of your code).
3.) Since the condition “Fire1 = true” is met, the animator transitions from fingidle to fingerslap state.
4.) When the fingerslap state ends, the “Exit Time” condition is met and the animator transitions from fingerslap to fingidle.
5.) However, since “Fire1 = true” still, the animator transitions straight back from fingidle to fingerslap again…

Steps 3.) and 4.) will continue to be repeated indefinitely until “Fire1 = false”, which you only do when a collision is detected with something other than the player (line 32).

Create a function to set Fire1 false and call it at line 25 (anyway right after you SetBool it to true):

function StopFire() {
   animator.SetBool("Fire1", false);

And make sure you haven’t a transition from “Any state” to fingerslap (the only transition should be from fingeridle to fingerslap and its condition must be Fire1=true).