Handle
Description
The Handle is a class that acts as the Spring System for an object, meaning that it takes forces and then moves, rotates and scales the object you create it for; we give its value when subscribing an object to the Motion Manager and can be used to add forces to the object.
To subscribe an object to the Motion Manager, we have to invoke the subscribe method, and pass a Spring Data value for each property we want to change (position, rotation or scale).
How does it work?
The way this component works is by taking forces we apply to it, and then add them together with the Spring Data values for the correct property, finally it applies the results to the correct game-object. The Handle itself does not have an update method, and thus the Motion Manager is in-charge of invoking all the handles’ updates.
Usage
Once you subscribe an object to the Motion Manager trough a component, that component gains access to a Handle, this can now be used to translate, rotate or even scale the object in question.
You can move an object every frame by using the following code:
private void Update() {
//Keeps the spring stretching by one unit.
handle.Translate(Vector3.up);
}
Last updated
Was this helpful?