把以下代碼綁定到要旋轉的物體,具體要圍繞x,y,z 哪個軸旋轉就改相應的值即可。
- using UnityEngine;
- using System.Collections;
- public class PickUp : MonoBehaviour {
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- transform.Rotate(new Vector3(0,1,0)); //繞y軸旋轉 //應該是物體圍繞自身的XYZ軸旋轉,改變的是Y軸的角度,測試下就好了 //不是,物體繞着世界中心0,0,0的Y軸進行旋轉,
- }
- }