You Probably Don’t Want Walls Colliding With One Another… Probably…

There are many game genre’s that rely on physics, maybe even almost all of them actually. Bullet hell, hack and slash, platformer, action, and maybe even puzzle games. So chances are, a game you are working on needs things to bump into other things.

But the thing is, you might not actually need them to collide with ALL of the other things.

To give a quick example, in bullet hell games, you might want enemy bullets to collide with the player, but not between themselves or with other fellow enemies. So, have them not interact between them at all then. Not only will this reduce the amount of calculations, but will also save you the need extra condition checks like:

public int damageToMake;
private void OnTriggerEnter2D(Collider2D other)
	if (other.tag.Equals("Player"))

You could potentially remove the if condition if you knew right away it can **ONLY** collide with the player. This might not look like much at first, but when the amount of bullets that appear on screen are well other a thousand, this is golden optimization.

It Is Hidden In Plain Sight

If you want to edit the collision matrix yourself just head to:

Edit > Project Settings > Physics / Physics 2D

Just note that if your project uses both 2D and 3D physics at the same time (for a good reason above normal comprehension), you will have to edit both matrices, as they are independent from one another.

See The Wiki Entry

Get More Useful Tips On The GitHub Wiki

What you just read about was ONE of several unity tips that are available on the Unity Tips Wiki.

Please also note that the wiki is updated often, so make sure to check it out!

Read More Unity Tips!

I felt like doing a bullet hell game just after finding about this matrix, but I guess that is just me.
But hopefully, you learned something useful today.

But Like Always…

Thank you very much for reading my blog :3

GDCR - Juice It Or Lose It

While working in a game, ever felt like your progress is kinda bland? That it is missing something. That something might be juice, so keep an eye on this talk. Continue reading

Software Suggestion - Hootsuite

Published on April 05, 2018

Unity Tip - Built-In Primitive Sprites

Published on April 04, 2018