HPL3/SOMA/Scripting/Input Types
Contents
What are Input types?
Input types (InputHandler_types.hps) is a script consisting of two Shared Enum classes which can be considered as a list of possible actions.
?Be sure to use them correctly as trying to add own Enum Class while trying to use them as a part of gameplay should not work.?
Names of these classes are somewhat self-explanatory:
eAction
- Button-like action (fixed step)
Handler
These interactions are directly handled by "OnAction ( alAction, abPressed )". However the game some of these actions later converts to Analog type and then handles just like eAnalogTypes
Params:
(int) alAction
- Number representation (?of input type position?) in eAction
- addressable using one of the eAction enum entries
(bool) abPressed
- Has it been pressed?
Typical use
void OnAction(int alAction, bool abPressed)
{
///////////////////////////////////
// Flashlight
if(abPressed && alAction==eAction_Flashlight)
{
SetFlashlightOn(!mbFlashlightOn);
}
}
code that takes care of FlashLight. (- script/player/Player.hps)
eAnalogTypes
- Joystick-like action (Analog step)
Handler
These are being handled by functions "OnAnalogInput ( alAnalogID, avAmount )" .
Params:
- (int) alAnalogId
- number representation (?of input type position?) in eAnalogTypes
- addressable using one of the eAnalogTypes enum entries
- number representation (?of input type position?) in eAnalogTypes
- (cVector3f) avAmount
- 3D vector (?Basket class?) with parameters:
- X
- Y
- Z
- Values of [-1.0f ; 1.0f]
- 3D vector (?Basket class?) with parameters:
Typical use
void OnAnalogInput(int alAnalogId, const cVector3f &in avAmount)
{
//....................
//////////////////////
// Move
if(alAnalogId == eAnalogType_Move || alAnalogId == eAnalogType_GamepadMove)
{
iCharacterBody@ pCharBody = mBaseObj.GetCharacterBody();
float fLength = avAmount.Length();
if(fLength > 0.1f)
{
//////////////////////////////
// Lean
if(mbAnalogLeanPressed)
{
Lean(avAmount.x);
}
//////////////////////////////
// Movement
else
{
if(cMath_Abs(avAmount.y) > 0.001f)
pCharBody.Move(eCharDir_Forward, avAmount.y);
if(cMath_Abs(avAmount.x) > 0.001f)
pCharBody.Move(eCharDir_Right, avAmount.x);
}
}
}
//....................
}
Here you can see also already mentioned analog type (eAnalogType_Move) that was earlier sampled and quantized from eAction_Forward / _Backward / _Right / _Left, by other script. (- script/player/Player.hps)
Weakspot
This is your weakspot in case you want to control the game using almost anything imaginable. Only thing needed is an Controller emulator that translates