Crashes when TryActivateAbility for a specific GameplayAbility

Unbelievably, I found the cause of the problem right after I posted this question.

The reason was that I had set nullptr to GrantedAbility in GameplayEffect…

Well, maybe it will be useful to someone someday.

It may be strange English because it uses translation.

I’m sorry.

As the title says, Crashes when TryActivateAbility for a specific GameplayAbility.

The error is as follows.

Assertion failed: Spec.Ability [File:D:/Build/++UE4/Sync/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/AbilitySystemComponent_Abilities.cpp] [Line: 250]

When I checked the error destination, it was check(Spec.Ability) in GiveAbility.

However, it is when I do TryActivateAbility that it actually crashes.

GiveAbility is done when the character owns the controller, so it’s strange that it crashes when TryActivateAbility is done.

About the target GameplayAbility :

The target GameplayAbility just applies the GameplayEffect to the owner.

What I’ve tried.:

  1. I recreated the GameplayAbility for the target.

I don’t know the cause.

Can someone please help me?

Thank you in advance.

Thank you so so so much, that was killing me! For others who stumble past here, my issue was I had exposed a variable in my character class of type TSubclassOf but had forgotten to assign the blueprint to the variable slot in my character editor. So I’m assuming any nullptr or uninitialized error will throw this message.

Note: In my case it was due to an Attribute Set that was not initialized:

I added this and it caused the crash

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
class UEquipmentAttributeSet* AttributeSet;

Then, adding initialization in the constructor solved the situation:

AttributeSet = CreateDefaultSubobject<UEquipmentAttributeSet>(TEXT("Attributes"));

This resolved the issue for me!

I was dynamically creating attribute sets for actors. So, for those actors who didn’t have the relevant attribute set, the ability that committed the cost of that attribute crashed the game when activated!

Example - Jump committing stamina cost on an actor that didn’t have stamina attribute set.

Hope Epic fixes this. Commit Ability is broken. This is the second time commit is causing a crash for me - the other time when Super::ActivateAbility(...) incorrectly Commits ability (Fixed in UE 5.3).