Offset

An offset is the amount or distance by which something is out of line.

Description

As the quote says, an offset is just the distance out of line, and that is exactly what this component does, move something from its initial state.

Changes in the position and rotation of an object based on the player's current state is what the Offset component is best for.

How does it work?

Every frame the State Handler sends the State Data, and as long as it isn’t null (which shouldn’t be possible,) the Offset component adds a translation and rotation force as defined in that data.

Tweaking the effect

To set a position and rotation for an object, you can change the State Data field in the States Component for that object.

The reason an object's position and rotation are not a variable inside the component is that frankly, it would be too limiting; when changing the value inside the script, that value is final, and can’t change easily anymore.

Instead, when setting a value for each state, the spring system can easily change to a new value when the player's state changes, which means we can have things like the camera moving down when the player crouches.

Last updated

Was this helpful?