Working on entrance and building out first level
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -22,15 +23,18 @@ namespace StarterAssets
|
||||
public bool cursorLocked = true;
|
||||
public bool cursorInputForLook = true;
|
||||
|
||||
public bool inputEnabled = true;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
public void OnMove(InputValue value)
|
||||
{
|
||||
MoveInput(value.Get<Vector2>());
|
||||
if(inputEnabled)
|
||||
MoveInput(value.Get<Vector2>());
|
||||
}
|
||||
|
||||
public void OnLook(InputValue value)
|
||||
{
|
||||
if(cursorInputForLook)
|
||||
if(cursorInputForLook && inputEnabled)
|
||||
{
|
||||
LookInput(value.Get<Vector2>());
|
||||
}
|
||||
@@ -38,20 +42,24 @@ namespace StarterAssets
|
||||
|
||||
public void OnJump(InputValue value)
|
||||
{
|
||||
JumpInput(value.isPressed);
|
||||
if(inputEnabled)
|
||||
JumpInput(value.isPressed);
|
||||
}
|
||||
|
||||
public void OnSprint(InputValue value)
|
||||
{
|
||||
SprintInput(value.isPressed);
|
||||
if(inputEnabled)
|
||||
SprintInput(value.isPressed);
|
||||
}
|
||||
public void OnShoot(InputValue value)
|
||||
{
|
||||
ShootInput(value.isPressed);
|
||||
if(inputEnabled)
|
||||
ShootInput(value.isPressed);
|
||||
}
|
||||
public void OnInteract(InputValue value)
|
||||
{
|
||||
InteractInput(value.isPressed);
|
||||
if(inputEnabled)
|
||||
InteractInput(value.isPressed);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -93,6 +101,23 @@ namespace StarterAssets
|
||||
{
|
||||
Cursor.lockState = newState ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
}
|
||||
public void EnableInput()
|
||||
{
|
||||
inputEnabled = true;
|
||||
}
|
||||
public void DisableInput()
|
||||
{
|
||||
inputEnabled = false;
|
||||
}
|
||||
public IEnumerator ToggleInput(float delay)
|
||||
{
|
||||
inputEnabled = false; // Disable immediately
|
||||
move = Vector2.zero;
|
||||
look = Vector2.zero;
|
||||
GetComponents<CharacterController>()[0].Move(Vector3.zero); // Prevents character from sliding
|
||||
yield return new WaitForSeconds(delay);
|
||||
inputEnabled = true; // Re-enable after delay
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user