Wetsy
Wetsy

Reputation: 3

How to move a 3D object in godot with mouse coordinations with?

I'm encountering a problem using godot engine with GDscript, (but if you know the answer with other godot languages, I welcome those answers too! 😊 )

Assume that my object is a ball. The specific action I want to make with my mouse is:

If I move my mouse to the right: the 3D object would move to the right

If I move my mouse to the left: the 3D object would move to the left

If I move my mouse up: the 3D object would move forward

If I move my mouse down: the 3D object would move backward

I'd be thanked if you guide me to how to write the script! Thanks!!

Upvotes: 0

Views: 1682

Answers (1)

Jummit
Jummit

Reputation: 116

You can use the _input function for that. It receives an event, which you can check for if it is an InputEventMouseMouseMotion. Then you can use event.relative to move the ball in the direction.

Upvotes: 0

Related Questions