Hello, I’m creating a virtual Rubik’s Snake designer program using Godot, and I’m trying to get the camera controls down. Basically, I want them to work like they do in Godot’s 3D editor (or even Blender), where you orbit around a point and pan your camera sideways. I managed to get the orbiting part using a point-point-camera gimbal setup, but I don’t know how’d I implement the panning.
The panning action I implemented only pans the central focus point alongside the global X and Y axis, my question is how would I make it move in the axis of a “plane” rotated the same way the camera is (or the 2 gimbals in my case)? I was thinking maybe something with transforms, although I wouldn’t know where to start with my skill. Or maybe the whole structure of the gimbal setup should be changed?
Solved, for anybody wondering, I asked Claude AI and it gave me this solution which worked well for me after some adjustments for my setup (sorry if posting AI code is against the rules, just thought it’d be useful for others with the same issue):
if (Input.is_action_pressed("cam_pan") or (Input.is_action_pressed("cam_rotate") and Input.is_action_pressed("cam_pan_modif"))) and event is InputEventMouseMotion:
var cam_basis = $CamGymbalX/Camera3D.global_transform.basis
var right = cam_basis.x
var up = cam_basis.y
var movement = -right * event.relative.x * mouse_sensitivity # I set mine at mouse_sensitivity = 0.0075
movement -= up * -event.relative.y * mouse_sensitivity
global_translate(movement)
Hey I’m trying to do kind of the same thing with a game I’m working on. I have the gimbal set up and that all works fine, I don’t want to pan the camera but I want to be able to rotate the camera like in the editor but no matter what I can never get the camera to rotate properly like it does in the editor. Mine always ends up tilting no matter what I try. Can you help?