I want to use a remote to teleport a prop to a player for a small amount of time,
i’ve figured out how to teleport the prop, but i cant figure out how to get the player position
this is the code i have so far:
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
Hey, I’ve written a script that implements and explains how to do it.
Feel free to ask about anything that’s not clear.
using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
# Teleports the given Prop to the Player after SecondsBeforeTeleport.
TeleportPropToPlayerAfterDelay<public>(Prop:creative_prop, InPlayer:player, SecondsBeforeTeleport:float)<suspends>:void=
Sleep(SecondsBeforeTeleport)
# Since we have multiple function calls that could fail, we can wrap all of them in a single
# failure context (the if statement). If any of the function calls fail, the entire block will rollback.
if:
# We need to retrieve the fort_character from the player, which is the actual pawn that the player controls.
FortCharacter := InPlayer.GetFortCharacter[]
# fort_character implements the positional interface, which means we can call GetTransform on it.
Transform := FortCharacter.GetTransform()
Prop.TeleportTo[Transform.Translation, Transform.Rotation]
then:
Print("Prop Teleported to Player!")
signal_remote_mover := class(creative_device):
@editable
SignalRemoteManager:signal_remote_manager_device = signal_remote_manager_device{}
@editable
Prop:creative_prop = creative_prop{}
@editable
SecondsBeforeTeleport:float = 1.0
OnBegin<override>()<suspends>:void=
SignalRemoteManager.PrimarySignalEvent.Subscribe(SignalRemotePrimarySignalEvent)
SignalRemotePrimarySignalEvent<private>(Agent:agent):void=
# We need to make sure the Agent is actually a player by casting to the player type.
if (TargetedPlayer := player[Agent]):
# Since you'd like some delay before the prop teleports to the player, we'll use a coroutine.
# A coroutine is created by `spawn`ing an asynchrounous (<suspends>) function.
spawn{TeleportPropToPlayerAfterDelay(Prop, TargetedPlayer, SecondsBeforeTeleport)}