- Home /
Strange errors after update to Unity 5...
So I know that one of the things in the new update is removing the shortcut variables like "Rigidbody2D.velocity" and the likes. Thing is when I change my code to apropriate the change I get some strange errors about the placement of "(" and ";".
#pragma strict
var moveSpeed:float;
var jumpHeight:float;
var myRigidbody2D: Rigidbody2D;
function Start () {
myRigidbody2D = GetComponent<Rigidbody2D>();
}
function Update () {
if(Input.GetKeyDown(KeyCode.Space)){
myRigidbody2D.velocity = new Vector2(0, jumpHeight);
}
}
This is my code and the errors I get are on the line of code int the Start function. The errors are: "Assets/Scripts/PlayerController.js(11,51): BCE0043: Unexpected token: )."
"Assets/Scripts/PlayerController.js(11,53): BCE0044: expecting ), found ';'."
and "Assets/Scripts/PlayerController.js(11,54): UCE0001: ';' expected. Insert a semicolon at the end."
And thanks for the help in advance. :)
Answer by DoTA_KAMIKADzE · May 06, 2015 at 11:20 PM
You're mixing c# with javascript. Change your line#11 to this:
myRigidbody2D = GetComponent(Rigidbody2D);
Your answer
Follow this Question
Related Questions
GetComponent Picking up multiple scripts from differrent objects? 1 Answer
How do I check if the gameobject I collided with has a certain script? (C#) 1 Answer
Weird GetComponent error 2 Answers
My scripts are not working properly 0 Answers
GetComponent Editing Variables not working in 3.5? 0 Answers