Input Handler

Get Fire

Returns true if the fire/shoot input is pressed.

if(InputHandler.GetFire())
{
  Debug.Log("Fire button pressed");
}

Get Jump

Returns true if the jump input is pressed.

if(InputHandler.GetJump())
{
  Debug.Log("Jump button pressed");
}

Get Crouch

Returns true if the crouch input is pressed.

if(InputHandler.GetCrouch())
{
  Debug.Log("Crouch button pressed");
}

Get Sprint

Returns true if the sprint input is pressed.

if(InputHandler.GetSprint())
{
  Debug.Log("Sprint button pressed");
}

Get Reload

Returns true if the reload input is pressed.

if(InputHandler.GetReload())
{
  Debug.Log("Reload button pressed");
}

Get Inventory

Returns true if the inventory input is pressed.

if(InputHandler.GetInventory())
{
  Debug.Log("Inventory button pressed");
}

Get Interact

Returns true if the interact input is pressed.

if(InputHandler.GetInteract())
{
  Debug.Log("Interact button pressed");
}

Get Map

Returns true if the map input is pressed.

if(InputHandler.GetMap())
{
  Debug.Log("Map button pressed");
}

Get Previous

Returns true if the previous input is pressed.

if(InputHandler.GetPrevious())
{
  Debug.Log("Previous button pressed");
}

Get Next

Returns true if the next input is pressed.

if(InputHandler.GetBack())
{
  Debug.Log("Back button pressed");
}

Get Pause

Returns true if the next input is pressed.

if(InputHandler.GetPause())
{
  Debug.Log("Pause button pressed");
}

Get Left

Returns true if the left mouse button is pressed.

if(InputHandler.GetLeft())
{
  Debug.Log("Left button pressed");
}

Get Right

Returns true if the right mouse button is pressed.

if(InputHandler.GetRight())
{
  Debug.Log("Right button pressed");
}

Get Swipe

Returns a directional enum (None, Left, Right, Up, Down) based on swipe gesture input.

if(InputHandler.GetSwipe() == InputHandler.SwipeLeft)
{
  Debug.Log("Swipe left detected");
}


if(InputHandler.GetSwipe() == InputHandler.SwipeRight)
{
  Debug.Log("Swipe right detected");
}

Get Move

Returns a Vector2 representing directional input (WASD, joystick, etc.).

if(InputHandler.GetMove() != Vector2.zero)
{
  Debug.Log("Movement detected: " + InputHandler.GetMove());
}

Get Screen Position

Returns the input's position in screen coordinates (e.g., mouse or touch location).

if(InputHandler.GetScreenPosition() != Vector2.zero)
{
  Debug.Log("Screen position detected: " + 
  InputHandler.GetScreenPosition());
}

Get World Position

Returns the input's position in world coordinates (e.g., mouse or touch location).

if(InputHandler.GetWorldPosition() != Vector2.zero)
{
  Debug.Log("World position detected: " + 
  InputHandler.GetWorldPosition());
}

Get Cast 2D

Performs a 2D raycast from the pointer and returns a Collider2D hit.

Collider2D hit2D = InputHandler.GetCast2D();

if (hit2D != null) Debug.Log("2D Object hit: " + hit2D.name);

Get Cast 3D

Performs a 3D raycast and returns a Collider hit.

Collider hit3D = InputHandler.GetCast3D();

if (hit3D != null) Debug.Log("3D Object hit: " + hit3D.name);

Get Cast Rect

Raycasts UI elements and returns a RectTransform if something was hit.

RectTransform uiHit = InputHandler.GetCastRect();

if (uiHit != null) Debug.Log("UI Element hit: " + uiHit.name);

Get Key<T>

Fetches a custom input value (bool, float, Vector2, etc.) by action name defined in the Input Actions asset.

float customFloat = InputHandler.GetKey<float>("CustomFloat");

Vector2 customVector2 = InputHandler.GetKey<Vector2>("CustomVector2");

bool customBool = InputHandler.GetKey<bool>("CustomBool");

Last updated