- Home /
How to make an arc like motion from one end to other for my 2D sprite
In my 2D game the char goes left and right on tapping and it's running walls so on tapping I want it to make an arc like motion when going to other wall from point A to point B but come back to same initial position in y axis but in opposite side. Idk if I explained clearly in words so here's a photo to explain more
I want to make an arc from point A to B back and forth, it should be smooth and it's really important it should be in same line just opposite side everytime I tap. I have also searched quite a bit, a whole day I spent on it I found Bezier curves but I don't think that would be smooth enough but if anyone can help me then I will really appreciate it, it's taking too much of my time please help
Answer by Llama_w_2Ls · Feb 01, 2021 at 09:21 AM
You could take a look at using a sine wave.
The wave smoothes at the peaks, and accelerates and gets steeper at the edges. If you are familiar with trigonometry, sin(x) = sin(180 - x), which means that sin(30) = sin(150).
You can choose a random point for x inbetween 0 and 180, and then use the sin wave to plot points of movement for the object, up to 180 - x, because that is where the other side of the wave is equal to the starting point. Hope that makes sense. @KimMingyuSVT
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Help with making a map based game! 3 Answers
Why does my swiping code not work? 1 Answer