Hello Guest

Author Topic: Rotation of a 3d object using tk2dUITouch  (Read 3621 times)

Martin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Rotation of a 3d object using tk2dUITouch
« 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Rotation of a 3d object using tk2dUITouch
« Reply #1 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.