- Home /
Double Jump With UI BUTTONS;
hello, i am working on a endless runner (2.5D) i've setup controls with 3 touch buttons (jump, slide,Dash). i have double jump in my game but i want one single button for (JUMP And Double Jump). Player has to Double Tap (Jump) button for it. i have setup UI Controls. My Canvas
i have made a script for them .
MY SCRIPT for controls
namespace RunnerGame
{
public class UIInputControl : MonoBehaviour
{
[SerializeField] private CharacterControl control;
private void Awake()
{
control = GetComponent<CharacterControl>();
}
private void Update()
{
Time.timeScale = 0.075f;
}
public void OnJumpPressed()
{
control.Jump = true;
}
public void OnJumpReleased()
{
if (!control.Start)
{
control.Start = true;
}
control.Jump = false;
}
public void OnDashPressed()
{
control.Dash = true;
}
public void OnDashReleased()
{
if (!control.Start)
{
control.Start = true;
}
control.Dash = false;
}
public void OnSlidePressed()
{
control.isOnSlope = true;
}
public void OnSlideReleased()
{
if (!control.Start)
{
control.Start = true;
}
control.isOnSlope = false;
}
}
}
MY SCRIPT for double jump
namespace RunnerGame
{
public class UIInputControl : MonoBehaviour
{
[SerializeField] private CharacterControl control;
private void Awake()
{
control = GetComponent<CharacterControl>();
}
private void Update()
{
Time.timeScale = 0.075f;
}
public void OnJumpPressed()
{
control.Jump = true;
}
public void OnJumpReleased()
{
if (!control.Start)
{
control.Start = true;
}
control.Jump = false;
}
public void OnDashPressed()
{
control.Dash = true;
}
public void OnDashReleased()
{
if (!control.Start)
{
control.Start = true;
}
control.Dash = false;
}
public void OnSlidePressed()
{
control.isOnSlope = true;
}
public void OnSlideReleased()
{
if (!control.Start)
{
control.Start = true;
}
control.isOnSlope = false;
}
}
}
Problem is double jump is detecting even if i press it single time. can' figure out how to make, Event trigger to detect Double Tap
Things to know
I am using Finite state machine for player Control (combination with scriptable objects).
thing are working fine when i use mouse click for jump.
i am using Event Trigger. PointerDown & PointerUp to be extact.
My project is on github i'll share if anyone willing to Help.
Your answer
Follow this Question
Related Questions
How can I reuse 2 Buttons for multiple decisions?,How ro reuse the same 2 Buttons? 2 Answers
How to change anchor? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers