Givago
1
Hi, I’m doing a tutorial and on tutorial it is the following code:
#pragma strict
var velocidade: float;
var velocidadeAtual: float;
function Start () {
Rigidbody myRigidbody = (Rigidbody).GetComponent(typeof(Rigidbody));
}
function Update () {
velocidade = 0.5;
velocidadeAtual = myRigidbody.velocity.magnitude;
myRigidbody.velocity += transform.forward*velocidade*Input.GetAxis("Vertical");
}
but it is giving error on my.
vintar
2
So the first error I can see is that you use javascript, the second being that you didn’t actually post what the error was.
Givago
3
Sorry =P I am using java to a problem with that? (do not know).
ERROR:
Assets/MovimentacaoCarro.js(9,13): UCE0001: ‘;’ expected. Insert a semicolon at the end.
I dont know javascript, but is there suppose to be a period after (Rigidbody) cast in the start method?
The syntax is
var myRigidbody : Rigidbody;
function Start() {
myRigidbody = GetComponent.<Rigidbody>();
}
…but to be fair, you should absolutely be learning C# instead, especially since that seems to be closer to your way of thinking already.
Givago
6
still has the same error.
Is that to wanting to do this tutorial and understand Rigidbody
Can you post the entire script as it is now?
Givago
8
Thank you, it worked now.
I had a small mistake.