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"

PhysicalMaterial Crash when reading the name

Hi,

I have a .fbx road, which have materials different for each part of the road. I want to know the hit material name when using a line trace.

So I have this code:

 this->GetWorld()->LineTraceSingleByObjectType(OutHit, VFStart_LR, VFLeft,FCollisionObjectQueryParams(FCollisionObjectQueryParams::AllObjects),CollisionParams);
 if(OutHit.bBlockingHit){
    UPhysicalMaterial* mat = OutHit.PhysMaterial.Get();
    // Crash here...
    FString str = mat->GetName();
    UE_LOG(LogTemp, Log, TEXT("Hit Mat Name: %s"),*str);
 }

The error message is:

 CommonLinuxCrashHandler: Signal=11
 [2018.05.15-13.37.47:132][110]LogLinux: === Critical error: ===
 Unhandled Exception: SIGSEGV: invalid attempt to read memory at address 0x0000000000000000

So I think there is no name for the physMaterial, but there are namesalt text

So how can I get the correct material names?

Thanks a lot! :)

L

Product Version: UE 4.19
Tags:
more ▼

asked May 15 '18 at 01:43 PM in C++ Programming

avatar image

Lunarix_
3 1 8

avatar image Lunarix_ May 15 '18 at 01:47 PM

Okay - so I can validate it with: if(OutHit.PhysMaterial.IsValid())

But then I still do not get these names. How to get them from a FHitResult?

So I can get the name with: OutHit.GetComponent()->GetMaterial(X)->GetFName().ToString()

but how to get the current X that is hit?

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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