x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[C++] How can Character BP edit & call component subclasses?

I want a certain functionality for my APSCharacter class, but am not sure how to do it.

APSCharacter is the base class. In game class differentiation will arise from creating blue print instances of APSCharacter and setting giving them different abilities.

I want to be able to:

  • select the abilities is the APSCharacter blueprints & have this update fields for that component in BP when i select it

  • edit component properties for that specific UAbility subclass.

  • call the overridden UAbilitySubclass's OnUse() function.

My current failed attempt at this: (Excluding implementation for OnUse)

Relevant code from PSCharacter:

declaration of the component

   /** AugmentationOne class */
     UPROPERTY(EditDefaultsOnly, Category=Abilities)
     TSubclassOf<class UAbility> PrimAugComponentClass;
     class UAbility* PrimAugComponent;

initialization of PrimAugComponent in the APSCharacter constructor

  APSCharacter::APSCharacter(const FObjectInitializer& ObjectInitializer)
 : Super(ObjectInitializer)
 {
     // ...
     PrimAugComponent = CreateDefaultSubobject<UAbility>(TEXT("PrimAugComponent"));
     // ...
 }

the calling of OnUse() this is the function I want to call in the subclass implementation

 void APSCharacter::OnUsePrimAug()
 {
     // ...
     PrimAugComponent->OnUse();
     //...
 }

Relevant Code from UAbility:

The function I want to overload

 virtual void OnUse();

An example property I want to edit in the APSCharacter blueprint when I select the added UAbility components

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Cooldown)
     float CDDuration;

ResevantCode from UAbilitySubclass:

the overriding of the OnUse function by my subclass.

 virtual void OnUse() override;

Issues I'm currently having:

  • When PrimAugComponent->OnUse(); is called the subclass's implementation is not called.

  • I can not edit values for the component & cooldown in the PSCharacter's BP instance, or Projectiles to be used for different abilities.

So, how should I go about this layout to get the effect I want? Where have I gone wrong?

Product Version: UE 4.10
Tags:
more ▼

asked Feb 23 '16 at 06:06 PM in C++ Programming

avatar image

Plotnus
3 5 4 6

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question