Solution
I posted an example scenario answer on the linked post but I thought that maybe I should provide a more direct answer on this page.
So, as you can see, the green line seems to bend toward the normal then bend away again toward the final position. To do this, we can use two LibGDX Circle
instances with the same radii - being large enough for the first point at the turn's edge to be where you want the turning to start.
So now we have two points with two radii, now what? Well, we check when the entity reaches the center of the circle and then makes a small delay of around half a second. After this delay, the line will start to bend towards the vertical normal line and will move simultaneously.
Eventually, it will reach the normal and stop bending but then it will reach the edge of the second circle that surrounds the end point. As it reaches this point, it will again have a small delay of around a quarter of a second then start to bend toward the end point and again move simultaneously. After reaching the correct angle it will continue to move in that direction till it reaches the point.
Well, I've talked about moving on an angle but how do we achieve this? Simple really, (I'm in 9th grade / Year 10 and I know this) we use the equation of the line or y=m*x+c
in which y
represents the Y coordinate on the screen depending on the gradient m
and starting at the intercept c
but this is basic straight-line graph calculus and this has 2 turns. Assuming we go by the calculus rules of dimensional naming conventions, 1D = straight-line, 2D = quadratic, 3D = cubic etc., then this would be a cubic function graph since there are 3 different line equations but to do cubic function graphs. I'm not sure of those but here's a link: Click me!
Hope this helps!