Git Product home page Git Product logo

inputsystem_warriors's Introduction

Unity Input System - 'Warriors' Example Project

warriors.png

Overview

Description

This Unity example project has been created to demonstrate a variety of tools and functionality with Unity's Input System.

You can learn more about the Input System here: https://unity.com/features/input-system

Input System Demonstrated Scenarios

  • Input Action Control Scheme for basic Player Controls (Directional Axis for Movement, Button press for Attack)
  • Setting up Keyboard and Generic Gamepad bindings to the Control Scheme
    • Tested with the follwing controllers: PlayStation Dualshock 4, Xbox One and Nintendo Switch Pro
  • Instancing multiple Player Controllers for a local multiplayer setup
  • UI Input (Virtual Joystick and Virtual Button) for Touchscreen Controls
  • Runtime switching between Player Control and Menu Control Action Maps
  • UI for rebdining action controls to new buttons and joysticks
  • Displaying connected device data in both Screen Space and World Space UI
  • Callbacks for an Input Device runtime disconnecting and reconnecting

Other Demonstrated Scenarios

  • Universal Render Pipeline's Camera Stacking for Overlay UI
  • Universal Render Pipeline's Scriptable Render Pass for Scene Blur UI Overlay
  • Universal Render Pipeline's Integrated Post-Processing for Tonemapping
  • Nested UI Prefab for Displaying Input Device Information
  • Shader Graph for filtering a Mask Map for Team Colors
  • TextMesh Pro for rendering Screen Space and World Space UI Text
  • Scriptable Object for storing Device Display Colors and Display Names

Project Versions and Branches

Important: The project is in continuous development and improvement! Branches are used as 'time-stamps' for project states for Webinars.

Tech Info

Unity Version

Packages

  • com.unity.inputsystem: 1.0.0
  • com.unity.textmeshpro: 2.0.1
  • com.unity.render-pipelines.universal: 7.3.1

Hardware

This example project has been developed and tested with the following input devices:

  • Keyboard
  • PlayStation 4 Dualshock Controller
  • Xbox One Controller
  • Nintendo Switch Pro Controller
  • Android Samsung Galaxy S9 (Touchscreen for Virtual Joystick and Virtual Button)
  • Mouse (For simulating touchscreen input in the Unity Editor)

Software

This example project was developed and tested on Windows 10.

Usage

This example project is publicly available for you to:

  • Use as a learning resource for the Input System or any other implemented feature & tool
  • Use as a foundation for building your own projects
  • Extract code, assets and information for your own projects

If you do use this example project in some form, please feel free to contact Andy Touch (andyt[at]unity3d.com); he'd love to hear from you about your your experience with it!

Credits & Feedback

This example project is developed by Unity Technologies and has involvement from R&D, Product Management, Product Marketing and Evangelism.

If you have any feedback or questions about Unity's Input System, you are invited to join us on the forums: https://forum.unity.com/forums/new-input-system.103/

If you have any issues, errors or feedback about the example project; you can open an issue on this repository or send an email to andyt[at]unity3d.com

Technical Disclaimers & Known Issues

  • The GameManager script has a toggle for spawning a group of Warriors at Runtime.

    • The number of warriors that is spawned is based on a fixed integer variable (manually set in the Inspector), and is not based on the number of input devices connected and detected.
  • When opening the project for the first time, the Pause Menu Screen Blur Effect might not be rendering.

    • To fix this, locate the UniversalRenderPipeline_Renderer_MenuBlur asset and add the Kawase Blur Render Pass to the Renderer Features

inputsystem_warriors's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inputsystem_warriors's Issues

Setting `Number of Players` to more than one with only one input device throws an error

