This script I’m using on a Rigidbody object is KIND OF working. My first jump is pretty high, and all subsequent jumps are about 1/8th the force. What gives?
#pragma strict
var speed : float;
var grounded : boolean = true;
function Update () {
var moveHorizontal : float = Input.GetAxis("Horizontal");
var moveVertical : float = Input.GetAxis("Vertical");
var moveUp : float;
if (Input.GetKeyDown("space") && grounded == true) {
moveUp = 20;
grounded = false;
}
var movement : Vector3 = Vector3(moveHorizontal, moveUp, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
function OnCollisionStay(collisionInfo : Collision) {
grounded = true;
}