Tank Firing Script

I really need a script that will allow me to fire. A rocket launcher script would do, but I can’t find any. I tried writing one but I am failing. What I need is something that will instantiate a projectile prefab at a position when I press the space bar, and then wait about a second before allowing the player to fire another projectile. My projectile is working fine; it has it’s own script plus a constant force and so on. But my tank is not firing properly. Any ideas?

1 Answer

1

How in the world are all these ‘write a script for me’ questions making it through today??

public GameObject projectile;
public Transform projectileSpawnRef;

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
        GameObject.Instantiate(projectile, projectileSpawnRef.position, projectileSpawnRef.rotation);
}