I have a set of objects placed on the same layer where all the objects are invisible except one. When I drag an object into a selected area, the current dragged object gets destroyed, and the object should be loaded in the same position. I have added polygon collider and rigid body (SET FIXED ANGLE) to all the objects. The problem here is: when I drag the object to the selected area, the object gets destroyed, and the next object gets loaded, but the position varies when the object is loaded.
public Vector3 ObjectSpawnPosition1;
public GameObject obj1;
void OnCollisionEnter2D(Collision2D col) {
if (col.gameObject.name == "SemiCircle") {
if (Input.GetMouseButtonUp(0)) {
scoreCalculate.currentScore += 10;
Destroy(gameObject);
Instantiate(obj1, ObjectSpawnPosition1, Quaternion.identity);
obj1.renderer.enabled = true;
}
}
}