High velocity collision detection best practice

I need to simulate M4 assault rifle velocity which is based on the official specs 880m/s .Now,I know that it can be problematic to detect collision of fast moving bodies with other objects.How does Unreal handle it?And how is it usually done in games?Is a ray shoot in the same direction?My goal is to simulate the bullet ballistics so I don’t think that raycast is god enough here.Can I rely on built in collision detection system of Unreal?

Hi,

for high velocity collision detection you can use

Use CCD Whether or not to use Continuous Collision Detection for this component. Increases accuracy of collision detection.

Regards

Pierdek

https://developer.nvidia.com/sites/default/files/akamai/physx/Manual/Advanced.html

When continuous collision detection
(or CCD) is turned on, the affected
rigid bodies will not go through other
objects at high velocities (a problem
also known as tunneling).

You can find more details about CCD in physx docs.

I don’t want CCD on for everything as
I suppose it impacts performance
considerably.

CCD in UE4 is enabled by default, but first of all you must enable BodyInstance flag: bUseCCD to true to get ccd working.

BodyInstance.cpp:

// enable swept bounds for CCD for this shape
PxRigidBody* PBody = GetPxRigidActor()->is<PxRigidBody>();
if (bSimCollision && !bPhysicsStatic && bUseCCD && PBody)
{
	PBody->setRigidBodyFlag(PxRigidBodyFlag::eENABLE_CCD, true);
}
else if (PBody)
{
	PBody->setRigidBodyFlag(PxRigidBodyFlag::eENABLE_CCD, false);
}

But I want to know if CCD deals with high velocities perfectly or it just “increases accuracy of collision detection” Also this is global settings.I don’t want CCD on for everything as I suppose it impacts performance considerably.