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"

UMeshComponent specification to Skeletal/Static in children

In my case i try to make a generic UMeshComponent in C++ to further specify whether it will be a Skeletal or a Static mesh in the child classes. (i need half of the children skeletal and half static)

Parent code:

UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UMeshComponent* mesh;

Then in a child BP editor, i set the default value to static/skeletal mesh and compile (BP compilation, not C++): alt text

but the compilation resets the default value (type) to None again.

any ideas?

if i set it in C++ constructor like this it does work (but i need it in BP)


 mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("mesh"));
Product Version: Not Selected
Tags:
screenshot-2.png (17.3 kB)
more ▼

asked Feb 11 '18 at 01:29 PM in C++ Programming

avatar image

Arty-McLabin
868 19 41 61

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

3 answers: sort voted first

try visibleanywhere

more ▼

answered Feb 17 '18 at 09:22 PM

avatar image

kay.B
6 2 2

avatar image Arty-McLabin Feb 17 '18 at 10:25 PM

i don't know how exactly is it relevant to the issue, but anyway it doesn't work. please delete this answer to attract more views, thank you.

avatar image kay.B Feb 17 '18 at 11:29 PM

may be TSubclass will help... just guessing

avatar image Arty-McLabin Feb 18 '18 at 12:26 AM

how exactly? as described, C++ version works as it is. The problem is in BP which resets to None on BP recompilation

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

well actually i tried writing that code but its working fine in blueprints here... did you try creating new child BP?

more ▼

answered Feb 18 '18 at 12:32 AM

avatar image

kay.B
6 2 2

avatar image Arty-McLabin Feb 19 '18 at 10:35 PM

good idea. i will try to create a new one and report back with my findings. could be a bugged BP indeed.

avatar image Arty-McLabin Mar 01 '18 at 07:05 PM

well nope, doesn't work. are you sure you replicate the code correctly?

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

This is a longstanding blueprint limitation that there is no ideal solution for. An epic staff mentioned wanting to allow this back when I first started using UE4 3 years ago. I wouldn't hold your breath.

There are various workarounds. The simplest approach is to make your variable VisibleAnywhere, and simply require the component to be added to the child blueprint in the regular way via the AddComponent button. Then in C++ BeginPlay or similar, you find the component using FindComponentByClass (or similar variant) and cache it in your variable for future access. Main drawback to this method is that you can't cleanly enforce that child blueprints always have the component of an acceptable type added.

It's possible to go the route you tried with a dropdown instanced property, but it involves kind of going against how the engine deals with components. You need to start overriding PostEditChange to register/unregister the component etc, and there are also potential issues related to construction script like you've seen. I've found it's not worth the bother.

more ▼

answered Feb 18 '18 at 11:47 PM

avatar image

kamrann
2.1k 83 33 119

avatar image Arty-McLabin Feb 19 '18 at 10:38 PM

thanks for the detailed info, however it is not an instanced property. the dropdown way i try is actually in the child BP defaults (class-wide) basically overriding

avatar image kamrann Feb 20 '18 at 04:36 AM

Pretty sure we're talking about the same thing. All components are marked 'InstancedByDefault' and 'EditInlineNew', so by making a component property EditAnywhere, you have an instanced property. The issue is that components require special registration, which doesn't happen automatically when you create it via an instanced dropdown.

avatar image Arty-McLabin Feb 21 '18 at 01:15 PM

hmm interesting. any clues on where can i find more info about registering the components? never heard of this process before.

(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