Hey,
While porting a game to mobile I’ve ran into a problem with executing code on a UI button. I have the following jump code:
if (Input.GetButton("Jump") && !_rolling)
{
Jump();
}
public void Jump()
{
if (_jumping == false)
{
Debug.Log("jumped");
_jumping = true;
_moveDirection.y = _jumpSpeed;
_anim.SetBool("Jump", _jumping);
}
if (_onLedge)
{
_anim.SetTrigger("ClimbUp");
}
}
This code works completely fine when the space key is pressed. The problem is making a ui button that executes the Jump() function.
When I do this, the console does log the “jumped” indicator that the code is being ran but the jump doesn’t actually occur. If the player _onledge is true it also climbs up correctly so the code is being ran but isnt behaving the same as when the space key is pressed, which seems odd because its the same function.
Does anyone have any ideas to maybe why this isn’t working?
Thanks