CrossPlatformInputManager.GetButtonDown is a function in Unity's Input System API that checks if a specific button/key is pressed down in the current frame.
Example 1: Let's say we want to move the character when the user presses the 'W' key. To do this, we can use the code:
if (CrossPlatformInputManager.GetButtonDown("Jump")) { characterController.Move(new Vector3(0, jumpSpeed, 0)); }
This code checks if the 'Jump' button/key was pressed down in the current frame using the CrossPlatformInputManager and moves the character upwards if it was.
Example 2: Another example can be using CrossPlatformInputManager.GetButtonDown to shoot a bullet when the user clicks on the screen/taps on the screen. For this we use:
if (CrossPlatformInputManager.GetButtonDown("Fire1")) { shootBullet(); }
This code checks if the 'Fire1' button/key was pressed down in the current frame using CrossPlatformInputManager and shoots a bullet if it was.
The CrossPlatformInputManager package/library is included in the Unity Standard Assets package which can be downloaded from the Asset Store in Unity.
C# (CSharp) CrossPlatformInputManager.GetButtonDown - 30 examples found. These are the top rated real world C# (CSharp) examples of CrossPlatformInputManager.GetButtonDown extracted from open source projects. You can rate examples to help us improve the quality of examples.