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. Dismiss Notice

Question Is there sth like "Event.current.isAxis?"

Discussion in 'Scripting' started by Aviation_Simmer, Dec 17, 2022.

  1. Aviation_Simmer

    Aviation_Simmer

    Joined:
    Aug 30, 2021
    Posts:
    110
    Hi there! I want a keybinding system. After researching for way to many hours, I dont really know if its even possible... For my flightsimulator, you should be able to set the axes of the controllers to do things. but how can I do that?

    This is how I did it for keys:
    Code (CSharp):
    1.     void OnGUI()
    2.     {
    3.         Event e = Event.current;
    4.         if (e.isKey)
    5.         {
    6.             Debug.Log("Detected character: " + e.keyCode);
    7.             //it displays the key you press.
    8.         }
    9.     }
    Now How can I display axes from controllers/joysticks?

    Thanks for help, Jonas
     
  2. Lekret

    Lekret

    Joined:
    Sep 10, 2020
    Posts:
    272
    Use unity official Input System package. It has built in crossplatform input, rebinding, everything you need. Using Event.current to determine stuff isn't something I would use honestly.