The following error is thrown per extra player.

ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
UnityEngine.InputSystem.Utilities.ReadOnlyArray`1[TValue].get_Item (System.Int32 index) (at Library/PackageCache/[email protected]/InputSystem/Utilities/ReadOnlyArray.cs:117)
UIMenuManager.UpdateRebindPlayerPanelList () (at Assets/Scripts/UIMenuManager.cs:34)
GameManager.UpdateUIMenuPlayerList () (at Assets/Scripts/GameManager.cs:84)
GameManager.SpawnPlayers () (at Assets/Scripts/GameManager.cs:79)
GameManager.SetupActivePlayers () (at Assets/Scripts/GameManager.cs:47)
GameManager.Start () (at Assets/Scripts/GameManager.cs:30)

GitIgnore isn't working

I'm getting Library and Temp folders in my project when I clone. Also why isn't the project folder at the root?

Package errors

Tried opening in 2020.1 and consistent 'Failed to load Window Layout'
Opened in 20194.4.8f1 and get multiple issues in various packages. (Collab / TMP) First error was related to RectMask2D.padding.

Cant Press C Key when holding D And S Key At the same time after rebinding

Cant Press C Key when holding D And S Key At the same time after rebinding

If I were to rebind the Attack key to the C key on keyboard,
I wouldn't be able to attack again if I were to repeatedly Press the C Key while holding down the D And S Key at the same time.

The C key would only start working again if I were to press it after I released the D And S Key.

Error and Warning when opening project the first time

Hi,
I am quite new into Unity and eager to learn the input system.
So I cloned this repo, switched to branch "V2", installed the Editor version 2019.4.13f1 and opened the project from the Unity Hub.
After some time opening and importing all the stuff, the editor comes up with some info, error and warning messages:

  • [INFO] Rebuilding Library because the asset database could not be found!
  • [ERROR] UniversalRenderPipeline_Renderer_MenuBlur is missing RendererFeatures
    • This could be due to missing scripts or compile error.
    • UnityEngine.Rendering.Universal.ScriptableRendererData:OnValidate() (at Library/PackageCache/[email protected]/Runtime/ScriptableRendererData.cs:55)
  • [WARNING] Assets\Scripts\Utilities\DeviceDisplayConfigurator.cs(87,20): warning CS0472: The result of the expression is always 'true' since a value of type 'bool' is never equal to 'null' of type 'bool?'
  • [INFO] The editor layout could not be fully loaded, this can happen when the layout contains EditorWindows not available in this project
    • UnityEditor.WindowLayout:LoadDefaultWindowPreferences()

And, looking at the hierarchy, it looks so generic and now what I saw on the tutorial video.
image

Edit:
I am using Windows as my OS
I am using Rider as my IDE and did not install Visual Studio.

Did I miss some documentation or some setup video? Would be glad if anyone could give me some advice.

Pause menu orange circle not scaling correctly

In the pause menu, the colored circle with the device number in it doesn't stay round when the window size is changed. You should add an aspect ratio fitter to the Image_PlayerDevice game object, then set the mode to Width Controls Height and the ratio to 1.0.

Warrior speed with Free Camera is dependent on camera angle

There seems to be a scaling issue with the Cinemachine example. If you look more at the horizon and press say the w key, the player will move across a square with about 3 key presses. If you rotate and look more straight down it will take about 10 key presses to go the same distance. Not key to the learning on the Input System, but ...

Type in your language with Gboard

I'm using Gboard to type in Balkan Gagauz Turkish (Handwriting), Arabic (Sudan) (Arabic), Spanish (US) (QWERTY (Ñ)), Arabic (Sudan) (Arabic (2)), Baoulé (Dvorak), Cebuano (Dvorak), Chinese (Traditional) (Cangjie), Cantonese (Handwriting), Classical Syriac (Classical Syriac), Cherokee (Uppercase and Lowercase) (Cherokee), Spanish (US) (Dvorak (ÑÇ)), Assyrian (Syria) (Assyrian), Buryat (Russia) (Buryat), Cantonese (Quick), Basque (PC), Arabic (Oman) (Arabic (2)), Coptic (Coptic), Cantonese (Romanization), Arabic (Mauritania) (Arabic), Assamese (Latin) (Colemak), Arabic (Gulf) (Arabic), Assamese (Latin) (PC), Arabic (Mauritania) (Arabic (2)), Choctaw (Colemak), Bagheli (abc → बघेली), Baoulé (QWERTY), Baoulé (QWERTZ), Cebuano (QWERTY), Cebuano (QWERTZ), Chakma (Chakma), English (US) (AZERTY), Basque (AZERTY), Arabic (Yemen) (Arabic (2)), Baoulé (Colemak), Alphabet (Dvorak), Yao (AZERTY), Spanish (US) (PC), Assamese (Latin) (Dvorak), English (US) (PC), Yao (Colemak), Cantonese (Stroke), Arabic (Oman) (Arabic), Bench (Ge'ez) (Bench), Choctaw (PC), Arabic (Yemen) (Arabic), Bagheli (Bagheli), Arabic (Saudi Arabia) (Arabic), English (US) (Morse code), Chaldean Neo-Aramaic (Chaldean Neo-Aramaic), Albanian (Dvorak), Cantonese (Cangjie), Albanian (Colemak), Balkan Gagauz Turkish (Dvorak), Alphabet (QWERTY), Alphabet (QWERTZ), Arabic (Morocco) (Handwriting), Assamese (Latin) (QWERTY), Spanish (US) (Dvorak), Assamese (Latin) (QWERTZ), Anaang (Dvorak), Basque (Handwriting), Arabic (Morocco) (Arabic (2)), Arabic (Egypt) (Arabic (2)), Anaang (PC), Balkan Gagauz Turkish (Colemak), Albanian (PC), Alphabet (PC), Cebuano (PC), Anaang (Handwriting), Cebuano (Colemak), Spanish (US) (Handwriting), Basque (Colemak), Arabic (Egypt) (Handwriting), Arabic (Morocco) (Arabic), Amharic (Amharic), Abkhaz (Abkhaz), Amharic (Handwriting), Choctaw (Dvorak), Albanian (QWERTY), Albanian (QWERTZ), Albanian (Albanian), Chinese (Traditional) (Handwriting), Balkan Gagauz Turkish (QWERTY), Balkan Gagauz Turkish (QWERTZ), Balkan Gagauz Turkish (PC), Spanish (US) (QWERTY), Spanish (US) (QWERTZ), Assamese (India) (Handwriting), Anaang (QWERTY), Anaang (QWERTZ), Baoulé (AZERTY), Cebuano (AZERTY), Chinese (Traditional) (Pinyin), Amdo Tibetan (Amdo Tibetan), Arabic (Saudi Arabia) (Arabic (2)), Cebuano (Handwriting), Cebuano (QWERTY (Ñ)), Basque (QWERTY (Ñ)), Bagheli (Handwriting), Cherokee (Uppercase Only) (Cherokee), English (US) (Colemak), Choctaw (QWERTY), Choctaw (QWERTZ), Assamese (India) (Assamese), Baoulé (Baoulé), Chinese (Simplified) (Pinyin), English (US) (Handwriting), Albanian (Handwriting), English (US) (Dvorak), Basque (Dvorak), Yao (Dvorak), Chinese (Simplified) (Handwriting), Alphabet (AZERTY), Ahirani (Ahirani), Basque (Dvorak (ÑÇ)), Assamese (Latin) (AZERTY), Chakma (Chakma Compact), Alphabet (Colemak), Bagri (Pakistan) (Bagri), Ahirani (abc → आहिराणी), Assyrian (Iraq) (Assyrian), Chinese (Traditional) (Quick), Assamese (India) (abc → অসমীয়া), Anaang (Colemak), Choctaw (Choctaw), Bagri (Pakistan) (abc → بهاغري), Balkan Gagauz Turkish (Turkish-F), Balkan Gagauz Turkish (Turkish-Q), English (US) (QWERTY), English (US) (QWERTZ), Basque (QWERTY), Basque (QWERTZ), Yao (PC), Albanian (AZERTY), Arabic (Gulf) (Arabic (2)), Church Slavonic (ЙЦУКЕН), Yao (QWERTY), Yao (QWERTZ), Balkan Gagauz Turkish (AZERTY), Yao (Yao), Spanish (US) (Colemak), Spanish (US) (AZERTY), Chinese (Simplified) (9key), Anaang (AZERTY), Chinese (Traditional) (Zhuyin), Chechen (Chechen), Chinese (Simplified) (Stroke), Baoulé (PC), Church Slavonic (Church Slavonic), Choctaw (AZERTY) and Arabic (Egypt) (Arabic). You can try it at: https://gboard.app.goo.gl/Uh9dG

playerInput.devices[0] NullReferenceException: Object reference not set to an instance of an object

playerInput.devices[0] is accessed before the player setup is done. The error is triggered in PlayerController.OnControlsChanged before the SetupPlayer() is called.

NullReferenceException: Object reference not set to an instance of an object
DeviceDisplayConfigurator.GetDeviceName (UnityEngine.InputSystem.PlayerInput playerInput) (at Assets/Scripts/Utilities/DeviceDisplayConfigurator.cs:33)
PlayerVisualsBehaviour.UpdateUIDisplay () (at Assets/Scripts/Behaviours/Player/PlayerVisualsBehaviour.cs:49)
PlayerVisualsBehaviour.UpdatePlayerVisuals () (at Assets/Scripts/Behaviours/Player/PlayerVisualsBehaviour.cs:41)
PlayerController.OnControlsChanged () (at Assets/Scripts/Behaviours/Player/PlayerController.cs:91)
UnityEngine.Events.InvokableCall.Invoke () (at <82c503977c5347cf82f44677f633fcf6>:0)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <82c503977c5347cf82f44677f633fcf6>:0)
UnityEngine.InputSystem.PlayerInput.HandleControlsChanged () (at Library/PackageCache/[email protected]/InputSystem/Plugins/PlayerInput/PlayerInput.cs:1806)
UnityEngine.InputSystem.PlayerInput.OnEnable () (at Library/PackageCache/[email protected]/InputSystem/Plugins/PlayerInput/PlayerInput.cs:1660)

Assets\Scripts\Utilities\DeviceDisplayConfigurator.cs(87,20): warning CS0472: The result of the expression is always 'true' since a value of type 'bool' is never equal to 'null' of type 'bool?'

Testing best practices

hi,

Since this is a demo/sample project, it would be great to show best practices for testing new input system as well.

Input Actions TogglePause missing gamepad

The InputActions_Player, Player Controls, TogglePause, Start [GamePad] action doesn't have the Use in control scheme->GamePad option checked like every other action does. Not a biggie, just not consistent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.