I have a problem with my bullet once it fires. I have a script that checks for a bool if the player is facing left or not. And what I want to happen is that when the player faces the left direction and fires the bullet will go in the direction that he is facing. The script below is attached to the actual bullet and the bullet itself is the gameobject that checks for the bool. And it will work fine until I turn left the bullet would start to shake uncontrollably. What am I doing wrong here?
public float speed;
public float death;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if(GameObject.Find("Player").GetComponent<PlayerMovement>().facingLeft)
{
speed = 1 * -speed;
}
transform.Translate(0, 0, Time.deltaTime * speed);
StartCoroutine("DestroyBullet");
}
IEnumerator DestroyBullet()
{
yield return new WaitForSeconds(death);
Destroy(gameObject);
}