- Home /
expected. Insert a semicolon at the end
Please tell me what's up with this script
var bullet : Transform;
var spawnDistance : int = 3;
var firingDelay : float - 1;
private var nextFire = 0.0;
function Update () {
if (Input.GetKey("space") && Time.time > nextFire) {
nextFire = Time.time + firingDelay;
Instantiate (bullet, Vector3(transform.position.x +
spawnDistance, transform.position.y, transform.position.z),
}
}
The layout came out wrong In the question but that right
Answer by robertbu · Dec 13, 2013 at 04:29 PM
On Line 3, you have a '-' sign where you should have an '=' sign. On line 10, you did not complete the function call for Instantiate(). I recommend keeping a #pragma strict at the top of the file. In addition to forcing static typing (performance issue) of variables, it will also help you out by producing compile time errors for some things that would be runtime errors otherwise.
#pragma strict
var bullet : Transform;
var spawnDistance : int = 3;
var firingDelay : float = 1;
private var nextFire = 0.0;
function Update () {
if (Input.GetKey("space") && Time.time > nextFire) {
nextFire = Time.time + firingDelay;
Instantiate (bullet, Vector3(transform.position.x +
spawnDistance, transform.position.y, transform.position.z), Quaternion.identity);
}
}
Your answer
Follow this Question
Related Questions
Can't Add Scripts, even if they are very first in project and brand new 1 Answer
Public List of Scripts? 1 Answer
Animation clips anyone? 1 Answer
How do you add levels to your game? 1 Answer
Need Help for AirPlane Script 1 Answer