#OnClick working for mouse, but fires 3 times for touchscreen tap

1 messages · Page 1 of 1 (latest)

swift locust
#

Title, basically. Down to the final bug but it's an annoying one. It's working perfectly fine for mouse clicks, only firing a single time per click. Controller selection, single fire too. Touch screen tap though it's consistently firing 3 times in rapid succession with a single tap. I tried to use OnPointerDown but that doesn't fire at all for mouse or touch, googling says you can only really do that once in the project or something idk?? But I can't refactor the entire project to use that function here.
This is the only script that uses OnClick though, everywhere else touch only registers once as it should

acoustic linden
#

what OnClick are you using here?

#

also OnPointerDown needs a raycaster and an interface to be implemented, so if you didn't have those, that'd be the issue

googling says you can only really do that once in the project or something idk
not sure where you're getting that. that's definitely not true

swift locust
swift locust
acoustic linden
#

that doesn't mean you can't have 2 pointer handlers in the same scene

swift locust
#

Pointer down did have a raycast an all tho. I copied stuff over from another script

#

Debug log at the very start of the function just never fires

acoustic linden
#

the object with the pointer handler had a raycast?

swift locust
#

Yeah

acoustic linden
#

yeah that's not correct

#

you need a raycaster on the camera, iirc? might be the canvas for a graphic raycaster

#

and also a corresponding target on the, well, target

swift locust
#

The raycasting code is already in onclick and works perfectly for clicking idk what you mean. It's raycasting from the position of the pointer to the target

acoustic linden
#

i'm not talking about Physics.Raycast

#

a raycaster is a component that's required for the pointer handlers

swift locust
#

Idk man all I know is pointer down is working literally in the rest of the game, even on the same screen I'm trying to get this to work

acoustic linden
#

you just tried onpointerdown for this, but it's working in the rest of the game? i'm confused

#

you really aren't giving much info to work with here

swift locust
acoustic linden
#

no, i'm confused what the scenario you're in is, because that's self-conflicting

#

you still have not said what OnClick is from

swift locust
#

Just clicking in the scene. Nothing is directly calling OnClick

acoustic linden
#

is it from a playerinput or something? there's no OnClick built-in message either

#

what do you expect to be calling it

iron void
#

show your code; we have no idea what you're currently doing

swift locust
#

When the user clicks or taps, which is what it does - but tapping causes it to fire 3 times. I guess I should look at the input action then - NGL thought it was a built in action

swift locust
#

Hm, the binding is set to touch*/press in the input action

#

Changing it to press single input still fires 3 times 🤔 twice when pressing, once when releasing

#

There is nothing calling the function at all. It's just the input action

acoustic linden
#

just say it's the input action

swift locust
#

What do you mean?

#

What should the input action be set to to only register 1 tap?

#

Flipped some stuff in input actions and it's now working perfectly