Hi @Yamabuki_Iro ,
Well @Yamabuki_Iro @Punkcat ,
Wont allow me a new post so Replacing this one with
from Code Snippets Dynamic Player Teleporter Device
This has been changed to effectively adding failure recovery and when a failure occurs it retries.
The teleport function is possibly broken, this attempts to program verse code to stop runtime errors
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
# To use this device, create a prop and attach a teleporter device to it. Ensure the teleport device
# has zero local position and rotation. Assign the prop and teleporter device to the editable
# properties and then call `TeleportAgentTo`.
dynamic_player_teleporter_device_log := class(log_channel){}
dynamic_player_teleporter_device := class(creative_device):
Logger : log = log{Channel:=dynamic_player_teleporter_device_log}
@editable
TeleporterDevice: teleporter_device = teleporter_device{}
@editable
TeleporterRoot: creative_prop = creative_prop{}
# Teleports an agent to a given translation and rotation. Note, only the yaw axis is used
# on rotation by setting the teleporter rotation (if you configure your teleporter to use set player rotation)
TeleportAgentTo(Agent: agent, Translation: vector3, Rotation: rotation):void =
if(TeleporterRoot.TeleportTo[Translation, Rotation]):
Logger.Print("Teleporting agent to {Translation}", ?Level:=log_level.Verbose)
# the attempt have worked now call the real TeleporterDevice will not cause runtime error
TeleporterDevice.Teleport(Agent)
else. Logger.Print("Failed to move dynamic teleporter prop!", ?Level:=log_level.Error)
# Try for the second time as it may be transient
if(TeleporterRoot.TeleportTo[Translation, Rotation]):
Logger.Print("Worked on second attempt Teleporting agent to {Translation}", ?Level:=log_level.Verbose)
TeleporterDevice.Teleport(Agent)
else. Logger.Print("Final attempt dynamic teleporter prop!", ?Level:=log_level.Error)
# This second else will stop a runtime error stopping Verse crashing
There may be typing and format errors, but the reason is to show the logic of stopping a runtime error then reporting the error and retrying