0 votes

I am trying to rotate a camera around a FocusPoint (Spatial). The camera is child of FocusPoint. The code below works as long as only one axis is rotated at a time. It quickly goes all wonky when both axes are used. I have been reading the Godot 3D docs and trying to understand Transforms but I need some tips.

if event is InputEventMouseMotion and is_camera_dragged:
        $FocusPoint.rotate_object_local(Vector3(0,0,1), event.relative.y * PI/360)
        $FocusPoint.rotate_object_local(Vector3(0,-1,0), event.relative.x * PI/360)
in Engine by (61 points)

1 Answer

+2 votes
Best answer

Use a gimbal
1 Spatital per Axis

outer
--- inner
--------------camera

by (284 points)
selected by

So simple and works great!!

Thanks!
if event is InputEventMouseMotion and is_camera_dragged: $FocusPoint/Gimbal.rotate_object_local(Vector3(0,0,1), event.relative.y * PI/360) $FocusPoint.rotate_object_local(Vector3(0,-1,0), event.relative.x * PI/360)

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.