Finding a gameobject during collision

So for the block breaker section I have it set so that after destroying a block there is a chance of dropping a power up and im mostly questioning if I should have the newly spawned powerups Look for the paddle/ball upon collision with the Paddle(being picked up by player) or just at the Start of it being spawned.

The reason I want to do it at collision is because it wouldn’t have to find the paddle/ball if the player didnt pick up the powerup which is good for optimization i think, is there any issues doing it this way though?

I think a good rule of thumb is not to worry about optimization until it becomes a problem. In a small game like this just getting to understand how to make a game is good enough. Later you worry about what is called Big-O notation which is where you look at what causes issues and what type of impact a certain portion of your code actually has on your program.

Fixing a section of code that is called a handful of times is a waste of time. Fixing a piece of code that gets called or loops every update that maybe some you want to look at. As you get better and start to understand why and where you should implement different design patterns is when you will really start to understand when, why, where to optimize. Till then you will likely spend time doing something that makes little impact when you could have used that time to learn what would really help at this moment.

It is also a fact that failing is the best route to success. Fail lots and Fail fast as each failure brings you a step closer to a success. You will see with a failure what you could have done better and remember not to that the next time. I have failed big and learned big several times, happy for it. Don’t be afraid to fail. Try it, Do it, review it, and then REFACTOR! lol. This is my motto.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.