Unity — ControlFreak2 Swipe Controls

Just putting a note here because I kept forgetting how to setup swipe controls using ControlFreak2. It’s a really good mobile (and desktop) controls library for Unity, but if you forget how to use it, it won’t exactly be a smooth ride to re-learn its over-complex looking settings.

Key bindings

To start, right click in Hierarchy and select Control Freak 2 > Total Package (Event System + Rig + Gamepad Manager).

Using it in script

To use it in script, start by importing it using:

using ControlFreak2;
if ( CF2Input.GetKeyDown ( KeyCode.UpArrow ) 
|| CF2Input.GetKeyDown ( KeyCode.W ) ) {
// Move up
}
if ( CF2Input.GetKeyDown ( KeyCode.DownArrow )
|| CF2Input.GetKeyDown ( KeyCode.S ) ) {
// Move down
}
if ( CF2Input.GetKeyDown ( KeyCode.LeftArrow )
|| CF2Input.GetKeyDown ( KeyCode.A ) ) {
// Move left
}
if ( CF2Input.GetKeyDown ( KeyCode.RightArrow )
|| CF2Input.GetKeyDown ( KeyCode.D ) ) {
// Move right
}

Software developer, web/mobile dev evangelist. Enthusiast of: NodeJS, React, Redux, Flutter, Unity, Golang, Django, etc.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store