I’m currently making mobile compatibility for my game and what I have is a button that just says shoot on it and when the player holds down on the button it makes the gun shoot. The issue is that while the player is holding down on the button they cant move their screen to aim unless they use a separate finger which makes the whole process inconvenient. I want them to be able to hold down the button to shoot while also move the camera with the same button.
In mobile arsenal they have the shoot button with this red box around it so that as long as you’re in the red box area the gun still shoots and it still allows the camera to move. I’m not sure what they used but for me whenever I press any button and move my finger the camera will no longer move until I release the button and press again.
You can utilise the touch events in UserInputService to handle touch inputs without it sinking the input. The input object returns the current position of the player’s finger on the screen.
I ended up doing exactly that where I’m using the touch location to detect if the finger is in the shooting zone. Everything works now except now if I shoot while moving the touch.Position different because it’s also detecting me touching the joystick to move. How can I ignore that?
function inButtonZone(touch)
if touch.Position.X > mShoot.AbsolutePosition.X
and touch.Position.X < mShoot.AbsolutePosition.X + mShoot.AbsoluteSize.X
and touch.Position.Y > mShoot.AbsolutePosition.Y
and touch.Position.Y < mShoot.AbsolutePosition.Y + mShoot.AbsoluteSize.Y then
return true
end
return false
end
I’m aware this is old, but I found from another post that setting your fire button’s Active property to false allows camera movement. I tested this and it works!
no mouseEntered has some flaws like it activates when you slide your thumb across the button. you should use MouseButton1Down to start the input and MouseLeave to end the input.
In my case, I have not seen this happen. With the active property off I can easily move my camera around and shoot while holding the button down on mobile. There might be a better way of doing this, however!
this is what i was saying. disable the active property, and the input functions still work. The description of the active property litterally is “if it sinks input”