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"

LineTraceSingle Does Not Work!

I used this tut: https://www.youtube.com/watch?v=eT-TloEzJC0 But he has a older version of the engine. Basicly in the part of the code:

     if (**GetWorld()->**LineTraceSingle****(HitResult, StartTrace, EndTrace, ECC_Visibility, *TracePrams)) {
         DrawDebugLine(GetWorld(), StartTrace, EndTrace, FColor::Green, false, 5.f);

         ATarget* TestTarget = Cast<ATarget>(HitResult->Actor.Get());

         if (TestTarget != NULL && !TestTarget->IsPendingKill()) {

             TestTarget->DamageTarget(50.f);
         }
     }

However the compiler in vs 2017 says: "LineTraceSingle" is not part of UWorld

Any feedback on a fix is appreciated!

Thanks in advance, Haven_Remix

Product Version: UE 4.17
Tags:
more ▼

asked Dec 12 '17 at 04:21 AM in C++ Programming

avatar image

SAVAGE ROOSTER
33 2 5 5

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

1 answer: sort voted first

Propably what you want to use is UWorld::LineTraceSingleByChannel.

Another option would be to use the UKismetSystemLibrary, it's basically the same, just remember to include the header if you use it, here is an example:

 FHitResult HitResult;
 TArray<AActor*> actorsToIgnore;
 
 const FVector& ActorLocation = GetActorLocation();
 if (UKismetSystemLibrary::LineTraceSingle(this, ActorLocation, ActorLocation + FVector(0.0f, 0.0f, -500.0f), UEngineTypes::ConvertToTraceType(ECC_Camera), false, actorsToIgnore, EDrawDebugTrace::None, HitResult, true, FLinearColor::Red, FLinearColor::Green, 0.0f))
 {
     return HitResult.Location;
 }


more ▼

answered Dec 12 '17 at 11:13 AM

avatar image

virtual_nomak
356 15 16 25

(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