How to implement actors following each other in a chain (like classic snake game)

Hi,

I am learning UE4 and for my first Project I try to do a clone of the classic snake game. However, it will be using 3d actors and not be 2d. The way it works is that the Player moves around on the map (landscpape). Whenever he collides with a pickup item, then one snake element is added to the player. The elements always follow the element in front of the. Each picked up pickup item will make the snake one element longer. If the Player collides with a wall or any of the snake elements, he dies. Now in unreal Terms, how do I set this up?

  • Player will be a pawn. Question: Would you code the movement in the pawn or use a movement component instead? and why?
  • snake elements will be actors.
  • pickup items will be actors.

What I don’t know how to is the following:

  • How do I make the snake elements follow the Player/element in front of them? I suppose i store a list of such items, but where? And how do I find the correct place to spawn a new element to the snake, after a collision has happened with a pickup item?

Any help or ideas on how to setup such a game are greatly appreciated!

Are the snake elements cube or very simple primitives which will be updated for example per second or per several hundreds of miliseconds? If it is not, if it is more realistics then that and elements will be moved contniously(seemlesly) then you should use something like Spline Meshes.

But if it is an old traditional snake game. You can hold all snake nodes in array anywhere you want then you can simply update last element’s position to the point where the first element should go in -for example- once per-econd.