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++ Components with sub components.

Hiya! I'm trying to make a system for a building game where I can place modular sockets and ports on objects throughout the world. You can imagine this concept as similar to data ports and power ports on a PC, where you have ports of varying types, pin counts, etc that conform to a standard.

My initial idea for doing this was to use scene components that contained all the logic, data, interactions, and graphics for each type of port, and then place them on the user placeable object actors. The main issue I'm running into is that I think I'll need sub-components or something similar to achieve this. I'll need two static meshes, multiple colliders, and perhaps particles and sounds to boot, and that's just my first thoughts so I'm sure I'll need more features as I move on. Is there any way to achieve something like that? I am using C++, but will likely put these port components on blueprint actors as well as C++ actors.

Product Version: UE 4.17
more ▼

asked Oct 08 '17 at 01:40 AM in C++ Programming

avatar image

3 1 4 6

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

1 answer: sort voted first

Yes, make scene component. One of features of scene components if fact that it can contain other scene components, this action is called attaching.


Make that Port component and that port component code will attach static mesh component to it self to define there apperance.

Alternatively you can extend from UStaticMeshComponent and just set mesh and add game play code to it, it should display mesh normally and execute that extra code. But first option let developer to modify appearance of components more smoothly as they can attach more components to it themselves in bluepritnt editor

there also option to use Child Actor Component which allows to use any actor which contains components defining there appearance as a component in other actor, this also allows to use port out side of the actor.

more ▼

answered Oct 08 '17 at 03:15 AM

avatar image

37.2k 936 172 1116

avatar image Birblay Oct 08 '17 at 03:21 AM

Lol I was actually in the middle typing up my own response saying basically the same thing. I reworded my Google search and found some threads saying that was possible. After making some custom Blueprint Scene components in the past, I was under the impression they couldn't actually have sub-components at all! For more context for people visiting this later, you can in fact instantiate components from a SceneComponent's constructor and attach and manage them from that SceneComponent. This allows you to have whatever component features you need on any custom C++ SceneComponent.

avatar image Shadowriver Oct 08 '17 at 03:23 AM

i just added other possible option for you if you interested :)

avatar image Syclone3D Dec 03 '17 at 10:27 AM

Tried adding subcomponents out. It kind of works. The sub components don't show up in the blueprint editor in the hierarchy. Also if you have a SceneComponent and add another one as a subcomponent, the editor duplicates all properties in one window instead of treating it as a separate component.

That plus there is no viewport if you create a blueprint of this component. Even if its a static mesh component. These issues tell me that the idea of subcomponents just happens to kind of work but wasn't really a requirement of their current implementation.

Since I have ran into these issues I feel like my only option is making a separate actor and using the Child Actor component to spawn it. You essentially get the same result, but some annoyances of interactions and references between the main parent actor and its "child actor".

(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