Skip to main content

Moving Objects

In general there are 4 ways to move objects in UEFN. This video does a deep dive:

Snippets

Moving an Object with Verse

This device moves an object relative to its starting position, and resets it back to its starting point when it reaches its destination.

using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }

relative_prop_mover_device := class(creative_device):
@editable
MovableProp : creative_prop = creative_prop{}

@editable
MovementSpeed : float = 1.0

@editable
PositionOffset : vector3 = vector3{}

var InitialPosition : vector3 = vector3{}
var TargetPosition : vector3 = vector3{}

OnBegin<override>()<suspends>:void=
set InitialPosition = MovableProp.GetTransform().Translation
set TargetPosition = InitialPosition + PositionOffset

loop:
Result : move_to_result = MovableProp.MoveTo(TargetPosition, MovableProp.GetTransform().Rotation, MovementSpeed)
if (Result = move_to_result.DestinationReached):
if (MovableProp.TeleportTo[InitialPosition, MovableProp.GetTransform().Rotation]):
Print("Reset")