<p>Unity InputSystemã§ãã¼ã®å²ãå½ã¦ã夿´ããæ¹æ³ã§ããä»åã¯Player Inputã®Create Actionsã§çæãããInput Actionsã®Action Maps ->; Player ->; Actions ->; Fire ã« Space [Keyboard]ã追å ãã¦ãããå®è¡å¾ã«ã¹ã¯ãªãããã夿´ãã¾ãã</p>



<p>ããã±ã¼ã¸ããã¼ã¸ã£ã¼ããInput Systemãã¤ã³ã¹ãã¼ã«ãã¾ãã</p>



<p>ãªãã¸ã§ã¯ã(GameObject)ã« Player Input ã³ã³ãã¼ãã³ãã追å ãã¾ããCreate Actionsãã¿ã³ãã¯ãªãã¯ãã¦Input Actionsã使ãã¾ããinputactionsãã¡ã¤ã«ã鏿ã㦠Edit asset ãã¿ã³ãã¯ãªãã¯ãã¾ãã</p>



<p>Action Maps ->; Player ->; Actions ->; Fire ã鏿ãã¾ããAll Control SchemesãKeyboardMouseã«å¤æ´ãã¾ããFireã®+ãã¿ã³ãã¯ãªãã¯ãã¦Add Bindingã鏿ãã¾ããPropertiesã®Binding &#8211; Path ãã¯ãªãã¯ãã¾ããKeyboard ->; By Location of Key (Using US Layout)ã®Spaceã鏿ãã¾ããUse in Control Scheme ã® Keyboard&;Mouseããã§ãã¯ãã¾ãã</p>



<p>ã¹ã¯ãªããã追å ã夿´ãã¾ãã以ä¸ã®ããã«å¤æ´ãã¾ããã¯ã©ã¹ã®å®£è¨ã¯çç¥ãã¦ãã¾ãã</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""> 
 public PlayerInput playerInput;
 private InputAction fireInputAction;
 private InputBinding keyboardInputBinding;

ã// Start is called before the first frame update
 void Start()
 {
 playerInput = GetComponent<;PlayerInput>();

 fireInputAction= playerInput.actions["Fire"];
 // keyboardInputBinding= fireInputAction.bindings[5];
 fireInputAction.ApplyBindingOverride(new InputBinding() { path = "<;Keyboard>/space", overridePath = "<;Keyboard>/q" });
 // fireInputAction.ApplyBindingOverride(5, "<;Keyboard>/q");
 // keyboardInputBinding = fireInputAction.bindings[5];

 }

 // Update is called once per frame
 void Update()
 {

 }

 public void OnMove(InputValue value)
 {
 var wasd = value.Get<;Vector2>();
 }

 public void OnLook(InputValue value)
 {

 }

 public void OnFire()
 {
 // Spaceãã¼ã®ä»£ããã«Qãã¼ãæ¼ãã¨ä»¥ä¸ã®ã³ã¼ããå®è¡ããã¾ã
 }
</pre>



<p>keyboardInputBinding.path ã &#8220;<;Keyboard>;/space&#8221; ãã&#8221;<;Keyboard>;/q&#8221; ã«å¤æ´ããã¾ããqã¯å¤§æåãå°æåã©ã¡ãã§ãæ§ããªãããã§ããkeyboardInputBinding.groupsã¯Keyboard&;Mouseã¨ãªãã¾ãã</p>



<p>ApplyBindingOverrideã¯InputBindingã¯ã©ã¹ã使ããæ¹æ³ã¨indexãæå®ããæ¹æ³ã¨ããã¾ãã</p>



<p>Actionsã®Fireã¨ããååããã®ã¾ã¾OnFireã¨ããã¡ã½ããã®ååã«ãªãã¾ãã</p>



<p>éç¨ã¨ãã¦ã¯UIã«Canvasã使ãã¦ã¤ã³ã¿ã©ã¯ã·ã§ã³ã³ã³ãã¼ãã³ããå©ç¨ãã¦å¤æ´ãããã¨ã«ãªãã¾ããã»ãã®ã²ã¼ã ã§ã¯å·¦å³ã«ç¢å°ãã¿ã³ãé ç½®ãã¦ã¯ãªãã¯ãã¦é¸æãããããã¼å ¥åãåãä»ããããã¦å¤æ´ãã¦ãã¾ãã</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Unityã®æ°ããå ¥åã·ã¹ãã InputSystemã使ã£ã¦ã¿ã</p><cite>https://gametukurikata.com/basic/inputsystem</cite></blockquote>



<p>ãã¡ãã®ãµã¤ããåèã«ãªãã¾ãã</p>



<p></p>

- 5年 ago
kawano
Unity Input System
Related Post
-
Unity Scriptable Render Pipeline
スクリプタブルレンダーパイプラ…
-
Unity ‘Object at index 0 is null’ error
Unityで Object a…