我正在建立一个统一的应用程序。 当用户点击GameObject时,模型位置会发生变化。 现在我需要改变位置,旋转也随着极限轴/协调点而改变。
这是我对gameObject输入点击位置的代码更改。
using UnityEngine;
using System.Collections;
public class centertheroombox : MonoBehaviour
{
public GameObject box345;
public int speed = 1;
// Update is called once per frame
void Update ()
{
foreach (Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Ended)
{
Ray ray = Camera.main.ScreenPointToRay(touch.position);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1000.0f))
{
if (hit.collider.gameObject.name == "Box345")
{
Debug.Log("yupiee pressed");
box345.transform.position = new Vector3(3, 0, -9);
//box345.transform.Rotate(Vector3.right, Time.deltaTime);
//box345.transform.Rotate = new Vector3(353,0,0);
}
}
}
}
}
}