using System.Collections.Generic;
using UnityEngine;
public class TriggerRoll : MonoBehaviour
{
public Transform target;
public bool x = false, y = false, z = false;
public float speed = 20f;
public bool isReverse = false;
private bool isRun = false;
public float prevRot;
private int dir = 1;
void Update()
{
if (UnityEditor.TransformUtils.GetInspectorRotation(target.transform).z != prevRot)
{
isRun = true;
if (prevRot < UnityEditor.TransformUtils.GetInspectorRotation(target.transform).z)
{
dir = 1;
}
else
dir = -1;
prevRot = UnityEditor.TransformUtils.GetInspectorRotation(target.transform).z;
}
else
isRun = false;
if (isRun)
{
if (!isReverse)
{
transform.Rotate(x ? 6f*dir * speed * Time.deltaTime : 0f,
y ? 6f * dir * speed * Time.deltaTime : 0f,
z ? 6f * dir * speed * Time.deltaTime : 0f);
}
else
{
transform.Rotate(x ? 6f * dir * speed * Time.deltaTime * -1 : 0f,
y ? 6f * dir * speed * Time.deltaTime * -1 : 0f,
z ? 6f * dir * speed * Time.deltaTime * -1 : 0f);
}
}
}
}
댓글 없음:
댓글 쓰기