I am makeing a snake-styled game. To draw the tail, I constantly spawn segments at the location of the snakes head and let them disappear after a certain time.
--> When the segment appears, a timer starts, after one second the segment gets destroyed.
I want the snake to grow, when it eats food. I want the tailsegment to disappear later, when the snake eats food.
I tried: Everytime the snake collides with food, (Every time a tail segment is really close to the food, I use proximity for that) the time until the segments disappear gets longer
--> Does not really work... The timer seems to reset itself to its initial value after each collision and only one segment stayed longer. Yes I understand, that only the "new" segments will stay longer.
What am I forgetting/ignoring/not seeing?
I tried to emit the segments instead of spawning them --> The segments appeared somewhere beside the head of the snake, it doesn't look nice.
it's this game: https://flowlab.io/game/play/831928
Thanks for your help!