Game development live blogging - Part 2
Alright yesterday I left a body-less snake alone in Part 1. Today I am going to make it attach with its body, and have you test-drive the snake in the editor, even in "Edit mode"... Fancy! I know, that's one of the strength's of Unity3d's editors. Recap : So far, in the editor, edit mode, I am able to drag the snake's head GameObject, and snap it to the grid. Now its time to link them together. Usually in the past, I always hold them all in a single array like data structure and keep updating their position using code, by shifting their position data from head to body 1, and body 1 to body 2 and so on. This time I am going to try a new approach. Let's do it the Unity3d's way. First I am going to declare a new variable called "nextPart" of type SnakePart. I realised, each part's responsibility is only to pass its old position to the next body part. This will be a chain effect and the entire snake will move. Also we never use th...