Hi!
I’m new to Unity and Java and C#. I bought a book “Unity 3.x Game Development Essentials”
But I’m stuck with the first script. Everything is written correct. I have checked it twice. It says "Log in file: Assets/Shooter.js at line 19. But I have no line 19. Can someone check this script?
#pragma strict
function Start () {
}
var bullet : Rigidbody;
var power : float = 1500;
var moveSpeed : float = 5;
function Update () {
var h : float = Input.GetAxis(“Horizontal”) * Time.deltaTime * moveSpeed;
var v : float = Input.GetAxis(“Vertical”) * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if(Input.GetbuttonUp(“Fire1”)){
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation);
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
Thank you
Please, post your script between code tags. It’s much easier to read.
When the console says there’s an error at a line you don’t have, it’s almost allways a forgotten character. You forgot to close your function “update” with a brace.
I also first declare variables and the I add functions. I think yours also works, but it’s very important to keep it nice and clean.
#pragma strict
var bullet : Rigidbody;
var power : float = 1500;
var moveSpeed : float = 5;
function Start ()
{
}
function Update ()
{
var h : float = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
var v : float = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if(Input.GetbuttonUp("Fire1"))
{
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation);
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
}
Here’s the code, hope it works! 
Hi!
Thanks for the help. But now I get some other errors at line 25.
“Assets/Shooter.js(25,11): BCE0043: Unexpected token: var.”
“Assets/Shooter.js(25,14): UCE0001: ‘;’ expected. Insert a semicolon at the end.”
“Assets/Shooter.js(25,15): BCE0043: Unexpected token: instance.”
I can’t understand the problem. I have followed the book. And this line is exactly the same as in the book.
#pragma strict
var bullet : Rigidbody;
var power : float = 1500;
var moveSpeed : float = 5;
function Start ()
{
}
function Update ()
{
var h : float = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
var v : float = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if(Input.GetbuttonUp("Fire1")){
{
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation);
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
}
Your line at line 21 is the cause of this error… you have an extra bracket where there shouldn’t be one.
if(Input.GetbuttonUp("Fire1")){
{
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation);
should read as
if(Input.GetbuttonUp("Fire1")){
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation);
You can generally spot this kind of thing by counting the number of { (open) brackets and comparing it to the number of } (close) brackets. There has to be one opening bracket for each closing bracket. By now you’re likely familiar with what happens if you don’t obey this computer law.
Thank you, but now I get also error. This will never end. 
The code will be like this.
#pragma strict
var bullet : Rigidbody;
var power : float = 1500;
var moveSpeed : float = 5;
function Start ()
{
}
function Update ()
{
var h : float = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
var v : float = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if(Input.GetbuttonUp("Fire1")){
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation);
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
At this code I will get the error
“Assets/Shooter.js(28,1): BCE0044: expecting }, found ‘’.”
#pragma strict
var bullet : Rigidbody;
var power : float = 1500;
var moveSpeed : float = 5;
function Start ()
{
}
function Update ()
{
var h : float = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
var v : float = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if(Input.GetbuttonUp("Fire1")){
var instance: Rigidbody = Instantiate(bullet, transform.position, transform.rotation);
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
}
At this code I will get this error. Here I add } at line 28.
“Assets/Shooter.js(21,15): BCE0019: ‘GetbuttonUp’ is not a member of ‘UnityEngine.Input’. Did you mean ‘GetButton’?”
lower case and upper case is also important, GetButton is not the same as Getbutton
GetButtonUp on line 21.
I know you’re trying to follow along with a tutorial and it can be difficult when tying to type from a video but all of the errors you’re having are typo’s. Keep at it though you’ll get it eventually.
Edit : Doh… beaten again by koyima… I must be a slow typer
Finally, it works.
Thank you all for the help 