Character not turning towards input direction

Godot Version

Godot 4.2.1

Question

I can’t make my character face left, right, or back, depending on the input. When I move it, it does look where the camera is facing, but not based on the input. How can I implement that in my script? Also, I’m using the Phantom Camera Add-On, but I was told by the developers that my issue is a godot one, not an add-on issue.

I tried to use look_at “$%Character.look_at(global_transform.origin + direction, Vector3.UP)”, but the character faces the opposite side of the input (ex: faces left if I pressright) for a split of a second. It then never faces any direction again, it just faces where the camera looks, as I explained previously.

I was just told that look_at wouldn’t work for that, but rather a rotation setter, where you set the rotation of the character relative to the camera’s rotation and based on the direction you press. The current look_at() approach doesn’t seem to take that into account?




You have the “#Update the character’s rotation based on input” code, then right after the “#Update the character’s rotation based on camera rotation” code that “overwrites” whatever the former does with look_at() to the character’s rotation.

Try commenting out the whole “based on camera rotation” part to see how it works using only look_at().

Three things happen after removing/commenting out those lines:

The camera now can rotate without rotating the model, which was expected.

The character moves forward if pressed up, then looks in the opposite direction of the input whenever I press right/left/down. I figured it was the look_at part of the script, so I removed it and everything seems stable, but now I need to find a way to rotate the model.

The character’s inputs are independent of the direction of the camera. if I press up the character will go forward wherever the model is facing. I assume this is due to the movement being attached to the orientation of the model.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.