Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
inflamesc

Move an object along the svg path with mouse

Recommended Posts

Hello guys,

I'm totally new to JS. Trying to learn and improve. I'm trying to build a minimap and move an object that represents player movements on the map. You'll see 2 things in the code. One is a straight line the other one is a map. I was only able to find animated movements. So When the user wants to move the object on the straight line with the mouse, also this movement has to be reflected for the object on the map too. I just want to be able to move that point with the mouse. How can i do it?

Best Regards

See the Pen pLddVZ by inflamesc (@inflamesc) on CodePen

Link to comment
Share on other sites

Check this thread for drag along the path demo by @OSUblake

 

 

  • Like 4
Link to comment
Share on other sites

Yep. That should give you an idea on how to get started, but it's not a perfect solution. For example, if the mouse is equal distance between two or more points on a path, which point should it use? That's something you'll need to figure out.

  • Like 4
Link to comment
Share on other sites

OSUblake, 

2 hours ago, OSUblake said:

Yep. That should give you an idea on how to get started, but it's not a perfect solution. For example, if the mouse is equal distance between two or more points on a path, which point should it use? That's something you'll need to figure out.

 

Sir your work saved me from sleepless nights. Thank you master!

  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...
On 3/27/2018 at 11:14 AM, OSUblake said:

Yep. That should give you an idea on how to get started, but it's not a perfect solution. For example, if the mouse is equal distance between two or more points on a path, which point should it use? That's something you'll need to figure out.

How can I stop it from moving to another point of map regarding the position of the mouse? I just want to drag it along the path. 

Link to comment
Share on other sites

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.
×