Weird 3D camera X rotation behaviour

Godot Version

v4.4.1.stable.mono.official.49a5bc7b6

Question

` Hi yall! I am trying to make a 3D character controller, it went very well. I heard about bone attachment. So I used it to attach the camera it so the camera is synced with the player’s head.

After doing this, looking up and downusing mouse ‘X ROTATION’ started to glitch. After few rotations and walking a little bit it started to rotating instead of up and down it started rotating up and down with like 45 degress added to it around axis Y. You can see that on video.`

This did not happened when the camera parent 3D node was not attached to the bone.

Script: extends CharacterBody3Dvar speedconst WALK_SPEED = 5.0const SPRINT_SPEED - Pastebin.com
Layout:

Video: https://youtu.be/zSezI3HIlmM

This is called Gimbal Lock. It happens when you try to rotate something on the x and y axis using Euler coordinates. You can solve it by rotating a node in the y-axis, and the camera as a child of that node on the x-axis. Here’s a good tutorial on it.

1 Like

The link dosen’t work. But thanks I will look at it.

Fixed the link.

is there any other solution? I mean rotation system that dosent have gimball

There might be, but I have yet to find it. Is there a reason this solution won’t work for you?

I tried what have you said but it did not work. I heard eular angles are a bad habbit. I have found some forum thread with code here: https://forum.godotengine.org/t/using-quaternion-math-for-camera-controls-because-i-am-scared-of-euler-angles/74123/2

But thanks for help!

1 Like

I did some googling. Seems like it depends on what you’re doing. Using 3D transforms — Godot Engine (stable) documentation in English Here’s the Godot docs on what to do.

I also found this thread which I found the last response interesting.

@pennyloafers I noticed that you commented on the Godot doc I linked above. Do you know any good tutorials on creating a first person controller using quaternion transforms?