6
\$\begingroup\$

I want to create a realistic spring object, as a sprite, that compresses and expands when a force is applied and released, respectively. The only thing I know is that it requires some complex animation, but have no idea how to do it. I'm using the Unity engine, but otherwise, it is a general question.

When force pushes down on the sprint, it compresses, when force is release, the spring comes back to its original position. When force is also applied in a sidewards direction, the spring should also bend.

\$\endgroup\$
7
  • \$\begingroup\$ To what complexity would you like to simulate the spring? The most basic one involves using a spring coefficient and drawing some loops, more complex ones involve the material of the spring and the size of it (wire length, height, diameter) and compute the momentum of the spring (it makes it wobbly) \$\endgroup\$
    – Bálint
    Mar 20, 2017 at 12:15
  • \$\begingroup\$ You probably wouldn't want to use a sprite for this, but a line. \$\endgroup\$
    – Bálint
    Mar 20, 2017 at 12:18
  • \$\begingroup\$ Not very complex, just the basic stuff as shown in the figure. How would a line be used and look realistic? \$\endgroup\$
    – codeit
    Mar 20, 2017 at 12:44
  • \$\begingroup\$ Springs are basically wires in a looped shape. I'll probably post an answer, wich involves makimg the lines go around an arc \$\endgroup\$
    – Bálint
    Mar 20, 2017 at 12:48
  • \$\begingroup\$ Thank you. I would request you to please help me on this issue. \$\endgroup\$
    – codeit
    Mar 20, 2017 at 12:57

1 Answer 1

1
\$\begingroup\$

You might be over-complicating the problem. It sounds like you're really looking for a spring that does the following 3 things:

  1. Compresses
  2. Springs upwards
  3. Springs upwards and sideways

Try using three simple animations and some simple code to recognise when each should happen. With a nice animation that springs up and wobbles both ways when horizontal pressure is applied, that covers both directions, and the down and up are simple enough.

This would take far less work, and make the solution much more reliable and less prone to error.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ This seems more of a comment, but far more useful than your previous answer (both came up in the review queue). I have removed the specific commentary (answers are not a place for seeking clarification from the author). Perhaps you could elaborate on such code? Perhaps provide some pseudo-code? \$\endgroup\$
    – Gnemlock
    Apr 27, 2017 at 7:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .