Instert Semicolon

Hello. I know the title might have too little info in it but I will try to explain here.
So when I was coding a script I inserted this line:

UnityEngine.Rigidbody AddRelativeTorque; (Vector3.back * rotation);

Then unity gave me this alert:

Assets/NewBehaviourScript BACKUP.js(8,26): UCE0001: ‘;’ expected. Insert a semicolon at the end.

I went to the exact line and exact color but no matter what it kept giving me this alert.
This might be a simple mistake but if anyone knows how to fix this please respond.
Below is my script.

Thanks,

2881111--211532--bandicam 2016-12-10 11-30-20-122.jpg

You have a semicolon in the middle

Also, you shouldnt be calling the static method, you should provide a reference to an actual rigidbody. Go tutorials

lol that looks more like a typo or a mistake he made without double checking code than necessarily misundestanding how to code, happens all the time and when you’re on a big project you just don’t realise what you’ve done because there’s so much there.

Hahahahaha fail :smile:

Can anyone send me the code that i need?

var rb: Rigidbody;

rb.AddRelativeForce(Vector3.back * rotation);

You need a variable reference to your Rigidbody, assigned in the inspector.
Should be correct unless my UnityScript syntax is off.
(Insert something about using C# :p)

Thanks

#pragma strict
var rotationSpeed = 100;
function Update () {
    var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
    rotation *= Time.deltaTime;
    var rb: Rigidbody;
    rb.AddRelativeForce(Vector3.back * rotation);
    }

Now this error comes up:

NullReferenceException: Object reference not set to an instance of an object
NewBehaviourScript.Update () (at Assets/NewBehaviourScript.js:7)

Could you help me with this too?

If so thanks for helping me out!

This line:

var rb: Rigidbody;

Goes at the top under the #pragma strict. it is a VARIABLE.
There is only so much I can give you. I suggest you search for some more tutorials on basic programming.

Is there any particular reason you decided to do this using UnityScript? You should consider using C# instead unless it would be unpractical for some reason.

1 Like

Would I have to change the code for this? (sorry I’m new to all this)

At this point im sorry but I have to say this.
STOP, Just stop.
You need to go learn basic programming concepts.
Everyone has been here, starting from scratch, dont make the same mistake like a lot of people thinking you can “make a game”. It is a lot of work and skill, a lot that you dont have yet. Start from the bottom and NOT on unity.

At this point I agree with you.

BUT ill never give up.

bye everyone.

You can still use Unity and learn programming at the same time. But, start learning C#, not UnityScript.
But just use Unity to compile the code and view the Console. Practice creating scripts and using Debug.Log in the scripts to print information to the Console. In unity editor the information is put in the console so you can see what the script is doing.

1 Like

Thanks for all your advice and I think I’m gonna learn a lot about not starting too early! Thanks again for all your help.

1 Like

Good idea.
I would like to personally recommend Quill18Creates on YouTube.
He has a pure C# tutorial which should help you out, depending on how you learn.

https://www.youtube.com/watch?v=eycAAKpoJxA

Its a great place to start.

Once you master it C# is incredibly powerful. Make sure you really know how it works rather than just “it does what I want”, though.

Thanks, everyone I’m gonna start watching those tutorials.