I have a gameobject that I want to animate along a specific path/curve but the animation should be controlled by mouse/touch position. So when I touch/click on the gameobject and move the finger/mouse on the path (or maybe its easier to just move down) the gameobject should follow the defined path.
I like iTween, but I think it is not possible to find a solution using it here, right?
thnx!
If it is made of multiple small line segments, then this is how you would do it:
T = location of touch/tap.
- Iterate through each line segment.
- Find the closest point on each line segment to P.
- From all the closest-points, choose the one that is closest to T. Lets call it CP.
- Place your object at CP.
If you are using a mathematical curve, then you can find the closest point mathematically. The method will depend on the curve.