[C++] Crashing with physics projectiles

Hello,

I’ve been working on a multiplayer FPS, and in my game there is a type of projectile which will stick into players, like an arrow.

These arrows use physics, they are using a vertical root capsule collider, and then turned horizontal after spawning. Projectile movement component’s “Rotation Follows Velocity” would keep them vertical in flight. These projectiles also use Continuous Collision Detection (CCD) physics because they move so quickly, some of them get lost through walls occasionally.

Every tick while in flight, this projectile does a short trace forwards to check if the front will hit a stickable surface.

After long hours of trial and error, I’ve managed to get my projectile to ignore the capsule collider around the player, and trace/hit the skeletal mesh (or perhaps physics asset), which returns a proper bone name and hit info.

The crash occurs seemingly at random, but always occurs when a projectile hits a surface. Rapid-firing seems to make the crash happen sooner.

My editor crashes with no callstack or log info, and while debugging the editor in VS I get the following error message in the screenshot.

I’ve also included the function I use to stick projectiles to surfaces in the screenshot.

Any advice would be appreciated.

Please let me know if you need any further information from me.

Thanks

PS. If anyone is going to use this code, please note that the “Rotate to face surface” section does not seem to be working. Although using the “GetLookAtRotation” node in blueprint does work.

#Advice

  1. Save your project in its current state

  2. Start dismantling your game mechanic piece by piece until it no longer crashes this way

  3. Let us know what piece of your code, when added back, causes the crash to occur again

Personally I think you should start with not rotating the capsule at runtime.

But start breaking the problem down

and see what part of your code, when removed stops the crashes, and when added back makes crashes happen again

Then we need that whole coded posted here

#:heart:

Rama

PS: in about 70% of cases, by the time you’ve dismantled your project sufficiently to stop crashes you will have also figured out the issue and found a better way to do it that does not cause crashes, good luck!

Thank you! I will do all of this.

Did you ever find the cause of this dbinteractive? I am having the exact same crash in the exact same circumstances (PhysX projectile hitting a surface)

I am trying to solve this issue forever, this issue is turning around from ue4.16 version. I have found there is some serious memmory error in physxsupport.cpp oncontact() event when trying to getmaterialfrominternalfaceindex causing memmory access violation reading location i believe its comming from memmory missaligment sometimes returning NAN values for impulses , points etc . Todays its 4.21 version & it still persist. Hope incomming physx 4.0 will fix this.