I'm creating a quick game for android, and I'm just wondering how can I translate this code I wrote (which works perfect with keyboards controls)
public float rotationSpeed = 450f;
public float walkSpeed = 5;
public float runSpeed = 8;
private Quaternion targetRotation;
private CharacterController controller;
public Camera viewCamera;
void Start ()
controller = GetComponent<CharacterController>();
void Update ()
void ControlWASD ()
Vector3 input = new Vector3 (Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
if (input != Vector3.zero)
targetRotation = Quaternion.LookRotation(input);
transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle(transform.eulerAngles.y, targetRotation.eulerAngles.y, rotationSpeed * Time.deltaTime);
Vector3 motion = input;
motion *= (Mathf.Abs(input.x) == 1 && Mathf.Abs(input.z) == 1)? 0.7f:1;
motion *= (Input.GetButton("Run"))?runSpeed:walkSpeed;
motion += Vector3.up * -8;
controller.Move(motion * Time.deltaTime);
Into Android controls. I'm stuck finding a lot of 2D content, but not working in 3D. Any ideas are welcome.
Thanks in advance
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
150 People are following this question.
Tap Control on Android
Touchscreen controller for airplane game
Differentiate swipe from tap android
Is there a way to toggle between active characters via a GUI?
Dual joystick Position always resets on playing