Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void AFpCppCharacter::Tick(float DeltaTime)
- {
- Super::Tick(DeltaTime);
- //Hit contains information about what the raycast hit.
- FHitResult Hit;
- //The length of the ray in units.
- //For more flexibility you can expose a public variable in the editor
- float RayLength = 200;
- //The Origin of the raycast
- FVector StartLocation = FirstPersonCameraComponent->GetComponentLocation();
- //The EndLocation of the raycast
- FVector EndLocation = StartLocation + (FirstPersonCameraComponent->GetForwardVector() * RayLength);
- //Collision parameters. The following syntax means that we don't want the trace to be complex
- FCollisionQueryParams CollisionParameters;
- //Perform the line trace
- //The ECollisionChannel parameter is used in order to determine what we are looking for when performing the raycast
- ActorLineTraceSingle(Hit, StartLocation, EndLocation, ECollisionChannel::ECC_WorldDynamic, CollisionParameters);
- //DrawDebugLine is used in order to see the raycast we performed
- //The boolean parameter used here means that we want the lines to be persistent so we can see the actual raycast
- //The last parameter is the width of the lines.
- DrawDebugLine(GetWorld(), StartLocation, EndLocation, FColor::Green, true, -1, 0, 1.f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement