Abiltity system in UE5.2 - crashes

Hello, I am trying to use the ability system in UE5.2, but the whole engine crashes when I do!

In header I include

#include "AbilitySystemInterface.h"
#include "AbilitySystemComponent.h"

In protected section:

UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = "Abilities")
UAbilitySystemComponent* AbilitySystemComponent;

Then in public definition:
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;

Then implement it like this:

UAbilitySystemComponent* AMyCharacter::GetAbilitySystemComponent() const
{
    return AbilitySystemComponent;
}

Did I miss any step?

Yes, you haven’t actually created the component. You created a variable that can point to one, but you never actually created an instance of it (or you haven’t assigned the one you created in your blueprint to it).

1 Like

Create a instance:

class MyClass : public IAbilitySystemInterface

AbilitySystemComponent = ObjectInitializer.CreateDefaultSubobject<UTheAbilitySystemComponent>(this,(FName("AbilitySystem")));

AbilitySystemComponent->SetIsReplicated(true);
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);