I did put input into Update() but it should not response well
i have to many time in order the z button to response
https://www.loom.com/share/f54c1b3020314baa8093f6deb79d2e9e
link demo
I am not sure what went wrong, anyone pls do point out what went wrong
Cheers, your help is most appreciated
Code:
public const string zPressDashing = "zPressDashing";
string buttonPressed;
void Update()
{
if (Input.GetKeyDown(KeyCode.Z))
{
Debug.Log("pressed z");
buttonPressed = zPressDashing;
}
else
{
buttonPressed = null;
}
}
private void FixedUpdate()
{
if (buttonPressed == zPressDashing)
{
body.AddForce(new Vector2(-50f, 0f));
Debug.Log("i m dashing");
}
}