I am trying to connect Rigidbody2d to a cube named Player so that it is able to jump. This is my code so far…
#pragma strict
function Start () {
}
function Update () {
if (Input.GetKeyDown(KeyCode.Space)); {
GetComponent(Rigidbody2D).velocity = new Vector2(0,10);
}
}
When I try to play my game this comes up…
MissingComponentException: There is no ‘Rigidbody2D’ attached to the “Player” game object, but a script is trying to access it.
What do I do to fix this. I am using Javascript.