Check Player Look Direction
using { /Fortnite.com/Devices }
using { /Verse.org/Native }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /Verse.org }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation/Tags }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/Diagnostics }
building_manager_device := class(creative_device):
IsLookingAtLocation(Character:fort_character, LocationToCheck: vector3, Threshold: float):logic=
# Get the character's view location
ViewLocation := Character.GetViewLocation()
# Get the character's view rotation
ViewRotation := Character.GetViewRotation()
# Create a direction vector from the view location to the target vecto
DirectionVector := Normalize(LocationToCheck - ViewLocation)
# Convert the view rotation to a direction vector
ViewDirection := ViewRotation.GetLocalForward()
DrawDebugCone(Character.GetTransform().Translation, ViewDirection)
DrawDebugLine(Character.GetTransform().Translation, Character.GetTransform().Translation + ViewDirection * 1000.0)
# Compare the direction vector and the view direction
# Use a dot product to find the cosine of the angle between the two vectors.
# If it's close to 1, then the vectors are nearly parallel, so the character is looking at the target.
CosAngle := DotProduct(ViewDirection, DirectionVector)
if(IsFacing := CosAngle > Threshold):
return true
return false
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.