0 votes

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.

Godot version 3.5
in Engine by (19 points)

1 Answer

0 votes
Best answer

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)
by (19 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.