Search code examples
androidanimation2dgame-physicsgodot

Recreating a game for learning purposes : what's that feature?


I picked up Godot a week ago and I am recreating apps to get good at developing, which works fine. But sometimes there's a little feature I am obsessive about and can't figure out. You can see the trail of the ball in the Android game Dune in this video. It's some kind of animation, that obeys the laws of physics. I tried particles and although it serves the purpose, the outcome is by far not the same.

Any ideas?


Solution

  • As meowgoesthedog already mentioned, the trail is simply a location history and does not do any physics processing. That is all done by the ball and the history will automatically reflect this.

    To answer how you get one solid trail instead of disconnected particles you will have to draw a polygon. Look at custom drawing in 2d how to do this, and then at the actual method to draw a polygon.

    To get the points of your polygon you iterate your location history from small to big, and add each point + its radius in the y direction. Make sure the first radius is 0 and include the current position of the ball. Then you iterate the location history from big to small and you add each point - its radius in the y direction. The result is that you trace the upper edge first, then jump down to the lower edge, but this should be hidden by the actual ball. Then you trace the lower edge and meet in the point.