hey guys why does this code not work to my game? please write down the fail to me #pragma strict var rotationSpeed = 100; function Update var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed; rotation *= Time.deltaTime; Rigidbody.AddRelativeTorque (Vector3.back * rotation);
Hi, you should check these tutorials, answer is there http://unity3d.com/learn/tutorials/modules/beginner/scripting
put 100 instead of rotationSpeed var rotation : float = Input.GetAxis ("Horizontal") * 100; rotationSpeed is public variable, i think you might have put 0 value in inspector.
???? ! #pragma strict var rotationSpeed = 100; function Update var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed; rotation *= Time.deltaTime; Rigidbody.AddRelativeTorque (Vector3.back * rotation); this is my code but it stil says Assets/ballcontrol.js(7,4): BCE0044: expecting (, found 'var'. and Assets/ballcontrol.js(7,8): BCE0044: expecting EOF, found 'rotation'.
The problem is that you've omitted a lot of the syntax for a function. Check whatever tutorial or sample script you're working from, and make sure you get all the bits - parentheses, curly brackets, etc.
#pragma strict var rotationSpeed = 100; function Update () ( var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed; rotation *= Time.deltaTime; rigidbody.AddRelativeTorque (Vector3.back * rotation); ) it stil says - All compiler errors have to be fixed before you can enter gamemode. What should i do- plzz give an understandbile explanation
This message is never going to be the only error message. (Although, it will be the most recent one, and will therefore show up at the bottom of the main Unity window.) Have you pulled up the Console window to see what the other errors shown are?
Assets/ballcontrol.js(7,4): BCE0044: expecting (, found 'var'. and Assets/ballcontrol.js(7,8): BCE0044: expecting EOF, found 'rotation'.
It looks like you are using the wrong braces, "(" instead of "{". Try this: Code (JavaScript): #pragma strict var rotationSpeed = 100; function Update () { var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed; rotation *= Time.deltaTime; rigidbody.AddRelativeTorque (Vector3.back * rotation); }