Question by
synjaqt · Jan 27, 2017 at 07:51 PM ·
scripting problembug
Can someone help me fix this bug?
The is the code I'm using:
#pragma strict
var rotationSpeed = 100;
function Update ()
{
var rotation : float = Input.GetAxis ("Horizantal") * rotationSpeed;
rotation *= Time.deltaTime;
Rigidbody.AddRelativeTorque (Vector3.back * rotation);
}
and this is the error that shows up: BCE0044: unexpected char: 0xFEFF
Comment
Best Answer
Answer by Hellium · Jan 27, 2017 at 08:02 PM
You need the Rigidbody component of the gameobject if you want to apply the force :
var rigidbody: Rigidbody = gameObject.GetComponent(Rigidbody ) as Rigidbody ;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
Okay you fixed a problem I didn't realize I had, but it turns out I believe I had a space after one of the semicolons and so that fixed my other problem, but revealed a third problem that I believe is completely unrelated. So thank you so much for your help