RigidBody.AddForce example in JavaScript

I can’t seem to get the simple tutorial working with JavaScript.

#pragma strict

var rb;

function Start () {
  rb = GetComponent('<RigidBody>');

function FixedUpdate () {
  var moveHorizontal = Input.GetAxis("Horizontal");
  var moveVertical = Input.GetAxis("Vertical");
  var movement = new Vector3(moveHorizontal, 0, moveVertical);


keeps outputting: Assets/PlayerController.js(15,12): BCE0019: 'AddForce' is not a member of 'Object'.

Perhaps it’s my GetComponent usage?

I’d appreciate some help.

EDIT: Doesn’t work either with rb = GetComponent('RigidBody');

D’oh. I’m a fool.

It’s Rigidbody with a lowercase b… not B.


rb = GetComponent('Rigidbody');