Skip to main content
‹ Back to Tutorials
Intermediate Unity

Can you implement Lean Touch - Free in Unity in under a 1 Min? YES - #Shorts

Jul 28, 2021
About this tutorial

Easily set up touch events in Unity using Lean Touch in under a minute. Easy to do with no code. Add the Lean Touch asset and you can test touch events directly in the Unity editor. Also check out How to Make a Bounce Game Series https://bit.ly/39HIYBU. #Shorts ► Download Playmaker at https://b

Written Guide

Lean Touch is a free Unity asset for handling touch and drag input, and it can be dropped into a scene in about a minute with no code at all. Here's the full setup, using a low poly taxi that needs to be draggable along a road but not able to leave it.

Grab the assets

Two assets from the Unity Asset Store are used here: Lean Touch Free, which provides the input handling, and the Low Poly Ultimate Pack, which supplies the car and the road.

Add both to your account on the Asset Store, then head into Unity, open the Package Manager, and download and install each of them into the project. Everything after this happens inside the editor.

Add the Lean Touch object

In the Hierarchy, right click (or control click on a Mac) and go to Lean, then Touch. This adds a Lean Touch GameObject to the scene.

This object is the manager for the whole system. Nothing else in Lean Touch works without it present in the scene, and it only needs to exist once.

Add the simulator

From the same menu, also add the simulator. This simulates touch input inside the game environment, which means you can test touch behavior with a mouse in the editor rather than building to a device every time you change something.

It's easy to skip this step and then conclude Lean Touch is broken because nothing responds in play mode. Add the simulator up front and save yourself the confusion.

Make the car draggable

Select the car and add a Lean Drag Translate component to it. That's the component that turns finger or mouse drags into movement, and by default it will let you drag the object around in all three axes: X, Y, and Z.

At this point the taxi already moves with a drag. The problem is that it moves in ways it shouldn't.

Constrain it to the road

A car dragged freely in three dimensions will lift off the road surface, which isn't what you want. The fix is a constraint on the vertical axis.

Add a Lean Constraint to the car and set it to the Y axis, with the values set to 0 and 0. Locking the minimum and maximum to the same value pins the car's height, so it can only slide across the ground plane no matter how the player drags.

Hit play and test it. The taxi moves around under your cursor, stays on the road, and there isn't a line of code anywhere in the project. Three components and one constraint is the entire implementation, which is why Lean Touch is worth knowing about for any mobile prototype where you need drag input working today.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →