Hello I need help with my jump script.
The problem is that my player keeps falling trough the ground
var JumpStrength : float = 5;
var JumpDecay : float =0.01;
var Jumped : boolean = false;
function Start () {
this.gameObject.AddComponent(Rigidbody);
this.rigidbody.freezeRotation = true;
}
function Update () {
if (this.Jumped)
{
this.transform.position.y += this.JumpStrength - this.JumpDecay;
this.JumpDecay += 0.009;
}
}
function LateUpdate()
{
if ( !this.Jumped)
this.Jumped = true;
}
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.tag == "Ground")
{
this.Jumped=false;
this.JumpDecay=0;
}
}
Can someone help?