I have a script that moves the object you’re touching to the position of your finger, it’s based on a tag so when i touch an object with the tag all the objects with the same tag move to that position. Is there a way to separate them?
The script
public class ObjectDrag : MonoBehaviour
{
void FixedUpdate()
{
if (Input.touchCount > 0)
{
RaycastHit2D hitInformation = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position), Camera.main.transform.forward);
if (hitInformation.collider.gameObject.tag == "RocketPrefab")
{
Vector3 touchPosition = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
touchPosition.z = -4;
transform.position = touchPosition;
Debug.Log(touchPosition);
}
}
}
}