Hi, i have created a simple Javascript that allows the player to shoot in the direction they are facing, with the left mouse. But i have a problem that i cant fix. I have also created a basic pause game script (JS also), but whenever i pause the game and click the GUI buttons (Like options etc), the game character fires the bullets while paused! (The projectiles remain static but build on each click). On resume, the bullets shoot in the direction i’m facing, depending on how many times i have clicked in the pause menu screen. Is there anyway to deactivate the shooting script when the escape key is press (When paused)?
Scripts used:
var Bullet:Transform;
var shootForce:float;
function Update() {
if(Input.GetButtonDown("Fire1")) {
var instanceBullet = Instantiate(Bullet, transform.position, Quaternion.identity);
instanceBullet.rigidbody.AddForce(transform.forward * shootForce);
}
}
And:
var paused : boolean = false;
var myCheck : boolean = false;
function Update () {
if(Input.GetButtonDown("Pause")) {
if(!paused){
Time.timeScale = 0; paused = true;
} else {
Time.timeScale = 1;
paused = false;
}
}
}
function OnGUI() {
if(paused) {
if(GUI.Button (Rect (10, 50, 100, 30), "Resume")) {
Time.timeScale = 1.0f;
paused = false;
}
if(GUI.Button (Rect (10, 90, 100, 30), "Options")) {
//Pause Game Options
}
if(GUI.Button (Rect (10, 130, 100, 30), "Exit")) {
Application.Quit();
}
}
}