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\Plugins\AllIn1SpringsToolkit\Scripts\SpringsAPIThese 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.
Main Methods
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()andSetTarget()- Get or set the target value of the springGetCurrentValue()andSetCurrentValue()- Get or set the current value of the springGetVelocity()andSetVelocity()- Get or set the velocity of the springAddVelocity()- Add velocity to the springGetForce()andSetForce()- Get or set the force applied to the springGetDrag()andSetDrag()- Get or set the drag applied to the springSetMinValues()andSetMaxValues()- Set the minimum and maximum values for clampingSetClampCurrentValues()- 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