Applying rotations to a player

Hello Everyone!

I’ve tried to run a couple tests on Rotation a player by the yaw, however i’ve had no luck yet. The issue currently is that i am applying the yaw to an rotation but its not updating for the user. I’ve also not found any way to just set the rotation because of an Data member extension fields are not yet implemented. Error.

Code below is current rotation script.

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 }

Rotation_Device := class(creative_device):
    OnBegin<override>()<suspends>:void=
        AllPlayers := GetPlayspace().GetPlayers()
        for (Agent : AllPlayers, Player := player[Agent], FortCharacter := Player.GetFortCharacter[]):
            loop:
                FortCharacter.GetTransform().Rotation.RotateBy(FortCharacter.GetTransform().Rotation.ApplyYaw(2.0))
                Print("{FortCharacter.GetTransform().Rotation}")
                Sleep(1.0)

Hi, it isn’t possible to set a player’s rotation right now.
FortCharacter.GetTransform().Rotation.RotateBy returns a new Rotation, i.e. it doesn’t apply the rotation to the original Transform retrieved via GetTransform().

As said above, it’s not directly editable, but there is a hacky way to do it if you want to get creative. You can spawn a Teleporter device, set the teleporter device to not preserve momentum, set face player in direction of teleporter, and then call the teleporters .Teleport method, passing in the character. I obviously wouldn’t use that for constant movement, but I’m using it to distribute players around a table conditionally and it works pretty well.

3 Likes

@AngularRat Ah, does that work? I didn’t think it was possible to spawn or move Devices yet!

You can respawn your player at a position with a rotation. You only have to get the current position before

using { /Fortnite.com/FortPlayerUtilities }
Player := Button.InteractedWithEvent.Await()
Player.Respawn(Position,Rotation)

tysm this works, kinda weird tho that its called respawn when it doesn’t respawn the player but just teleports him. But it’s perfectly what i was looking for so can’t complain.
(is there a reason why there is no respawn display)

To clarify, when I say Spawn…I mean, place one in the level. Sorry, that was probably confusing. So you have a teleporter in the level already set up for where you want the character to face, and you just trigger it programmatically.

For people actually wanting to respawn a dead player at a specified rotation, this didn’t work for me at first, had to sleep two frames for some reason : (one frame works, but not everytime)

Agent.Respawn(Transform.Translation, Transform.Rotation)
Sleep(0.0)
Sleep(0.0)
Agent.Respawn(Transform.Translation, Transform.Rotation)