Collision Detection

I have physical bullets in my game and not a line trace system. The bullets skip the collision while still hitting the enmey and pass through it. When I set bullet velocity to less, the collision is perfect. What is the reason? I want to keep bullet speed high while keeping perfect collision checks. Please let me know the issue. Thanks

Have you tried CCD?

2 Likes

No, I haven’t. By the way what is this CCD?

Hey there @Adeel_Yaqoob! CCD is Continuous* Collision Detection. It basically increases accuracy/rate of collisions. However with extremely high speed objects, you may need to stretch them length wise. Another alternative is tracing where it was to where it was last frame and if you get any hits just count that as a connection, however both of these methods have their drawbacks.

2 Likes

@SupportiveEntity Thank you so much <3

No problem! I forgot to mention, if none of these (and a combination of which) don’t work for you, you may just be moving your bullets too fast. Often-times when bullets need to go so fast they are lasers, it’s often better to swap to traces and fake the physical bullets. Many games do this, and a good example of it is done in Lyra if you’d like to see it in action.

2 Likes

@SupportiveEntity Wow, Amazing <3

@SupportiveEntity Does the other actor also has to have CCD checked?

Since the bullet is the fast moving object, only it requires it. Evaluating the bullet position matters more than the other object unless the other object is also moving quickly.

That said if the bullet is too fast, you may need to combine a couple of the other options. Movement and framerate are tied so if frames are lower you’ll also see more misses that way.

2 Likes

Understood

Hey SupportiveEntity, not OP but I am also having some issues with very fast melee attacks not registering hits.
I’m very interested in the solutions you provided and I was wondering if you have any resources to point me towards that explain how I would go about achieving the things you mentioned (stretching the length time wise, checking between frames, etc).
Or maybe if you could explain briefly either in c++ or pseudocode. Do I use tick and deltatime to achieve these things?
Any help or guidance would be appreciated.

Hey there @GRE_Alexander! So depending on how you’re handling your collision there’s tons of ways to go about it. If you’re tracing during animation with animation notifies, you’d just poll every frame tick and widen the trace. However if you are using collision volumes, you’re turn on CCD in the collision’s settings and widen the collision as well. Alternate means can get a bit more programmatic.

Hey SupportiveEntity, thanks for the reply.
Yes, I am using anim notifies to enable/disable tracing. Unfortunately, simply widening the trace isn’t much of a solution I can use, since I am trying to get a bit more precision with my traces/checks.
You mentioned there may be more programmatic solutions so I am wondering if you can send any resources my way or if you are aware of any talk/book/paper (or anything really) that explains how precise collision detection works in games.

I don’t have any scholarly resources on hand, but the general method used would be to trace from where a checkpoint/socket/bone on a weapon was in one frame and trace it to where it is now, and should work down to even lower framerates losing comparatively less accuracy. This can be done perpendicular or parallel.

(Image from Marketplace plugin: Impact Melee Trace from Darkmodegamedev)

In this older thread users go a bit into detail with some similar systems:

1 Like

I see, thank you for taking the time to reply. Much appreciated!
I will do a bit more research on the topic and look into that plugin.