Hello i forgot how i write a simple line of code that let the gameobject move .
it was like this.
Rigidbody.velocity = 20
Hello i forgot how i write a simple line of code that let the gameobject move .
it was like this.
Rigidbody.velocity = 20
See the scripting reference.
First, you need to address the actual rigidbody component on your object, not the rigidbody class. In a script this is done with the lowercase classname, i.e. rigidbody.
Second, velocity is a 3D vector. If you want to change it, you must set it to another 3D vector - either by assigning a new one or by modifying the old one through multiplication etc.
So, your code should look something like this:
rigidbody.velocity = Vector3(0,10,0); // set object to move up
rigidbody.velocity *= 4; // make object 4 times as fast
If your game object has a Rigidbody, you may set its velocity directly - but remember that this is a velocity vector, a Vector3 defining whose length is the absolute speed. If you want to put a rigidbody to move in its forward direction, use this:
rigidbody.velocity = transform.forward * 20;