The MultiTransform module makes it possible to have multiple scripts affect the same transform, without conflict. It provides logic scripts to include in your own behaviours, or a MonoBehaviour handling this functionality.
Within DuskModules, MultiTransform is mainly used by effect modules, allowing multiple effect behaviours targetting the same transform object to work together flawlessly.
This module adds the scripting definition symbol MULTI_TRANSFORM to your project. MultiTransform has no dependencies.
The standard Transform behaviour in Unity contains one value for position, one for rotation and one for scale. Useful if there is only one script controlling those values. But if you have multiple scripts that each need control over transform values, then conflicts quickly arise. An example where this happens is when multiple effect behaviours, like one for a 'wobble' effect and one for 'growing to 1 from 0', both affect the scale of the object.
This module solves this problem by providing 3 logic classes, each taking control over position, rotation and scale respectively. The logic classes keep a list of transform values (Vector3 for position and scale, Quaternion for rotation), which are combined and applied to a target transform behaviour each frame.
The MultiTransformer is a behaviour you can add to any GameObject which contains all 3 logic classes. It provides a single and easy to use access point for applying multiple transform values to a single transform.
To use it, have any script reference it and call the methods:
AddNewPosition(), which returns a MultiPositionValue.
AddNewRotation(), which returns a MultiRotationValue.
AddNewScale(), which returns a MultiScaleValue.
Each returned value is a wrapper for a Vector3 or Quaternion. Simply update the values within them in order to affect the MultiTransform's transform. They act as referencable Vector3's and Quaternions.
In the LateUpdate of the MultiTransformer, all current position, rotation and scale values are combined and applied. This means the actual modification of the transform values occurs after all gameplay code has run for that frame. Because of this, it's recommended to use MultiTransform only for visual effects, that have no effect on player gameplay beyond making it look good.
Don't forget to add using DuskModules.MultiTransform; to any script using the module.