A snake with 2D chain physics and collision!
A simple controllable snake animation inspired by argonaut's video!
The snake is animated by constraining the center of each segment to the radius of the previous segment, then constraining the angles between segments by a specific amount. This was really fun to make and ended up being way more satisfying than I thought it would be! The mouse moves the collider, and scrolling the scroll-wheel adds segments. (Scrolling down deletes all the segments, I kept getting stale references and I was too tired to figure out why.)
This was my first time trying this for myself! I'd used circle collision in other game making tools, but going through the process of building them was far more interesting! In the end, I couldn't figure out how to get the sides based off the direction of segments so I crawled to chat gpt for help. It gave me a simpler solution, to just find the perpendicular lines of the direction vector. It works, but that means I can't find any other point relative to the segment for things like fins and eyes in the video... guess I've got to work on that next!
Link to the video by argonaut:
[Please log in to post a comment]