Help with touch button (can't call a function)
I'm trying to make touch button with function jump but it only calls the Debug.Log not the function jump(); where is the problem? please help, I made game and this is the only thing left, Im trying like 1 week to fix this button thing still nothing :/
function OnGUI ()
{
if(GUI.Button(new Rect(15, 15, 100, 50), "Imma Button"))
{
Debug.Log("Clicked");
Jump();
}
}
Hi, can you poste the code of the jump method too. Did you tried to insert a Debug line into the Jump() $$anonymous$$ethod, so that you can realy say it get not called. The method should get called, i think there is a mistake in the Jump() method so that it has not the desired effect you assume.
This is my Jump() function public function Jump() {
//Jump
if (Input.GetButtonDown("Jump") && IsGrounded())
{
GetComponent.<Rigidbody>().velocity.y = jumpHeight;
playerAnim.SetTrigger("Jump");
}
}
For that code to work you have to touch the button and the "Jump" button on your keyboard or joystick in the same frame.
If you just want it to jump when pressing the graphic "Imma button" ins$$anonymous$$d of the jump key, remove the "Inpu.GetButtonDown("Jump")" part of the condition.