Download

How to build good convex collision meshes for small things like guns and other pickups?

I have this gun in my game. This is the convex collision mesh setup I have built for it so far.

In Maya

In Engine (The triangle is there to force the static mesh to import. The gun itself is actually a skeletal mesh separate from the collision)

It sometimes falls through the ground if falling from a high distance so I tried enabling CCD. With CCD on it refuses to fall and stays upright when landing even though I gave the little pistol grip things on the bottom some angles.

I might even be overkilling it a bit and should go for an even simpler collision setup?

Falling through the ground isn’t necessarily the collider itself, but rather that it’s a dynamic object. I see this happen in my game too with dynamic objects that the player interacts with or carries. One thing I do is slow down the movement of the objects in question.

Also in Project Settings you can tweak some settings to improve how physics is detecting moving objects more frequently.

Project Settings → Physics → Substepping on.

I also play with the Max Substeps. I think the default is 6 and you can increase it, but it isn’t without paying a price on the game engine.

In one part of my game I teleport objects that can be thrown off of high areas in my game. If those objects fall and are important they teleport back into the game to a spot where I make sure they hit at least one thing on the way down (they pick up speed as they fall after all ) and then they hit the surface I want them on slowed down. Because objects like this are important in my game, and they are limited I’m using this solution over increasing Physics calculations. I put my trigger volume under my world where things may vanish through the floor, and they come back.

i know it’s not ideal, but I spend about fifty percent of my game development time lately trying to keep my game running at a decent frame rate… so anything I can do to eliminate slow downs is important.

I forgot to mention that some objects I have played with the physics material, making them bouncy. Bouncy is okay unless the object is too light, then they end up flying off and penetrating walls and floors quickly disappearing. I make sure that the weight of the object isn’t so light that they don’t move too fast if I want them to not get lost because of physics calculations not being able to keep up with them. That’s what I meant by slow the movement… playing with their weight.

Ah yeah. I set a physics material for it and had to increase density to 3 and decrease restitution to .1. It stopped falling through the ground after that. It also has a much nicer bounce now instead of bouncing as high as it used to, making it feel like a much heavier object like a shotgun should.

If it falls at a slow enough speed though, it still remains upright for some reason. I had an earlier version of this model that fell to the side just fine.

I fixed my gun staying upright. I looked at how I did it with a past model. I simply off center the angled bit and the gun will always lose balance now. It’s a clean enough hack that even I forgot how I did this and thought I just made a nice collision model back in the day.