I need help to remove double jump. This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerMovment : MonoBehaviour
{
public CharacterController2D controller;
public float runSpeed = 40f;
float horizontalMove = 0f;
bool jump = false;
bool chouch = false;
void Update ()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
if (Input.GetButtonDown("Jump"))
{
jump = true;
}
if (Input.GetButtonDown("chouch"))
{
chouch = true;
} else if (Input.GetButtonUp("chouch"))
{
chouch = false;
}
}
void FixedUpdate ()
{
controller.Move(horizontalMove * Time.fixedDeltaTime, chouch, jump);
jump = false;
}
}
Gamer_peeps:
remove double jump
Go look up any number of a bazillion scripts that check if you are on the ground to prevent you from jumping when you are not on the ground. Here’s one example… there are thousands of others, including Youtube tutorials:
Welcome!
First, please use code tags: Using code tags properly when you post code.
But secondly, what is weird is that this is the second time recently that I’ve seen this code reported broken.
I went and investigated and what appears to have happened is that Unity’s example used to work back on earlier versions of Unity.
BUT… on more recent Unity versions, I concur with you that it presently does NOT work reliably, at least for jumping.
If I had to guess why, I believe it is their two sepa…
1 Like
Kurt-Dekker:
Go look up any number of a bazillion scripts that check if you are on the ground to prevent you from jumping when you are not on the ground. Here’s one example… there are thousands of others, including Youtube tutorials:
https://discussions.unity.com/t/811250/2
no I want to fix the script that allredy have
He told you how to do it. And he mentioned examples you can reference. Checking if you can jump is the fix for removing double jump.
2 Likes
Excellent! Go for it. The other script will show you precisely what you need to add to yours.
1 Like
um… I need help on that too, if you know how to fix it can you plz do it for me :(:(;):(;):(:)