So how can i make a script ( iOS/Android ) for touching the screen ?
I searched on youtube,on unity,nothing …
I want to make a script ( for now ) that when i touch the screen an object will move.How do i do that ? I tried like this ( followed tutorials on internet ) but i dont quite understand what happens with the input.gettouch or touchphase etc …
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public Rigidbody2D obiect;
public float speed = 50f;
public bool touch = Input.GetTouch(0) ;
// Use this for initialization
void Start () {
obiect = gameObject.GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
if (touch=TouchPhase.Moved && Input.touchCount>0)
{
obiect.AddForce(Vector2.down * speed);
}
}
}
Tried to make input.gettouch(0) a bool because i get an error with the && between bool and touch but this doesnt work too.
Also,how can i make a script that my character is moving to left/right depending on my finger movement ? cant find that anywhere.All i found was old tutorials on youtube with buttons,not touching the screen.