I have a school assignment to make a 2D platformer game, with a character that moves like a slinky:

Example of slinky movement

(Animated example from the assignment linked above)

  1. At first, the character needs to grow in height over time

  2. When the player presses a button, the character starts to bend toward the next platform

  3. Its height when you press the button determines whether it will hit the next platform

  4. After that it must shrink to its initial size, and it goes over again.

How can I approach this?

  • 2
    \$\begingroup\$ There's a lot that could go into such a character - the gameplay logic of staging out the growth/bending/shrinking phases, the math & physics queries needed to check whether it's the right size to hit the platform, the rendering of the shape etc. Which part are you having trouble with at the moment? What have you tried so far, using eg. LineRenderers? \$\endgroup\$ – DMGregory Apr 13 '19 at 11:14
  • \$\begingroup\$ I tried to use the logic of snake game, it means an objects starts flying up and it spawns other objects over time and connects them to the first object. Then when you press a button the initial objects goes left and down dragging all the spawned objects. Im pretty sure its not the right way to do it. \$\endgroup\$ – Val Kul Apr 13 '19 at 11:24
  • 3
    \$\begingroup\$ Sounds like a great start - put that in your question! Your next step: take the idea that there's a "right" way to implement a new game feature and set it on fire, until it is nothing but ash. It will be the single biggest obstacle to your progress. Now that we're not caught up on right vs wrong, let's talk about consequences: how does the game behave when you build it the way you've described? Does it meet your goals? In what specific ways does it differ from what you want? Highlighting those differences helps us focus on solutions to those specific problems. \$\endgroup\$ – DMGregory Apr 13 '19 at 11:31

Like @DMGregory said, there can be multiple ways of doing it. One way can be creating multiple blocks and connecting them to unity's physics joints. (Which you probably tried already)

Another way of doing it would be mesh deformation. You can create a spline bend to make a curve. See this tutorial on Spline Bending. It might help u get started.

From unity 2018, there is a new feature called Sprite Shape. It makes the sprite bending easy. There are not many tutorials available on Sprite Shape. But you can look into Unity Documentation to get some idea.

So, the idea should be

  1. Scale the sprite on mouse down.

  2. Then On mouse Up-

    (a) Divide the sprite into equal bending points [e.g. Say I wanna split it into 5 points, I will pick the points in each (sprite.bounds.y/5) position]. You can insert point to the spline by spline.InsertPointAt(int index, vector3 point) method.

    (b) Then Bend the sprite in each point. (spline.SetPosition(index, position)). Here you will need some math calculations to pick where the next points should sit.

    (c) When you have the new list of points you can now Lerp to the new points from the old one.

Let know in the comment if it helps, or you could make it work??


Since you didn't specify the language (maybe it was in the doc, but I can't read cyrillic, I'm sorry) I will give write some pseudocode / description.

First, you need the "slinky" object. I would build it out of two sub classes. "EndBlock" and "FillerBlock". Slinky only has one "EndBlock" to begin with, and is built like this:

buildWithPrecision(int precision){
    for (i){


At this point you should have a nice, hierarchical structure. This will be useful later.


bend(float deltaTime, float bendingSpeed){
    getChildBlock().rotation.add(deltaTime * bendingSpeed);

This will work recursively. It should bend all the way until the last child.

At the endblock you should check if it touched the floor:

OnHit(Object other){
    if(other == floor){

Reverse bend should stop bending, start bending the other way, and inform all the blocks that they have to shrink.

    getChild().bend(deltaTime, bendingSpeed);

I know this is not a fully working solution, but it should be a good way to start the project. If you have more questions, just add a comment.

  • \$\begingroup\$ The language (Unity C#) is specified in the question's tags. \$\endgroup\$ – DMGregory Apr 13 '19 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.