(I) IMPORTANT: Understanding this section is vital to using Platformer PRO.
This section covers the basics of controlling a Character via an Input. An Input is any concrete implementation of the abstract Input class.
To quickly add an input to your game:
- Create an empty GameObject in your Scene.
- Select your newly created GameObject
- Press the AddComponent button.
- Add the StandardInput component to your GameObject (you can quickly find the component by typing its name).
- (Optional) You may want to press the Clear Preferences button on the Standard Input to ensure there are no Player Preferences set.
Overview of Input Classes
The following Input classes come with Platformer PRO:
|Standard Input||The standard input is a flexible and powerful input class for desktop and consoles. Most games that aren't for mobile will use the StandardInput.||Standard Input|
|Basic Touch Input||A simple input for touch devices.|
|Unity Input||An Input class that allows you to use standard Unity input definitions.|
|Buffered Input||A special input class, which buffers the input from another input to provide more sensitive controls. You cannot use a buffered input by itself.||Buffered Input|
|Multi Input||An input class which provides a single interface in front of multiple other inputs. For example it allows you to have both keyboard and joystick configured simultaneously.||Multi Input|
How a Character find its Input
Although you can directly assign an Input to a character using the character s Input property if this is not assigned the character uses the following process to find an Input:
- Find all active Inputs in the scene.
- If none are found log an error.
- If one is found assign it.
- If two or more are found:
- Try to find a Buffered Input and assign it.
- If no Buffered Input is found, log a warning and assign the first Input found.
Buttons like Jump and Run, Up and Down, are self explanatory but you may also need extra buttons in your game for things like using items or attacking. Action buttons allow you to define any number of arbitrary buttons.
When used in other components action buttons are identified by their array index. So for example if you define two buttons as follows:
And you want to use the second button (V) to attack you would set the action button index of the Attack to 1.
Tip: As with C# arrays are zero-indexed. In other words the first action button has the array index of 0.
Using Third-Party Input Systems
You can use other Input systems with Platformer PRO by wrapping them in your own implementation of the abstract class. For example if you were using cInput 2 (a popular third party Input asset) you might write a class as follows:
public class cInputWrapper : PlatformerPro.Input
// And so on for the rest of the methods ...
Note that the Input class defines a number of abstract methods which allow in-game customisation of input. In many cases if you are using a third-party system these may not be applicable. Suggested implementation in these cases is something like:
|override public KeyCode GetKeyForType(KeyType type, int keyNumber)
Debug.LogError ("This Input does not allow for in game control configuration.");