Mobile: Touchscript rescales all object even though I only drag/scale one object?

HI. Is anyone familiar with a combination of Vuforia AR SDK and the Lean touch scripts?
I am creating a project in which I have multiple child objects of my image target. (a cube, a sphere etc.) When I try to add the transform functionality from the lean touch script it transforms all objects even though I only pick (and touch) one of them.

For those not familiar with the Lean touch script:
I have attached a touch script to an empty gameobject. Also each object that needs to be dragged has a draggable and transform script attached. BUT when I touch and scale one object it affects all the other objects aswell. What To Do?

I have attached a image of the hierarchy and the inspector of one of the draggable objects
[81286-skærmbillede-2016-11-01-kl-114528.png|81286]

The transform script:
using UnityEngine;

namespace Lean.Touch
{
	// This script allows you to transform the current GameObject
	public class LeanTransform : MonoBehaviour
	{
		public bool AllowTranslate = true;

		public bool AllowRotate = true;

		public bool AllowScale = true;

		protected virtual void Update()
		{
			if (AllowTranslate == true)
			{
				Translate(LeanTouch.DragDelta);
			}

			if (AllowRotate == true)
			{
				Rotate(LeanTouch.TwistDegrees);
			}

			if (AllowScale == true)
			{
				Scale(LeanTouch.PinchScale);
			}
		}

		private void Translate(Vector2 screenPositionDelta)
		{
			// Screen position of the transform
			var screenPosition = Camera.main.WorldToScreenPoint(transform.position);
			
			// Add the deltaPosition
			screenPosition += (Vector3)screenPositionDelta;
			
			// Convert back to world space
			transform.position = Camera.main.ScreenToWorldPoint(screenPosition);
		}

		private void Rotate(float angleDelta)
		{
			transform.rotation *= Quaternion.Euler(0.0f, 0.0f, angleDelta);
		}

		private void Scale(float scale)
		{
			// Make sure the scale is valid
			if (scale > 0.0f)
			{
				// Grow the local scale by scale
				transform.localScale *= scale;
			}
		}
	}
}

3 Answers

3

Hello, I’m also interested in how to scale objects separately. I searched for solutions too, but the results were not optimal. However, I would like to share them. Maybe it works for you.

option 1

Someone made a video on how he did it. (link: https://drive.google.com/file/d/0B6WOE1SuIGL3VmdfZ0EyVS05WlE/view)

He used an old version of LeanTouch. This can be found here:

(Just download the whole project and copy the Lean Touch map to your project.)

It works on my Android phone for a few minutes, but after 5 minutes or less, the Scaling/Moving stops working properly.

option 2

I also found a youtube video about moving and scaling objects separately. (link: Augmented Reality Tutorial#5: Scale and drag multiple objects individually. - YouTube)

With this tutorial I can move objects separately, but Scaling still does not work for me.
(I followed the exact same steps of the tutorial.)

I am still figuring out how to scale the objects separately, and unfortunately, the two methods above did not work for me.

If someone already discovered how to Scale the objects individually (with or without LeanTouch), please share your solution/scripts.

Did you find out how to do this in the end?

Dude. You create your tilemap with Tiled and then import it into Unity with Tiled2Unity. Where's the problem with that?

Same issue here any results ?
@hjortebjerg

thanks for your time, i got problems with colliders :(':(