Difference between revisions of "HPL3/SOMA/Scripting/Input Types"
m (Possible mod uses ("why should I care") section added) |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 12: | Line 12: | ||
===Handler=== | ===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 [[Input Types#eAnalogTypes|eAnalogTypes]] | + | 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 [[HPL3/SOMA/Scripting/Input Types#eAnalogTypes|eAnalogTypes]] |
====Params:==== | ====Params:==== | ||
Line 93: | Line 93: | ||
</syntaxhighlight>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. <u>(- script/player/Player.hps)</u> | </syntaxhighlight>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. <u>(- script/player/Player.hps)</u> | ||
− | == Uses == | + | ==Uses== |
This class could be considered a Weak Spot in case you ever wanted to do some new player implementations or to make your game controllable by virtually anything. | This class could be considered a Weak Spot in case you ever wanted to do some new player implementations or to make your game controllable by virtually anything. | ||
− | With a slight combination of [[Input Handler]] and [[Player Overview|Player]] scripts even [https://youtu.be/ZS0fIS2qrSA implementing a Microphone is possible.] | + | With a slight combination of [[HPL3/SOMA/Scripting/Input Handler|Input Handler]] and [[HPL3/SOMA/Scripting/Player Overview|Player]] scripts even [https://youtu.be/ZS0fIS2qrSA implementing a Microphone is possible.] |
Latest revision as of 02:57, 14 September 2021
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)
Uses
This class could be considered a Weak Spot in case you ever wanted to do some new player implementations or to make your game controllable by virtually anything.
With a slight combination of Input Handler and Player scripts even implementing a Microphone is possible.