Object pool system on Brick Breaker game

Hey,
I got this object pool system to work. The problem is that I really dont have any ideas how to position these objects I have loaded to memory. For example I have coins that should come from brick I hit with the ball. How do I get position from this brick to move my coin there?

you detect the “hit” from your ball with the brick, or? Then use this timing and instantiate the coin at ball.position. It’s not that hard to figure a way out, as it’s just Instantiate at position XY, but what you need is finding the right condition or time when you want to instantiate that coin. For example at the time when the ball hit’s the brick, or when the ball is x meters away from something, or whatever, you’re going to check for this event, so just use it also for your coins, that’s it :wink:

okey thanks SlyRippe,

so I dont want to Instantiate anything. the prefab (coin) is allready loaded in the scene but inactivated. So when I hit a brick with the ball one of the loaded coins becomes activated and appears to the screen. But I cant figure out how to get that position from the brick i just hit to tell the coin to start falling from that spot

Presuming you are destroying your bricks when they are hit you could always use OnDestroy().
So basically you have your brick which will contain a reference to a coin(Instantiating would have been easier for this), so every brick will need to have reference to a coin somewhere on screen.

Then some code along these lines attached to the brick will do the trick.

void OnDestroy()
{
 //myCoin is the coin to be positioned by the brick. 
 //it would probably be worth putting an enabler script inside the instance of myCoin so that you can control rigidbodies etc. 
  myCoin.transform.position = transform.position; 
  myCoin.enabled = true; 
}