# This is our main script # It connects to the Prop we placed using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } using { /UnrealEngine.com/Temporary/SpatialMath } # We create a special device for our code # creative_device is the real base class for island scripts my_moving_prop := class(creative_device): # This is the prop we want to move # It is like a named slot for the object # Mark it @editable so you can assign it in the UEFN details panel @editable Prop : creative_prop = creative_prop{} # This is a variable for speed # Variables can change their value var Speed : float = 2.0 # This function starts the action # It runs once when the game begins OnBegin() : void = # We enter a loop here # A loop repeats code forever loop: # Get the current time in seconds # Time is always moving forward CurrentTime := GetSimulationElapsedTime() # Calculate the height using a Sine Wave # Sin() makes a smooth up-and-down curve # We multiply by Speed to change how fast it waves Height := Sin(CurrentTime * Speed) * 200.0 # Get the prop's current spot CurrentTransform := Prop.GetTransform() CurrentLocation := CurrentTransform.Translation # Create a new location # We keep left-right and forward-back the same # We only change the up-down part (Z) NewLocation := vector3{X := CurrentLocation.X, Y := CurrentLocation.Y, Z := CurrentLocation.Z + Height} # Move the prop to the new spot # This happens every frame! # TeleportTo is the real API for repositioning a creative_prop if (Prop.TeleportTo[NewLocation, CurrentTransform.Rotation]): false # Wait a tiny bit before the next move # This keeps the game smooth Sleep(1.0 / 60.0)