holopy3/Assets/Scripts/TurnAround.cs
Lena Biresch 490ef558ef CleanUp
2021-01-28 13:07:52 +01:00

34 lines
589 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurnAround : MonoBehaviour
{
private bool turn = true;
private void OnEnable()
{
PassTheEdgeTrigger.OnPassingTheEdge += StopTurning;
}
private void OnDisable()
{
PassTheEdgeTrigger.OnPassingTheEdge -= StopTurning;
}
public float Speed = 3.0f;
void Update()
{
if (turn)
{
gameObject.transform.Rotate(Vector3.up / Speed);
}
}
private void StopTurning()
{
turn = false;
}
}