Skip to content

3 – AnalogInputEvent component

AnalogInputEvent listens to one analog Input Action and fires a UnityEvent<float> every time the value changes. The value runs from 0 to 1, whatever the board’s resolution.

In this tutorial a potentiometer on A0 controls the brightness of a spotlight.

  1. Create an empty GameObject, for example Knob.
  2. Add Component > search AnalogInputEvent.
  3. In Action Reference, pick the A0 action from your generated Input Actions asset.

The component enables the action for you. You don’t need a PlayerInput component.

The package includes a small example script, LightMultiplier, in Assets/SerialInputBridge/fromtutorialvideos/. It sets a light’s intensity to value × multiplier.

  1. Add a Spot Light to the scene.
  2. Add the LightMultiplier component to any GameObject and drag the spotlight into Spot Light. Leave Multiplier at 100 or adjust to taste.
  3. Back on the AnalogInputEvent, click + under On Value Changed.
  4. Drag the GameObject with LightMultiplier into the slot and choose LightMultiplier > SetIntensity from the Dynamic float section at the top of the list.

Turn the knob. The spotlight dims and brightens.

Any public method with a single float parameter shows up under Dynamic float:

using UnityEngine;
public class RotateWithKnob : MonoBehaviour
{
public float maxAngle = 270f;
// Hook to AnalogInputEvent > On Value Changed (Dynamic float)
public void SetValue(float value)
{
transform.localRotation = Quaternion.Euler(0f, value * maxAngle, 0f);
}
}

React to a button with DigitalInputEvent →