So basically I have a Collision.
In one of the colliding objects, I save a reference to the other and at the same time, I set its parent to the same collider.
void OnTriggerEnter2D(Collider2D collision){
saveObject = collision.transform.gameObject;
saveObject.SetParent(transform);
}
The second time I enter OnTrigger Enter2D with another object, saveObject is null.
If I remove, SetParent(), the object is still the collision-object as expected.
Basically, I want to remove the previous object, before adding the new one.
Can anybody explain why this happens, and how to circumvent it?