Static mesh collision going through walls at high velocity
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.
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.
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.
answered Jan 14 '16 at 03:23 PM
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 :)
answered Jan 15 '16 at 11:06 PM
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.
answered Jun 06 '17 at 08:19 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here