possible to track the tap position on display screen ?
Hey people,
can you hint me to a solution where I can read the absolute position of where on the screen my tap happened? I´d like something to follow my finger when moving it across the screen..
Would that be possible at all without interfering with the standard swipe gestures?
thanksalotta.
Cheers Linus
Hi El Be! There's actually a fairly simple way to do this that uses the Touch and Manipulate component. Basically, you add an object to the scene that's rotated 90 degrees in the X. And then a sprite child that's rotated back with Touch and Manipulate components added. Then, we have to add a small script to allow there to be a negative min distance.
Example project here. Look at the object MyMovableSprite. Test it out by dragging the Sprite in the Preview panel:
https://storage.googleapis.com/snapchat-lens-assets/f1a09194-f02d-43ed-92b8-62e843179ff0/lensStudio/Forum-Helpers/2d_manipulate_example.zip
hey Travis, thank you for your quick response - meanwhile I found what I was looking for: it was the TapPosition Vector.
Which now brings me to the question how I could translate a normalized Position to Screenposition? Can you help me on that one? That would require to know the display size of the users phone I guess.... so how do I get those values?
any help is truly appreciated
cheers Linus
Hi eL Be,
Do you want to convert the touch position to world space? If so you can use the screenSpaceToWorldSpace() function found on the Camera component. You can check the details here: https://lensstudio.snapchat.com/api/classes/Camera/
Here's a quick example of finding world space position from touch:
If you want to convert the touch position to the units used by SpriteAligner, you can translate like this:
And here's a full example script using that:
Hope this answers your question!
Hey Jacob - wow that does it for me. Thanksalotta.