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"

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. 

UStaticMeshComponent->SetPhysMaterialOverride crash

I took Puzzle basic template for c++ project. There I add in Block class pointer to phys material:

 UPROPERTY()
 class UPhysicalMaterial* PhysMaterial;

And for now I initialize material through ConstructorHelpers and SetPhysMaterialOverride on UStaticMeshComponent with this material like this:

 struct FConstructorStatics
     {
         ConstructorHelpers::FObjectFinderOptional<UPhysicalMaterial> PhysMaterial;
         FConstructorStatics()
             : PhysMaterial(TEXT("/Game/StonePhysicalMaterial"))
         {
         }
     };
 
 BlockMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BlockMesh0"));
 ...
 BlockMesh->SetPhysMaterialOverride(PhysMaterial);

So when I play project in editor all works fine. But If I'm trying to launch project as a game, or just play standalone game through editor then application is crashed and report points to this line:

 BlockMesh->SetPhysMaterialOverride(PhysMaterial);

After that If I restart editor it'll be not running with the same crash report. I sent report, my machine ID is 7B9A5253489C7324713D93A95783DC83

Product Version: UE 4.10
Tags:
more ▼

asked Jan 18 '16 at 12:58 PM in C++ Programming

avatar image

alkohol
231 12 5 16

avatar image alkohol Jan 18 '16 at 01:07 PM

And 1 additional question. After first crash my level BP is broken too. It couldn't to find BlueprintCallable function from my GameInstance class, I implemented there 4 BlueprintCallable functions(they successfully worked all past time and I didn't change them), but level BP begins to see only first one. I don't know why. Can anyone explain that?

avatar image Doug E ♦♦ STAFF Jan 18 '16 at 04:57 PM

Hey alkohol-

Where in code are you creating your struct? Additionally, ConstructorHelpers are only meant to be used inside of a constructor. Can you post the full setup for the class (.h and .cpp) where this code is so that I can follow your setup on my end? Also, can you post the callstack and logs from the crash?

Cheers

Doug Wilson

avatar image alkohol Jan 18 '16 at 05:20 PM

Hi Doug,

Thank you for reply. Yes I do it in constructor. Log and sources are attached. I didn't remove unnecessary code, maybe that affects something. Physical material is just physical material created within editor :)

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

1 answer: sort voted first

Hey alkohol-

Since you're setting this in the constructor, the crash is likely caused by attempting to access something before the game has had the chance to create it. I found that placing what is line 12 in your original post inside an if(GetWorld()) call will prevent the crash. This tells the game to set the physical material only if the game world has already been created.

Cheers

Doug Wilson

more ▼

answered Jan 20 '16 at 02:10 PM

avatar image alkohol Jan 20 '16 at 02:15 PM

Thanks Doug,

that's very impressive and interesting. I didn't think about such possibility. Now I know one more thing which is worth checking out

avatar image haloweenj May 04 '18 at 12:18 PM

Hello,

Sorry for digging this up, but I'm having the same problem.

I tried to use your workaround, but I found that GetWorld() is always NULL in the constructor... So, although it does not crash, it does load the material either... ever. Not even when reloading the map.

(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