Hey guys, I made a simple camera shake state and animation in Mecanim. I have a player character and I want it to trigger this camera shake when he actually shoots. My shoot script is here below:
using UnityEngine;
using System.Collections;
public class PlayerShoot : MonoBehaviour
{
public GameObject bullet;
public string shotButton = "Fire1";
public float shotDelay = 0.2f;
private bool readyToShoot = true;
// Update is called once per frame
void Update ()
{
{
if(Input.GetButton(shotButton) && readyToShoot)
{
if(audio != null)
{
if(!audio.isPlaying)
{
audio.Play();
}
}
Instantiate(bullet,transform.position,transform.rotation);
readyToShoot = false;
Invoke("ResetReadyToShoot", shotDelay);
}
}
}
void ResetReadyToShoot()
{
readyToShoot = true;
}
}
So every 0.2 seconds my character shoots. I also want it to play the camera shake animation every 0.2 seconds. My issue is I have no idea how to do this. I added a bool parameter in the cameraController called “Shake” and set it as the transition condition for the camera to go from idle to shaking.
How do I actually set that bool to true all the way from my player’s shooting script?