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"

How can I make the root component of an actor overridable?

I'm working on an actor that has very specific code that relies on a particular component, but doesn't, at it's base, require anything else. (It's a USceneCaptureComponent2D, and some render target code). Because the Scene Capture Component is the only component I implement in c++, it's by default the root, and I can't override that in Blueprint. Is there a way to make it so I can override it in Blueprint so I can, say, parent it to a static mesh?

Product Version: UE 4.19
Tags:
more ▼

asked Jul 26 '18 at 05:59 AM in C++ Programming

avatar image

Sam54123
45 5 8

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

1 answer: sort voted first

Use an empty component (USceneComponent) as a root and attach your whole object hierarchy to it. (In your case - the capture component) ...If you need your component not being the root.

Edit: You need a wrapper component to encapsulate the logic you need to override as I don't think there is a way to override inherited components in blueprint.

more ▼

answered Jul 26 '18 at 10:20 PM

avatar image

dZh0
1.3k 6 5 9

avatar image Sam54123 Jul 26 '18 at 10:58 PM

Can you go into more detail about what actual code you need? I'm not doing any code overriding, just replacing the root component.

avatar image Sam54123 Jul 26 '18 at 11:21 PM

And this didn't work:

 UPROPERTY(EditAnywhere, Category = "Compoents")
         USceneCaptureComponent2D* SceneCaptureComp;

  

and

 DefaultRoot = CreateDefaultSubobject<USceneCaptureComponent>("DefaultRootComponent");
     RootComponent = DefaultRoot;
 
     SceneCaptureComp = CreateDefaultSubobject<USceneCaptureComponent2D>(TEXT("SceneCaptureComponent"));
     SceneCaptureComp->bCaptureEveryFrame = false;
     SceneCaptureComp->bCaptureOnMovement = false;
     SceneCaptureComp->SetupAttachment(DefaultRoot);


avatar image dZh0 Jul 28 '18 at 08:47 AM

What are you trying to achieve?

Make the component usable in blueprint for other actors?

Make the component not placed at the root of your Actor?

What are you trying to "override" as you used the word twice in the question?

avatar image Sam54123 Jul 28 '18 at 04:47 PM

The c++ code requires that a certain scene component exists, and therefore I define it in c++, but it doesn’t matter where in the component hierarchy it is, so I want the designer to be able to place it wherever he/she wants.

avatar image dZh0 Jul 30 '18 at 07:45 AM

If your sole purpose is to make the component usable by the designers you should make a blueprint component out of your C++ component.

Right click on your C++ component in the editor and you should see the option in the context menu. (2-nd option I think)

The blueprint component would inherit all functionality from your C++ class and can be further modified depending on what was exposed in your C++ code.

(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