The Why
What Benproductions is trying to point out is that the CharacterController is one component that can be added to an object, and only handles the physics, not the movement. When you add one of the prefab character controllers (First Person Controller or Third Person Controller) to your game, you get an object with CharacterController attached, plus a CharacterMotor script and either the FPSInputController or ThirdPersonInputController (along with ThirdPersonCamera for the Third Person controller). These input controllers are what determine how the character actually moves. They direct the CharacterController to move, it merely handles collisions and such. So to move to a platform type game, you remove the current input controller script and add the PlatformInputController script. So if you wanted to handle different controls for android, you would either modify one of these input controller scripts, or roll your own with whatever controls you want for the mobile.
The How
For the FPSInputController script and the PlatformInputController, one of the first lines in Update is something like:
var directionVector = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
Just change that line to use whichever parts of Input.accelerometer you want to use. A simple version that I did is just changing it to
`
var v = new Vector2(Input.acceleration.x, Input.acceleration.y).normalized;
var directionVector = new Vector3(v.x, v.y, 0);
`
That requires you to play with your tablet flat on a table, and doesn’t allow any real zero point, so you always move. You would probably want to implement something in your interface to offset the acceleration vector to allow your player to hold the tablet however they wanted. You would probably also want to change the next lines, that check to see if the directionVector magnitude is > 0, to be something other than 0 to allow a “dead zone”.
To do touch will be slightly more complicated, and will depend on how you want to do it. The simplest way I can think of is to set a static Vector2 called AimPoint in your InputController class that is accessible from other scripts. Then whenever you detect a touch on your game field, set AimPoint to the world coordinate. Then the inputController would calculate directionVector as an offset from the current position to the AimPoint. This should have your character moving toward wherever you touch.
For the third person controller, it’s more complicated. I haven’t dug into the code completely, but it looks like it is slowly applying your direction changes and such to get smooth cornering. But it still boils down to changing the input axes (plus however you want to handle jumping). Update calls UpdateSmoothedMovementDirection, which then sets v to Input.GetAxisRaw(“Vertical”) and h to Input.GetAxisRaw(“Horizontal”). Just change those to set to either an offset/normalized vector to your touch location, or to the appropriate components of the acceleration vector.