How to make a rigid body move faster.

Here is my js :


private var speed : Vector3 = Vector3 (0, 0, -3);

function FixedUpdate () {
  if(Input.GetKey("w"))
  {
    rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime);
  }
}

I need a way of making rigidbody move faster. I have next to nothing js knowlage. I’m just trying to make my player move faster. Thank you!

Your vector is making it move 3m/s in the negative Z axis. To make it move faster, just increase your -3 value in speed. Or well, decrease it since it’s a negative number.

Declare velocity as a float instead of a Vector3:


private var speed : float = 3; // just increase speed value to go faster

function FixedUpdate () {
  if(Input.GetKey("w"))
  {
    var vSpeed: Vector3 = speed * Vector3(0,0,-1);
    rigidbody.MovePosition(rigidbody.position + vSpeed * Time.deltaTime);
  }
}

But this isn’t a good way to move a rigidbody. You could move it via AddForce - but set the rigidbody Drag field to a reasonable value, like 0.5 to 1.0, or the rigidbody will behave like an ice block:


var force: float = 10;
var turnSpeed: float = 120;

function FixedUpdate () {
	transform.Rotate(0, turnSpeed * Input.GetAxis("Horizontal") * Time.deltaTime, 0);
	rigidbody.AddForce(transform.forward * Input.GetAxis("Vertical") * force);
}

But maybe a rigidbody isn’t what you want. If the rigidbody is your character, consider to use a CharacterController instead - take a look at SimpleMove (includes gravity automatically, but doesn’t allow jumping) and 2 (gravity is in your hands).