spencer-melnick / Threshold

Untitled Unreal Engine project
Other
6 stars 2 forks source link

Add input buffering #10

Closed spencer-melnick closed 4 years ago

spencer-melnick commented 4 years ago

Add input buffering to the ability system component input bindings. This is a sub-issue of https://github.com/spencer-melnick/Threshold/issues/4

Input actions should be held in a small circular queue until they can be triggered (ideally until UGameplayAbility::CanActivateAbility() is true. It might be helpful to look at https://github.com/tranek/GASDocumentation#concepts-ga-input-noactivate

It may be helpful to only add the input buffering on a subclassed PlayerAbilitySystemComponent, add a function to the custom subclass for GameplayAbility that can be used to determine if an ability should try to buffer input, and add a virtual function in the GameplayAbility to try and grab the player inputs (consider possibly storing the saved input in a variable for an instanced ability). This will also allow the ability to determine in it's own method for determining something like directional input (e.g. the dodge ability will want to grab the character's last movement input, but default to backwards if there is no input).

spencer-melnick commented 4 years ago

A simple input buffering system is now working. The ability system component must have bInputBufferEnabled set to true for any buffering to happen, but any ability that returns true for GetInputBufferingEnabled() is guaranteed to have its GenerateInputData() and ConsumeInputData() functions called prior to activation.

If input is actually buffered, any data created via GenerateInputData() will be stored in the ability system component and fed back locally via ConsumeInputData() later when the actual activation occurs. This does require that the ability be instanced currently, and if there are more than one instances of the ability on an ability system component, it may not work properly.

Please note that this data is only passed around locally! Any data to be sent over the network will have to use the UAT_ServerWaitForClientTargetData task and SendTargetDataToServer() (see CharacterDodge.cpp for an example).

I will look into a better method for providing input data to the ability activation, but in the meantime this appears to work properly.

I have run into a weird issue with the client process getting stuck if the dodge is triggered at a very high rate, but it seems like the client is still able to send input to the server while this is happening. I cannot find the exact cause currently.