Sometimes, multiple Abilities need to be triggered in one logical process, like a statemachine
At this point, I don’t want to create files for each Ability but rather have multiple logical Abilities created by a certain Ability.
I tried the following method but it triggered the engine’s assertion. May I ask what the correct method is?
[Image Removed]
[Image Removed]
[Image Removed]
Hi [mention removed],
To better understand your situation, a bit more context would be helpful. Are you trying to avoid creating a separate class for each UGameplayAbility, meaning you want to avoid individual .h/.cpp files or separate .uasset assets for each ability?
Regarding the issue you’re encountering: UAbilitySystemComponent::CreateNewInstanceOfAbility is designed to create a new instance of an ability when its instancing policy is set to either InstancedPerActor or InstancedPerExecution. The check for the RF_ClassDefaultObject flag exists because GAS expects to receive a Class Default Object (CDO) when instantiating a new ability. The system is intentionally designed to operate using ability classes, not pre-instantiated or manually created UGameplayAbility objects at runtime.
As far as I’ve been able to search in the engine, this function is currently the only supported mechanism for instantiating new instanced ability objects from the AbilitySystemComponent. As such, there’s no built-in or recommended way to instantiate abilities dynamically from a non CDO instance.
If you want to generate a single UGameplayAbility that contains internally all the logic of other logical abilities inside, I would personally use a “master” Gameplay Ability with branching logic to define the state machine. You could also use GameplayTags internally to define these transictions and let the main ability manage all the GAS framework.
I’ll be waiting for a little more information.
Best Regards,
Joan
Yes. Especially want to avoid separate .uasset assets for each ability.
Second is I want edit each ability property in editor window like the image blow.
The reason I use seperate abilities to do this is I want use more biuldin funtionality like predition flow (ability cost cooldown checkcanactive and so on)
Ultimately maybe I will make a common ability for the “state machine’s state” and a “statemachine ability”
and for the cdo, For me personally, the ability created by unreal editor is cdo to me.
[Image Removed]
Hi [mention removed]
Thanks for developing a bit more the case. Will talk with the GAS team and see if this is possible. I’ll also check it myself and see if there is a work around so you can instantiate the abilities as you want.
WIll answer back shortly.
Best,
Joan