Does anyone know how to make a Charge jump script in Javascript. I am pretty new at Javascript so I didn’t know how to.
So when you hold the “W” key down depending on how long you hold it thats how high you would go.
I already have jump and move script but I also need to know where you would put the charged the jump script or if you would make a whole new script
-------------------------------------------------------------------------------------
#pragma strict
var rotationSpeed = 400;
var jumpHeight = 10;
var jumpHeight2 = 10;
var isFalling = false;
function Update ()
{
// this is to Handle the Ball rotation.
var rotation : float = Input.GetAxis("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent(Rigidbody).AddRelativeTorque(Vector3.back * rotation);
// this is to help the ball jump.
if (Input.GetKey(KeyCode.W)&& isFalling == false)
{
GetComponent(Rigidbody).velocity.y = jumpHeight;
}
}
function OnCollisionStay ()
{
isFalling = false;
}
function OnCollisionExit ()
{
isFalling = true;
}
-------------------------------------------------------------------------------------
I currently don’t have any errors.