using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
# This is our device class. Think of it as the "brain" of the trap.
spyglass_trap_device := class(concrete creative_device):
# @editable variables appear in the device settings in UEFN.
# Threshold: How precise the "looking" needs to be.
# 0.95 = very precise (narrow cone), 0.5 = wide angle.
@editable
LookThreshold: float = 0.95
# The location we want players to look at.
# We will set this via code to a fixed point in the sky.
TargetLocation: vector3 = vector3(0.0, 0.0, 1000.0)
# This function runs automatically when the game starts.
OnBegin<override>()<suspends>: void =
# Infinite loop! This keeps checking forever.
loop:
# Get all players currently in the game.
# GetPlayers() returns a list of all active players.
players := Self.GetPlayspace().GetPlayers()
for player in players:
# Get the character model for this player.
# Not all players might have a character loaded yet, so we check.
if (character := player.GetFortCharacter()):
Verse Library
verse
01 Standalone
Custom device that continuously monitors player camera directions to detect if they are looking at a specific target location.
verse-library/fortnite-how-to-check-if-a-player-is-looking-at-a-location/01-standalone.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.