Added basic features
This commit is contained in:
35
Assets/Scripts/PlayerInteraction.cs
Normal file
35
Assets/Scripts/PlayerInteraction.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
public class PlayerInteraction : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private WorldSwitcher _worldSwitcher;
|
||||
|
||||
private PlayerInput _playerInput;
|
||||
private InputAction _interactAction;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_playerInput = GetComponent<PlayerInput>();
|
||||
_interactAction = _playerInput.actions["SwitchWorld"];
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_interactAction != null)
|
||||
{
|
||||
_interactAction.Enable();
|
||||
_interactAction.performed += OnInteractPerformed;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInteractPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
_worldSwitcher.SwitchNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user