Hello! I’m struggling to integrate a double jump script to my mobile game, but it doesn’t work the way it should. So I have created a UI image, that acts like a jump button and it consist of following script:
using UnityEngine;
using UnityEngine.EventSystems;
public class JoyButtonScript : MonoBehaviour, IPointerUpHandler, IPointerDownHandler
{
[HideInInspector]public bool jumpPressed;
public void OnPointerDown(PointerEventData eventData){
jumpPressed = true;
}
public void OnPointerUp(PointerEventData eventData){
jumpPressed = false;
}
}
Also I have PlayerMovement script attached to my player(script is down below). feetPos is a gameObject attached to player’s feets, to detect if player is grounded && whatIsGround is just LayerMask that is attached to my ground textures
This seems to be the exact same question you asked here yesterday:
Did you even read my response? Did you even make the slightest attempt to find out what code is running? I gave you very specific steps to approach and understand the problem in the other thread linked above and yet you seem to have simply ignored it. Are you trying to help yourself or just hoping someone else will write it for you if you keep asking the same question again and again?
The likely culprit is that you’re being set to grounded, resetting your jump count to 0, the very next frame in between physics ticks. You should process your input in Update() but the actual physics elements in FixedUpdate().