player can enter the door
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Door : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private string _scene;
|
||||
[SerializeField]
|
||||
private string _exitName;
|
||||
[SerializeField]
|
||||
private string _enterName;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (PlayerPrefs.GetString("lastExitName") == _enterName)
|
||||
{
|
||||
print($"Player came from to {_scene}");
|
||||
Player.Instance.SetPosition(_interactionPoint.position);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
print($"Player go to {_scene}");
|
||||
if (!string.IsNullOrEmpty(_exitName))
|
||||
{
|
||||
PlayerPrefs.SetString("lastExitName", _exitName);
|
||||
}
|
||||
SceneManager.LoadScene(_scene);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user