[SOLVED] Object Slowly Following Mouse

Version: 1.19.3

I am having trouble making the code for an object slowly following the mouse.

speedFactor=10;
yourClip.x +=(mouseX-yourClip.x) / speedFactor;
yourClip.y +=(mouseY-yourClip.y) / speedFactor;

should give you a clip that follow your mouse.
The closer the clip gets to mouse position the slower it moves.
Higher speedFactor will result in a clip moving slower

if you want clip constant speed it’s a little more tricky but one simple workaround could be:
clipSpeed=2;
mouseX >= yourClip.x ? yourClip.x+=clipSpeed : yourClip.x-=clipSpeed;
mouseY >= yourClip.y ? yourClip.y+=clipSpeed : yourClip.y-=clipSpeed;

2 Likes

This worked, thank you!