Hello! I am a new unity user and I was following a tutorial on Unity but the jump script was not working well. I have a sphere character. I've tried many solutions but none have worked. Basically, when my ball moves from one cube to another, it won't jump at all anymore. This also happens if I hit a slope or a ceiling. JavaScript script by the way.
Script:
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
private var isFalling = false;
function Update ()
{
//moves ball left and right
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKey(KeyCode.UpArrow) && isFalling == false)
{
rigidbody.velocity.y = jumpHeight;
isFalling = true;
}
}
function OnTriggerEnter()
{
isFalling = false;
}
function OnTriggerExit()
{
isFalling = true;
}
A picture of one of the areas my jump breaks:
http://puu.sh/9IzmO/6f9175bf9c.jpg
Thanks in advance
↧