美文网首页
物体自身旋转和移动

物体自身旋转和移动

作者: Moment__格调 | 来源:发表于2016-10-10 10:24 被阅读33次
Paste_Image.png

using UnityEngine;
using System.Collections;

public class Rotate : MonoBehaviour {
public float TurnX;
public float TurnY;
public float TurnZ;

public float MoveX;
public float MoveY;
public float MoveZ;

public bool World;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    if (World == true)
    {
      gameObject.  transform.Rotate(TurnX * Time.deltaTime, TurnY * Time.deltaTime, TurnZ * Time.deltaTime, Space.World);
        gameObject.transform.Translate(MoveX * Time.deltaTime, MoveY * Time.deltaTime, MoveZ * Time.deltaTime, Space.World);

    }
    else
    {
        gameObject.transform.Rotate(TurnX * Time.deltaTime, TurnY * Time.deltaTime, TurnZ * Time.deltaTime, Space.Self);
        gameObject.transform.Translate(MoveX * Time.deltaTime, MoveY * Time.deltaTime, MoveZ * Time.deltaTime, Space.Self);
    }
}

}

相关文章

网友评论

      本文标题:物体自身旋转和移动

      本文链接:https://www.haomeiwen.com/subject/ykwmyttx.html