Using Unityengine;
Using System.Collections;
public class Chnge:monobehaviour {
Public Gameobject POS;
public Transform target;
Vector3 Touchpos;
Vector3 position11;
float angle;
void Start ()
{
Angle = Vector3.angle (Touchpos, position11);
Position11 = pos.transform.position;
}
void Update ()
{
Touchtext ();
}
void Touchtext () {
if (Input.touchcount = = 1)
{
if (Input.gettouch (0). Phase = = touchphase.moved)
{
Touchpos = Input.gettouch (0). deltaposition;
Target.transform.Rotate (0, 0,-touchpos.x * 3, space.self);
}
}
if (Input.gettouch (0). Phase = = touchphase.ended)
{
Vector3 Viewpos = camera. Worldtoviewportpoint (target.position);
if (Viewpos.x > 0.5F)
{
target.transform.rotation = Quaternion.euler (0, 0, Angle);
}
Else
{
target.transform.rotation = Quaternion.euler (0, 0,-angle);
}
}
}
}
So it's so simple why do I want to be so complicated.
Touch Rotate auto Update position-------------------Worldtoviewportpoint