Mouse input to rotate a object in Godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By j0bbes

Hello! I’ll be brief. Imagine Google Earth. There you can rotate the planet around its axis with the mouse. How do I implement this in Godot with another object? Thank you!

:bust_in_silhouette: Reply From: kidscancode

Using InputEventMouseMotion, you get a relative property: InputEventMouseMotion — Godot Engine (3.2) documentation in English

That tells you how much the mouse has moved (in screen coordinates). Then you use that value to rotate your object around its y axis with rotate_object_local(Vector3.UP, event.relative.x * sensitivity). You can adjust the sensitivity variable to tweak how much the object rotates for a given mouse movement.

I know that. It allows you to move an object when you move the mouse, and I need the object to rotate when you click on it and scroll further

j0bbes | 2020-02-03 07:59