Rotate third-person KinematicBody then move it, relative to camera

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By busboy

I have been trying to figure out how to rotate a KinematicBody in the direction of input relative to camera, then move it in the same direction, to make a simple third-person 3D platformer character controller, but it has me pulling my hair out in frustration.

99% of tutorials I’ve looked at rotate the mesh child of the KinematicBody around Y , making the character lose its orientation if a physics operation causes the KinematicBody to rotate, like a spinning platform. The rest use tank controls that have left/right rotating the character, and up/down moving them forward and back.

Is it unusual to want to rotate the KinematicBody instead of just rotating the mesh? Is this just preferred because most people have their cameras parented to the KinematicBody? Am I missing something?

I would really appreciate some help in going about doing this.

:bust_in_silhouette: Reply From: busboy

I figured it out. After unparenting the camera, I have this code at the bottom of my physics_process() for my KinematicBody node.

camera_pivot.global_transform.origin = global_transform.origin
velocity = move_and_slide(velocity, up)
	if direction.length() > 0:
		look_at(global_transform.origin - direction, global_transform.basis.y)