using System.Collections;public class PlayerController : MonoBehaviour{// Using same speed reference in both, desktop and other devicespublic float speed =1000;void Main (){// Preventing mobile devices going in to sleep mode//(actual problem if only accelerometer input is used)Screen.sleepTimeout = SleepTimeout.NeverSleep;}void Update(){if (SystemInfo.deviceType == DeviceType.Desktop){// Exit condition for Desktop devicesif (Input.GetKey("escape"))Application.Quit();}else{// Exit condition for mobile devicesif (Input.GetKeyDown(KeyCode.Escape))Application.Quit();}}void FixedUpdate (){if (SystemInfo.deviceType == DeviceType.Desktop){// Player movement in desktop devices// Definition of force vector X and Y componentsfloat moveHorizontal = Input.GetAxis("Horizontal");float moveVertical = Input.GetAxis("Vertical");// Building of force vectorVector3 movement = new Vector3 (moveHorizontal,0.0f,moveVertical);// Adding force to rigidbodyrigidbody.AddForce(movement * speed * Time.deltaTime);}else{// Player movement in mobile devices// Building of force vectorVector3 movement = new Vector3 (Input.acceleration.x, 0.0f, Input.acceleration.y);// Adding force to rigidbodyrigidbody.AddForce(movement * speed * Time.deltaTime);}}}Read more
using UnityEngine;












