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"

Cannot use Hit.Item in my linetrace C++

Hi, I'm relatively new to C++, and am currently loosing my mind trying to access the (int32)Item value from a FHitResult. I know my linetrace works ( *Hit.GetActor()->GetName() returns the correct object), but if I try logging *Hit.Item, I'm getting the following error pointing at the UE_LOG line: "error C2100: illegal indirection" .

   FHitResult Hit;
   if (GetWorld()->GetFirstPlayerController()->GetHitResultUnderCursor(ECollisionChannel::ECC_Camera, true, Hit))
             UE_LOG(LogTemp, Log, TEXT("%s"), *Hit.Item);
Product Version: UE 4.21
more ▼

asked Feb 11 '19 at 12:18 PM in C++ Programming

avatar image

3 3 3 9

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

1 answer: sort voted first

That's because Item is an int32. The %s refers to a String or a Char.

Replace "%s" with "%d" and remove the pointer from Hit.Item.

Like this:

  UE_LOG(LogTemp, Log, TEXT("%d"), Hit.Item);

more ▼

answered Feb 11 '19 at 12:59 PM

avatar image

181 4 7 8

avatar image Gamji Feb 11 '19 at 01:07 PM

Ah ... I feel dumb ahaha Thank you that was it!

avatar image SenseiHaketon Feb 11 '19 at 01:20 PM

No need to feel dumb. When I started, I struggled with this too ;)

(comments are locked)
10|2000 characters needed characters left
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