Slightly wrong/misleading explaination for collisions and shapes

In the course’s video, there’s a few misleading/misconceptions explained which can lead to some massive optimization issues for anyone who follows them to the letter.

First, there are 3 ways which allow you to add collision to imported .glb files, not just 2.

Method A) Add the collision from the Import’s advanced menu.
Method B) Create a new Inherited version (clicking the movie clip icon right of the placed asset)
Method C) Right click on the imported asset and enable the check box “Editable Children”.

Basically, the method C (which is not shown/explained) allow you to tell Godot to keep the original .glb file, but add a few modifications when loading them. It’s basically the same as the method A), but you keep controls and can design the settings. It’s also possible to do the Method A), enable the “Editable Children” and then modify the settings/Collisions/shapes/etc. which are added to the asset.

Considering that we’re building a Mesh library based on the Tile scene, doing the Method C in the Tile scenes (and handling changes in said Tile scene) is much more efficient than doing Method A which requires you to look up each individual .glb and basically set their collision in stone (unless, again, you do Method C) afterward.)

Another (more important) misleading point in the video is the mention that “you should use Trimesh because it’s impossible to have the custom form of the mesh” (like the T wall junction). Not only is that wrong, but it’s also extremely bad, performance-wise. You should always avoid using Trimesh whenever possible. A single Trimesh of a cube is 16x heavier, performance-wise, than a Box shape collider so imagine the performance hit if you ask the game to generate a Trimesh of a complex wall with details automatically generated (totally useless for its collisions).

So, how can we all those custom chaped T or L wall?
Simple: Use 2 Collision Shape with Box Shape as children of the StaticBody3D node.

When it comes to collision, always focus on primitive/basic shapes first whenever possible.

Some people might think that having multiple Collision shapes is more demanding than having a single complex Trimesh-based collision shape, but that’s 100% wrong. Game engine work internally by using the object bounds first. In Godot, you can see the bounds by the yellow-ish lines when you select the asset. That bound is a zone that allows the Physics engine to know if it has to check anything with that mesh or not. For example, static mesh collider only gets added to physics checks if non-static mesh collider are involved. Once a non-static collider (like a player) enter that yellow-lined bound, the Physic engine check for any included Mesh Colliders.

For custom mesh collider (such as Trimesh generated), the Physic engine reads every vertices and calculate (normals) surface collision based on those vertices. Even if it’s a simple form with barely 30 vertices, it’s still a complex position-to-normals collision calculation. On the other hand, a primitive shape (like a box shape) is defined by a position, width, height and depth. It’s some of the most basics maths ever for a computer: If coordinate between X, -X, Y, -Y, Z, -Z of A is within X, -X, Y, -Y, Z, -Z of B, collision detected. There’s no surface/normals calculation done unless there’s a rigid body involved.

Another thing that is quite good to take into account is to re-use colliders data if some are used repetitively. When you use the import method, every .glb file generate a new mesh collider shape data. If you have various mesh which can use the same collision data (like walls with the same type of basic collision, but few decorative details), you can just generate 1 collision for the first wall variant, save that collision as a Collision shape in a .tres file, then apply that same shape to the other variant.

When it comes to Godot’s Grid Map tool, it’s extremely important to consider avoiding Trimesh generated collider whenever possible. The difference can be like night & day when generating something like a NavMesh.

If anyone is looking for the potential of having dynamic generated dungeons at some point, stay clear of the Trimesh colliders like a plague. (Especially if you’re looking up to release on mobiles.)


Privacy & Terms