Hello I am developing a simulator in unity the problem that I have is with the Sprites that would be being tools in the game / simulator, in this case I must use about 8 sprites that simulate being objects which I have to take them and drag them to another object all this in a "touch" for SmartPhones, what happens is that when I take a sprite and pass on another sprite they are absorbed and then I can not separate them becoming a bug. then I show them the code I use for the movement hopefully can help to know what to add to solve this.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class movimiento : MonoBehaviour {
public float speed = 0.1F;
public bool calor = false;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.touchCount > 0)
print(Input.touchCount);
//Gets the world position of the mouse on the screen
Vector2 mousePosition = Camera.main.ScreenToWorldPoint( Input.mousePosition );
//Checks whether the mouse is over the sprite
bool overSprite = this.GetComponent<SpriteRenderer>().bounds.Contains( mousePosition );
//If it's over the sprite
if (overSprite)
{
//If we've pressed down on the mouse (or touched on the iphone)
if (Input.GetButton("Fire1"))
{
//Set the position to the mouse position
this.transform.position = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x,
Camera.main.ScreenToWorldPoint(Input.mousePosition).y,
0.0f);
}
}
}
void OnCollisionEnter2D(Collision2D coll) {
if (coll.gameObject.tag == "cabeza")
calor = true;
Debug.Log ("ouch");
Debug.Log (calor);
}
}