Engine crashes when applying impulse to object

I’m using the ShooterGame base and to register a hit on the vehicle class I ported from the starter vehicle content, it needs to apply force on hit.

Whenever I do shoot at the vehicle, the engine instantly crashes. I’m probably doing something wrong here, and I’m not very good at C++, so any help would be appreciated.

Here’s the code I used, lines 212-220.

Hey thete, csn you send the crash log and call stack?

Yeah, here you go!

My guess is that actortomove is nullptr when you do the cast. So to prevent from crashing do this before the cast: if (ActorToMove == nullptr) return;

Your suggestion worked, thank you! I still need help getting it to apply force to the vehicle on hit. I need a way to apply it on impact.

The best way to explain it is through this picture. The vehicle blueprint is set up so that it prints a message on hit, but there’s no force applied at the moment, so it never prints. How would I apply force on impact with this vehicle?

First of all you need to understand why actortohit was null. I would suggest for you to use impact getactor and save that to a local variable, i assume that is the actor of the line trace or projectile hit, you should get the mesh from that and apply force to it. To be able to apply force the mesh needs to be in simulate physics and the collisions need to have physics only or query and physics. Also make sure that the force is great enough, so its better to overdoit and start lowering rhan to have a low value that just tickles the mesh.

I’ll try this and get back to you. Thank you for your help!

I fixed it, but used a blueprint instead. Your solution did work, but I had a hard time wrapping my head around what to do (as I said, I’m not good at C++ :P)

Regardless, thank you for your help! Here’s the blueprint in case anyone else has this issue.

I fixed it, but used a blueprint instead. Your solution did work, but I had a hard time wrapping my head around what to do (as I said, I’m not good at C++ :P)

Regardless, thank you for your help! Here’s the blueprint in case anyone else has this issue.

Good to know :slight_smile: