I have a jumping script and it should be right, but I keep getting an error that says… “An instance type ‘Unity.Collision’ is required to access non static member ‘gameObject’” I do not know how to fix this and help would be appreciated. Here is the script I’m using for jumping.
#pragma strict
var JumpStrength : float = 0.3;
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 - JumpDecay;
this.JumpDecay += 0.009;
}
}
function LateUpdate ()
{
if (Input.GetKeyDown("space") )
{
if ( !this.Jumped )
{
this.Jumped = true;
}
}
}
function OnCollisionEnter ( collision : Collision )
{
if (Collision.gameObject.name == "Floor" )
{
this.Jumped = false;
this.JumpDecay = 0.01;
}
}