Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Equivalent to Simple Camera Controller

Discussion in 'Input System' started by b3m9, May 17, 2020.

  1. b3m9

    b3m9

    Joined:
    Apr 30, 2020
    Posts:
    2
    Hi, I am looking for an equivalent to the Simple Camera Controller script from the URP demo scene (a simple free fly controller) for the new input system. Any help/example highly appreciated.
     
  2. TubbyStubby

    TubbyStubby

    Joined:
    Nov 28, 2019
    Posts:
    6
    You can create new action map with say movement action with its respective bindings. Then reference those maps and use the events to do something in your case moving the camera.
    something like this-
    upload_2020-5-17_20-18-1.png
    Make sure to create script when you create new Input Action.
    and then to use these bindings
    Code (CSharp):
    1. public class SomeController : MonoBehaviour
    2. {
    3.     Controls controls;
    4.     Private void OnEnable() => controls.Enable();
    5.     Private void OnEnable() => controls.Disable();
    6.     void Awake() {
    7.         controls.Player.Move.performed += ctx => MoveCamera(ctx.ReadValue<Vector2>());
    8.     }
    9.     void MoveCamera(Vector2 value) {
    10.         //some movement logic
    11.     }
    12. }
    Since you have controller script you can change the inputs in it. or you can check out this video or checkout this thread.