I’m fairly new to unity, and I’ve been looking at tutorial after tutorial to try and piece together a way to build a snake-like game as a way to get myself used to what Unity has to offer. The kicker is that where the head moves is based on a constant velocity dictated by mouse clicks or screen touches (the head would change direction towards the point of touch/click). So far, that part is working perfectly, and enables me to have the snake move 360 degrees instead of simply up/down/left/right as old snake games would do. My challenge now is that when I attempt to add in the tail pieces, they do not follow along the path the head took, but rather they are placed correctly, and then veer in a curved arc towards the head. I’ve tried using waypoints, using velocity markers that the tail pieces would use to travel the same direction/speed as the head did when it changes direction, etc but to no avail. Every option no matter how I tweak it seems to end with the same result.
Now I fully expect that I’m just not proficient enough with the scripting side of unity to properly bring about my vision, so all I’m asking is that if anyone happens to know of any good tutorials or scripting examples that I could look at to try and extrapolate a solution that works for my project.
If I am understanding correctly you want the tail to follow the exact same path as the head?
You could try to have only the head move through physics and the rest simply follows along each frame by getting moved towards the next segment’s previous location a distance equal to the head’s movement, with a minimum distance between the segments
That was something I’d tried to achieve through waypoints. When the head changed direction, it created a new waypoint, which each tail piece was supposed to follow in order to match the head’s path of movement (first tail piece moved at the same speed as the head to the first waypoint, then second piece to the second waypoint, etc). But rather than move to each waypoint and then be at that waypoint when the head created a new one, each tail piece would instead just head straight for the head’s location (and I mean like I could have 10 tail pieces, and even the 10th one would simply head straight for the head’s location). I have no idea why it did that, seeing as the code was not written that way (I would show you the code I had, but I have since deleted that version and re-coded so I don’t have it anymore).