Static mesh collision going through walls at high velocity

Hello people!

I’ve got a top down space sim game I’m working on which is all physics based and I’m having some issues with collision.

The movement of the ship is controlled by set rotation and add force on a small collision sphere at the center of the ship.

Is it possible to add a custom shaped collision component to an actor or does anyone know how to stop my static mesh collision from penetrating through walls when rotated and moving at high velocity?

Original setup:
Issue penetration at high velocity.

I’m using the skeletal mesh for collision because it looks very cool when the mesh contacted with surfaces and bounced off with the correct rotation.

CCD is on.

Collision not working, rotation working

Unfortunately when moving at high speeds (Velocity of 3k+) the static mesh’s collision isn’t enough to stop it penetrating through objects when the ship is rotated to the side.

I’ve tried building a few custom collisions for the mesh and none work (If anyone knows how the mesh interacts with the scene e.g. Vertex normals please tell me as I can try other collision meshes.

I can fix the issue by turning off the collision on the static mesh and turning on collision on the sphere but then I get no rotation from impacting the wall.

Collision Working Rotation not working

I think it might have something to do with the rotation on the static mesh.

It will very frequently go through collision when rotated even when not moving at high speed

Any help or suggestions are appreciated.

The only solution I can think of is getting the hit event checking to see if it hit a wall, and then adding a random rotation force based off the angle of impact from the wall but that would never give me an accurate result.

Also If I turn collision on for both the ball and the mesh it will go through the wall and never seem to check the ball’s collision which is super frustrating.

Thank you!
P.s. I tried turning on sub steeping for physics and that helped partially
(When I was using the static meshes collision) but it still would penetrate through.

Try turning on continuous collision detection. There’s a “Use CCD” checkbox in the advanced collision settings for your mesh component.

3 Likes

I’ve tried turning that on and nothing changes it still penetrates through :confused:
Unreal doesn’t seem to do anything different if you have 2 collisions running at the same time.

Oh, I’m an idiot. I didn’t read your post very well did I, sorry. Two things stand out: 1. You have Auto Weld on, so the static mesh should be inheriting it’s physical properties from the sphere (though it doesn’t seem to be). and 2. you’re setting rotation rather than using a torque, so it could be rotating into an object.

Nah I did a Ninja edit, well the thing penetrates walls even if it’s not rotated so long as it’s going fast enough so the torque thing doesn’t really matter.

The auto weld thing is effecting it, it looks like it’s a decent avenue of research.
I did manage to kind of fix it by cranking the sub steeping into turbo mode with max delta time of 0.1 and 16 max substeps now it will only penetrate if the velocity is >10k which it never will be because that’s much too fast. So it’s kind of a fix but will probably trash my performance in the long run… :frowning:

I’d still like to know why the sphere collision never penetrates without substepping where as my static mesh does, also I’d love to know why the collision is worse when both the sphere and the static mesh collision are used, maybe it calculates one surface at a time or the collision components have a special property to them that allow them to be updated with higher priority (Which is why I want to know if you can create your own custom collision component)

Right so seeming as no one else has answered and I needed this fixed I came up with my own solution.

I’m not really happy about it because I use an event tick, but it solves my problem without turning on physics sub steeping onto something ridiculously low and there fore expensive.

I’m not sure which of the two is more costly an event tick or sub stepping if anyone knows how to measure this I’d appreciate it.

My solution is to perform a line trace to look ahead of the actor and if were going fast enough to penetrate through a wall then slow down to a speed that wont penetrate just before hitting the wall, which then in turn allows unreal collision detection to catch up

Hope this helps someone else :slight_smile:

Aha. Hmm. It’s strange that CCD doesn’t fix it. Have you tried changing the collision mesh for your static mesh just to see if any other shapes work? And your mesh isn’t really small or anything? (less than 10-ish) Could you upload your project so I can test it myself? (there’s a “Zip Up Project” option in the packaging menu in case you didn’t know.) I have a physics-based top down space project myself and I’ve never had collision issues.

Interesting solution. I’m having problems with ragdoll bones getting stuck behind walls that they penetrated and not sure yet what to do about it. Set Physics Linear Velocity is pretty expensive for every tick. You should be able to get the same working with using Add Force instead

I can’t point you to a checkbox that will solve everything, but I think my solution will be faster than what you’re doing now.

Start with a collision shape that is slightly larger than your ship. Then, on tick, add (velocity * elapsedSeconds) to the dimension(s) of the collision shape. That way, the faster you’re going, the larger the collision shape around the ship, and thus the earlier the collision will be detected. I take the (velocity*seconds) value and multiply it by some small amount (like 4) to add a little buffer room.

The easiest thing is to grow all three dimensions by the length of the velocity vector. That would be good for an initial test, but with some math you can grow the shape along individual axes based on the actor’s rotation and velocity along that axis.

On collision shapes, the only way to not use a standard collision shape is to use ‘complex’ collision. I’ve never seen that work right though and it sucks up CPU like an infinite loop.

That’s pretty raw and not optimized solution indeed - but I like the IDEA
And will definitely use the idea.
However the implementation could be deeply optimized :slight_smile:

I found the correct answer to this issue a few years ago when working in Unity.

The solution is to track your previous location and new location on each update. The updates don’t have to be incredibly fast, so long as they’re not slow enough to cause some visual issues with animations or particles. You will cast a ray between the two points and look for collisions. If there is a collision, you know the object would have hit something and you can act accordingly at the location where the collision would occur.

This method allows you to get rid of the collider because you are doing the detection yourself.

1 Like