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"

4.8 Major issues in attaching child component and Overlap trigger (With repro)

Summary of issues:

Issue 1) Attaching a child component (eg: SphereComponent) from C++ code to an Actor's root in 4.8 results in an error on PIE with the message

 Template Mismatch during attachment. Attaching instanced component to template component. Parent 'SceneRoot' Self 'MyTrigger'


Issue 2) Even if the first issue is bypassed through a workaround, Overlap events are not triggered for attached collision components. Attaching a similar sphere component through the Blueprint components screen works perfectly so this issue appears limited to C++. IIRC, various issues with overlap events in 4.8 have been reported by others as well.

Note: The workaround needed to fix issue 1 involves moving attachment of the child component from the constructor to PostInitializeComponents (as attaching from the constructor causes the template mismatch error).

Issue 3) Issue #2 can be fixed by recompiling the blueprint in question and launching PIE again. This time, all overlap events work, however once the PIE session is closed the editor crashes with the following message:

 Fatal error: 
 Critical Error BillboardComponent /Game/ThirdPersonBP/Maps/UEDPIE_0_ThirdPersonExampleMap.ThirdPersonExampleMap:PersistentLevel.GameNetworkManager_1.Sprite Object from PIE level still referenced. Shortest path from root:    (Object is not currently rooted)


Repro project links:

All three issues are reproducible with blank template projects and some simple code for attaching a sphere component.

Issue #1 - https://drive.google.com/file/d/0BwBa98V8pf2sRC14ZmppUjZVWkU/view?usp=sharing

Issue #2 and #3 - https://drive.google.com/file/d/0BwBa98V8pf2sUkFfd1lPR2k3OXc/view?usp=sharing

In both projects take a look at the AMyActor C++ classes and MyActor Blueprint (which has been dropped into the level). Launching PIE should crash the first project (issue #1). The second project will launch PIE but overlap events won't be triggered for MyActor (issue #2). Recompile the MyActor blueprint and run PIE again, this time the editor will crash after PIE exits (issue #3)

I've posted a single bug report for these issues as I get the feeling they're coupled with each other, am happy to raise separate reports for each of these if that's preferred though.

Code snippets

A quick look at code for each issue follows:

Issue #1:

 AMyActor::AMyActor(const FObjectInitializer& ObjectInitializer)
 : Super(ObjectInitializer)
 {
     PrimaryActorTick.bCanEverTick = true;
 
     SceneComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneRoot"));
     RootComponent = SceneComponent;
 
     MyTrigger = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("MyTrigger"));
     MyTrigger->AttachParent = RootComponent;    
 }


Issue #2, #3:

 AMyActor::AMyActor(const FObjectInitializer& ObjectInitializer)
 : Super(ObjectInitializer)
 {
     PrimaryActorTick.bCanEverTick = true;
 
     SceneComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneRoot"));
     RootComponent = SceneComponent;
 
     MyTrigger = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("MyTrigger"));
 }
 
 void AMyActor::PostInitializeComponents()
 {    
         // THIS IS A WORKAROUND FOR ISSUE #1 - Attaching in the constructor causes template mismatch issue
     MyTrigger->AttachTo(RootComponent);
 
     Super::PostInitializeComponents();
 }

Thanks for looking, this is preventing me from moving on to 4.8 so can't wait to get past the issues!

Product Version: UE 4.8
Tags:
more ▼

asked Jun 16 '15 at 05:59 PM in Bug Reports

avatar image

VSZ
954 24 29 55

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

1 answer: sort voted first

Hey VSZ-

I opened your project (the first one) and did not receive any error message when I PIE however I did notice that the actor blueprint was at the world origin rather than where it was placed in the level. Looking at the projects you supplied, I changed the UPROPERTY() of the scene component and sphere component from "VisibleDefaultsOnly" to "EditAnywhere" which solved the issue of the actor moving to the world origin as well as allowed the OnComponentBeginOverlap event to play appropriately. Let me know if making this change helps on your end or if you're still having any issues.

Cheers

Doug Wilson

more ▼

answered Jun 17 '15 at 09:36 PM

avatar image VSZ Jun 18 '15 at 01:00 PM

Thanks Doug, that worked!

I should have added the crash occurs in debug mode, from uproject it silently prints to log.

Do you know why this needs to be set to EditAnywhere in 4.8? Current setup worked fine since 4.3 for me so just want to understand why this is needed. I'm not seeing the connection b/w templated/non-templated and VisibleDefaultsOnly/EditAnywhere and would probably never have figured this out without your help!

avatar image Doug E ♦♦ STAFF Jun 19 '15 at 07:27 PM

Hey VSZ-

I don't know why this is different between 4.7 and 4.8 but I did confirm that using VisibleDefaultsOnly does work as you described in 4.7 with the same code. I've submitted a bug report to try to determine where this change occurred and if it was intentional or not.

avatar image VSZ Dec 22 '15 at 04:02 PM

Hey Doug, just checking whether it is now known why EditAnywhere needs to be set in the scenario described above for certain components to be attached successfully.

Another user ran into this issue on this thread so I thought it's a good time to check. Even in this user's case the issue seems to manifest when a C++ actor with a pre-existing hierarchy of attached components is subclassed to a child Blueprint. Perhaps the component attachment code of blueprints is messing up the pre-existing hierarchy somehow.

The main issue with the workaround of using EditAnywhere is that it clutters up the details panel in an unacceptable way when a StaticMeshComponent or other complex components are involved.

Thank you!

avatar image Doug E ♦♦ STAFF Dec 22 '15 at 08:20 PM

Hey VSZ-

I opened a project in 4.10.1 (binary) and did not receive the crash mentioned previously. I also tried setting up a component in code that was set as VisibleDefaultsOnly and did not receive any errors/warnings in the logs in the editor during PIE. If you're still seeing this behavior in 4.10 are you using the same setup from before or has anything been changed?

Cheers

Doug Wilson

avatar image VSZ Dec 23 '15 at 05:05 AM

Hi Doug, thanks for the prompt reply! Sorry I should have clarified this better - what happened is that another user on 4.10 found a case where not using EditAnywhere affects the ability of a C++ component to be properly attached in a BP subclass. Not sure if non-EditAnywhere tags cause a crash any longer, but it still seems to be required for proper attachment.

I have a few classes in my own project (4.10) where EditAnywhere is still used for this purpose so whenever I touch that code the next time I'll try creating a clean repro focusing on just the attachment rather than crashing and upload it to answerhub for your scrutiny.

Until then I suppose this workaround will have to do! Thanks again.

(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