您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
41 行
1.1 KiB
41 行
1.1 KiB
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.Utility
|
|
{
|
|
public class AutoMoveAndRotate : MonoBehaviour
|
|
{
|
|
public Vector3andSpace moveUnitsPerSecond;
|
|
public Vector3andSpace rotateDegreesPerSecond;
|
|
public bool ignoreTimescale;
|
|
private float m_LastRealTime;
|
|
|
|
|
|
private void Start()
|
|
{
|
|
m_LastRealTime = Time.realtimeSinceStartup;
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
private void Update()
|
|
{
|
|
float deltaTime = Time.deltaTime;
|
|
if (ignoreTimescale)
|
|
{
|
|
deltaTime = (Time.realtimeSinceStartup - m_LastRealTime);
|
|
m_LastRealTime = Time.realtimeSinceStartup;
|
|
}
|
|
transform.Translate(moveUnitsPerSecond.value*deltaTime, moveUnitsPerSecond.space);
|
|
transform.Rotate(rotateDegreesPerSecond.value*deltaTime, moveUnitsPerSecond.space);
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
public class Vector3andSpace
|
|
{
|
|
public Vector3 value;
|
|
public Space space = Space.Self;
|
|
}
|
|
}
|
|
}
|