How expensive are box collisions?

I have a generic tile that my character can walk on. In a final level, there will be hundreds of these tiles. They have a few different box collisions that the player can hit, and certain tiles need different box collisions. If there’s hundreds of these tiles, will these box collisions affect performance? Is it more or less efficient to have the box collisions created in the construction script as needed (for example, not all tiles have ladders, so the box collisions wouldn’t be created until a ladder is enabled on a tile)? Or are they so cheap it doesn’t make a difference?

Hey @sweeetjd!

Every little bit counts… BUT unless the product is HUGE the impact on performance is pretty negligible.

Your idea to only create them in construction as needed is good practice, both for eventual performance and also just the cleanliness of your scene and navigating it while constructing it.

Thanks, I will start doing that then!

I noticed that when I create box collisions in the Construction Script, they work fine, but if I create them OnBeginPlay, they don’t seem to generate collision events, even though I used the same script. Do you know why that is?

the bindings for the physics system happen when the object (the sceneComponent that is the collider) is registered to the World this happens before the BeginPlay() fires where the latest possible moment is a function on the C++ side called PostInitializeComponents()
on the Blueprint side the closest you get to PostInitializeComponents() is the construction script
if you are going to be working in blueprints solely, or you need to modify the geometry of the collider, or change the collision response event at runtime then you might be able to accomplish that by disabling the Physics on the collider in question and then re-enabling it which should cause it to re-register the collision response Delegate to the Physics system.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.