I have a device that places a teleporter 800 units horizontally in front of the player character, no matter where the player looks. If the player activates a remote in their hand, they get teleported to the teleporters location. The problem with this is, that you can teleport yourself inside of walls and out of bounds because the teleporter clips through walls.
How can I make the teleporter stop when hitting a wall, even if the player moves closer to said wall? I don’t know if you can make a tracer that gets the object the player is looking at and calculate the distance between teleporter and player based on the objects location. Or is there a way to somehow enable collision for the teleporter?
Here’s the code I have so far:
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 we've created (TeleporterDevice)
@editable
Teleporter<public>: teleporter_device = teleporter_device{}
PlaceNearPlayer()<suspends>: void =
loop:
if (PlayerList := GetPlayspace().GetPlayers(), FortniteCharacter := PlayerList[0].GetFortCharacter[]):
PlayerRotation := FortniteCharacter.GetViewRotation()
PlayerPosition := FortniteCharacter.GetTransform().Translation
LocalForward := PlayerRotation.GetLocalForward()
HorizontalForward := LocalForward - vector3 { Z := LocalForward.Z }
TeleportDestination := PlayerPosition + HorizontalForward * 800.0
TeleporterRotation: rotation = PlayerRotation
Teleporter.MoveTo(TeleportDestination, TeleporterRotation, 0.001)
#Print("Teleporting to: {TeleportDestination}")
else:
break
OnBegin<override>()<suspends>: void =
PlaceNearPlayer()
Any suggestions?