I have a game where i want to make if i place the 1st object on the second object it goes back to it’s original place, but whenever i try to place it on the second object they both go back to their old places
here is the 1st object code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerUndoer : MonoBehaviour
{
public GameObject GO;
void OnCollisionEnter(Collision collision)
{
if (collision.collider.tag == "Bounce")
{
GO.transform.position = new Vector3(-5.8f, -3.85f, 0);
}
}
}
here’s the 2nd object code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerUndoer2 : MonoBehaviour
{
public GameObject GO2;
void OnCollisionEnter(Collision collision)
{
if (collision.collider.tag == "Bounce")
{
GO2.transform.position = new Vector3(-4, -3.85f, 0);
}
}
}