1.snake_geo (which contains mesh renderer, mesh filter and the texture of the model)
2.snake_group (which contains the first snake bone which is the tail)
each snake bones contains another snake bone as a children (they have nothing but transform component)
that goes until the 20th bone of the snake which is the head
I’ve been struggling of which components I need (rigid body,colliders,joins?,etc…) for the snake and how to script it’s movement
I basically want the snake to move straight all the time (like in a snake game), and to be able to rotate the head of it with left-right arrows. the rest of the snake should follow accordingly to the head in a snake like movement.
I’m not sure if you actually need physics for this type of movement. What you need is basically for the motions that the head makes to be passed down the body over time - either in discrete units for an “8 bit” look, or continuously for a smooth look.
It seems like a script that’s probably been written already, so a bit of searching (not for Unity implementations specifically, but for the Snake algorithm in general) would be worthwhile.
Edit: Thought about it, the basics are simple:
Each [time unit], iterate from tail to head:
* Tail: Move [segment length] in the direction you're currently facing, then act as a Segment
* Segment: If your child is rotated, set your rotation to that amount and the child's rotation to zero.
* Head: If the player is pressing left/right, rotate that way. Otherwise nothing.
That’s the “discrete units” version; blend the movement/rotation over [time unit] if you want it to look smooth.
Errorstaz thank you but I already have a movement algorithm (made of cubes - snakeHead and snakeBody - everytime you eat an apple a snakeBody is created before the last piece and is given a SmoothFollow script to the last piece)
I’m trying to implant my algorithm to the snake model and I don’t know how
sorry for the bumps but I think it will do good for the community if someone solve this because I didn’t find anything for object manipulation like I’m trying to do, the closest thing I found was about IK rigs and I’m not sure if that’s what I need to make it work.
I dont do much work scripting bones but I think there will be a section of hierachy broken out (on humanoids it starts at hip), each of these represents a bone, or in your case a segment. Thus you should be able to just add the smooth follow script to each segment.
The most obvious tell of being at the right place is the fact it wont have any components on it, also if you modify the transform drastically the snake will look really deformed and silly