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"

Crash on Geometry Brush with FHitResult

I'm trying to some simple LineTrace stuff so I can

  1. See if the character is looking at something (within a certain distance)

  2. See if that thing is a certain class (so that we can interact with it, pick it up, etc.)

I'm having a trouble with Step 2. If the object IS one of the classes I'm looking for, it registers properly and all that. If, however, I'm looking at a Geometry Brush object, UE4 crashes immediately.

The culprit line is as follows:

 if (HitResult.Actor->IsA(ACBaseWeapon::StaticClass()))

This conditional crashes the game, as does the line UE_LOG(LogTemp, Log, TEXT("Actor Name: %s"), *HitResult.Actor->GetName());

I assume therefore that the issue is with HitResult.Actor and geometry brushes. What work around do I need to use?

Thanks!

Product Version: UE 4.9
Tags:
more ▼

asked Dec 10 '15 at 10:11 PM in C++ Programming

avatar image

Kowbell
165 18 27 39

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

1 answer: sort voted first

Found the solution. Since geometry brushes have no "root actor", and only mesh components, getting the actor from a LineTrace returns a Null. When you try to get the name of a Null and print it, things go downhill.

Instead, if you might be looking at geometry brushes in your level, you might want to check if what you're looking at has an actor first:

         if (HitResult.GetComponent()->GetAttachmentRootActor() != NULL)
         {
             UE_LOG(LogTemp, Warning, TEXT("We have an actor that won't crash! Actor Name: %s"), *HitResult.GetActor()->GetName());
         }
more ▼

answered Dec 13 '15 at 01:25 PM

avatar image

Kowbell
165 18 27 39

(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