error says UnityEngine.Rigidbody required to access non static member "velocity"

my question is very simple, i am trying to make my 2d character jump on the y axis but when i try to run the game it says “Assets/jump.js(7,24): BCE0020: An instance of type ‘UnityEngine.Rigidbody’ is required to access non static member ‘velocity’.” i have a rigidbody on my character. do i need to assign a rigidbody in the script? or is it completely different?
my script is very simple, just;

var jump : int = 5;
    
    function Update () {
       if(Input.GetKeyUp("up"))
          {
    	     Rigidbody.velocity = Vector3(0, 5, 0);
    	  }
    }

1 Answer

1

“Rigidbody” is a class. The Rigidbody component attached to an object is a variable called “rigidbody”. (Technically it’s a property rather than a variable, but the docs call it a variable.)

By the way, use KeyCode enums rather than strings.

so you have probably figured im new to this and still learning the bare basics lol. how do i fix this error?

Well, I already said...rigidbody rather than Rigidbody.

yea i tried that now it does nothing with no error... i should just give up now....

ok i made a new scene and i worked on that character but not in the scene i want it to... :/ i dont think i was ever intended to be a game maker...