๐ŸŽฎInput System

In this section you will learn about the property system.

Overview

The FPS Animation Framework introduces a standalone input property system. The idea is that you can define custom properties in the Input Config asset and then use them in runtime:

Once the game starts, the User Input Controller will register all the properties from the Input Config, so they can be modified in runtime. So far only 4 types are supported:

  • Int

  • Float

  • Bool

  • Vector4

Tip: floats have an interpolation feature. Set the interpolation speed to something higher than 0, and the system will automatically interpolate the value in realtime. This is a useful function for weights, when you want to smoothly disable/enable some animation features.

The framework provides a default Input Config, which you can use as a starting point:

To get or set values in runtime, you can use these methods:

// Where T is your custom type.

public virtual T GetValue<T>(int propertyIndex)
public virtual T GetValue<T>(string propertyName)

public virtual void SetValue(string propertyName, object value)
public virtual void SetValue(int propertyIndex, object value)

While it is possible to get/set a property by name, it is recommended to use the property index instead. You can get the property index in the Start() event like this:

private UserInputController _inputController;
private int _myPropertyIndex;

private void Start()
{
    _inputController = GetComponent<UserInputController>();
    _myPropertyIndex = _inputController.GetPropertyIndex("yourPropertyName");
}

Now let's learn what parameters control what in the default Input Config.

Default Properties

Float properties

  • PlayablesWeight - controls the weight of the custom animations.

  • StabilizationWeight - controls the stability of the upper body. If set to 1 - fully stabilized, if 0 - overidden locally, stability is not guaranteed.

  • LookLayerWeight - controls the weight of the Look Layer.

  • LeanInput - defines the lean angle. Used in the Look Layer.

  • Aiming Weight - an internal parameter, that defines the weight of the ADS. It is modified in the Ads Layer, and used in the View Layer.

Bool properties

  • IsAiming - defines the current state of aiming.

  • UseFreeAim - whether we use the deadzone mechanic or not. Only used in by the Sway Layer.-

Vector4 properties

  • MouseInput - defines accumulative mouse look input. X is the yaw rotation, while Y is the pitch rotation. Z and W components are not used. Primarily used by the Look Layer.

  • MouseDeltaInput - defines the delta mouse look input. X is the yaw delta rotation, while Y is the pitch delta rotation. Only used by the Sway Layer.

  • MoveInput - defines the current movement input. X represents the horizontal movement, and Y - horizontal. Used by the Sway Layer.

Last updated