Member-only story
Implementing a basic mouse follow logic in Godot/C#
Let’s setup a simple 2D movement scheme for our little ship!

With the ever-growing diversity of gamepads, and mobile screens, and VR controllers, it looks like player inputs aren’t as easy as they used to be. Long gone are the days where you had a simple joystick to change the course of your paddle in Pong!
And yet: there are some gameplays and input types that seem to survive throughout the years, such as the well-known “your avatar follows your mouse”. This interaction scheme is quite common in small mini-games, and it is actually not that hard to implement…
So, today, let’s discuss how we can implement this mouse follow logic to have a little ship avatar follow the cursor in a simple 2D game, using Godot and C#!
This tutorial is available in video or text format — see below for the text version :)
Check out the Github repo with all my Godot tutorials! 🚀
Quick demo
By the end of the video, we’ll have this basic scene with our ship avatar in the middle, that follows the position of our cursor on screen:

We’ll give our avatar a particular speed, so that it doesn’t just instantly jump to the mouse position but rather glides towards it, which will allow us to avoid the asteroids around us while keeping it the game fairly challenging. We’ll also do some 2D drawing to visualise the target position more clearly.
As usual, don’t forget that if you want to get the files of this tutorial directly, you can…