i like the snake physics and art, movement is a little weird, but not so different from my snake game xd
nice job
may i ask, did you use forward kinematics + collisions?
Viewing post in Jörmungandr Quest jam comments
Thanks for the kind words!
And yes we did, the snake is made up out of its head, a bunch of capsule body parts and its tail. Which are connected with hinge joints. These all get a rigidbody (set to dynamic) and a collider (both 2D of course). The rigidbodies are setup mostly the same but the tail is set to be slightly heavier. We also use linear and angular dampening to make it slide around less.
In order to move the snake a script applies a forward or backwards force and a torque for side to side to the head based on input. We also apply only a forward force to the body parts were the force gets reduced by a reduction factor based on how far along in the chain it is. (We apply the force relative to local space by using AddRelativeForce)
That last parts was C_raider’s solution, we found it makes the snake feel a lot better then only applying the force to the head. The problem you run into there is that if you add more body parts the snake would become heavier, making it slower. If we just increase the speed based on the number of segments it becomes inconsistent.
Pegs only have a circle collider unless they are on a track then they have a rigidbody too, but we dont apply any forces through script.
I like your game btw, I’ll leave a comment on your page :)
I’d be curios to know how you solved it.
Thanks for checking out my game!
I never thought of using rigidbodies that way, im sure it made the collisions easy to add.
My snake is completely transform based, and is attached together using a bit of math.
Similar to you, i have a bunch of segments, the head, middle segments, and the tail. I put all of them in a class
Ill try to explain as best as i can.
Basically, its a big chain of connected points. Each point is confined to another via a distance constraint (takes the distance between one point and another, and normalizes it). If one point moves, the rest follow it. Its pretty simple on its own, but i also managed to add angle constraints for each individual segment, so the snake cant turn on to itself too weirdly.
And thats pretty much the concept, all i have to do is move the head and the rest of the body follows smoothly. It is a bit more complicated in code, especially with the angle constraints, though.
One problem with transforms, i couldnt get collision physics to work, so i just changed the angle when the snake hits a wall.
Thanks for sharing :) nice to see how other people do it
I think it might have been fine if you only added a rbody to the head for collision? But i'm geussing you tried that. Alternatively as long as you snake has colliders you could give the walls rbodies instead.
Also what your doing kinda sounds like re-inventing hinge joints, but doing it yourself does make it super flexible
Either way cool approach and thanks for letting me know, it seems to work well for the more fast paced nature of your game