Making a Sprite Follow the Mouse
This tutorial will explain how to make a sprite always be where the mouse is, follow the mouse indefinitely, if a button is pressed, if the mouse is too close to the sprite, or have the sprite follow at a distance.
Always Going to the Mouse
This script makes a sprite always be at the location of the mouse:
The Draggable Sprite Feature can also be used, but this requires the user to click.
Following the Mouse Indefinitely
This script will make the sprite follow the mouse, but if one moves the mouse fast enough the sprite will lag behind some.
Alternatively, the following script can be used:
This gives the object following the mouse a bit more of a velocity.
Following the Mouse if a Boolean is True
This script makes a sprite follow the mouse if the Boolean is true.
Following the Mouse if a Sprite Comes Close Enough
This script will make the sprite follow the mouse, but only if the mouse-pointer comes within a certain distance of the sprite.
Following the Mouse at a Distance
This script will make the sprite follow the mouse indefinitely, but will never come to touch the mouse. One thing to notice about the script is that there is that there is a cushion zone. If the distance is between 50 and 70 then nothing will happen. This is designed so that the sprite will not jump or bounce erratically.
Following the Mouse Quicker as the Mouse Moves Away
This script will make the sprite follow the mouse indefinitely. As the mouse gets farther away from the sprite, the sprite will speed up until it gets closer again, and then slow down again.