#pragma strict
var jumpHeight = 10;
var isFalling = false;
var moveSpeed = 8;
var sideCollision = false;
function Start ()
{
}
function Update ()
{
//Player move right
rigidbody2D.velocity.x = moveSpeed;
//Player movement
if (Input.GetKeyDown(KeyCode.Space) && isFalling == false)
{
rigidbody2D.velocity.y = jumpHeight;
}
isFalling = true;
//roof collision
if (Input.GetKey(KeyCode.Space) && sideCollision == false)
{
rigidbody2D.velocity.y = jumpHeight;
}
sideCollision = true;
}
function OnCollisionStay2D ()
{
isFalling = false;
sideCollision = false;
}
it is different when is on the second platform…