I am starting with Unity in the development of a simulator for Smartphones for both Android and Ios, it is basically a drag and drop of objects to simulate actions. I followed some tutorials of movement of objects and actions but I need this to be touch and from that I could not find anything. Well all this I want to be in a 2D environment, and for the object I use the properties of RigidBody 2D and CirculeCollider 2D
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PlayerController : MonoBehaviour {
public float speed;
public Text counText;
public Text Wintext;
private Rigidbody2D rb2d;
private int count;
void Start()
{
rb2d = GetComponent<Rigidbody2D> ();
count = 0;
SetCountText ();
Wintext.text = "";
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector2 movment = new Vector2 (moveHorizontal, moveVertical);
rb2d.AddForce (movment * speed);
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag ("PickUp"))
{
other.gameObject.SetActive (false);
count = count + 1;
SetCountText ();
}
}
void SetCountText ()
{
counText.text = "count: " + count.ToString ();
if (count >= 7)
{
Wintext.text = "you win!";
}
}
}
So far that's what I have for the movement but how can I do it to recognize the touch of cell phones?