Understanding OnTrigger methods in Unity

Let’s talk about OnTrigger methods in Unity! Do you know when they are invoked or for what you can use them? Let’s see in this post! ?

In one of the recent posts, we spoke about OnCollision methods and the fact that Unity has two separate physics engines.

Of course, like with collisions, there are different trigger methods for the 2D and the 3D engines. For 3D there are OnTriggerEnter(), OnTriggerStay() and OnTriggerExit() methods. For 2D there are almost the same OnTriggerEnter2D(), OnTriggerStay2D() and OnTriggerExit2D() methods.

Continue reading “Understanding OnTrigger methods in Unity”

Asset Preview Grid for Unity

Some time ago, I was a little bit irritated that after I received a new package of 3D models, I had to place them manually on the scene to preview them. So why don’t we build a little script that will do it for us? ?

I’m a lazy guy, and I always try to find a way that will make my life easier. After I get a few packages, I decided that I don’t want to move them manually anymore! It was horrible, and I needed to find a medicine for my pain. ?

Luckily, having programming skills is priceless in game development. So it was time to build a simple but relieving solution. ?‍?

Continue reading “Asset Preview Grid for Unity”

Understanding OnCollision methods in Unity

In this post, we’ll talk about Unity methods related to collisions. So fasten your seatbelt as we are heading into collision! ?

Currently, in Unity, there are two separate physics engines. One for 3D physics, and another one for 2D. Both work in the very same manner, but they are using different components.

So for example, if we want to turn an object into a physical object in 3D space, we would use Rigidbody. Analogous we would use Rigidbody2D if we want to turn it into a 2D physical object.

Continue reading “Understanding OnCollision methods in Unity”

Creating Replace Tool in Unity for Level Designers

Do you wish you could make a level with simple cubes and later replace them all with some other object with one click? This is what we are going to create today!

A long time ago, I created posts about the basics of creating extensions for the editor. I’m not going to cover that topic here, so go ahead and check the post about creating custom editor windows. ?

This post will cover creating tool window, gathering of selected objects on the scene, and using Unity’s Undo class. ?‍?

Continue reading “Creating Replace Tool in Unity for Level Designers”

Understanding Component Destruction in Unity

We did a post about what happens when an object is created and initialized. we also did one on different update methods. Now it’s time to see what happens at the end of the object life-cycle with OnDisable() and OnDestroy().

This time, we don’t have so many methods to cover as there are only two of them, but the question remains the same. When they are called, and what should you use them for? ?‍♂️

Continue reading “Understanding Component Destruction in Unity”