Instantiate/Clone object same position

There is a cannonball in the game and as you press the button, it sends three balls that go in sequence, then the number of balls doubles when passing through the place where it says "2X". The problem is that the doubled balls, the cloned balls, travel in different positions. What I want is; cloned balls follow the balls from which they were cloned.

Well, if you instantiate multiple objects at the same position or at positions where they overlap, they would collide with each other and seperation forces would be applied to all of them which may push them off into various directions. You essentially have two possibliities:

  • Make sure you space them out far enough so they never overlap or bump into each other.
  • Or disable the collision between your cannonballs using layermasks.

The second option is usually the better one, though it depends on your game design. When you disable collision between the cannonballs, it means they can simply fly through each other without affecting each other. Of course that means the cannon balls need to be placed on a seperate layer. You can choose which layer can callide with which other layers in the physics settings in the layer collision matrix. You would still allow the cannonballs to collide with your targets / enemies / player / whatever but you would disable collision between objects in the cannonball layer. If you have a lot of cannonballs active at the same time, this can also increase performance.