Segmented or linked targets

So, I am working on an ode to the old Centipede game, but I can’t find any information on how to link the segments of the centipede to move it jointly.

How do I join the parts of a centipede but then if a segment if hit it splits the centipede in to 2 centipede that go into different directions?

1 Like

There’s an extension called animate shadow clones that can help create a snake or centipede. The 2nd body objects conditions can be checked and I’m guessing you could use a condition to detect which copy to delete and then reduce the number of copies and add another main object. I haven’t tested that part.

I don’t recall the specifics of centipede. Did it move like on a grid like snakes or did it move more fluid.

1 Like

It’s probably not far from this Zuma-like:

But this example is a bit complicated, there are simpler ones for this extension:
https://wiki.gdevelop.io/gdevelop5/extensions/object-stack/

1 Like

it moved across the screen until it hit a mushroom then moved down one and changed direction. snake like when rapidly when bouncing from mushroom to mushroom if they are close together. But when hit by a bullet it split into two new centipedes which each go into different directions. this goes on until all pieces of the centipedes are destroyed.

Have you tried the extension that I mentioned? If you use a variable for the length and then change that value it deletes any extra objects. I just tested it and if you unlink the objects instead of deleting them then you could link them to a new head.

I don’t know how experienced you are with extension. This basically just adds the position of the head to an array. It then moves the body objects to the old position from the array.

When you shrink the centipede, you could copy the last part of array. It’s based on the number of selected frames, so I don’t think it would be tough to calculate.

You could either modify the extension or use its concept to create your own events.

Unlink the excess objects, replace the first object with a new head. Link the old objects to the new head. Copy the last part of the array.