Hi :), how to create a gameobject with the 2d collision of two game objects which are the same?

I want to create a new gameObject after two gameobjects collided, for example there are two balls in the mid-air they collided and a bigger boll is generate

Please help me

I assume your ball is a prefab? Just instantiate the prefab at the location of the collision.

Alternatively, you can destroy one ball while increasing the scale of the other.

Either way, make sure to use a great explosion sound and particle effects :slight_smile:

1 Like

Thanks for answering :slight_smile:
but the problem in that the script that instantiates the bigger ball are in both 2 smaller ball and when they collide their “OnTriggerEnter2D” are Triggered at the same time and two bigger balls are instantiated

In your OnTriggerEnter2D just have each object call GetInstanceID on itself and the other object. Have each of the colliding objects only instantiate the bigger ball if the other’s instance ID is less then their own. One object’s instance ID will always be less than the other and one instance ID will always be greater, so only one of the two objects will ever instantiate the bigger ball.

3 Likes

Thanks you so much, :smile:, you are great