TopDown Engine v4.5
Loading...
Searching...
No Matches
MoreMountains.TopDownEngine.InputSystemManager Class Reference

This is a replacement InputManager if you prefer using Unity's InputSystem over the legacy one. Note that it's not the default solution in the engine at the moment, because older versions of Unity don't support it, and most people still prefer not using it You can see an example of how to set it up in the MinimalScene3D_InputSystem demo scene. More...

Inheritance diagram for MoreMountains.TopDownEngine.InputSystemManager:
MoreMountains.TopDownEngine.InputManager MoreMountains.Tools.MMSingleton< T >

Public Member Functions

override void SetMovement ()
 Called every frame, if not on mobile, gets primary movement values from input.
override void SetSecondaryMovement ()
 Called every frame, if not on mobile, gets secondary movement values from input.
Public Member Functions inherited from MoreMountains.TopDownEngine.InputManager
virtual void ControlsModeDetection ()
 Turns mobile controls on or off depending on what's been defined in the inspector, and what target device we're on.
virtual void ProcessButtonStates ()
 Called at LateUpdate(), this method processes the button states of all registered buttons.
virtual void SetMovement (Vector2 movement)
 If you're using a touch joystick, bind your main joystick to this method.
virtual void SetCameraRotation (Vector2 movement)
 This method lets you bind a mobile joystick to camera rotation.
virtual void SetSecondaryMovement (Vector2 movement)
 If you're using a touch joystick, bind your secondary joystick to this method.
virtual void SetHorizontalMovement (float horizontalInput)
 If you're using touch arrows, bind your left/right arrows to this method.
virtual void SetVerticalMovement (float verticalInput)
 If you're using touch arrows, bind your secondary down/up arrows to this method.
virtual void SetSecondaryHorizontalMovement (float horizontalInput)
 If you're using touch arrows, bind your secondary left/right arrows to this method.
virtual void SetSecondaryVerticalMovement (float verticalInput)
 If you're using touch arrows, bind your down/up arrows to this method.
virtual void SetCamera (Camera targetCamera, bool camera3D)
 Sets an associated camera, used to rotate input based on camera position.
virtual void SetCameraRotationInput (float newValue)
 Sets the current camera rotation input, which you'll want to keep between -1 (left) and 1 (right), 0 being no rotation.
virtual Vector2 ApplyCameraRotation (Vector2 input)
 Rotates input based on camera orientation.
virtual void ForceAllButtonStatesTo (MMInput.ButtonStates newState)
 Lets you force the state of all buttons in the InputManager to the one specified in parameters.
virtual void JumpButtonDown ()
virtual void JumpButtonPressed ()
virtual void JumpButtonUp ()
virtual void DashButtonDown ()
virtual void DashButtonPressed ()
virtual void DashButtonUp ()
virtual void CrouchButtonDown ()
virtual void CrouchButtonPressed ()
virtual void CrouchButtonUp ()
virtual void RunButtonDown ()
virtual void RunButtonPressed ()
virtual void RunButtonUp ()
virtual void ReloadButtonDown ()
virtual void ReloadButtonPressed ()
virtual void ReloadButtonUp ()
virtual void InteractButtonDown ()
virtual void InteractButtonPressed ()
virtual void InteractButtonUp ()
virtual void ShootButtonDown ()
virtual void ShootButtonPressed ()
virtual void ShootButtonUp ()
virtual void SecondaryShootButtonDown ()
virtual void SecondaryShootButtonPressed ()
virtual void SecondaryShootButtonUp ()
virtual void PauseButtonDown ()
virtual void PauseButtonPressed ()
virtual void PauseButtonUp ()
virtual void TimeControlButtonDown ()
virtual void TimeControlButtonPressed ()
virtual void TimeControlButtonUp ()
virtual void SwitchWeaponButtonDown ()
virtual void SwitchWeaponButtonPressed ()
virtual void SwitchWeaponButtonUp ()
virtual void SwitchCharacterButtonDown ()
virtual void SwitchCharacterButtonPressed ()
virtual void SwitchCharacterButtonUp ()

