platformer
Classes | Public Member Functions | Public Attributes | Protected Attributes | List of all members
UnityPlatformer.PlatformerInput Class Referenceabstract

Handle input for: Players and IA More...

Inheritance diagram for UnityPlatformer.PlatformerInput:
UnityPlatformer.AIInput UnityPlatformer.DefaultInput

Classes

class  InputDictionary
 Serializable type for input actions/states More...
 

Public Member Functions

delegate void InputActionDelegate (string button)
 callback type for keyup/keydown More...
 
virtual void Start ()
 Init actions Dictionary More...
 
virtual void Update ()
 Listen to changs in Unity Input More...
 
abstract bool IsActionHeld (string action)
 Returns true while the Action(~Button) is held down. More...
 
abstract bool IsActionDown (string action)
 Returns true this frame the Action(~Button) is down. NOTE you could miss down event, use Held instead More...
 
abstract bool IsActionUp (string action)
 Returns true this frame the Action(~Button) is up. NOTE you could miss up event, use Held instead More...
 
abstract bool IsLeftDown ()
 Returns true while Left is down. More...
 
abstract bool IsRightDown ()
 Returns true while Right is down. More...
 
abstract bool IsUpDown ()
 Returns true while Up is down. More...
 
abstract bool IsDownDown ()
 Returns true while Down is down. More...
 
abstract float GetAxisRawX ()
 Returns Input.GetAxisRaw ("Horizontal") or equivalent More...
 
abstract float GetAxisRawY ()
 Returns Input.GetAxisRaw ("Vertical") or equivalent More...
 
abstract Vector2 GetAxisRaw ()
 Returns a Vector2 with GetAxisRawX and GetAxisRawY More...
 

Public Attributes

List< string > listenActions = new List<string> {"Jump", "Attack", "Use", "Run", "Pull"}
 List of all available actions to listen More...
 
InputActionDelegate onActionUp
 callback when action up (key/button associated is up) More...
 
InputActionDelegate onActionDown
 callback when action down (key/button associated is down) More...
 

Protected Attributes

InputDictionary actions = new InputDictionary()
 Dictionary of actions/states More...
 

Detailed Description

Handle input for: Players and IA

The Action concept is the same as keys for keyboards but it's abstracted to handle the rest with just a single name.
example: action Jump. On keyboard: Space key. PS4: X button. WII: A button.
You map everything to the 'Jump' action, extend the PlatformerInput to read input properly :)
NOTE onActionUp, onActionDown it's the recommended way to handle input rather than calling IsActionUp/Down, because you can miss a frame and don't catch IsActionDown. Or you can use a more reliable version: IsActionHeld

Member Function Documentation

◆ GetAxisRaw()

abstract Vector2 UnityPlatformer.PlatformerInput.GetAxisRaw ( )
pure virtual

Returns a Vector2 with GetAxisRawX and GetAxisRawY

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ GetAxisRawX()

abstract float UnityPlatformer.PlatformerInput.GetAxisRawX ( )
pure virtual

Returns Input.GetAxisRaw ("Horizontal") or equivalent

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ GetAxisRawY()

abstract float UnityPlatformer.PlatformerInput.GetAxisRawY ( )
pure virtual

Returns Input.GetAxisRaw ("Vertical") or equivalent

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ InputActionDelegate()

delegate void UnityPlatformer.PlatformerInput.InputActionDelegate ( string  button)

callback type for keyup/keydown

◆ IsActionDown()

abstract bool UnityPlatformer.PlatformerInput.IsActionDown ( string  action)
pure virtual

Returns true this frame the Action(~Button) is down. NOTE you could miss down event, use Held instead

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ IsActionHeld()

abstract bool UnityPlatformer.PlatformerInput.IsActionHeld ( string  action)
pure virtual

Returns true while the Action(~Button) is held down.

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ IsActionUp()

abstract bool UnityPlatformer.PlatformerInput.IsActionUp ( string  action)
pure virtual

Returns true this frame the Action(~Button) is up. NOTE you could miss up event, use Held instead

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ IsDownDown()

abstract bool UnityPlatformer.PlatformerInput.IsDownDown ( )
pure virtual

Returns true while Down is down.

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ IsLeftDown()

abstract bool UnityPlatformer.PlatformerInput.IsLeftDown ( )
pure virtual

Returns true while Left is down.

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ IsRightDown()

abstract bool UnityPlatformer.PlatformerInput.IsRightDown ( )
pure virtual

Returns true while Right is down.

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ IsUpDown()

abstract bool UnityPlatformer.PlatformerInput.IsUpDown ( )
pure virtual

Returns true while Up is down.

Implemented in UnityPlatformer.DefaultInput, and UnityPlatformer.AIInput.

◆ Start()

virtual void UnityPlatformer.PlatformerInput.Start ( )
inlinevirtual

Init actions Dictionary

Reimplemented in UnityPlatformer.DefaultInput.

◆ Update()

virtual void UnityPlatformer.PlatformerInput.Update ( )
inlinevirtual

Listen to changs in Unity Input

Reimplemented in UnityPlatformer.DefaultInput.

Member Data Documentation

◆ actions

InputDictionary UnityPlatformer.PlatformerInput.actions = new InputDictionary()
protected

Dictionary of actions/states

◆ listenActions

List<string> UnityPlatformer.PlatformerInput.listenActions = new List<string> {"Jump", "Attack", "Use", "Run", "Pull"}

List of all available actions to listen

◆ onActionDown

InputActionDelegate UnityPlatformer.PlatformerInput.onActionDown

callback when action down (key/button associated is down)

◆ onActionUp

InputActionDelegate UnityPlatformer.PlatformerInput.onActionUp

callback when action up (key/button associated is up)


The documentation for this class was generated from the following file: