# Calculating a rotation and using it in a function?

Hi all, I haven’t fully groked rotations and am hoping someone can easily point out the correct syntax.

Imagine a Square, and the player will TeleportTo a random side of the square when they take damage.

I was able to get location teleportation working, however I want the player to face the center of the square (‘MyProp’ location) on respawn.

My desire is to calculate the rotation and feed it into the TeleportTo function.

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

MyGameManager := class(creative_device):

@editable
MyProp : creative_prop=creative_prop{}

var Players : []player = array{}

RespawnLocations : []vector3 = array {vector3 {X:=0.0, Y:=-1536.0, Z:=50.0} , vector3 {X:=-0.0, Y:=1536.0, Z:=50.0} , vector3 {X:=-1536.0, Y:=-0.0, Z:=50.0} , vector3 {X:=1536.0, Y:=-0.0, Z:=50.0}}
#A different approach: Instead of calculating rotation to center, make an array of transforms?
#RespawnTransforms : []transform = array {} ...but how to hard code array of vectors + rotations?

OnBegin<override>()<suspends>:void=
AllPlayers := GetPlayspace().GetPlayers()
for(Player : AllPlayers):
AgentSetup(Player)

AgentSetup(Agent: agent):void=
if(FortChar := Agent.GetFortCharacter[]):
FortChar.DamagedEvent().Subscribe(OnDamaged)

OnJoin(Agent: agent):void=
AgentSetup(Agent)

OnDamaged(DamageResult: damage_result):void=
if:
DamagedFortChar := fort_character[DamageResult.Target]
DamagedFortChar.TeleportTo[RespawnLocations[GetRandomInt(0,3)], CalculateDesiredRotation()]

CalculateDesiredRotation() : rotation =
if(Player:= Players [0], FortniteChar := Player.GetFortCharacter[]):
PlayerPosition := FortniteChar.GetTransform().Translation
MyPropPosition := MyProp.GetTransform().Translation

if (LookDirection := (MyPropPosition - PlayerPosition).MakeUnitVector[]):