How to make a configurable camera with the new Unity Input System
Now that there’s some initial code, it’s time to do a test run to see how it’s behaving. To do this, you’ll need to tell the Input System where to route the actions.
This can be done by adding the Player Input component to a game object in the scene:
CameraController.OnMove()
That’s it! Push play on your game and move the camera around.
While we will use the “Invoke Unity Events” notification behavior, it is important to understand the different options and how they behave:
- Send Messages: This will send input messages to all scripts located on this game object only.
- Broadcast Messages: In addition to sending input messages to components on the same game object, it will also send them down the child hierarchy.
- Invoke Unity Events: Invokes a UnityEvent for each type of message. The UI can be used to setup callback methods.
- Invoke C Sharp Events: Similar Invoke Unity Events, but instead are C# events that must be registered via callbacks in your scripts.
You can read more on the different event types as well as how to set them up here.