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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Adding an Actor Component in C++ keeps crashing UE4

I have a custom Volume named CycloneDomain. I want to add a Procedural Mesh Component to this actor as soon as it is placed in the editor, but UE4 crashes every time the first line in the OnConstrustion function runs. I already added in procedural mesh dependencies in the .build.cs and .uproject files, and it compiles just fine as well.

.h file (just the parts you need to see ;)

 #pragma once
 #include "CoreMinimal.h"
 #include "ProceduralMeshComponent.h"
 #include "Engine/Engine.h"
 #include "GameFramework/Volume.h"
 #include "Components/ActorComponent.h"
 #include "CycloneDomain.generated.h"
 class CYCLONEFLUIDSIM_API ACycloneDomain : public AVolume
     const UObject* WorldContextObject = GetWorld();
     virtual void OnConstruction(const FTransform& Transform) override;
     UProceduralMeshComponent* mesh;

.cpp file (I only put up the relevant code)

 #include "CycloneDomain.h"

 void ACycloneDomain::OnConstruction(const FTransform& Transform) 
     mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("GeneratedMesh"));
     RootComponent = mesh;

     // multi-threaded PhysX cooking.
     mesh->bUseAsyncCooking = true;

How do I change/fix this so it won't crash the engine

Product Version: UE 4.19
more ▼

asked Apr 23 '18 at 06:43 PM in C++ Programming

avatar image

5 1 6

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

1 answer: sort voted first

You should declare components like that in constructor so engine will be aware of by default. If you don't do that those component won't be visible in blueprint component list.

Other that that if you get crash first thing you need to do is check logs in Saved/Logs directory of your project. Every crash, or else it uncontrolled one (like calling on null or invalid pointer where OS suddenly stops the UE4) prints out information about in logs, is most cases those are assertions fails which engine meet unexpected condition and to prevent instability it crash it self and it prints failed condition, which require some figureing out what happened:


But is some cases there are full descriptive error that can cause crash and they are printed in logs, specially once related to component initiation, so checking the logs alone can solve many issues

more ▼

answered Apr 24 '18 at 04:24 AM

avatar image

36.6k 931 169 1111

avatar image OutlawEmporer Apr 24 '18 at 05:13 AM

I did what you said and it works. The editor doesn't crash anymore, but now I can't move, scale, or rotate the actor.

What I mean by that is the gimbal inside of the level editor moves and looks like it's rotating/scaling/translating, but the volume no longer follows the gimbal around. Although, once the level is played, the volume transforms to its desired location/rotation/scale.

Do you know what's happening or how to fix it?

(Sorry, I'm a bit of a newb when it comes to ue4)

avatar image Shadowriver Apr 24 '18 at 06:26 AM

Check mobility vararable on component you made


If root component is static the entire actor becomes immobile

(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