Jump Script not Working JavaScript
I am working on a double jump script for a game I am making but when I run the game my character does not jump at all, not once nor twice. I am not sure what the problem with the script is I was wondering if I could get some help.
My code is below:
var jumps: int = 2; // Max number of Jumps
var onGround : boolean = true;
function Update () {
//Reset Jumps when player hits the ground
if( onGround == true){
jumps = 2;
}
//Jump if you have any jumps left
if(( Input.GetButton("Jump")) && (jumps >=1)){
jumps --;
GetComponent.<Rigidbody>().velocity.y = 5; //Insert Your Jump Code Here
}
}
//Checking if player is on the ground
function OnCollisionEnter(collision: Collision) {
onGround = true;
}
function OnCollisionExit(collision : Collision) {
onGround = false;
}
Answer by helencmilleryii · Mar 22, 2018 at 07:30 AM
Just use instead of and use CSS to style it to look like a link if you wish.
Buttons are made specifically for clicking, and they don't need any href attributes.
The best way is to use onload action to create the button and append it where you need via javascript, so with javascript disabled, they will not show at all and do not confuse the user.
When you use href="#" you get tons of different links pointing to the same location, which won't work when the agent does not support JavaScript.
Reference by Yiioverflow
Your answer
Follow this Question
Related Questions
Error when trying to make script for main menu. 0 Answers
How to make the character walk-jump and walk (and resize the collider when crouched) ? 0 Answers
Collision in the air after jumping 1 Answer
Helppp meee about making Cube... Urgent... 1 Answer
Can't get my character controller to jump properly (3d) 1 Answer