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"

Actor component not showing on component list

Hello bois

I've been trying to create a weapon component deriving from UActorComponent (and a custom interface). here's the code I'm using in the constructor of the actor owning it:

     DefaultWpn = CreateDefaultSubobject<UDefaultWeaponComponent>("Big gun");
     AddOwnedComponent(DefaultWpn);

DefaultWpn is an instance variable of type UDefaultWeaponComponent*. Here't the "but", when I run the game, the component is not visible in the component list of the actor, nor can I use its methods. Am I doing something wrong?

Yours

Product Version: UE 4.21
Tags:
more ▼

asked Nov 26 '18 at 03:18 PM in C++ Programming

avatar image

returnVoid
1 1

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

2 answers: sort voted first

i think it's because you're not doing the "SetupAttachment()" that has to be done after creating a SubObject so its spawning in world 0,0,0

DefaultWpn = CreateDefaultSubobject("Big gun"); DefaultWpn->SetupAttachment( // RootComponent, or another component, or a socket, or whatever you want );

more ▼

answered Nov 26 '18 at 08:44 PM

avatar image

Evigmae
1.6k 7 3 8

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

Ups, my bad, I just needed to make the ptr edit everywhere. The method problem was elsewhere (my controller wasn't binded.

more ▼

answered Nov 26 '18 at 09:20 PM

avatar image

returnVoid
1 1

(comments are locked)
10|2000 characters needed characters left
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