i always wanted to know how to achieve a procedurally created snake
something like this
or this
i have experience with procedural mesh generation using splines and geometry data for road generation and also some experience with procedural animation using IK
but i couldn’t wrap my head around how to make a snake mesh procedurally while having it animated
and getting it to grow in length
Generally you’re going to keep a series of points in space where the centers of the snake are, and how they move along.
When they grow in length, you add more of those points, just like your basic SNAKE game as seen in the 1976 “Blockade” game, which started snake.
BUT… what your procedural mesh code will do is regenerate the nice smoothly-moving outer shell of the snake, based on the positions of that series of points.
The smoother and curvier it is the more you will have to contend with subdividing the mesh adequately so that the surface of the snake does not appear to shimmer in terms of its thickness as the segments of the body pass a given point in time.
Thank you very much for you input
I thought about that but wouldn’t that cause performance issues when you keep reapplying the vertices uvs etc… to the mesh ?
like each time you move you regenerate the mesh from scratch or is there a way to make the vertices follow the points, just like bones when animation ?
maybe i’m just overthinking things
Sounds like speculative performance worry to me. If your snake is 200 polygons, probably not gonna be an issue. If your snake is 200,000,000 polygons, yeah, it will probably leave a mark trying to update it each frame.
Sure, you could use bones I guess. Somethings gonna have to stretch though… I mean you can speculate about 27,000 different technologies, but it is always better to roll some code and build and run it on the actual target hardware.
If you have performance issues, attach the profiler (Window → Analysis → Profiler). If you suspect that you will have issues, attach it earlier and oftener and at every time you change what the computational load might be.
This is just the economics of engineering against real world hardware.