Expecting }, found 'static'
Also: expecting EOF, found '}'.
#pragma strict
var rotationSpeed = 100;
function Update ()
{
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
static Rigidbody.AddRelativeForce (Vector3.back * rotation);
}
Without the 'static' on the second to last line it would give me an error telling me i cannot use non-static variables with static variables.
Answer by Happy-Zomby · Apr 16, 2016 at 09:14 AM
Hi, Is there a reason why you can't use a getcomponent rigibody? GetComponent().AddRelativeForce(Vector3.back * rotation); http://docs.unity3d.com/ScriptReference/Rigidbody.AddRelativeForce.html
Answer by Gingerninja800 · Apr 16, 2016 at 10:42 AM
No reason, im just very new to all this - didn't know about it.
Line 9 is also supposed to be 'AddRelativeTorque'. Not force - forgot to change it back when playing around with it.
It still worked though with:
#pragma strict
var rotationSpeed = 100;
function Update ()
{
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent(Rigidbody).AddRelativeTorque (Vector3.back * rotation);
}
Many Thanks my friend.
Your welcome - if you want to use unityscript(javascript) - I would strongly recommend you go through the walker boys tutorials http://www.walkerboystudio.com/wbstudio/learn-unity/ You may also want to think about C# versus Unityscript - I was doing Unityscript (aka javascript in unity manual) until recently but if I understood right it is rather specific to unity whereas if you learn in c# you can re-use that knowledge elsewhere... also visual studio works great with c# and having the tool offer you the right keywords and identifying the issues more specifically does help. I'm happy to have switched. Just food for thought.
Your answer
Follow this Question
Related Questions
Javascript error on runtime semi colon required 1 Answer
How To Make A Kill Counter 1 Answer
Js autocomplete not working in 5.3.4 f1 2 Answers
About UnityScript - us.exe compiler 0 Answers