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);
}
}
}
}
所以这么简单我为什么想这么复杂。