- Home /
Question by
J.Peasmouldgrunnfuttok · Jan 20, 2015 at 07:59 AM ·
javascriptmovement script
Rolling ball
I am trying to make a ball move however I get this error: ECU0001 ';' expected. Insert semicolon at the end. This is my code:
#pragma strict
public var speed : float;
void FixedUpdate(){
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
Comment
Best Answer
Answer by SeasiaInfotechind · Jan 20, 2015 at 09:11 AM
Hello J.Peasmouldgrunnfuttok ,
you have declared the variable according to the java script and rest of the code is in c#. It should be like:
javaScript:
#pragma strict
public var speed : float;
function FixedUpdate()
{
var moveHorizontal : float = Input.GetAxis("Horizontal");
var moveVertical : float = Input.GetAxis("Vertical");
var movement: Vector3 =Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
C#
public float speed;
void FixedUpdate(){
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
Thanks
Answer by zharik86 · Jan 20, 2015 at 08:02 AM
You try write script on both language: CSharp and Java. Write on Java:
#pragma strict
public var speed : float;
void FixedUpdate() {
var moveHorizontal: float = Input.GetAxis("Horizontal");
var moveVertical: float = Input.GetAxis("Vertical");
var movement: Vector3 = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
I hope that it will help you.