Created
September 2, 2025 10:15
-
-
Save unitycoder/d0c25b07fc2d6974925955176b74ae89 to your computer and use it in GitHub Desktop.
Revisions
-
unitycoder created this gist
Sep 2, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ // example script from Unity about this issue https://issuetracker.unity3d.com/issues/the-new-input-system-is-not-detecting-clicks-when-under-heavy-load using UnityEngine; // Use action set asset instead of lose InputActions directly on component. public class SimpleController_UsingActionAsset : MonoBehaviour { private SimpleControls m_Controls; Vector3 m_MovementSum = Vector3.zero; public float speed = 10f; public void Awake() { m_Controls = new SimpleControls(); m_Controls.gameplay.move.performed += (callbackContext) => Sum(callbackContext.ReadValue<Vector2>()); } public void Update() { var move = m_Controls.gameplay.move.ReadValue<Vector2>(); if (move != Vector2.zero ) { // Calculate sum for the callback's and apply that here. Move(move); m_MovementSum = Vector3.zero; } else if (m_MovementSum != Vector3.zero && m_Controls.gameplay.move.WasPressedThisFrame()) { Move(m_MovementSum); m_MovementSum = Vector3.zero; } } private void Move(Vector3 move) { transform.Translate(move * speed * Time.deltaTime); } private void Sum(Vector2 direction) { m_MovementSum += new Vector3(direction.x, direction.y, 0); } }