2D Toolkit Forum

2D Toolkit => Support => Topic started by: Martin on September 05, 2013, 01:24:11 pm

Title: Rotation of a 3d object using tk2dUITouch
Post by: Martin on September 05, 2013, 01:24:11 pm

How coul I rotate an object using tk2dUITouch from a tk2dUIItem?

I would like to achieve something similar as the code below, to rotate the object on 3 axis when dragging over it (either mouse or finger).

Code: [Select]
public class ModelViewer : MonoBehaviour
{
public Transform rotateMe;
private float speed = 200.0f; //how fast the object should rotate
  private Vector3 axis = new Vector3();

void Update ()
{
axis.x = Input.GetAxis ("Mouse X");
axis.y = Input.GetAxis ("Mouse Y");
rotateMe.Rotate( axis  * Time.deltaTime * speed);
}
}

Code from: http://answers.unity3d.com/questions/10443/how-to-rotate-an-objects-x-y-z-based-on-mouse-move.html (http://answers.unity3d.com/questions/10443/how-to-rotate-an-objects-x-y-z-based-on-mouse-move.html)
Title: Re: Rotation of a 3d object using tk2dUITouch
Post by: unikronsoftware on September 05, 2013, 03:43:03 pm
You need to hook into the OnDown / OnUp and then only run the Update function when the button is "tapped". That should do the job.