Don't know how to end animation of shooting ! (code) Please help !
After i made a transition from normal state to shooting state, i got stuck. My character does all the animations, but after shooting and playing the animation for shooting, it gets stuck that way because i don't know what condition to apply in the script so i can make him transition back from the animation after he shoots. Bassicaly i need any type of code that will tell my character when shooting stops so it can transition to the other animation. Here is my script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Weapon : MonoBehaviour { public Transform firePoint; public GameObject bulletPrefab; public Animator animator;
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Shoot();
animator.SetBool("IsShooting", true);
}
}
void Shoot()
{
//shooting logic
Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
}
}
how am i supposed to end the animator.setbool"isShooting", and make it false, i am looking for any condition to apply, like when bullet travels a certain distance, or after a second of playing, or any other ideea?