Using cInput to Control Your Game

Once your inputs are defined in your setup script, you'll probably want to use those inputs to control your game. This is very simple to do using cInput's GetKey(), GetKeyDown(), GetKeyUp(), and GetAxis() functions, which all work in the same way as Unity's Input class functions of the same name.

For example:

// this will only trigger once each time the "Jump" button is pressed if (cInput.GetKeyDown("Jump")) { // jumping code here } // this will trigger repeatedly while the "Shoot" button is held down if (cInput.GetKey("Shoot")) { // shooting code here } // this will only trigger once each time the "Grenade" button is released if (cInput.GetKeyUp("Grenade")) { // throw grenade code here } // movement based on analog or virtual analog axis float dx = cInput.GetAxis("Horizontal");

If the above code seems familiar, it should! One of the main tenets of cInput was to make its syntax as similar to Unity's Input class as possible.

results matching ""

    No results matching ""