Add an Action to a New Script

How to add a Player Action to a New Unity Script

Add an action to a new script

  • Add a new Axe in the Axes list, by pressing the button Add New Axe or Add Action.

  • Set the name that you want for that action and a keyboard button.

  • Declare an inputManager variable type (if the script doesn’t contain it yet), get the main inputManager in the scene, and add the above functions to the script, setting the type of press button and the action that you want to check. In this example you can see it better:

if (input.checkInputButton ("newAction", inputManager.buttonType.getKeyDown)){
//KeyDown, key pressed, call the need function
}
if (input.checkInputButton ("newAction", inputManager.buttonType.getKey)){
//Key, key held call the need function
}
if (input.checkInputButton ("newAction", inputManager.buttonType.getKeyUp)){
//KeyUp, key released, call the need function
}

Last updated