SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //.h
  2.    
  3. UFUNCTION(BlueprintCallable)
  4. void MyRayTrace(float InteractRange, ECollisionChannel TraceChannel, AActor* SelfActor, FHitResult& HitOut);
  5.  
  6.  
  7. // .cpp
  8. void APBaseCharacter::MyRayTrace(float InteractRange,
  9.     ECollisionChannel TraceChannel,
  10.     AActor* SelfActor, FHitResult& HitOut)
  11. {
  12.     FCollisionQueryParams MyQueryParams = FCollisionQueryParams::DefaultQueryParam;
  13.     MyQueryParams.AddIgnoredActor(SelfActor);
  14.  
  15.  
  16.     FVector Location;
  17.     FRotator Rotation;
  18.     FHitResult Hit;
  19.  
  20.     GetController()->GetPlayerViewPoint(Location, Rotation);
  21.  
  22.     FVector Start = Location;
  23.     FVector End = Start + (Rotation.Vector() * InteractRange);
  24.  
  25.     bool bHit = GetWorld()->LineTraceSingleByChannel(Hit, Start, End, TraceChannel, MyQueryParams);
  26.  
  27.     if (bHit)
  28.     {
  29.         HitOut = Hit;
  30.     }
  31.  
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top