SpringComponent Public Methods and API
The SpringComponent partial Public Methods classes provide enhanced usability and easier access to spring functionality for each SpringComponent. While all methods are accessible through the springs directly (for example: FloatSpringComponent.springFloat.SetTarget), these Public Methods classes offer shorter, more convenient calls and serve as self-contained documentation.
Each SpringComponent has a corresponding partial class that exposes key methods for manipulating and querying the spring's state. This approach allows for more intuitive and type-safe interaction with the springs from your scripts. These partial classes are located in: Assets\AllIn1SpringsToolkit\Scripts\SpringsAPI
These methods provide direct access to the spring's properties, allowing you to easily get or set values such as the target, current value, velocity, force, and drag. You can also manipulate clamping behavior and add velocity for more dynamic animations.
Similar partial classes exist for all SpringComponents, each tailored to the specific spring type they represent. This consistent API across all spring types ensures a uniform interaction model, making it easier to work with different spring components in your projects.
The methods contained in these classes are the basic methods we'll use to interact with the Target, Current Value, Velocity, Drag, Force and Clamping. These are the main methods all partial classes contain:
GetTarget() and SetTarget(): Get or set the target value of the spring.
GetCurrentValue() and SetCurrentValue(): Get or set the current value of the spring.
GetVelocity() and SetVelocity(): Get or set the velocity of the spring.
AddVelocity(): Add velocity to the spring.
GetForce() and SetForce(): Get or set the force applied to the spring.
GetDrag() and SetDrag(): Get or set the drag applied to the spring.
SetMinValues() and SetMaxValues(): Set the minimum and maximum values for clamping.
SetClampCurrentValues(): Enable or disable clamping of the current values.
By using these public methods, you can create more readable and maintainable code when working with springs, as well as benefit from IDE auto-completion and type checking. They offer a more streamlined way to interact with the springs while also serving as easily accessible documentation for the available operations on each spring type.
Last updated