Comments (12)
In the project input settings I have an input action for Jump.
In GASDocumentation.h
there's a struct of all the input bindings that are bound to the ASC:
UENUM(BlueprintType)
enum class EGDAbilityInputID : uint8
{
// 0 None
None UMETA(DisplayName = "None"),
// 1 Confirm
Confirm UMETA(DisplayName = "Confirm"),
// 2 Cancel
Cancel UMETA(DisplayName = "Cancel"),
// 3 LMB
Ability1 UMETA(DisplayName = "Ability1"),
// 4 RMB
Ability2 UMETA(DisplayName = "Ability2"),
// 5 Q
Ability3 UMETA(DisplayName = "Ability3"),
// 6 E
Ability4 UMETA(DisplayName = "Ability4"),
// 7 R
Ability5 UMETA(DisplayName = "Ability5"),
// 8 Sprint
Sprint UMETA(DisplayName = "Sprint"),
// 9 Jump
Jump UMETA(DisplayName = "Jump")
};
GDHeroCharacter
binds the InputComponent
to the ASC using that struct as a mapping.
void AGDHeroCharacter::BindASCInput()
{
if (!ASCInputBound && AbilitySystemComponent.IsValid() && IsValid(InputComponent))
{
AbilitySystemComponent->BindAbilityActivationToInputComponent(InputComponent, FGameplayAbilityInputBinds(FString("ConfirmTarget"),
FString("CancelTarget"), FString("EGDAbilityInputID"), static_cast<int32>(EGDAbilityInputID::Confirm), static_cast<int32>(EGDAbilityInputID::Cancel)));
ASCInputBound = true;
}
}
A EGDAbilityInputID
is stored on the UGDGameplayAbility
class (set manually in the blueprint or C++ constructor of the ability subclass) that I read from when I grant the ability to the ASC that tells it to associate that ability with that input action.
void AGDCharacterBase::AddCharacterAbilities()
{
// Grant abilities, but only on the server
if (GetLocalRole() != ROLE_Authority || !AbilitySystemComponent.IsValid() || AbilitySystemComponent->CharacterAbilitiesGiven)
{
return;
}
for (TSubclassOf<UGDGameplayAbility>& StartupAbility : CharacterAbilities)
{
AbilitySystemComponent->GiveAbility(
FGameplayAbilitySpec(StartupAbility, GetAbilityLevel(StartupAbility.GetDefaultObject()->AbilityID), static_cast<int32>(StartupAbility.GetDefaultObject()->AbilityInputID), this));
}
AbilitySystemComponent->CharacterAbilitiesGiven = true;
}
Jump's input action EGDAbilityInputID
is set in the ability constructor.
UGDGA_CharacterJump::UGDGA_CharacterJump()
{
AbilityInputID = EGDAbilityInputID::Jump;
InstancingPolicy = EGameplayAbilityInstancingPolicy::NonInstanced;
AbilityTags.AddTag(FGameplayTag::RequestGameplayTag(FName("Ability.Jump")));
}
Any abilities bound to an input like this are automatically activated when the input is triggered. This also allows the ability to use the input related ability tasks.
from gasdocumentation.
I will check it.
from gasdocumentation.
One more question
Why are you doing this at 2 places. One inside Character and another inside Player Controller.
to be precise
Character -> PossessedBy
Controller -> OnPossess
if (PS)
{
// Set the ASC on the Server. Clients do this in OnRep_PlayerState()
AbilitySystemComponent = Cast<UGDAbilitySystemComponent>(PS->GetAbilitySystemComponent());
// AI won't have PlayerControllers so we can init again here just to be sure. No harm in initing twice for heroes that have PlayerControllers.
PS->GetAbilitySystemComponent()->InitAbilityActorInfo(PS, this);
from gasdocumentation.
The InitAbilityActorInfo()
? It might be redundant and that's okay. I think I made the PlayerController
version first thinking that I would catch all new pawns but then realized when making the GDHeroCharacter
that the AI don't have PlayerControllers
so they needed to init the ASC either in AIController
or in the GDHeroCharacter
.
I would expect if you just have the one in GDHeroCharacter
that you'll be fine and cover every scenario.
from gasdocumentation.
I'll add that it also guarantees that the player's ASC (on the PlayerState
) always has a valid AvatarActor
. I'm not sure if that matters or not.
from gasdocumentation.
enum class EGDAbilityInputID : uint8
{
// 0 None
None UMETA(DisplayName = "None"),
// 1 Confirm
Confirm UMETA(DisplayName = "Confirm"),
// 2 Cancel
Cancel UMETA(DisplayName = "Cancel"),
// 3 LMB
Ability1 UMETA(DisplayName = "Ability1"),
// 4 RMB
Ability2 UMETA(DisplayName = "Ability2"),
// 5 Q
Ability3 UMETA(DisplayName = "Ability3"),
// 6 E
Ability4 UMETA(DisplayName = "Ability4"),
// 7 R
Ability5 UMETA(DisplayName = "Ability5"),
// 8 Sprint
Sprint UMETA(DisplayName = "Sprint"),
// 9 Jump
Jump UMETA(DisplayName = "Jump")
};
Does this need to be exact same as that of Binding from editor. ProjectSettings->Inputs
![Untitled](https://user-images.githubusercontent.com/5199691/71480594-efc53f00-281f-11ea-8f00-f002b9b6057e.png)
from gasdocumentation.
Will it handle the touch inputs as well.
Why I m asking this because in UE4.24 there is a bug for Android deployment on Android 10. I have reported this bug, but they are not listening.
I couldn't test this.
from gasdocumentation.
Yes, the struct members need to be the exact same except for Confirm/Cancel. Please read the README which explains this in more detail. https://github.com/tranek/GASDocumentation#concepts-ga-input
I am not sure about touch inputs, you'll have to check the source code.
from gasdocumentation.
What will happen if i m handling input actions as usual along with Gameplay bindings?
from gasdocumentation.
It'll be fine. If you handle input actions that are also handled by the ASC, make sure that you don't consume the input otherwise they won't reach the ASC.
from gasdocumentation.
Finally I wrote my own JumpingAbility and its working really great. All Thanks to you.
I had setup my input in PlayerController rather than Character what u did.
from gasdocumentation.
Adding touch 1 along with spacebar in the input for Jump makes it jump on mobile devices.
from gasdocumentation.
Related Issues (20)
- Possible unnecessary cast in PlayMontageAndWaitForEvent HOT 2
- StaticLoadClass DamageNumberClass doesn't work when packaged HOT 1
- PlayMontageAndWaitForEvent doesn't work on clients HOT 5
- Suggestion to add Gameplay Event/GameplayEvent section, more information about them and example uses
- Clamping value on PreAttributeChanged not working on client
- CDOing AttributeSet in constructor results in garbage collection
- Suggestion for section 4.11.2 (custom target actor confirmation type)
- How to load cues from a Plugin Content folder path? HOT 2
- Output Modifiers in Gameplay Effect Execution Calculations Cannot Modify Source Attributes HOT 1
- AsyncTaskCooldownChanged node's call back too long HOT 1
- UAsyncTaskCooldownChanged HOT 1
- Load gameplay tags from .ini in a Plugin/Config folder HOT 6
- Gameplay Effect Components added in UE5.3
- Suggestion to add explanation on how to setup "InitAttributeSetDefaults()"
- OnAvatarSet called with player state HOT 1
- Modifier tag filter is not available.
- Question : ASC not available in the player BP
- UE5.3 - AttributeSet Generated Error
- Bug activation stun gameplay cue
- Question: Loose gameplay tag vs gameplay effect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gasdocumentation.