I don’t get any error messages and the bullet does appear at the position of the gun, but it stays perfectly still on the screen at all times. This is incredibly frustrating any help is appreciated.
using UnityEngine;
using System.Collections;
public class Shooting : MonoBehaviour {
static public float damage;
public GameObject bullet;
public float bulletSpeed = 5f;
public bool shot = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Space) && shot == false)
{
Instantiate (bullet, transform.position, Quaternion.identity);
bullet.GetComponent<Rigidbody2D>().velocity = new Vector2 (bulletSpeed, 0);
shot = true;
StartCoroutine (waitToShoot (0.35f));
}
}
IEnumerator waitToShoot (float wait)
{
yield return new WaitForSeconds (wait);
shot = false;
}