Notes made after creating a spring for a game element in my current Unity project. I needed to animate the spring – The notes below provide a method which keeps the scale intact.
These notes probably won’t be useful for anyone other than myself. I’m planning on building models as required, rather than in one lump – Which means I’ll forget everything in the meantime & have to relearn every model I build – To avoid this as much as possible, I’m hoping to use these posts as a reference point.
Apologies for any obvious mistakes or omissions – These notes were made as I was learning, and not necessarily as I had learnt.
In the add modifier section change the value of the ‘Screw‘ field to stretch the spring to the desired maximum height.
next duplicate the spring using tools->duplicate – creating spring #2
Back in the add ‘Modifier Tools‘ section – change the ‘Screw‘ value of this duplicate so the spring #2 is at its minimum desired height – then click ‘Apply‘
Select the original (fully expanded) spring #1 and click ‘Apply‘ in the ‘Add Modifier‘ box
With the original (fully expanded) spring #1 – still selected
select ‘data object data‘ – the triangle icon next to the modifiers screwdriver icon
in the ‘shape keys‘ section of ‘data object data‘
click the + button/icon
this should add an element called ‘Basis‘
storing the settings the original (fully expanded) spring #1
Select the second (fully contracted) spring #2
hold down shift and select the original (fully expanded) spring #1
in the ‘shape keys‘ section of ‘data object data‘
click on the black arrow/triangle (under the ‘add button‘)
this should display a pull down menu
from this menu select ‘join as shapes‘
which will add a second element to the ‘shape keys list‘ – this element will have the name of the second (fully contracted) spring #2 (in this case Vert.001)
Since there no further need for the second (fully contracted) spring #2
this can be hidden (or deleted)
In the ‘shape keys‘ section of ‘data object data‘
click on the name of the second (fully contracted) spring #2 (vert.001)
doing this should expand the ‘data object data‘ section
displaying more the shape keys parameters
(if this doesn’t occur try clicking on the white down arrow on the right hand side of the ‘data object data‘ section
sliding the ‘value‘ parameter up and down should expand and contract the spring.
To create an animation – Using the animation bar move the green marker to the first frame
in the ‘shape keys‘ section of ‘data object data‘
slide the ‘Value‘ parameter and set the spring to fully coiled
& with the mouse pointer OVER the ‘Value‘ parameter press the I key
this will add a frame to the animation bar & turn the ‘Value‘ field green
in the animation bar move the green marker to the last frame
& with the mouse pointer over the value parameter press the I key
In the animation bar move the green marker to the middle frame
in the ‘shape keys‘ section of ‘data object data‘
slide the ‘Value‘ parameter and set the spring to fully uncoiled
& with the mouse pointer over the value parameter press the I key
Now pressing play – you should have a half decent bouncing spring animation
Next post: 1.7 Initial Unity FBX Import & Animation Notes (Part2)
Last post: 1.5 Creating a basic Spring