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.
You might be over-complicating the problem. It sounds like you're really looking for a spring that does the following 3 things:
- Springs upwards
- 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.