How can I make only a killing blow apply physics?

I want all enemies to be immune to physics unless the hit would kill them. In that case, I would like the physics of getting hit to apply. If there was a magic FrameBeforeCollision() method I could use, I could just turn off kinematics and be done, but Unity is not that nice.

I could potentially do this by having every projectile check in FixedUpdate() if there will be a collision in the next update, pass the damage value to the enemy to see if that hit would kill it, and if so turn off kinematics. Thus, the next update will be a collision, I can apply damage reducing the HP to 0, and then the physics of the hit will send the enemy flying. My worry here is if I have a very quick moving enemy and a collision on the edge of the collider, the prediction could be wrong since my projectiles are not instantaneous bullets.

I’m guessing a little bit, because I don’t fully understand your concept, but I think your suggested solution is going in the right direction. Though I think there is a slightly simpler way to do what you want to do. If most hits don’t kill, then the default should be to keep physics turned off. If a hit would kill, then you apply physics in the moment of that killing blow, through scripting. And the various OnTrigger / OnCollision events are pretty close to that magic method that you’re asking for.

In outline, I suggest you make all your colliders into trigger-type colliders and write some logic into the OnTriggerEnter method. Also, make sure all of your enemies have a kinematic rigidbody. When a bullet hits an enemy, the enemy’s OnTriggerEnter method would run. In that method, you would calculate damage, and change the enemy health accordingly. If the enemy health is below zero, then you could switch the enemy’s rigidbody to dynamic, and use either AddForce or AddForceAtPosition to apply a knockback to the enemy. All of this would happen within OnTriggerEnter.

The simplest solution I feel would be to disable kinematics any time a projectile is NEAR the player (close enough to hit) while also having a health that could be lethal if hit. That’s far less complicated than prediction. The only problem could be frame rate - physics objects can cause issues with lag and the result could be errored. That said, I think it might be good enough for your use case.