0 votes

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!

in Engine by (12 points)

1 Answer

0 votes

Using InputEventMouseMotion, you get a relative property: https://docs.godotengine.org/en/3.2/classes/class_inputeventmousemotion.html#class-inputeventmousemotion-property-relative

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.

by (20,677 points)

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

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 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 webmaster@godotengine.org with your username.