- Home /
Touch Controls Event Triggers
I want to implement a circle in my GUI for controlling the player movement on touch screen, because accelerometer controls were way too inaccurate. I have an image component on my canvas now, which should react on drag events, so I assigned my player object to the the drag event. But I can't figure out how to receive the drag event and get the exact location on screen. When using mouse I could obviously just get the mouse position but on a touch screen there can be multiple fingers recognized by the system. Any ideas how to do that?
Answer by Graham-Dunnett · Feb 24, 2015 at 01:32 PM
The documentation for processing touch input can tell you the id of each finger press. If you know you want id=42, then ignore the others. If you get told there is an second touch id=12345 then you know it's a different finger so can ignore it. This stuff isn't very difficult.
but how do get which id is the one that I am looking for? In the Event Trigger component on the Image object I can add a drag event that calls some function in my player script for example, but the function has to know at which position the event was and for that it needs to know the touch id right?