"Stretchy neck" effect (SOLVED)

Greetings,

You know how in various SNES games, some enemies or objects had arms or necks or whatever created from just a bunch of lined up sprites? You know, how their “neck” was made of balls and such?
stratchy neck
That’s what I’m trying to recreate here. I have an old Construct 3 example that does exactly that, so I started to translate that into GDevelop’s format instead:


Unfortunately, I have a major problem. “Loopindex,” an important expression used in C3 to make this work doesn’t exist in GDevelop…

(Loopindex only exists here currently as a placeholder)
I tried looking online for a substitute expression, or to see if this kind of object hierarchy system has been questioned before, but I had no luck. GDevelop doesn’t seem to have it’s own loop expression either…?
What can I use in place of loopindex to get this to work?

1 Like

Just wanted to say I am eagerly awaiting a solution for this, classic effect!

Instead of doing balls check out what Keith come up with

Try that project and see if that would not be better solution for you

If not i think only thing you need is expression to proportionally position balls on distance between two objects

For example you would set position of ball closest to head and most far from body to distance between two objects - 90% of that distance

So all you would need to get is expression for how to calculate 90% of something
And then for next ball 80% and so go on
And that would do the trick

So if you don’t like solution Keith made you better make post to ask about that kind of expression cause i just have IDEA how to do it but i am not good with expression
I guess it could be calculated same way as we calculate HP for HP bars but idk how to do that

1 Like

I love that concept. What about if you use scene variable, in this case i ?
lerp(head.X(),body.X(),i/(SceneInstancesCount(neck)+1))
lerp(head.Y(),body.Y(),i/(SceneInstancesCount(neck)+1))

Drag the “head”, click a “neck” object to delete and click the “body” to add a “neck” object
You need to drag the head to realign everything.

edit: Did I tell you how much I love this concept? This would automatically add or delete objects. (if you needed to) It might be more efficient to hide and show segments than delete them.

try me:

2 Likes


Thanks, these examples are very helpful. I modified it to fit my needs.
It’s doing the stretchy neck thing now, but uh…

…mine’s backwards for some reason…??
Have I overlooked something by mistake?

1 Like

I think it’s because you’re adding 1 in the lerp expressions without parenthesis around the segment count.
(segment count +1)

It’s making the lerp go from 1 to 2 instead of 0 to 1. The extra segment is to help with the centering.

1 Like

Perfect, it works just fine now, thanks!

2 Likes