I’m trying to create a GUI button for shooting. The player places their finger on that area and it should auto-fire until they don’t touch that area.
Using a gui button doesn’t work. For one thing the button only responds when you lift your finger so you have to tap it a repeatedly. Also, if you touch the screen anywhere else the button won’t respond (if you want to move the character with the joystick, etc.).
What solution should I pursue?
This is what I got so far:
I’m creating a rectangle area and then see if it’s being touched. As long as it’s touched it’s going to run the shoot function.
It doesn’t work as I got the syntax quite wrong, but am I even close?.. :-/
Rect rectButton1 = new Rect(Screen.width / 1 - 175 / 1,
Screen.height /1 - 175 /1,175, 175);
void OnUpdate()
{
if ( rectButton1.Contains(Input.GetTouch))
Shoot();
}