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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question How do I add other inputs/actions when using the Starter Assets First Person Controller?

Discussion in 'Input System' started by edhalsim, Aug 19, 2023.

  1. edhalsim

    edhalsim

    Joined:
    Dec 19, 2015
    Posts:
    15
    Hi,
    I'm using the Starter Assets First Person Controller and I want to add other inputs, such as pressing the "P" key to perform another action. I've looked at several videos, but I don't see anything on the proper way to do this. I assume you would copy code from say "jump" in StarterAssetsInputs, but then would you update the FirstPersonController script directly, which ideally I'd like to avoid, or create a new script? What code is needed?
    Thanks for your time.
     
  2. edhalsim

    edhalsim

    Joined:
    Dec 19, 2015
    Posts:
    15
    No one knows how to do this?
     
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,941
    I've never looked at the starter assets, but one would imagine you can look at the code to see how things work, and emulate the patterns in your own components.

    Depending on whether it's using the new Input system or not, you may need to update whatever means of interfacing with the system as well.
     
  4. edhalsim

    edhalsim

    Joined:
    Dec 19, 2015
    Posts:
    15
    I figured it out. I finally RTFM; there's a PDF attached to the Starter Assets that provides direction. Basically you need to:
    1. 1. Add the new input to the input system (e.g., Keyboard "Y" key)
    2. Update StarterAssetsInputs.cs and copy all code for an existing function (e.g., sprint) to your action.
    3. In FirstPersonController.cs you can then check for "_input.<your action>" and if it's true you know the user performed the action.