标签:unity3d public 代码 initial void 旋转 axis cto mon
//将以下代码绑定到相机上
using UnityEngine;
using System.Collections;
public class LookatScipt : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float x = Input.GetAxis ("Horizontal");//旋转相机
float y = Input.GetAxis ("Vertical");
gameObject.transform.RotateAround(gameObject.transform.position, Vector3.up, x);
gameObject.transform.RotateAround(gameObject.transform.position, Vector3.right, y);
GameObject cube = GameObject.Find("Cube");//要正对着相机的物体
cube.transform.RotateAround(gameObject.transform.position, Vector3.up, x);
cube.transform.RotateAround(gameObject.transform.position, Vector3.right, y);
}
}
Unity3d让某个物体一直正对着相机
标签:unity3d public 代码 initial void 旋转 axis cto mon
原文地址:http://www.cnblogs.com/C-9925/p/7350278.html