setting and printing player position and rotation

Hello Everyone!

I’m pretty new to programming in uefn with verse and i can’t find any documentation over player setting player rotations. The code i have underneath does get the player rotation but I haven’t found a way to actually print the results because of an argument is an incompatible value of type rotation error

Code

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

movement_device := class(creative_device):

    OnBegin<override>()<suspends>:void=
        AllPlayers := GetPlayspace().GetPlayers()
        for (Agent : AllPlayers, Player := player[Agent], FortCharacter := Player.GetFortCharacter[]):
            Rot := FortCharacter.GetViewRotation()
            Print(Rot)

ErrorMsg

This function parameter expects a value of type tuple([]char,?Duration:float = ...,?Color:color = ...), but this argument is an incompatible value of type rotation.(3509)

Not having looked at verse, the input to Print is a String (not a Rot), similar to the blueprint equivalent. In Blueprints they automatically convert your connections (where possible), so you may have to convert Rot to a String before using it as an argument.

Note the question marks before the other parameters, this probably means they are optionally required (defaulted).

image

found the solution for this, i was mission the import
using { /UnrealEngine.com/Temporary/SpatialMath }

this is the code on how to print the rotation in Verse

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

hello_world_device := class(creative_device):

    OnBegin<override>()<suspends>:void=
        AllPlayers := GetPlayspace().GetPlayers()
        for (Agent : AllPlayers, Player := player[Agent], FortCharacter := Player.GetFortCharacter[]):
            Rot := FortCharacter.GetViewRotation()
            Print("{Rot}")

I am still gonna look on how to rotate an player but that will be for later

1 Like

Did you figure out how to set the player’s rotation?

I was able to set the Player’s Position/Rotation using this: Agent.Respawn(pos, rot)

https://dev.epicgames.com/documentation/en-us/uefn/verse-api/fortnitedotcom/fortplayerutilities/respawn

2 Likes