|
TopDown Engine
v4.4
|
This persistent singleton handles the inputs and sends commands to the player. IMPORTANT : this script's Execution Order MUST be -100. You can define a script's execution order by clicking on the script's file and then clicking on the Execution Order button at the bottom right of the script's inspector. See https://docs.unity3d.com/Manual/class-ScriptExecution.html for more details More...
Public Types | |
| enum | InputForcedModes { InputForcedModes.None, InputForcedModes.Mobile, InputForcedModes.Desktop } |
| the possible modes for this input manager More... | |
| enum | MovementControls { MovementControls.Joystick, MovementControls.Arrows } |
| the possible kinds of control used for movement More... | |
Public Member Functions | |
| 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 More... | |
| virtual void | ProcessButtonStates () |
| Called at LateUpdate(), this method processes the button states of all registered buttons More... | |
| virtual void | SetMovement () |
| Called every frame, if not on mobile, gets primary movement values from input More... | |
| virtual void | SetSecondaryMovement () |
| Called every frame, if not on mobile, gets secondary movement values from input More... | |
| virtual void | SetMovement (Vector2 movement) |
| If you're using a touch joystick, bind your main joystick to this method More... | |
| virtual void | SetCameraRotation (Vector2 movement) |
| This method lets you bind a mobile joystick to camera rotation More... | |
| virtual void | SetSecondaryMovement (Vector2 movement) |
| If you're using a touch joystick, bind your secondary joystick to this method More... | |
| virtual void | SetHorizontalMovement (float horizontalInput) |
| If you're using touch arrows, bind your left/right arrows to this method More... | |
| virtual void | SetVerticalMovement (float verticalInput) |
| If you're using touch arrows, bind your secondary down/up arrows to this method More... | |
| virtual void | SetSecondaryHorizontalMovement (float horizontalInput) |
| If you're using touch arrows, bind your secondary left/right arrows to this method More... | |
| virtual void | SetSecondaryVerticalMovement (float verticalInput) |
| If you're using touch arrows, bind your down/up arrows to this method More... | |
| virtual void | SetCamera (Camera targetCamera, bool camera3D) |
| Sets an associated camera, used to rotate input based on camera position More... | |
| 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 More... | |
| virtual Vector2 | ApplyCameraRotation (Vector2 input) |
| Rotates input based on camera orientation More... | |
| virtual void | ForceAllButtonStatesTo (MMInput.ButtonStates newState) |
| Lets you force the state of all buttons in the InputManager to the one specified in parameters More... | |
| 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 | |
| bool | InputDetectionActive = true |
| set this to false to prevent the InputManager from reading input More... | |
| 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 More... | |
| 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 More... | |
| 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 More... | |
| InputForcedModes | InputForcedMode |
| use this to force desktop (keyboard, pad) or mobile (touch) mode More... | |
| bool | ForceWeaponMode = false |
| if this is true, the weapon mode will be forced to the selected WeaponForcedMode More... | |
| WeaponAim.AimControls | WeaponForcedMode |
| use this to force a control mode for weapons More... | |
| 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 More... | |
| MovementControls | MovementControl = MovementControls.Joystick |
| use this to specify whether you want to use the default joystick or arrows to move your character More... | |
| 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 More... | |
| bool | DelayedButtonPresses = false |
| if this is true, button state changes are offset by one frame (usually useful on Android) More... | |
| bool | AutoRevertToMobileIfPrimaryAxisInactive |
| if this is true, the system will revert to mobile controls if the primary axis is inactive for more than AutoRevertToMobileIfPrimaryAxisInactiveDuration More... | |
| float | AutoRevertToMobileIfPrimaryAxisInactiveDuration = 10f |
| the duration, in seconds, after which the system will revert to mobile controls if the primary axis is inactive More... | |
| bool | SmoothMovement =true |
| If set to true, acceleration / deceleration will take place when moving / stopping. More... | |
| 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) More... | |
| 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 More... | |
| virtual Vector2 | MousePosition => Input.mousePosition |
| the position of the mouse More... | |
Protected Member Functions | |
| override void | Awake () |
| On Awake we run our pre-initialization More... | |
| virtual void | Start () |
| On Start we look for what mode to use, and initialize our axis and buttons More... | |
| virtual void | PreInitialization () |
| Initializes buttons and axis More... | |
| virtual void | Initialization () |
| On init we auto detect control schemes More... | |
| virtual void | InitializeButtons () |
| Initializes the buttons. If you want to add more buttons, make sure to register them here. More... | |
| virtual void | InitializeAxis () |
| Initializes the axis strings. More... | |
| virtual void | LateUpdate () |
| On LateUpdate, we process our button states More... | |
| virtual void | Update () |
| At update, we check the various commands and update our values and states accordingly. More... | |
| virtual void | TestPrimaryAxis () |
| virtual void | GetLastNonNullValues () |
| Gets the last non null values for both primary and secondary axis More... | |
| virtual void | GetInputButtons () |
| If we're not on mobile, watches for input changes, and updates our buttons states accordingly More... | |
| IEnumerator | DelayButtonPress (MMInput.IMButton button) |
| A coroutine that changes the pressed state one frame later More... | |
| IEnumerator | DelayButtonRelease (MMInput.IMButton button) |
| A coroutine that changes the pressed state one frame later More... | |
| virtual void | SetShootAxis () |
| Called every frame, if not on mobile, gets shoot axis values from input More... | |
| virtual void | SetCameraRotationAxis () |
| Grabs camera rotation input and stores it More... | |
| void | OnApplicationFocus (bool hasFocus) |
| If we lose focus, we reset the states of all buttons More... | |
Protected Member Functions inherited from MoreMountains.Tools.MMSingleton< InputManager > | |
| virtual void | InitializeSingleton () |
| Initializes the singleton. More... | |
Static Protected Member Functions | |
| static void | InitializeStatics () |
| Statics initialization to support enter play modes More... | |
Protected Attributes | |
| Camera | _targetCamera |
| bool | _camera3D |
| float | _cameraAngle |
| List< MMInput.IMButton > | ButtonList |
| 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 | |
| virtual bool | IsMobile [get, protected set] |
| if this is true, we're currently in mobile mode More... | |
| virtual bool | IsPrimaryAxisActive [get, protected set] |
| virtual MMInput.IMButton | JumpButton [get, protected set] |
| the jump button, used for jumps and validation More... | |
| virtual MMInput.IMButton | RunButton [get, protected set] |
| the run button More... | |
| virtual MMInput.IMButton | DashButton [get, protected set] |
| the dash button More... | |
| virtual MMInput.IMButton | CrouchButton [get, protected set] |
| the crouch button More... | |
| virtual MMInput.IMButton | ShootButton [get, protected set] |
| the shoot button More... | |
| virtual MMInput.IMButton | InteractButton [get, protected set] |
| the activate button, used for interactions with zones More... | |
| virtual MMInput.IMButton | SecondaryShootButton [get, protected set] |
| the shoot button More... | |
| virtual MMInput.IMButton | ReloadButton [get, protected set] |
| the reload button More... | |
| virtual MMInput.IMButton | PauseButton [get, protected set] |
| the pause button More... | |
| virtual MMInput.IMButton | TimeControlButton [get, protected set] |
| the time control button More... | |
| virtual MMInput.IMButton | SwitchCharacterButton [get, protected set] |
| the button used to switch character (either via model or prefab switch) More... | |
| virtual MMInput.IMButton | SwitchWeaponButton [get, protected set] |
| the switch weapon button More... | |
| virtual MMInput.ButtonStates | ShootAxis [get, protected set] |
| the shoot axis, used as a button (non analogic) More... | |
| virtual MMInput.ButtonStates | SecondaryShootAxis [get, protected set] |
| the shoot axis, used as a button (non analogic) More... | |
| virtual Vector2 | PrimaryMovement [get] |
| the primary movement value (used to move the character around) More... | |
| virtual Vector2 | SecondaryMovement [get] |
| the secondary movement (usually the right stick on a gamepad), used to aim More... | |
| virtual Vector2 | LastNonNullPrimaryMovement [get, set] |
| the primary movement value (used to move the character around) More... | |
| virtual Vector2 | LastNonNullSecondaryMovement [get, set] |
| the secondary movement (usually the right stick on a gamepad), used to aim More... | |
| virtual float | CameraRotationInput [get] |
| the camera rotation axis input value More... | |
| virtual float | CameraAngle [get] |
| the current camera angle More... | |
Properties inherited from MoreMountains.Tools.MMSingleton< InputManager > | |
| static T | Instance [get] |
| Singleton design pattern More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from MoreMountains.Tools.MMSingleton< InputManager > | |
| static T | TryGetInstance () |
Static Public Attributes inherited from MoreMountains.Tools.MMSingleton< InputManager > | |
| static bool | HasInstance |
| static T | Current |
Static Protected Attributes inherited from MoreMountains.Tools.MMSingleton< InputManager > | |
| static T | _instance |
This persistent singleton handles the inputs and sends commands to the player. IMPORTANT : this script's Execution Order MUST be -100. You can define a script's execution order by clicking on the script's file and then clicking on the Execution Order button at the bottom right of the script's inspector. See https://docs.unity3d.com/Manual/class-ScriptExecution.html for more details
|
virtual |
Rotates input based on camera orientation
| input |
|
protectedvirtual |
On Awake we run our pre-initialization
Reimplemented from MoreMountains.Tools.MMSingleton< InputManager >.
Reimplemented in MoreMountains.TopDownEngine.InputSystemManager, and MoreMountains.TopDownEngine.InputSystemManagerBase< T >.
|
virtual |
Turns mobile controls on or off depending on what's been defined in the inspector, and what target device we're on
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
protected |
A coroutine that changes the pressed state one frame later
| button |
|
protected |
A coroutine that changes the pressed state one frame later
| button |
|
virtual |
Lets you force the state of all buttons in the InputManager to the one specified in parameters
| newState |
|
protectedvirtual |
If we're not on mobile, watches for input changes, and updates our buttons states accordingly
Reimplemented in MoreMountains.TopDownEngine.InputSystemManager, MoreMountains.TopDownEngine.InputSystemManagerEventsBased, and MoreMountains.TopDownEngine.InputSystemManagerBase< T >.
|
protectedvirtual |
Gets the last non null values for both primary and secondary axis
|
protectedvirtual |
On init we auto detect control schemes
Reimplemented in MoreMountains.TopDownEngine.InputSystemManager.
|
protectedvirtual |
Initializes the axis strings.
|
protectedvirtual |
Initializes the buttons. If you want to add more buttons, make sure to register them here.
|
staticprotected |
Statics initialization to support enter play modes
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
On LateUpdate, we process our button states
|
protected |
If we lose focus, we reset the states of all buttons
| hasFocus |
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
Initializes buttons and axis
|
virtual |
Called at LateUpdate(), this method processes the button states of all registered buttons
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Sets an associated camera, used to rotate input based on camera position
| targetCamera | |
| rotationAxis |
|
virtual |
This method lets you bind a mobile joystick to camera rotation
| movement |
|
protectedvirtual |
Grabs camera rotation input and stores it
Reimplemented in MoreMountains.TopDownEngine.InputSystemManager, MoreMountains.TopDownEngine.InputSystemManagerEventsBased, and MoreMountains.TopDownEngine.InputSystemManagerBase< T >.
|
virtual |
Sets the current camera rotation input, which you'll want to keep between -1 (left) and 1 (right), 0 being no rotation
| newValue |
|
virtual |
If you're using touch arrows, bind your left/right arrows to this method
.
|
virtual |
Called every frame, if not on mobile, gets primary movement values from input
Reimplemented in MoreMountains.TopDownEngine.InputSystemManager, MoreMountains.TopDownEngine.InputSystemManagerEventsBased, and MoreMountains.TopDownEngine.InputSystemManagerBase< T >.
|
virtual |
If you're using a touch joystick, bind your main joystick to this method
| movement | Movement. |
|
virtual |
If you're using touch arrows, bind your secondary left/right arrows to this method
.
|
virtual |
Called every frame, if not on mobile, gets secondary movement values from input
Reimplemented in MoreMountains.TopDownEngine.InputSystemManager, MoreMountains.TopDownEngine.InputSystemManagerEventsBased, and MoreMountains.TopDownEngine.InputSystemManagerBase< T >.
|
virtual |
If you're using a touch joystick, bind your secondary joystick to this method
| movement | Movement. |
|
virtual |
If you're using touch arrows, bind your down/up arrows to this method
.
|
protectedvirtual |
Called every frame, if not on mobile, gets shoot axis values from input
Reimplemented in MoreMountains.TopDownEngine.InputSystemManager, MoreMountains.TopDownEngine.InputSystemManagerEventsBased, and MoreMountains.TopDownEngine.InputSystemManagerBase< T >.
|
virtual |
If you're using touch arrows, bind your secondary down/up arrows to this method
.
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
On Start we look for what mode to use, and initialize our axis and buttons
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
At update, we check the various commands and update our values and states accordingly.
Reimplemented in MoreMountains.TopDownEngine.InputSystemManagerBase< T >, and MoreMountains.TopDownEngine.InputSystemManager.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| bool MoreMountains.TopDownEngine.InputManager.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
| bool MoreMountains.TopDownEngine.InputManager.AutoRevertToMobileIfPrimaryAxisInactive |
if this is true, the system will revert to mobile controls if the primary axis is inactive for more than AutoRevertToMobileIfPrimaryAxisInactiveDuration
| float MoreMountains.TopDownEngine.InputManager.AutoRevertToMobileIfPrimaryAxisInactiveDuration = 10f |
the duration, in seconds, after which the system will revert to mobile controls if the primary axis is inactive
|
protected |
| bool MoreMountains.TopDownEngine.InputManager.DelayedButtonPresses = false |
if this is true, button state changes are offset by one frame (usually useful on Android)
| bool MoreMountains.TopDownEngine.InputManager.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 MoreMountains.TopDownEngine.InputManager.ForceWeaponMode = false |
if this is true, the weapon mode will be forced to the selected WeaponForcedMode
| bool MoreMountains.TopDownEngine.InputManager.HideMobileControlsInEditor = false |
if this is true, mobile controls will be hidden in editor mode, regardless of the current build target or the forced mode
| bool MoreMountains.TopDownEngine.InputManager.InputDetectionActive = true |
set this to false to prevent the InputManager from reading input
| InputForcedModes MoreMountains.TopDownEngine.InputManager.InputForcedMode |
use this to force desktop (keyboard, pad) or mobile (touch) mode
| virtual Vector2 MoreMountains.TopDownEngine.InputManager.MousePosition => Input.mousePosition |
the position of the mouse
| MovementControls MoreMountains.TopDownEngine.InputManager.MovementControl = MovementControls.Joystick |
use this to specify whether you want to use the default joystick or arrows to move your character
| string MoreMountains.TopDownEngine.InputManager.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 MoreMountains.TopDownEngine.InputManager.ResetButtonStatesOnFocusLoss = true |
if this is true, button states will be reset on focus loss - when clicking outside the player window on PC, for example
| bool MoreMountains.TopDownEngine.InputManager.RotateInputBasedOnCameraDirection = false |
if this is true, any directional input coming into this input manager will be rotated to align with the current camera orientation
| bool MoreMountains.TopDownEngine.InputManager.SmoothMovement =true |
If set to true, acceleration / deceleration will take place when moving / stopping.
| Vector2 MoreMountains.TopDownEngine.InputManager.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)
| WeaponAim.AimControls MoreMountains.TopDownEngine.InputManager.WeaponForcedMode |
use this to force a control mode for weapons
|
get |
the current camera angle
|
get |
the camera rotation axis input value
|
getprotected set |
the crouch button
|
getprotected set |
the dash button
|
getprotected set |
the activate button, used for interactions with zones
|
getprotected set |
if this is true, we're currently in mobile mode
|
getprotected set |
|
getprotected set |
the jump button, used for jumps and validation
|
getset |
the primary movement value (used to move the character around)
|
getset |
the secondary movement (usually the right stick on a gamepad), used to aim
|
getprotected set |
the pause button
|
get |
the primary movement value (used to move the character around)
|
getprotected set |
the reload button
|
getprotected set |
the run button
|
get |
the secondary movement (usually the right stick on a gamepad), used to aim
|
getprotected set |
the shoot axis, used as a button (non analogic)
|
getprotected set |
the shoot button
|
getprotected set |
the shoot axis, used as a button (non analogic)
|
getprotected set |
the shoot button
|
getprotected set |
the button used to switch character (either via model or prefab switch)
|
getprotected set |
the switch weapon button
|
getprotected set |
the time control button