![]() The shape of the collider will be updated automatically when the sprite’s size changes. I will explain tiled draw mode in a later article, but if you’re curious now, you can read more about it here in Unity’s documentation. When you check this one, some properties disappear, “Is Trigger”, “Material”, “Used By Effector”, and “Edge Radius”, as they are controlled by the composite 2D component.Īuto Tiling: Check this if the sprite draw mode is Tiled. Used By Composite: check this box if you have a Composite Collider 2D component added to the game object. Used By Effector: check this if you have an Effector 2D component added to the game object, and you want to direct the forces according to that effector component when game objects collide with each other. If it is checked, a collision with a rigidbody won’t be registered. A trigger means that if a rigidbody gets in the trigger’s volume it will send these messages: OnTriggerEnter, OnTriggerExit, and OnTriggerStay. Is Trigger: check this one if you want the Cox collider 2D to be a trigger. Material: the physical material that covers your game object that affects its physical properties, such as friction and bounce. You can move the lines by selecting the small squares. ![]() ![]() When you click on it, you will see a green rectangle around the frog as shown in the image below. Edit Collider: As the name suggests, we can edit the collider rectangle by clicking on this button.Click on “Add Component” and select “Box Collider 2D”. Let’s add this component and check the inspector. The frog’s shape is closer to a rectangle so I chose the Box Collider 2D. Polygon collider 2D for 2D complex shape.There are several shapes for the Collider 2D aside from the “Box”, which is a rectangle shape, and they are: Collider 2D components help in defining the physical shape of the game object for collision and trigger purposes. Since we want to click on the frog, we need a Collider 2D component. Next, we’ll add two important components to the frog sprite. Just drag and drop the frog in the hierarchy, and scale the frog down to 0.1. In the hierarchy, you should have an event system and a canvas with the background image as a child. This is how the scene should look (below). Follow the exact steps that were covered here my last article. Open the new scene and add a background image. To add a new scene, simply right click in the Assets/Scenes folder > Create > Scene. Let’s add a new scene in the project we created last time. When players tap on them there will be a purple smoke effect. In this game, players will try to tap on frogs, who will be appearing in random places, before they fall into our lake. *Īt the end of this series, a 2D mini game will be created. *In this tutorial, Unity Version “2020.3.23f1” is used. The following should be installed on your computer to follow along this tutorial: In this article, we are going to walk-through adding a new scene, two important components (Rigid 2D and Box Collider 2D), how to destroy a game object, prefab, and how to instantiate a prefab. Over the next few posts we are going to develop a fully functional mini game. You can check out the first article, where I dive into Unity editor basics, here. Welcome to the second article in this Unity series.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |