Topic was automatically imported from the old Question2Answer platform.
Asked By
baribal
Old Version
Published before Godot 3 was released.
Hey,
i would like to get objects under my finger on touch screen, Not only on press on that objects, but when i move finger and get collision with them. Is any way to do that nicely ?
For now, what i’m thinking about is dragging hidden object to x,y of touch, and collide it with the objects under
I’d have an Area2D node that get its position updated with the InputEvent.SCREEN_DRAG, on which I’d subscribe to the body_enter or area_enter signals. You could do set_enable_monitoring on the Area2D node when InputEvent.SCREEN_TOUCH is fired, using the event.pressed boolean as an argument.
You can detect mouse and touch input on Area2D or other physics nodes (as you would on Controls) if you enable the pickable property. If you do so, you will get regular input events from them by connecting the input_event to your custom function CollisionObject2D — Godot Engine (stable) documentation in English
Hi there, jumping in on this thread as I’m trying the same thing.
I made an Area2D pick-able.
I then connected the input_event signal to my own function as so:
I have emulate_touchscreen turned on and when I click on the Area2D none of the print statements show anything (as in they don’t trigger at all).
I’m guessing I’m misunderstanding this? Can you or anyone explain what I’m doing wrong?
Thank you.
EDIT: I added a collision shape (rectangle) as a child of the Area2D and it worked. I don’t fully understand that but I’ll have a think and a read to make sense of it all.