only allow using elevator while on it
This commit is contained in:
@@ -8,7 +8,7 @@ using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType;
|
||||
|
||||
namespace Station46.Modules.Elevated_Platform.Scripts
|
||||
{
|
||||
[RequireComponent(typeof(Animator))]
|
||||
[RequireComponent(typeof(Animator), typeof(Collider))]
|
||||
public class PlatformElevator : MonoBehaviour
|
||||
{
|
||||
public enum Status
|
||||
@@ -34,7 +34,11 @@ namespace Station46.Modules.Elevated_Platform.Scripts
|
||||
case Status.Bottom:
|
||||
case Status.Top:
|
||||
ReleasePlayer();
|
||||
_button.Enable();
|
||||
if (!_leftElevatorWhileMoving)
|
||||
{
|
||||
_button.Enable();
|
||||
}
|
||||
_leftElevatorWhileMoving = false;
|
||||
break;
|
||||
case Status.Moving:
|
||||
_button.Disable();
|
||||
@@ -49,6 +53,7 @@ namespace Station46.Modules.Elevated_Platform.Scripts
|
||||
private Status _status = Status.Bottom;
|
||||
private Animator _animator;
|
||||
private Transform _previousPlayerParent;
|
||||
private bool _leftElevatorWhileMoving;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -104,5 +109,28 @@ namespace Station46.Modules.Elevated_Platform.Scripts
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (_status != Status.Moving && other.CompareTag("MainCamera"))
|
||||
{
|
||||
_button.Enable();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag("MainCamera"))
|
||||
{
|
||||
if (_status == Status.Moving)
|
||||
{
|
||||
_leftElevatorWhileMoving = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_button.Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user