Public Attributes

TopDownEngineInputActions InputActions
 a set of input actions to use to read input on
Public Attributes inherited from MoreMountains.TopDownEngine.InputManager
bool InputDetectionActive = true
 set this to false to prevent the InputManager from reading input
bool ResetButtonStatesOnFocusLoss = true
 if this is true, button states will be reset on focus loss - when clicking outside the player window on PC, for example
string PlayerID = "Player1"
 a string identifying the target player(s). You'll need to set this exact same string on your Character, and set its type to Player
bool AutoMobileDetection = true
 if this is set to true, the InputManager will try to detect what mode it should be in, based on the current target device
InputForcedModes InputForcedMode
 use this to force desktop (keyboard, pad) or mobile (touch) mode
bool ForceWeaponMode = false
 if this is true, the weapon mode will be forced to the selected WeaponForcedMode
WeaponAim.AimControls WeaponForcedMode
 use this to force a control mode for weapons
bool HideMobileControlsInEditor = false
 if this is true, mobile controls will be hidden in editor mode, regardless of the current build target or the forced mode
MovementControls MovementControl = MovementControls.Joystick
 use this to specify whether you want to use the default joystick or arrows to move your character
bool ForceDesktopIfPrimaryAxisActive = false
 if this is true, the mobile controls will be hidden when the primary desktop axis is active, and the input manager will switch to desktop inputs
bool DelayedButtonPresses = false
 if this is true, button state changes are offset by one frame (usually useful on Android)
bool AutoRevertToMobileIfPrimaryAxisInactive
 if this is true, the system will revert to mobile controls if the primary axis is inactive for more than AutoRevertToMobileIfPrimaryAxisInactiveDuration
float AutoRevertToMobileIfPrimaryAxisInactiveDuration = 10f
 the duration, in seconds, after which the system will revert to mobile controls if the primary axis is inactive
bool SmoothMovement =true
 If set to true, acceleration / deceleration will take place when moving / stopping.
Vector2 Threshold = new Vector2(0.1f, 0.4f)
 the minimum horizontal and vertical value you need to reach to trigger movement on an analog controller (joystick for example)
bool RotateInputBasedOnCameraDirection = false
 if this is true, any directional input coming into this input manager will be rotated to align with the current camera orientation

Protected Member Functions

override void Awake ()
 On Awake we run our pre-initialization.
override void Initialization ()
 On init we register to all our actions.
virtual void TestForceDesktop ()
override void Update ()
 At update, we check the various commands and update our values and states accordingly.
virtual void TestAutoRevert ()
virtual void BindButton (InputAction.CallbackContext context, MMInput.IMButton imButton)
 Changes the state of our button based on the input value.
override void GetInputButtons ()
 If we're not on mobile, watches for input changes, and updates our buttons states accordingly.
override void SetShootAxis ()
 Called every frame, if not on mobile, gets shoot axis values from input.
override void SetCameraRotationAxis ()
 Grabs camera rotation input and stores it.
override void TestPrimaryAxis ()
virtual void OnEnable ()
 On enable we enable our input actions.
virtual void OnDisable ()
 On disable we disable our input actions.
Protected Member Functions inherited from MoreMountains.TopDownEngine.InputManager
virtual void Start ()
 On Start we look for what mode to use, and initialize our axis and buttons.
virtual void PreInitialization ()
 Initializes buttons and axis.
virtual void InitializeButtons ()
 Initializes the buttons. If you want to add more buttons, make sure to register them here.
virtual void InitializeAxis ()
 Initializes the axis strings.
virtual void LateUpdate ()
 On LateUpdate, we process our button states.
virtual void GetLastNonNullValues ()
 Gets the last non null values for both primary and secondary axis.
IEnumerator DelayButtonPress (MMInput.IMButton button)
 A coroutine that changes the pressed state one frame later.
