Jump to content
Search Community

Cool follow mouse move effect

AsKadir test
Moderator Tag

Recommended Posts

One simple approach would be to set a seperate x & y speed in the example above from Zach. Then play around with each speed number until you get the desired effect. If that does not suffice then you would need to come up with further logic if required.

 

var speedX = 0.1;
var speedY = 0.3;
//
pos.x += (mouse.x - pos.x) * speedX;
pos.y += (mouse.y - pos.y) * speedY;

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

5 minutes ago, Shrug ¯\_(ツ)_/¯ said:

One simple approach would be to set a seperate x & y speed in the example above from Zach. Then play around with each speed number until you get the desired effect. If that does not suffice then you would need to come up with further logic if required.

 


var speedX = 0.1;
var speedY = 0.3;
//
pos.x += (mouse.x - pos.x) * speedX;
pos.y += (mouse.y - pos.y) * speedY;

 

How did I not guess?

That's exactly what I need!

Thanks a lot! @Shrug ¯\_(ツ)_/¯

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...