eltom
(eltom)
July 28, 2023, 1:31pm
1
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
Ivan3z
(Ivan3z)
July 28, 2023, 9:42pm
3
Create a instance:
class MyClass : public IAbilitySystemInterface
AbilitySystemComponent = ObjectInitializer.CreateDefaultSubobject<UTheAbilitySystemComponent>(this,(FName("AbilitySystem")));
AbilitySystemComponent->SetIsReplicated(true);
AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Mixed);