IEnumerator DelayButtonRelease (MMInput.IMButton button)
 A coroutine that changes the pressed state one frame later.
void OnApplicationFocus (bool hasFocus)
 If we lose focus, we reset the states of all buttons.
Protected Member Functions inherited from MoreMountains.Tools.MMSingleton< T >
virtual void InitializeSingleton ()
 Initializes the singleton.

Protected Attributes

Vector2 _primaryMovementInput
Vector2 _secondaryMovementInput
Protected Attributes inherited from MoreMountains.TopDownEngine.InputManager
Camera _targetCamera
bool _camera3D
float _cameraAngle
List< MMInput.IMButtonButtonList
Vector2 _primaryMovement = Vector2.zero
Vector2 _secondaryMovement = Vector2.zero
float _cameraRotationInput = 0f
string _axisHorizontal
string _axisVertical
string _axisSecondaryHorizontal
string _axisSecondaryVertical
string _axisShoot
string _axisShootSecondary
string _axisCamera
float _primaryAxisActiveTimestamp

Properties

override Vector2 MousePosition [get]
 the position of the mouse
Properties inherited from MoreMountains.TopDownEngine.InputManager
virtual bool IsMobile [get, protected set]
 if this is true, we're currently in mobile mode
virtual bool IsPrimaryAxisActive [get, protected set]
virtual MMInput.IMButton JumpButton [get, protected set]
 the jump button, used for jumps and validation
virtual MMInput.IMButton RunButton [get, protected set]
 the run button
virtual MMInput.IMButton DashButton [get, protected set]
 the dash button
virtual MMInput.IMButton CrouchButton [get, protected set]
 the crouch button
virtual MMInput.IMButton ShootButton [get, protected set]
 the shoot button
virtual MMInput.IMButton InteractButton [get, protected set]
 the activate button, used for interactions with zones
virtual MMInput.IMButton SecondaryShootButton [get, protected set]
 the shoot button
virtual MMInput.IMButton ReloadButton [get, protected set]
 the reload button
virtual MMInput.IMButton PauseButton [get, protected set]
 the pause button
virtual MMInput.IMButton TimeControlButton [get, protected set]
 the time control button
virtual MMInput.IMButton SwitchCharacterButton [get, protected set]
 the button used to switch character (either via model or prefab switch)
virtual MMInput.IMButton SwitchWeaponButton [get, protected set]
 the switch weapon button
virtual MMInput.ButtonStates ShootAxis [get, protected set]
 the shoot axis, used as a button (non analogic)
virtual MMInput.ButtonStates SecondaryShootAxis [get, protected set]
 the shoot axis, used as a button (non analogic)
virtual Vector2 PrimaryMovement [get]
 the primary movement value (used to move the character around)
virtual Vector2 SecondaryMovement [get]
 the secondary movement (usually the right stick on a gamepad), used to aim
virtual Vector2 LastNonNullPrimaryMovement [get, set]
 the primary movement value (used to move the character around)
virtual Vector2 LastNonNullSecondaryMovement [get, set]
 the secondary movement (usually the right stick on a gamepad), used to aim
virtual float CameraRotationInput [get]
 the camera rotation axis input value
virtual float CameraAngle [get]
 the current camera angle
virtual Vector2 MousePosition [get]
 the position of the mouse
Properties inherited from MoreMountains.Tools.MMSingleton< T >
static bool HasInstance [get]
static T Current [get]
static T Instance [get]
 Singleton design pattern.

Additional Inherited Members

Public Types inherited from MoreMountains.TopDownEngine.InputManager
enum  InputForcedModes { None , Mobile , Desktop }
 the possible modes for this input manager More...
enum  MovementControls { Joystick , Arrows }
 the possible kinds of control used for movement More...
Static Public Member Functions inherited from MoreMountains.Tools.MMSingleton< T >
static T TryGetInstance ()
Static Protected Member Functions inherited from MoreMountains.TopDownEngine.InputManager
static void InitializeStatics ()
 Statics initialization to support enter play modes.
