2D Game: Stop bullet on Platform Collision


An extra mechanic I wanted to add was bullets destroying on platform collision, I did this because, it was super unfair to the player if bullets went through walls and could hit them and make a game over, this would infuriate players if done incorrectly, but if done correctly, could make the game more fun, but for my game, I wanted players to get into cover.

I originally tried to script it into the bullet itself by gathering the reference from the platform and specifically target the platform itself and not the collision boxes, but unfortunately no matter how hard I searched and tested, I could not get this working. Then I had an amazing thought; because the platform has got a collision box and the bullet also does, but the bullet is at the same location, why don’t I target the platform in the platform blueprint. This was exactly what I needed, I made the code and it worked and it had way less steps to it. All I had to do was begin an EventOnComponent BeginOverlap (Platform) and then on collision cast to the bullet and delete the bullet itself.

From this I learnt that sometimes to get mechanics to work you need to make more mechanics, but this could get out of hand, so try to focus on mechanics that don’t require too many mechanics in. There isn’t really a way to be certain it needs a lot of mechanics, but maybe trying to think of as many ways as possible the mechanic can be used, even if you don’t use them, might tell you how many mechanics roughly will be needed to make it work in the way you want to.

Example a gun: shooting, recoil, reload, ammo, power, fire rate, switches, portals, charge shots, hitting enemies, hitting objects, explosions, life drain, poison, haste, fire and ice, but only 5 of these mechanics are most of the time necessary for a full functioning game; shooting, power, fire rate (fixed or custom), hitting enemies and hitting objects. The key is not to develop the ideas, unless you know you are going to use them. This idea and planning down could take a few hours, but it could save you weeks, months and possibly, but unlikely years of time developing a mechanic or set of mechanics that are useless or not needed, because they don’t function well, have very limited uses, etc.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s