Hi
The other day i made a player movement script and i just wanted to know if this definitely works (like moving with the player’s finger) for android phone.(because unity remote 5 doesn’t work)
thanks.
public float Speedup;
public GameObject scenemanager;
public float playerSpeed = 1400;
public float directionalSpeed = 20;
public AudioClip scoreup;
public AudioClip damage;
// Use this for initialization
void Start () {
InvokeRepeating(“SpeedUp”, 10, 5);
}
// Update is called once per frame
void Update () {
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
float moveHorizontal = Input.GetAxis(“Horizontal”);
transform.position = Vector3.Lerp(gameObject.transform.position, new Vector3(Mathf.Clamp(gameObject.transform.position.x + moveHorizontal, -2.5f, 2.5f), gameObject.transform.position.y, gameObject.transform.position.z), directionalSpeed * Time.deltaTime);
#endif
GetComponent().velocity = Vector3.forward * playerSpeed * Time.deltaTime;
//MOBILE CONTROLS
Vector2 touch = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10f));
if (Input.touchCount > 0)
{
transform.position = new Vector3(touch.x, transform.position.y, transform.position.z);
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == “scoreup”)
{
GetComponent().PlayOneShot(scoreup, 1.0f);
}
if (other.gameObject.tag == “triangle”)
{
GetComponent().PlayOneShot(damage, 1.0f);
scenemanager.GetComponent<App_initialize>().GameOver();
}
}
public void SpeedUp()
{
playerSpeed+=Speedup;
}