The forum on this site is closed for new comments and posts. Continue the conversation in the new forum, and learn more here.

Drag an image which connect with hand tracking

  • 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: 

    var event = script.createEvent("TouchMoveEvent");

    event.bind(function(eventData)

    {

    var touchPos = eventData.getTouchPosition();

    var localPosition = screenTransform.screenPointToParentPoint(touchPos)

    screenTransform.anchors.setCenter(localPosition)

    });

    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

    Comment actions Permalink
  • 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!

     

    Comment actions Permalink
  • 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:

    // @input Component.Image handImage

    var image = script.handImage;
    var screenTransform = image.getSceneObject().getFirstComponent("Component.ScreenTransform");

    // Enable full screen touches
    global.touchSystem.touchBlocking = true;

    var canDrag = false;

    var touchStarEvent = script.createEvent("TouchStartEvent");
    touchStarEvent.bind(function (eventData) {

    var touchPos = eventData.getTouchPosition();
    if (screenTransform.containsScreenPoint(touchPos)) {
    canDrag = true;// allow dragging if the touch started in the frog area
    }
    });

    var event = script.createEvent("TouchMoveEvent");
    event.bind(function (eventData) {
    if (canDrag) {
    var touchPos = eventData.getTouchPosition();
    var localPosition = screenTransform.screenPointToParentPoint(touchPos)
    screenTransform.anchors.setCenter(localPosition)
    }
    });

    var touchEndEvent = script.createEvent("TouchEndEvent");
    touchEndEvent.bind(function (eventData) {
    canDrag = false;
    //reset
    });

    More useful documentation about screen transform can be found here 

    Best 

    Olha

     

     

    Comment actions Permalink
  • 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!

    Comment actions Permalink
  • Dear Snapchat,

     

    Is there any help on this topic?Thank you so much.

     

     

    Comment actions Permalink
  • 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

     

     

    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!