holopy3/Assets/Scripts/TurnAround.cs

35 lines
589 B
C#
Raw Permalink Normal View History

2020-12-10 14:25:12 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurnAround : MonoBehaviour
{
2021-01-28 12:07:52 +00:00
private bool turn = true;
private void OnEnable()
{
PassTheEdgeTrigger.OnPassingTheEdge += StopTurning;
}
private void OnDisable()
{
PassTheEdgeTrigger.OnPassingTheEdge -= StopTurning;
}
2020-12-10 14:25:12 +00:00
public float Speed = 3.0f;
2021-01-28 12:07:52 +00:00
2020-12-10 14:25:12 +00:00
void Update()
{
2021-01-28 12:07:52 +00:00
if (turn)
{
gameObject.transform.Rotate(Vector3.up / Speed);
}
}
private void StopTurning()
{
turn = false;
2020-12-10 14:25:12 +00:00
}
}