- Home /
someone please help with my C# parsing error
hi everyone. please go easy on me. this is my FIRST attempt at using C#. i'm not sitting here claiming to know anything about it; i'm simply following the steps in a book.
can you please EXPLAIN my error as if i'm an idiot please. i feel as if i have typed it in exactly as the book has told me to but i get a parsing error message when attempting to play.
here is the code as i typed it in:
using UnityEngine;
using System.Collections;
public class Shooter : MonoBehaviour {
public Rigidbody bullet;
public float power = 1500f;
public float moveSpeed = 2f;
void Update () {
float h = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;
float v = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;
transform.Translate(h, v, 0);
if (Input.GetButtonUp ("Fire1")){
Rigidbody instance = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
Instance.addforce(fwd * power);
}
}
hi there. thanks so much you two. i started from scratch and along the way realised you were both correct. the case sensitive error caused issues and so did the missing '}'.
thanks though, my game is now working and i cant believe how awesome the software is. thanks for your help :)
Answer by robertbu · Jul 01, 2013 at 06:20 PM
The parsing error is a missing '}' at the bottom of the file to close off the class.
Answer by equalsequals · Jul 01, 2013 at 06:03 PM
Also I noticed that on line 14 you have instance, and 16 you have it spelled Instance. It's case sensitive so that would be a problem. Additionally on 16 it should be "AddForce".