Drag an image which connect with hand tracking
In the attached project, I created a head binding frog, and a hand tracking frog.
When you tap and hold to drag the head binding frog, it moves smoothly and accurately according to your finger position.
However, I was unable to use the above dragging method to drag the hand tracking frog. Hence I used another method to drag the hand tracking frog around. In result, the frog can move around, but not accurately according to your finger position.
Can you show me or create a demo project to show how to move the hand tracking frog accurately to the user touched position?
I only want the hand tracking frog to move the same as the head binding frog in the example.
Thank you so much.
https://www.dropbox.com/s/gth0f2746r7f2nq/touch%20demo.zip?dl=0
Hi, Vincent!
The difference is in Transforms :
- Head attached frog is in World Space
- Hand attached frog has ScreenTransform Component on it and is in Screen Transform Space. that works differently.
On your TouchController on TouchMove event please use next code to calculate position:
This will make it follow touch position. Then you can use your logic for rotation
I will definitely make a post about World Space, Screen Space and Screen Transform Space (Anchored Space) soon!
Let me know if that helps!
Best
Olha
Dear Olha,
Thank you so much! That is exactly what I am looking for.
However, wherever I start dragging in the screen, the hand tracking frog will move to that position.
For the head binding frog, only when I start dragging near the head binding frog, (in a box area), then the head binding frog will move.
How can I do the same for the hand tracking frog? So that, the hand tracking frog will only move if I start dragging near the hand tracking frog?
Thank you so much!
Hi, Vincent!
This can be achieved by adding a Touch Component to the object with this script. Then events will only fire when touch position is within the image.
But this script would do better (because sometimes while touch is moved (onTouchMove) can accidentally move out of the image and dragging will stop)
This script only checks if touch started within an image, and then drags it until released. (No Touch Component needed in this case)
I removed variables I'm not using so this script could be reused by anyone:
More useful documentation about screen transform can be found here
Best
Olha
Dear Olha,
Thank you so much.
Your suggestion works perfectly in my lens!
In addition to movement, I would like to enlarge & reduce the hand tracking frog too.
I want it to perform exactly like the head binding frog, when user use 2 finger to zoom the frog starting at the frog location, then the head binding frog will enlarge or reduce in size.
1. How can I accomplish this for the hand tracking frog?
2. May I ask what user input method can Lens studio identify?
e.g. tap screen, tap and drag, 2 finger zoom, phone rotate degree etc.
Can it detects a common rotate gesture? (2 finger moving clockwise or anti-clockwise)
If yes, how can we rotate the hand tracking frog?
Thank you so much!
Dear Snapchat,
Is there any help on this topic?Thank you so much.
Hi, Vincent!
Sorry for the late answer
Please take a look at the project attached
As I understood you want both frogs to behave almost the same but be attached to different objects.
So I created a copy of neck attached frog and set it up to follow screen position of a hand instead of using screen transforms. So it's using manipulate component in just the same way
Sorry for misunderstanding!
Best
Olha