Spring Main Elements
Last updated
Last updated
All springs, regardless of type, have three core values:
Current Value: The value of the spring at the current frame.
Target: The desired value that the spring aims to reach. The spring will gradually move the Current Value towards the Target value, frame by frame.
Velocity: Depending on the state of the spring, the velocity will vary. Generally, the further apart the Current Value and Target are, the higher the velocity will be. When both values are equal, the velocity is zero, and the spring is at rest.
To fine-tune the spring behaviors, you can adjust two parameters:
Force: This determines how much force is applied to move the Current Value towards the Target. A higher Force will cause the Current Value to approach the Target more quickly, resulting in a faster-growing and larger Velocity.
Drag: This parameter slows down the spring. The higher the Velocity, the more the Drag will pull back on the spring. A higher Drag value results in a more stable and predictable spring with less bouncing. When the Drag is low, the Current Value will bounce back and forth around the Target until eventually reaching equilibrium.
In summary, Force controls how quickly the Current Value reaches the Target, while Drag determines how gently it does so. Understanding the interplay between these elements is crucial for tuning the springs to achieve the desired feel.
In general Force and Drag will be setup in the spring component, in the editor, using the Inspector:
Although of course you can change it at any point in code.
Current Value, Target and Velocity are usually interacted with in code. As we’ll see in the next section.