why failed ?
in header,
UPROPERTY(VisibleDefaultsOnly, Category = "Default")
UGameplayEffect* GEforTarget;
in Cpp,
static ConstructorHelpers::FObjectFinder<UGameplayEffect> GEforTargetFinder(TEXT("/Game/Blueprints/GameplayEffects/Greystone/GE_MakeWay.GE_MakeWay"));
GEforTarget = GEforTargetFinder.Object;
compile success, but error while playing.
I want to make sure on construct time.
But if that’s not a good way, then I would like to set on BP based on that C++ class.
2 Likes
Natalo77
(Natalo77)
January 24, 2022, 8:35am
2
Hi there!
Can you please edit your code to have three backticks (`) above and below?
like this
Natalo77
(Natalo77)
January 24, 2022, 9:10am
4
What is GAGreystoneMakeWay
?
that class name is GAGreystoneMakeWay.
GA means GameplayAbility,
you can findthe official plug-in GameplayAbilities or GameplayAbilitySystem
Natalo77
(Natalo77)
January 24, 2022, 9:13am
6
Perhaps try using copy reference on the asset you want and using that as the path instead?
that path is copied one, removing front text “Blueprint”
Blueprint’/Game/Blueprints/GameplayEffects/Greystone/GE_MakeWay.GE_MakeWay’
1 Like
Natalo77
(Natalo77)
January 24, 2022, 9:33am
8
Try either not removing Blueprint, or removing the .GE_MakeWay
All failed… Iam gonna crazy
Natalo77
(Natalo77)
January 24, 2022, 11:59am
10
I’m not sure sorry
you may be better off just assigning the value in blueprints, to be honest.
hi, did you use “fix up redirections in folder” maybe you moved the files too much around. Refreshing vs project could help also.
Please dont abuse and use constructor helpers.
The proper way to do this is to create a TSubclassOf property and assigning the Gameplay Effect.
I would highly suggest also doing some basic UE4 C++ tutorials. Also think about why you are doing this. 90% of gameplay abilities in Fortnite are Blueprint based. You only need C++ for specific/special things. But in general your ability should be done in BP, including applying Gameplay Effects unless you have good reason for it to be in C++.
So to recap, don’t use constructor helpers. They are bad, they cause bloat (engine loads those depedencies even if the class is not used). Wont handle if the asset gets renamed/deleted. Just bad all round.
4 Likes
You means, even the programmer know the one’s class name, path, etc, it is more proper to assign Gameplay Effect on BP, which is based on C++. Right?
I will use
UPROPERTY(EditDefaultsOnly, Category = "Default")
TSubClassOf<UGEMakeWay> GEforTarget;
instead of,
UPROPERTY(VisibleDefaultsOnly, Category = "Default")
UGEMakeWay* GEforTarget;
I have another property, plase give me an advice too.
what about this one?
UPROPERTY(VisibleDefaultsOnly, Category = "Default")
UAnimMontage* SkillMontage;
ConstructorHelpers::FObjectFinder<UAnimMontage> SkillMontageFinder(TEXT("/Game/ParagonGreystone/Characters/Heroes/Greystone/Animations/AM_MakeWay.AM_MakeWay"));
SkillMontage = SkillMontageFinder.Object;
Is this OK?
You will have both. TSubClassOf will be set in the BP to whatever you want:
UPROPERTY(EditDefaultsOnly, Category = "Default")
TSubClassOf<UGEMakeWay> GEforTargetTemplate;
And you will store the actual object in:
UPROPERTY()
UGEMakeWay* GEforTarget;
Somewhere in your code you need to to initialize your object from the TSubClassOf
if(GEforTargetTemplate){
GEforTarget = NewObject<UGEMakeWay>(this, GEforTargetTemplate);
}
You can do the same setup for your second property
1 Like