Static Protected Attributes inherited from MoreMountains.Tools.MMSingleton< T >
static T _instance

Detailed Description

This is a replacement InputManager if you prefer using Unity's InputSystem over the legacy one. Note that it's not the default solution in the engine at the moment, because older versions of Unity don't support it, and most people still prefer not using it You can see an example of how to set it up in the MinimalScene3D_InputSystem demo scene.

Member Function Documentation

◆ Awake()

override void MoreMountains.TopDownEngine.InputSystemManager.Awake ( )
protectedvirtual

On Awake we run our pre-initialization.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

◆ BindButton()

virtual void MoreMountains.TopDownEngine.InputSystemManager.BindButton ( InputAction.CallbackContext context,
MMInput.IMButton imButton )
protectedvirtual

Changes the state of our button based on the input value.

Parameters
context
imButton

◆ GetInputButtons()

override void MoreMountains.TopDownEngine.InputSystemManager.GetInputButtons ( )
protectedvirtual

If we're not on mobile, watches for input changes, and updates our buttons states accordingly.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

◆ Initialization()

override void MoreMountains.TopDownEngine.InputSystemManager.Initialization ( )
protectedvirtual

On init we register to all our actions.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

◆ OnDisable()

virtual void MoreMountains.TopDownEngine.InputSystemManager.OnDisable ( )
protectedvirtual

On disable we disable our input actions.

◆ OnEnable()

virtual void MoreMountains.TopDownEngine.InputSystemManager.OnEnable ( )
protectedvirtual

On enable we enable our input actions.

◆ SetCameraRotationAxis()

override void MoreMountains.TopDownEngine.InputSystemManager.SetCameraRotationAxis ( )
protectedvirtual

Grabs camera rotation input and stores it.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

◆ SetMovement()

override void MoreMountains.TopDownEngine.InputSystemManager.SetMovement ( )
virtual

Called every frame, if not on mobile, gets primary movement values from input.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

◆ SetSecondaryMovement()

override void MoreMountains.TopDownEngine.InputSystemManager.SetSecondaryMovement ( )
virtual

Called every frame, if not on mobile, gets secondary movement values from input.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

◆ SetShootAxis()

override void MoreMountains.TopDownEngine.InputSystemManager.SetShootAxis ( )
protectedvirtual

Called every frame, if not on mobile, gets shoot axis values from input.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

◆ TestAutoRevert()

virtual void MoreMountains.TopDownEngine.InputSystemManager.TestAutoRevert ( )
protectedvirtual

◆ TestForceDesktop()

virtual void MoreMountains.TopDownEngine.InputSystemManager.TestForceDesktop ( )
protectedvirtual

◆ TestPrimaryAxis()

override void MoreMountains.TopDownEngine.InputSystemManager.TestPrimaryAxis ( )
protectedvirtual

◆ Update()

override void MoreMountains.TopDownEngine.InputSystemManager.Update ( )
protectedvirtual

At update, we check the various commands and update our values and states accordingly.

Reimplemented from MoreMountains.TopDownEngine.InputManager.

Member Data Documentation

◆ _primaryMovementInput

Vector2 MoreMountains.TopDownEngine.InputSystemManager._primaryMovementInput
protected

◆ _secondaryMovementInput

Vector2 MoreMountains.TopDownEngine.InputSystemManager._secondaryMovementInput
protected

◆ InputActions

TopDownEngineInputActions MoreMountains.TopDownEngine.InputSystemManager.InputActions

a set of input actions to use to read input on

Property Documentation

◆ MousePosition

override Vector2 MoreMountains.TopDownEngine.InputSystemManager.MousePosition
get

the position of the mouse


The documentation for this class was generated from the following file:
  • H:/Code/MoreMountains/topdownengine/Assets/TopDownEngine/Common/ScriptsInputSystem/Scripts/InputSystemManager.cs