How do I get the player's position?

This is for a one player game, so there will only ever be one player.

I have props I want to react to player movement, so I think I need the player’s GetTransform() results?

1 Like
# get the players
Players : []player = GetPlayspace().GetPlayers()

# get first player
if(Player : player = Players[0]):

    # get fort character of player
    if(FortniteCharacter : fort_character = Player.GetFortCharacter[]):

        # GetTransform().Translation is the location (vector3)
        # GetTransform().Rotation is the rotation (rotation)
        # GetTransform().Scale is the scale (vector3)
        PlayerPosition : vector3 = FortniteCharacter.GetTransform().Translation

        # if you wanted to seperate for whatever reason
        PlayerPositionX : float = PlayerPosition.X
        PlayerPositionY : float = PlayerPosition.Y
        PlayerPositionZ : float = PlayerPosition.Z

        # printing each seperately 
        Print("Player X position : {PlayerPositionX}")
        Print("Player Y position : {PlayerPositionY}")
        Print("Player Z position : {PlayerPositionZ}")

        # printing full postion
        Print("Player Position : {PlayerPosition}")

fort_character documentation
transform documentation

4 Likes