- Home /
Problems with my grenade PLEASE HELP!
I am new to scripting at unity and am trying to make an fps game. I downloaded some weapon things from dastardly bannana even though i had some scripts i needed gun models. Their weapons are all good except the grenade. I wanted the grenade to bounce and explode on a timer, not on collision, so i am re-scripting it(in java script). http://www.dastardlybanana.com/FPSConstructorWeapons.htm I think i almost got it except i keep getting this error:
Assets/my grenade.js(8,18): BCE0044 expecting (, found 'Update'.
Here is my script so far:
var ExplodeTime : float;
var Explosion : Transform; private var Thrown : boolean = false; var speed : int = 25;
function Start() { function Update() { if(Input.GetButtonDown("Fire1")) { gameObject.velocity = transform.TransformDirection( Vector3( 0, 0, speed) ); Physics.IgnoreCollision( gameObject.collider, transform.root.collider ); Thrown = true; } else { return; } if(Thrown = true) { yield WaitForSeconds (ExplodeTime); if(Time.time > ExplodeTime) { Instantiate(Explosion, transform.position, transform.rotation); Destroy(gameObject); } }
}
}
Please help me fix this or give me a new script. THANKYOU``
Answer by Nynex71 · Jan 16, 2011 at 01:44 AM
the function start () { is missing an end bracket, since you not doing anything with it you dont need it so your script should look like this
var ExplodeTime : float;
var Explosion : Transform;
private var Thrown : boolean = false;
var speed : int = 25;
function Update() {
if(Input.GetButtonDown("Fire1")) {
gameObject.velocity = transform.TransformDirection( Vector3( 0, 0, speed) );
Physics.IgnoreCollision( gameObject.collider, transform.root.collider );
Thrown = true; } else { return; }
if(Thrown = true) {
yield WaitForSeconds (ExplodeTime);
}
if(Time.time > ExplodeTime) {
Instantiate(Explosion, transform.position, transform.rotation); Destroy(gameObject); }
}
i might have messed up with to many { and } if so im sure you can fix im just tired
Your answer
![](https://koobas.hobune.stream/wayback/20220613095628im_/https://answers.unity.com/themes/thub/images/avi.jpg)