How to make prop look at Player?

Hi,

I’m trying to change a prop’s Rotation, so that it looks at the Player. I’m not quite sure what’s the correct way to:

a) set a prop’s Rotation
b) get the rotation from a vector to another (prop to Player)

Thanks!

You should be able to use the GetTransform() functions which exist on the creative_prop and the player’s fort_character and some 3d math to drive a TeleportTo on the prop.

This is a simple script that will continuously rotate a prop to point at the player.

hello_world_device := class(creative_device):

    @editable MyProp:creative_prop = creative_prop{}

    OnBegin<override>()<suspends>:void=

        loop:
            if (PlayerCharacter := GetPlayspace().GetPlayers()[0].GetFortCharacter[]):

                PropLocation := MyProp.GetTransform().Translation
                PlayerLocation := PlayerCharacter.GetTransform().Translation

                if (LookDirection := (PlayerLocation - PropLocation).MakeUnitVector[]):

                    Yaw := RadiansToDegrees(ArcTan(LookDirection.Y, LookDirection.X))
                    Pitch := RadiansToDegrees(ArcTan(LookDirection.Z, Sqrt((LookDirection.X * LookDirection.X) + (LookDirection.Y * LookDirection.Y))))
                    Roll := 0.0

                    NewRotation := MakeRotationFromYawPitchRollDegrees(Yaw, Pitch, Roll)

                    if:
                        MyProp.TeleportTo[PropLocation, NewRotation]
                        
            Sleep(0.1)
10 Likes