SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- //.h
- UFUNCTION(BlueprintCallable)
- void MyRayTrace(float InteractRange, ECollisionChannel TraceChannel, AActor* SelfActor, FHitResult& HitOut);
- // .cpp
- void APBaseCharacter::MyRayTrace(float InteractRange,
- ECollisionChannel TraceChannel,
- AActor* SelfActor, FHitResult& HitOut)
- {
- FCollisionQueryParams MyQueryParams = FCollisionQueryParams::DefaultQueryParam;
- MyQueryParams.AddIgnoredActor(SelfActor);
- FVector Location;
- FRotator Rotation;
- FHitResult Hit;
- GetController()->GetPlayerViewPoint(Location, Rotation);
- FVector Start = Location;
- FVector End = Start + (Rotation.Vector() * InteractRange);
- bool bHit = GetWorld()->LineTraceSingleByChannel(Hit, Start, End, TraceChannel, MyQueryParams);
- if (bHit)
- {
- HitOut = Hit;
- }
- }
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.