Download

Pawn raycast any objects?

Hello, even though I am developing 2D Final Fantasy ish game…

but I need Raycast for checking blocks and any objects to interact with.

I did googling about Raycast, but they are mostly from cameras.

and yeah… hard to find as C++, because some of my character’s movement (which will be added with raycast) codes are c++ not blueprint…

is there any way to use Raycast from Pawn by C++?

You can do a linetrace/raycast from any point in space.



FVector Start = GetActorLocation();       // this is a location from which the linetrace will start, you can use your actor's location for this
FVector End = GetActorForwardVector() * TraceLength + Start; // Just replace TraceLength with your value, this is just a linetrace length 
FHitResult Hit;
ECollisionChannel Channel = ECollisionChannel::ECC_Visibility;
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);

GetWorld()->LineTraceSingleByChannel(Hit, Start, End, CollisionChannel, Params);



Wow this is awesome forum! Thank you so much Blue man