物体上下浮动 加控制旋转轴的脚本

using UnityEngine;
using System.Collections;

public class Rotate : MonoBehaviour
{

public bool Up = false;
public bool Forward = true;
public bool Right = false;

public float Speed = 0.025f;

Vector3 oldPos;// 开始时候的坐标
public Vector3 vector;

void Start()
{
oldPos = transform.position; // 将最初的位置保存到oldPos
}
void Update()
{
if (Up)
transform.Rotate(Vector3.up, Speed);
if (Forward)
transform.Rotate(Vector3.forward, Speed);
if (Right)
transform.Rotate(Vector3.right, Speed);

transform.position = oldPos+new Vector3(0, Mathf.Sin(Time.time)* Speed);


}
}

posted on 2017-12-07 22:27  火多多  阅读(104)  评论(0)    收藏  举报

导航