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"

Expose a pointer to UActorComponent via UProperty?


I have a C++ component class:

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class DemoProject_API UWeaponComponent : public UActorComponent { GENERATED_BODY() }

And in another Actor class, I would like to expose a reference to it. What I am trying to do is have a Rifle blueprint, which has a property exposed in the Details panel, where the user can drag and drop a WeaponComponent into the field. The weapon component would exist in the Components tab as a child of the RootComponent of Rifle.

I know I could programmaticly search through the children, but I would quite like as an exercise to let someone drag and drop the component reference similar to how you might hook up a Monobehaviour reference in Unity. I would then want to actor upon that pointer in my gameplay code.

I have a UProperty defined like this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon") UWeaponComponent* WeaponComponent;

But it does not show up in the details panel. What am I missing? Thanks in advance.

Product Version: UE 4.16
more ▼

asked Aug 22 '17 at 08:12 PM in C++ Programming

avatar image

65 5 11 17

avatar image BenVlodgi Aug 27 '17 at 11:55 PM

Are you sure it isn't in the details panel under Weapon, you can search for it. If not, let us know.

avatar image plockhart Aug 28 '17 at 06:45 PM

Thanks for the reply, but I'm afraid not. I can only get it to appear if it is declared as a UObject, but it will only let me assign things from the Content Browser and not the Components tab. If I keep the declaration of UWeaponComponent then I can assign the variable myself via Blueprints via the Construction Script, but that's not what I would like to achieve.

avatar image BenVlodgi Aug 29 '17 at 12:58 AM

Ah, I understand now.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I don't think you can do that.

Instead you could create an enum of components that you could choose from, and select the component.

This might be worthy of a Bug Report / Feature Request.

more ▼

answered Aug 29 '17 at 12:57 AM

avatar image

2.2k 39 17 52

avatar image plockhart Aug 29 '17 at 09:38 PM

Ok, thanks :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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