Hello and welcome to another episode in the Godot basics tutorial series. In this episode we will be talking about collision polygon 280 collision polygon 2D like collision shape to do with the addition of two extra properties the first property is the build mode of property it takes in in enum value however in the shadow editor and the drop down menu you'll see two options solids and segments by default your build mode is set to solid the second property that is provided to you is the property named polygon the polygon property is just a pull vector to array object this array object is specifically made to hold vector 2D and the difference between using a poor vector to array versus an array that happens to hold vector two days is that the pull vector to array is optimized for memory basically Godot handles optimization internally for this array object and this is what a collision polygon today looks like when you set it in the go go up. Keep
Keep in mind that the white objects that you see at the corners are called vertices when it comes to polygon we have many different types of polygons over they can be categorized into two different types. The first type is concave The second type is convex. One thing to note is that the collision polygon to do is dynamic. You can set a polygon to be either convex or concave. However you are also able to do this with the collision shape to deal node. So again the collision shape to the node allows you to pick different shape to the objects.
The two choices that are polygon related are the convex polygon shape 2D and the concave polygon shape 2D. If
If you decide to go with collision shape 2D and you so happen to choose convex polygon.
Keep in mind that the dough assumes that you are using a convex polygon a convex polygon is a simple polygon in which no line segment between two points goes outside the polygon.
The easiest way to think about this is that all internal angles are less than one hundred and eighty degrees.
Here is an example of a convex polygon. Notice how all interior angles are less them 180 degrees no matter what shape you set in the Godot application. Godot will decompose your shape into as many convex polygons as possible to ensure that all collision checks against your game object is a check against a convex polygon in a sense. Godot is working internally to make the collision checks faster if you decide to go with concave polygon.
Godot does the exact same thing.
Godot will assume that you are using a concave Polygon a concave polygon is a polygon where one or more internal angles is greater than one hundred eighty degrees. In this case the vertex towards the metal top is the vertex that is greater than or rather has an angle greater than 180 degrees. Again no matter the shape Godot will work internally to decompose it into concave segments. Whatever you do do not use the concave polygon for rigid body 2D.
As a matter of fact that Godot API documentation advises that you use collision polygon 2D and solids mode instead. Or you can use multiple convex polygon shapes.
So which one you use is up to you.
Collision polygon 2D is easier to work with especially if your polygon changes dynamically over time because you do have options with build mode and in my opinion an easier way to change your vertices on your collision polygon to the object. However collision shape 2D and its polygon shapes are faster. And that's because they set themselves to handle exactly a single type of Polygon shape. Well that's all I have for you in this episode. Thank you so much for joining me. Thank you for clicking the Like button and thank you for clicking the Subscribe button.
If you have any questions or comments please feel free to leave them in the comments section down below. I look forward to seeing you in the next episode. Have an amazing day.