Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LEAN ⚡️ Touch / GUI / Texture / Localization / Transition / Pool

Discussion in 'Assets and Asset Store' started by Darkcoder, Aug 1, 2019.

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The next version will include a change check for all values, so this scenario should be avoided.
     
  2. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    113
    Great tool and easy to use.
    Question: is there a way to constrain the Lean Drag Translate to only the XZ plane?
    I got this AR app I'm working on, and want viewers to be able to move an object on the detected horizontal plane, but not up and down.
     
    SourceKraut likes this.
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Yes, LeanTouch+ comes with the LeanDragTranslateAlong component, which allows you to specify the drag surface like the XZ plane, a LeanPlane (arbitrary rotation), LeanPath, physics raycast, etc. There also components like LeanConstrainToCollider, which can be used to force the position to be within a specific shape.
     
  4. Volkerku

    Volkerku

    Joined:
    Nov 23, 2016
    Posts:
    113
    Thnaks for your quick response.
    I got Touch+ and tried LeanDragTranslateAlong but can't quite figure out how to use.
    Basically, I would like to constrain the translate to XZ only, and the current y-position to not change. How do I set thisup, please?
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The "Touch+/Examples/Drag/13 DragUnderAlongPlane" demo scene shows you how to do this along a LeanPlane that is flat on the XZ axis.

    You can also set the LeanDragTranslateAlong's ScreenDepth to HeightIntercept for the same effect if you don't want to use a LeanPlane, then you can specify the Y height of the plane below it in the "Y = " setting.
     
  6. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Hi

    I use Leanpool inside a script that runs in the Editor with [ExecuteAlways] and I have to use exceptions to use the regular Instantiate/DestroyImmediate if Leanpool is running in an Editor Script since Leanpool uses Destroy and Unity doesn't like that.

    Perhaps you could add something so Leanpool works out of the box inside editor scripts?

    Best regards
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This is a scenario I didn't consider, I'll send you a private message with a test build.
     
  8. TogoMango

    TogoMango

    Joined:
    Oct 8, 2014
    Posts:
    5
    Lean Localization In 2019.3.15f

    Hi
    I am currently making a mobile game with this free asset. I think it's a good asset after using it. But I found a bug in the final stage.
    I'm making language-changing buttons, and I'm connecting objects that have Lean Localization, and I'm choosing CurrentLanguage.
    "Missing LeanLocalization.set.CurrentLanguage" is displayed. Of course it doesn't work.
    Localization work is not being completed because of this. Is it possible to make a quick fix quickly? Or is there another way?
     

    Attached Files:

  9. TogoMango

    TogoMango

    Joined:
    Oct 8, 2014
    Posts:
    5

    Resolve in C#:)
     
    Darkcoder likes this.
  10. KonstantinAb

    KonstantinAb

    Joined:
    Aug 25, 2020
    Posts:
    1
    I am using Lean Touch.
    In my code I've implemented rotation using 2-finger gesture by getting it grom:
    Code (CSharp):
    1. var gesture = LeanTouch.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, 2);
    On iPhone if I accidentally pull the pull-down menu with one of my fingers when I am doing 2-finger rotation - the touch will stuck after going back to the app.

    After that lean thinks that I always have one finger down.

    Is it a known bug, is there any way to workaround it? Like disabling and enabling lean after going back to the app?
     
  11. Larry-Dietz

    Larry-Dietz

    Joined:
    Apr 22, 2010
    Posts:
    21
    I just purchased LeanTouch+ and am trying to make use of the shape detection, and am running into problems.

    In the demo scene, I have to draw the shapes several times, before it will finally decide that I drew the shape. I tried both with a finger, and with the mouse, and it seems like the level of precision has to be near perfect to get a match.

    I tried adjusting direction precision, but it doesn't appear to do anything.

    I even searched for all references to DirectionPrecision, and put a stopper on every one, then attached the debugger to unity, and ran the app, and none of the stoppers hit.

    Any idea what I am doing wrong? The shape detection is the primary reason I purchased the asset, and I would really like to get it working, without requiring a perfect trace, especially since I am NOT displaying a shape for them to trace :)

    Any help would be greatly appreciated.
    -Larry Dietz
     
  12. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Did you ever add TextMeshPro as an option?
     
  13. xahdpe

    xahdpe

    Joined:
    Mar 26, 2017
    Posts:
    6
    hello, looks like there is bug within lean touch (i use the last version).
    my setup :
    - 2 cameras for rendering of different layers.
    - (1 *Lean Select*+ 1 *Lean Finger Down*) per each camera.

    if I set *Auto Deselect* to true on one of them, same flag on the second Lean Select component is ignored - Unity invokes *OnDeselect* event right after *OnSelect* even if *Auto Deselect* flag set to false.

    can you please suggest if i'm doing wrong / right?
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Hey everyone,

    Version 2.1.5 of LeanTouch+ is now out!
    • Separated LeanConstrainToBox from BoxColliders.
    • Added LeanConstrainToAxis component.
    • Added Constrain / Constrain To Box demo scene.
    • Added Constrain / Constrain To Axis demo scene.
    • Rewrote LeanShapeDetector to use a different implementation.
    • Implemented LeanShapeDetector.Use setting.

    Enjoy :)

    This is a bug that Unity keeps fixing and breaking. I think it's fixed in the current latest versions though.


    Interesting, this sounds like a bug with Unity not reporting the finger going up, which could cause the finger to linger in LeanTouch. I could fix this by forcefully removing a finger if it suddenly disappears. This is how LeanTouch used to work, but it meant taps and such would be delayed by one frame, but I guess as a fallback it's not an issue. I'll see if I can implement it soon.

    Yes, it's in the current version. I don't remember exactly when I added it though, probably a while ago.


    LeanFingerDown (and most components) trigger when you begin touching the Unity 'screen'. They have no knowledge of what camera they belong to, or anything like this. In your scenario both LeanFingerDown components are probably triggering at the same time, which is causes your scenario to not work. This scenario could work with LeanTouch+ using the LeanFingerDownCanvas component, where you can place a different UI element over each, then LeanFingerDownCanvas will only trigger when you touch the specific UI element associated with that camera.
     
  15. tonygiang

    tonygiang

    Joined:
    Jun 13, 2017
    Posts:
    71
    Hi. Do you plan to add more easing functions into Lean Transition? I just found this cheat sheet and saw a lot of use cases for many of the functions on it.
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I could add more, but I don't see how useful many of those would be. Sine/Cubic/Quint/Circ/Quad/Quart/Expo look almost the same (Accelerate/Decelerate/Smooth are the same as Expo in/out/inOut). Otherwise the main difference is there is no easeInBounce/easeInOutBounce, or easeOutElasic/easeInOutElastic (there are only easeOut versions of these). I don't really see a scenario where these eases look good, they almost always just seem added for the sake of it. You can always extend the code for this in LeanEase.cs and LeanMethod.cs line 36+.
     
  17. tonygiang

    tonygiang

    Joined:
    Jun 13, 2017
    Posts:
    71
    I mainly have interest in:

    - The Circ easings. They are less abrupt than Lean Transition's Accelerate/Decelerate/Smooth. OutCirc looks especially nice when revealing a background with paint brush aesthetics. The longer linger toward the end is very fitting for the end of the brush stroke

    - InBounce can be used to transition the light intensity/range (when this feature eventually makes it to a release) of an old, worn light bulb flickering in the process of turning on.

    - InBack can be used to move an that prepares to charge forward.
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Alright, the next version will include an 'Advanced' list with all of those easing functions.
     
  19. jlhacode

    jlhacode

    Joined:
    Feb 20, 2020
    Posts:
    13
    Hi,

    I have text that lives on a TextMeshProUGUI component, and I'm trying to parse the word that I tap on. The method I'm using works fine, except that it also detects taps through panels that get shown above the dialogue. Do you know of any way to prevent clicking through other panels that are above the text?

    Here's the text click listener function:

    Code (CSharp):
    1.     private void HandleTap(LeanFinger finger) {
    2.  
    3.         var wordIndex = TMP_TextUtilities.FindIntersectingWord(textMeshProObject, finger.ScreenPosition, null);
    4.  
    5.         if (wordIndex != -1) {
    6.             var lastClickedWord = textMeshProObject.textInfo.wordInfo[wordIndex].GetWord();
    7.             OnTextClicked(lastClickedWord);
    8.         }
    9.     }
    Thanks!
     
  20. mrsimmo

    mrsimmo

    Joined:
    May 4, 2013
    Posts:
    12
    Forgive me, this is probably a really obvious answer but...

    With lean transition, is it possible to trigger a series of transitions created using the editor on a gameobject from a script?
    I *think* I should be able to target LeanPlayer.Begin, but I can't figure out how to get that working.

    Any pointers really appreciated!

    thanks!

    <FIGURED IT OUT>

    Need to target the LeanPlayer component and then use Begin() !
     
    Last edited: Sep 6, 2020
  21. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    I'm feeling really dumb trying to get started. Maybe is a Unity version thing, but I don't have Lean under GameObject when I try to add it to my project. The package manager says everything is imported, what am I missing here?

    Unity version 2020.1.0f1

    Thanks!
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    You should call the LeanTouch.RaycastGui method first, to make sure your finger is tapping on your text, rather than something else in front of your text.


    Great! If you don't want to use LeanPlayer then you can also directly call: LeanTransition.BeginAllTransitions(yourGameObject, speed); You can look at the LeanPlayer.Begin code to see how to do this with custom aliases too if you need.


    Does the console have any errors? If so, they will prevent scripts from running, thus they won't be added to the menus. You can also try restarting the editor, as it sometimes breaks. If not, let me know which Lean asset you're trying to use, thanks!
     
  23. dzalavadiya97

    dzalavadiya97

    Joined:
    Nov 14, 2019
    Posts:
    6
    Can anyone guide what am doing wrong in Demo scene 36 Isolate scene. I use two camera where one camera is for record render texture and the second one is as default camera.
    Now I use canvas forRAW IMAGE where I render First camera view.
    In this case UI element are stopped moving as per example.
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    What is the purpose of your second camera (RenderTexture one)? If you want to control something through your second camera based on its position on screen using a RawImage, then this isn't possible with LeanTouch.
     
  25. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    Wow, that was it. I had accidentally pasted some random text on the last line of my script that was open in VS.

    Thank you so much!
     
    Darkcoder likes this.
  26. mrsimmo

    mrsimmo

    Joined:
    May 4, 2013
    Posts:
    12
    back again...
    I'm struggling to work out how to access the ScaledValue of a joystick.. I'm trying to pass that value to a method using OnUp, but can't work out how to pass it...

    Any help really appreciated!
     
  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    OnUp doesn't provide the ScaledValue. Using the current setup I recommend you either:

    a) Use OnSet to send the ScaledValue to your script, which you can store. You can then use OnUp to trigger whatever using this stored value.

    b) When your script receives OnUp, you read the LeanJoystick's ScaledValue property.

    If you need OnUp to send the ScaledValue then I can modify it though, as that would make sense.
     
  28. jorrit-de-vries

    jorrit-de-vries

    Joined:
    Aug 7, 2009
    Posts:
    71
    Hi, I am quite new to Lean Touch, nice package. I am wondering how I can get tapped events on specific objects, without making use of selectable - I use the selectable system for dragging already, and draggable objects can also be tapped.

    The examples are afaict not showing such an example - tapped events on specific objects. Am I missing something while browsing?
     
  29. skjagan

    skjagan

    Joined:
    May 18, 2020
    Posts:
    6
    Can i use your free of cost asset: Lean touch, for commercial use in my project. I want to know that clearly as my project is ready to launch. Please clear me.
     
  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This isn't possible currently, but it's a good idea. I'll send you a new version via private message soon!


    Yes, same with almost all asset store assets unless they have a special license.
     
    jorrit-de-vries likes this.
  31. haywirephoenix

    haywirephoenix

    Joined:
    May 17, 2017
    Posts:
    101
    Hi there, I purchased Shapes and and enjoying LeanGUI, thanks! Just one question:

    Is there a way to setup the Sound Transition component to route though a specific audio source instead of create/destroy? Reason being I set up some toggles on Start which fire the sounds in the background and I'd like to mute that on firstrun. This is what I came up with for Bolt but any kind of check in there causes a good 1s delay to the sound.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections.Generic;
    4. using Bolt;
    5.  
    6. namespace Lean.Transition.Method
    7. {
    8.     public class LeanPlaySoundBoltReady : LeanPlaySound
    9.     {
    10.         public static LeanState Register(AudioClip target, float duration, float volume = 1.0f)
    11.         {
    12.             var data = LeanTransition.RegisterWithTarget(State.Pool, duration, target);
    13.  
    14.             data.Volume = volume;
    15.          
    16.             if((bool)Variables.Application.Get("InitComplete") == false)
    17.                 data.Volume= 0;
    18.  
    19.             return data;
    20.         }
    21.  
    22.     }
    23. }
     
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The PlaySound transition is designed to make it simple to play UI sounds. If you want more control with your own AudioSource then you can manually set one up, and use the LeanEvent / EventTransition to trigger its Play method.
     
  33. haywirephoenix

    haywirephoenix

    Joined:
    May 17, 2017
    Posts:
    101
    Thanks for the tip, I missed EventTransition. When you set LeanToggle to On in the inspector, it activates the transition to it's completed state immediately, is there a way to mimic this behaviour at runtime, such as LeanToggle.Toggle(false)?
     
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The LeanToggle transitions (as well as all other transitions) should play at their normal speed when you change its state, even in edit mode. They run at about 10 FPS in edit mode though, so it can seem like they are instant. To make them run faster you can always change the transition speed to something very high.
     
  35. tonygiang

    tonygiang

    Joined:
    Jun 13, 2017
    Posts:
    71
    Hi. I have a question about the duration value in Lean Transition, particularly regarding LeanEvent. If I set the duration value to 0, I can observe that the event will be fired off immediately, but is it actually doing that?

    My experience from using Unity's WaitForSeconds in coroutine informs me that by passing it a value of 0, it will still skip 1 frame and continue executing in the next frame. This has some implications for order-of-execution, which is why I would like to know whether LeanEvent will execute immediately or skip 1 frame when having a duration of 0.
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    It's executed from LeanTransition based on your current timing setting, which may have a 0 or 1 frame delay (default is Update, so probably 1 frame). I suppose executing it immediately would make sense though, I'll see if I can make the modifications.
     
  37. tonygiang

    tonygiang

    Joined:
    Jun 13, 2017
    Posts:
    71
    That's great! I actually can adapt to it executing 1 frame late, but having all Lean Transitions execute immediately when duration=0 can enable the use case of a "Set-up" transition.

    That is, what you're authoring in the Editor is how things look in the end, but when a scene first start, they will actually slide into place from the edge of the screen/drop down from above/"uncloaking" themselves/etc... I can achieve that just by having a Set-up transition that put all the things I need to transition to a starting position, duration 0, then the slide-in transition is just nested inside the Set-up transition. With the peace of mind that they start immediately, I can be sure that their end state won't flash on the screen for 1 frame before the slide-in transition.
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I've made the necessary changes, I'll send you a private message with a test build.
     
  39. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    169
    I'm getting this error when I start the game.

    Code (CSharp):
    1. InvalidOperationException: Collection was modified; enumeration operation may not execute.
    2. System.Collections.Generic.HashSet`1+Enumerator[T].MoveNext () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
    3. Lean.Touch.LeanTouch.PollFingers () (at Assets/Lean/Touch/Scripts/LeanTouch.cs:672)
    4. Lean.Touch.LeanTouch.Update () (at Assets/Lean/Touch/Scripts/LeanTouch.cs:469)
    Everything still works fine afterward though, but what's this error?

    This is the part of my code that use LeanTouch
    Code (CSharp):
    1.  
    2.     void Start()
    3.     {
    4.         LeanTouch.OnFingerDown += OnFingerDown;
    5.         LeanTouch.OnFingerUpdate += OnFingerUpdate;
    6.         LeanTouch.OnFingerUp += OnFingerUp;
    7.         playerShip = GetComponent<Rigidbody2D>();
    8.     }
    9.     Vector3 GetTouchWorldPosition(LeanFinger finger)
    10.     {
    11.         return finger.GetWorldPosition(Mathf.Abs(GameController.instance.Camera.transform.position.z), GameController.instance.Camera);
    12.     }
    13.     void OnFingerDown(LeanFinger finger)
    14.     {
    15.         Vector3 touchWorldPos = GetTouchWorldPosition(finger);
    16.         deltaMove = playerShip.position - (Vector2)touchWorldPos;
    17.         phase = Phase.Moving;
    18.     }
    19.     void OnFingerUpdate(LeanFinger finger)
    20.     {
    21.         Vector3 touchWorldPos = GetTouchWorldPosition(finger);
    22.         moveDestination = touchWorldPos + deltaMove;
    23.         float moveDestinationX = Mathf.Clamp(moveDestination.x, GameController.leftBorderX, GameController.rightBorderX);
    24.         float moveDestinationY = Mathf.Clamp(moveDestination.y, GameController.bottomBorderY, GameController.topBorderY);
    25.         moveDestination = new Vector3(moveDestinationX, moveDestinationY);
    26.         deltaMove = moveDestination - touchWorldPos;
    27.         //Debug.Log($"Update touch pos {touchWorldPos}, delta move {deltaMove}");
    28.     }
    29.     void OnFingerUp(LeanFinger finger)
    30.     {
    31.         phase = Phase.Idle;
    32.     }
    33.  
    I'm using LeanTouch v2.1.4
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This was fixed in 2.1.5 :)
     
    cdr9042 likes this.
  41. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    Hi Darkcoder, I'm new to touch input and trying to use LeanTouch.

    I made a small project first using Input.GetTouch() to capture squiggly lines drawn on the screen. I want to have different events for the line drawing vs. a single tap, and also avoid the UI, so your asset looked spot on.

    Do I need to remove the stock touch input code and go with only LeanTouch or can they peacefully coexist? I added a Spawn component exactly like your scene 08 but nothing is happening on the tap.

    Thank you so much!
     
  42. wedgiebee

    wedgiebee

    Joined:
    Aug 9, 2016
    Posts:
    40
    @Darkcoder I think I've found a bug with the "worldPositionStays" bool in LeanPool.Spawn. When using it to spawn an object and parent it to a transform with a non-uniform scale, the original scale is not preserved. When using GameObject.Instantiate, the scale is preserved. I made a Unity project with the functionality shown side-by-side to hopefully make it easier to figure out what's going on! Just open the project, open the scene "ReproScene," and hit play to see the bug.

    Also this is on Unity 2019.4.10f1

    Thanks for the help, and LeanPool is really great so far, thanks for making it!

    Here's a screenshot of what you'll see when you run the project:

    leanPoolBugScreenshot.jpg
     

    Attached Files:

  43. NoPants_

    NoPants_

    Joined:
    Apr 23, 2014
    Posts:
    59
    Edit - You can disregard this. I hadn't done any ui canvas optimization, but the big killer was having fonts set to best fit on anything with a transition.

    I'm having a bit of an issue, I'm not sure if you can help based on the information I can provide. I'm building my UI with leanguishapes, leantransition and leangui. I have a few large dropdowns, so I figured I would pool these dropdown options with leanpool so I can move them around and set them up as needed. But now I'm seeing that if I open my windows a lot, the app just crashes. There's nothing on the logcat, game isn't saved, it just stops. Would you have any kind of insight into what my problem could be? I tried pre-loading some of the gui elements, but no luck. I tried splitting them into their own canvas, that didn't help out either.
     
    Last edited: Sep 20, 2020
  44. Maund

    Maund

    Joined:
    May 12, 2016
    Posts:
    4
    Hi Darkcoder,
    Is there an option to disable input completle ? Something like Lean.Touch.LeanTouch.IsActive = value;
    There are scenarios where you want to disable all input. All fingers that were down, should change their state to up, fire event OnFingerUp, and then disable.
    I managed to implement that, modifing your code, but it's hard for me, to be up to date with your plugin.
    Great work and thanks
     
  45. andcl85

    andcl85

    Joined:
    Sep 14, 2020
    Posts:
    2
    Hi, first of all, congrats for the awesome package.
    Regarding the linked scene, is it possible to detect both finger taps and swipes on the same gameobject independently?
    Linked demo scene correctly detects swipes (yellow color transition) and fingers down (green color transitions, as part of swipes), but not tapping on spheres.
    Thanks in advance.
     
  46. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Sorry for the late reply!

    You can probably combine different input system together, though it depends exactly what they each do.

    To make the tap spawn work you need to hook up an event like LeanFingerTap's OnFinger/OnWorld and have it invoke LeanSpawn.Spawn. Your scene also needs to contain the LeanTouch component.

    Thanks, I can replicate this issue. I'll see what I can do!


    While a complex UI could cause slowdown, it shouldn't cause any crash. It sounds like your app is running out of memory, but I imagine that would show up in the log? hmm, not sure.


    This is something I haven't considered. The easiest way to implement it from LeanTouch.cs is to modify the OnDisable method to have: BeginFingers(); EndFingers(); UpdateEvents();

    This should work for disabling most touch interactions. There are quite a lot of components in LeanTouch+ though, so I imagine this solution wouldn't work with all of them, I'll add it to my to-do list to investigate. If you just want to disable touch for a tutorial or something then one thing you can do is add a giant invisible UI image on top of everything, that should block most components from doing anything.


    In the latest version of LeanTouch+ I added the LeanSelectSelf component. This allows you to manually detect when a finger is on top of the current GameObject. In the Touch+/Examples/Selection/11 demo scene I show you how LeanFingerTap can be used to trigger LeanSelectSelf, but you can also add LeanFingerSwipe with a similar setup to detect when you swipe on top, or any other event that gives you a finger. One thing I forgot to add to this component is the ability to specify a 'Root' like other components have. This means currently you have to place these components in a child GameObject to use multiple of them, and change Search to GetComponentInChildren. I'll improve this in the next version.
     
    wedgiebee likes this.
  47. dacoursey

    dacoursey

    Joined:
    Dec 17, 2016
    Posts:
    40
    Does this look right for the LeanSpawn? My GetTouch code seems to be catching the tap first and no tree is spawned.

    upload_2020-9-25_21-15-41.png
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This looks correct. One way to test is you can add the LeanTouchEvents component to your scene. This will output to the console when you touch the screen or tap. You can also connect the LeanFingerTap.OnWorld event to your own custom component to see if it's triggering. Perhaps your screen has an invisible UI element blocking touch or something?
     
  49. IceTrooper

    IceTrooper

    Joined:
    Jul 19, 2015
    Posts:
    35
    What really means "Dpi reference" in LeanTouch component? Should we change that value on game start according to Screen.dpi or just set default 200 and forget?
    upload_2020-9-26_16-33-37.png

    Second problem:
    My LeanUpdate works too sensitive. I mean I'm reacting to this event to know if player moves his finger to left or right, but the event raises even when finger is pressed harder (I think phone just think that player moved his finger 1-5 pixels from previous position). Do you have ideas how to get rid of this behaviour?
     
    Last edited: Sep 26, 2020
  50. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    1 - This allows you to control the 'Scaled' pixel values. For example, if your display is 200 DPI and you set ReferenceDPI to 200, then your finger's ScreenDelta will be the same as ScaledDelta. If your display is 400 DPI, then ScaledDelta will be something like half of ScreenDelta.

    2 - If you have LeanTouch+ you can use the LeanThresholdDelta component. You can send LeanFingerUpdate.OnDelta events to this, and once they go over the Threshold distance it will firs an event. If not, you can make a custom component to count the finger delta values, and have that trigger some action once they go over your limit.
     
    IceTrooper likes this.