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"

Issue with Components that create subcomponents in their constructor with CreateDefaultSubobject

Is it possible to create a component that has 2 sub-components in native code using the constructor? My current scenario is I have a child of UMotionControllerComponent that pre-creates 2 subcomponents in it's constructor using CreateDefaultSuboject (a USkeletalMeshComponent and a USphereComponent). Both of the subcomponents are attached to the their owner (the UMotionControllerComponent).

The problem I'm running in to is when I add my UMotionControllerComponent's to my Character's sub-components in it's constructor using CreateDefaultSubobject neither of the two sub-components are editable in the editor. And if I add a second of my UMotionControllerComponent, the object hierarchy breaks altogether. Maybe because the 2 auto-created sub components share the same name so the hierarchy stacks them under the first UMotionControllerComponent. It's worse if I try to add the via the add component button in the editor..

I'm guessing that I'm just breaking the paradigm for using components here. I can solve this in order ways but this seems like a case that should work. Am I just missing something?

Product Version: UE 4.20
Tags:
more ▼

asked Aug 28 '18 at 09:28 PM in C++ Programming

avatar image

Joe Wilcox WisE
11 1 2 2

avatar image Shadowriver Aug 28 '18 at 09:50 PM

did you trying to use "AttachToComponent"? and attach it to component you are in

avatar image Joe Wilcox WisE Aug 29 '18 at 12:03 PM

The sub-components are already attached to this (the UMotionControllerComponent) which is then, in the Character, attached to my UCameraComponent.

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

1 answer: sort voted first

I'm currently implementing some sub components and am facing a few issues too, so I can partly reply to your question It seems that unreal does not support having two components (or sub components) that have the same name To solve this, when you create your subcomponent, prefix its name with the parent component's name.

But in the end, the editor will never show the details of your subcomponents when you select them If you store them with the property specifier EditAnywhere, you will be able to edit all of their properties from the parent components details panel

more ▼

answered Feb 20 '19 at 10:15 AM

avatar image

developpeur2000
77 1 3 5

(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