I made a device that puts a teleporter about 800 units in front of the player character and when the player activates the remote they are teleported to the teleporters location.
I want the teleporter to only move horizontally but I don’t know how I can access the yaw of the player rotation alone. Here’s my code:
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
# The device that spawns... campfire devices. <- how it started
teleport_positioner := class(creative_device):
# Contains the teleporter prop-device (TeleporterDevice)
@editable
Teleporter<public>: teleporter_device = teleporter_device{}
PlaceNearPlayer()<suspends>: void =
loop:
if (PlayerList := GetPlayspace().GetPlayers(), FortniteCharacter := PlayerList[0].GetFortCharacter[]):
PlayerRotation: rotation = FortniteCharacter.GetViewRotation()
PlayerPosition: vector3 = FortniteCharacter.GetTransform().Translation
# Calculate the offset in the local space of the player
OffsetInLocalSpace: vector3 = PlayerRotation.RotateVector(vector3{X := 800.0, Y := 0.0, Z := 0.0})
# Calculate the position in front of the player
TeleportDestination: vector3 = PlayerPosition + OffsetInLocalSpace
# Calculate the rotation to face the player's view
TeleporterRotation: rotation = PlayerRotation
Teleporter.MoveTo(TeleportDestination, TeleporterRotation, 0.001)
#Print("Teleporting to: {TeleportDestination}")
else:
break
OnBegin<override>()<suspends>: void =
PlaceNearPlayer()
Any suggestions?