FYI, I refactored the script to use TeleportTo… and it compiles, it runs, all prints show that it is working… and yet prop doesn’t move
this is the script refactored to use TeleportTo
using { /Fortnite.com/Devices } # Import the devices module from Fortnite for device-related classes and functions
using { /Fortnite.com/Characters } # Import the characters module from Fortnite for character-related classes and functions
using { /Verse.org/Simulation } # Import the simulation module from Verse for simulation-related classes and functions
using { /UnrealEngine.com/Temporary/SpatialMath } # Import the SpatialMath module from Unreal Engine for spatial and mathematical operations
# Define a class with editable prop and volume_device variables
snap_prop_to_player := class(creative_device): # Define a new class called snap_prop_to_player, inheriting from creative_device
@editable # Allow this property to be set from the editor
PieceOfCode:creative_prop = creative_prop{} # Define an editable property PieceOfCode of type creative_prop and initialize it
@editable # Allow this property to be set from the editor
VolumeTrigger:volume_device = volume_device{} # Define an editable property VolumeTrigger of type volume_device and initialize it
# Define an event handler for when a player enters the volume
OnBegin<override>()<suspends>:void= # Override the OnBegin method to define custom behavior when the game starts; <suspends> indicates the method can be paused
# Subscribe to the volume's EnteredEvent
VolumeTrigger.AgentEntersEvent.Subscribe(AttachToPlayer) # Subscribe the AttachToPlayer method to the AgentEntersEvent of the VolumeTrigger
AttachToPlayer(Agent : agent) : void = # Define the AttachToPlayer method, which takes an Agent of type agent and returns void
spawn { OnPlayerEntered(Agent) } # Use the spawn keyword to start the OnPlayerEntered method asynchronously
# Event handler function for when a player enters the volume
OnPlayerEntered(InPlayer:agent)<suspends> :void= # Define the OnPlayerEntered method, which takes an InPlayer of type agent and suspends its execution
if (FortniteCharacter := InPlayer.GetFortCharacter[]): # Use an if statement to attempt to get the FortniteCharacter from InPlayer; the := operator assigns the result if successful
Print("Player entered volume and attached!", ?Duration:=6.0) # Print a message indicating the player has entered the volume, with the message displayed for 6 seconds
loop: # Start a loop block, which runs indefinitely until explicitly broken or interrupted
Sleep(0.1) # Pause execution for 0.1 seconds to allow other processes to run
PlayerTransform := FortniteCharacter.GetTransform() # Get the Transform object from the FortniteCharacter and assign it to PlayerTransform
PlayerPosition := PlayerTransform.Translation # Extract the Translation (position) vector from PlayerTransform and assign it to PlayerPosition
PlayerRotation := PlayerTransform.Rotation # Extract the Rotation from PlayerTransform and assign it to PlayerRotation
# Adjust the PlayerPosition with the required offsets
AdjustedPosition := vector3{X:=PlayerPosition.X, Y:=PlayerPosition.Y - 200.0, Z:=PlayerPosition.Z + 100.0} # Create an AdjustedPosition vector with the specified offsets
# Debug print to verify position update
Print("Moving prop to position: {AdjustedPosition}, Rotation: {PlayerRotation}", ?Duration:=0.1) # Print the AdjustedPosition and PlayerRotation for debugging, with the message displayed for 0.1 seconds
# Create a new transform for the teleportation
NewTransform := transform{Translation:=AdjustedPosition, Rotation:=PlayerRotation} # Create a new transform with the adjusted position and rotation
# Teleport the PieceOfCode to the AdjustedPosition and PlayerRotation
if (PieceOfCode.TeleportTo[NewTransform]): # Use the TeleportTo method to teleport the PieceOfCode to the new transform
Print("Prop successfully teleported!", ?Duration:=0.1) # Print a success message