I'm trying to teleport the advanced_storm_controller_device to one of the positions in my array, but I can't use the TeleportTo function

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

RandomSpawnDevice := class(creative_device):

    @editable
    DeviceStormController : advanced_storm_controller_device = advanced_storm_controller_device{}
    @editable
    Trigger : trigger_device = trigger_device{}

    TeleportDevice(MaybeAgent:?agent):void =
        var SpawnPoints : []vector3 = array{
            vector3{ Forward := 5340.000000, Left := -2000.000000, Up := 400.000000 },
            vector3{ Forward := 5000.000000, Left := -5000.000000, Up := 400.000000 }
        }
        DeviceStormController.TeleportTo(SpawnPoints[0], DeviceStormController.GetTransform().Rotation)

    OnBegin<override>()<suspends>:void =
        Trigger.TriggeredEvent.Subscribe(TeleportDevice)

What I want to do is move the advanced_storm_controller_device to a random position in my array at the start of the game, but I can’t use the TeleportTo function

On line 18 (where I use the function it gives me the errors: No overload of the function `TeleportTo` matches the provided arguments (:vector3,:rotation). Could be any of:
function (/Fortnite.com/Devices/storm_controller_device:)TeleportTo(:vector3,:rotation) in package Fortnite
function (/Fortnite.com/Devices/storm_controller_device:)TeleportTo(:transform) in package Fortnite(3509)

(Also tried with extension function arguments (:advanced_storm_controller_device,:tuple(vector3,rotation)))(3509)

Hey @Astr how are you?

Right now, UEFN has two different types of Vector3, one of them comes from Unreal Engine, and the other one from Verse.

In your code, you are using a LUF type of Vector3 (Left, Up, Forward), but “TeleportTo” needs an XYZ type of Vector3 (X, Y, Z). So, to make it work, you need to convert that LUF to XYZ.

In addition to that, “TeleportTo” function needs all the parameter to work (Location, Rotation, and Scale. In your code you are not providing the new Scale to the TeleportTo.

How you solve that?

  1. Add using { /UnrealEngine.com/Temporary/SpatialMath} to your code. This will highlight some “ambiguity” errors, but don’t worry! We are fixing that in a few moments.

  2. Add the following function (this will allow you to transform a LUF to XYZ):

    ConvertToXYZ(LUF : (/Verse.org/SpatialMath:)vector3) : (/UnrealEngine.com/Temporary/SpatialMath:)vector3 =
        return (/UnrealEngine.com/Temporary/SpatialMath:)vector3{
            X := LUF.Forward,
            Y := LUF.Left,
            Z := LUF.Up
        }

As you can see, here we can get a LUF Vector3 and convert it manually to XYZ Vector3, declaring their types explicitly.

  1. In the same way you created the previous function, you need to declare the type of your LUF Vector3 array, like this:
    TeleportDevice(MaybeAgent:?agent):void =
        var SpawnPoints : [](/Verse.org/SpatialMath:)vector3 = array{
            (/Verse.org/SpatialMath:)vector3{ Left := 5340.000000, Up := -2000.000000, Forward := 400.000000 },
            (/Verse.org/SpatialMath:)vector3{ Left := 5000.000000, Up := -5000.000000, Forward := 400.000000 }
        }
  1. Then you need to get that LUF Vector3 (which represents “Location”) and transform it to XYZ Vector3, and use “NewTransform” (with Location, Rotation, and Scale) to teleport the device:
CurrentTransform := DeviceStormController.GetTransform()
        if(NewTranslation := SpawnPoints[0]):
            FinalTranslation := ConvertToXYZ(NewTranslation)
            NewTransform := (/UnrealEngine.com/Temporary/SpatialMath:)transform{
                Translation := FinalTranslation,
                Rotation := CurrentTransform.Rotation,
                Scale := CurrentTransform.Scale
            }

            if(DeviceStormController.TeleportTo[NewTransform]):

The full teleport function should look like this:

    TeleportDevice(MaybeAgent:?agent):void =
        var SpawnPoints : [](/Verse.org/SpatialMath:)vector3 = array{
            (/Verse.org/SpatialMath:)vector3{ Left := 5340.000000, Up := -2000.000000, Forward := 400.000000 },
            (/Verse.org/SpatialMath:)vector3{ Left := 5000.000000, Up := -5000.000000, Forward := 400.000000 }
        }

        CurrentTransform := DeviceStormController.GetTransform()
        if(NewTranslation := SpawnPoints[0]):
            FinalTranslation := ConvertToXYZ(NewTranslation)
            NewTransform := (/UnrealEngine.com/Temporary/SpatialMath:)transform{
                Translation := FinalTranslation,
                Rotation := CurrentTransform.Rotation,
                Scale := CurrentTransform.Scale
            }

            if(DeviceStormController.TeleportTo[NewTransform]):

And that’s it! Now you have your teleport working!

Let me know if you need more help!

1 Like

As far as I know, there is no need to create custom conversion functions. We already have two FromVector3 functions that convert between the two vector3 types.

Similarity, we have two FromRotation, FromScalarVector3, and FromTransform functions.

1 Like