Moving an object along an array of vector3 points with Verse??

Me and ChatGPT are trying to write a simple Verse script for UEFN that can move an object to the different vector3 of an array…

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

# Define a class for our moving creative prop device
moving_prop_device := class(creative_device):

    @editable
    MovableProp : creative_prop = creative_prop{} # The creative prop to move

    @editable
    MovementPoints : []vector3 = array{} # Array of Vector3 points

    @editable
    MovementSpeed : float = 1.0 # Speed of movement

    var CurrentPointIndex : int = 0 # Index to track the current point in the array

    OnBegin<override>()<suspends>:void=
        # Loop to move the prop through each point in the array
        loop:
            if (CurrentPointIndex >= MovementPoints.Length):
                set CurrentPointIndex = 0 # Reset to start when end is reached

            # Safe array access
            if (CurrentPointIndex < MovementPoints.Length):
                # Move the prop to the current point
                TargetPoint := MovementPoints[CurrentPointIndex]
                MovableProp.MoveTo(TargetPoint, MovableProp.GetTransform().Rotation, MovementSpeed)

                # Wait for the movement to complete before moving to the next point
                Sleep(1.0 / MovementSpeed)
                set CurrentPointIndex += 1

For some reason I keep having problems with it, mainly when referencing the array index on line: “TargetPoint := MovementPoints[CurrentPointIndex]”

I keep getting this error : "This invocation calls a function that has the ‘decides’ effect, which is not allowed by its context. The ‘decides’ effect indicates that the invocation calls a function that might fail, and so must occur in a failure context that will handle the failure. Some examples of failure contexts are the condition clause of an ‘if’, the left operand of ‘or’, or the clause of the ‘logic’ macro.(3512).

Anybody know how I can get this script working properly or the best way to do it?

Ok here is how ChatGPT decided to solve the error with the “decides effect”. The script finally compiles now with no errors but the intended effects of the script are not happening. The object that I wanted to move is not moving still! Anybody else wanna try out this script and figure out how to get an object moving between vector3 points properly?

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

moving_prop_device := class(creative_device):

    @editable
    MovableProp : creative_prop = creative_prop{} # The creative prop to move

    @editable
    MovementPoints : []vector3 = array{} # Array of Vector3 points

    @editable
    MovementSpeed : float = 1.0 # Speed of movement

    var CurrentPointIndex : int = 0 # Index to track the current point in the array

    OnBegin<override>()<suspends>:void=
        # Loop to move the prop through each point in the array
        loop:
            if (CurrentPointIndex >= MovementPoints.Length):
                set CurrentPointIndex = 0 # Reset to start when end is reached

            # Safe array access with 'decides' effect
            if (TargetPoint := MovementPoints[CurrentPointIndex]):
                # Move the prop to the current point
                MovableProp.MoveTo(TargetPoint, MovableProp.GetTransform().Rotation, MovementSpeed)

                # Wait for the movement to complete before moving to the next point
                Sleep(1.0 / MovementSpeed)
                set CurrentPointIndex += 1
            else:
                # Handle the failure (e.g., log error, take corrective action, etc.)
                # Placeholder for failure handling logic

U still need help?

1 Like