Move sprite in path

Hi all,
I’m trying to move sprite in a path like below image.
Anyone know how to do this?
Thanks

image

This may answer half the question for now:

You could use A* (a-star) on the pixels, and only let it traverse selected color.

Or, you can check each pixel your object is at, from start to finish, for neighboring pixel colors and only allow movement to pixels of a particular you haven’t traversed already… You would only have to check a handful of pixels each frame of movement… Move any number of times each update frame.

You can either describe the path with a formula (this looks like a hyperbola). And move along that.

Or if the path is defined, you could use waypoints.

1 Like

In order to answer your question, we would need to know what your path actually is.

A texture? A Vector? What you want is waypoints and a path between it. The simplest form is just a line from A->B which would be just linear interpolating between A.xy to B.xy

you can add bezier information to these points and make them curves to move along - the basic principle here is interpolating along a fixed function for the path between 2 points. A more complex path is just a chain of points like A->B, B->C, C->D

If I remember right there is even a built-in interpolator for curves somewhere, which takes 4 parameters … edit: yes there is:

MathHelper.CatmullRom

1 Like

This video seems great, it was in my recommended by chance:

1 Like

I solved the problem. I used method to create points first and then used this video (Lubiii’s answer) to move in the created path.

Thanks all

1 Like