Rayfire 2. RayFireImpact OnImpact throw NullReference when rayfireRigid.ApplyDamage

Flem100

New member
Hello there. I have imported Rayfire 2 asset into my project, as well as the UCC integration package.
Reproduce error:
  1. Choose 1 of the green Cube game objects from the UCC Demo scene.
  2. Remove Rigidbody and Collider.
  3. Add Rayfire Rigid and the only thing in the integration; the RayFireImpact component.
  4. Make the following changes to the Rayfire Rigid component:
    1. Initialization = At Start.
    2. Optional. In the Damage section. Enable = true. Error happens either way
  5. Start the game and shoot at the cube with the Pistol.
The code dies here:
m_RayfireRigid.ApplyDamage(ctx.ImpactDamageData.DamageAmount * m_DamageMultiplier, ctx.ImpactCollisionData.ImpactPosition);
Because ctx.ImpactDamageData is null. It seems to be because the weapon is not an impact weapon like the grenade.

If I go into PistolWeaponRight and open Impact Module Group -> SimpleDamage and change it to UseContextData it doesn't help.

I looked at in a screen share with Cheo. He was the one telling me to try these things because I am still a noob with UCC :).
His solution is to instead use the Health component and call the Rayfire functions directly from Damage or OnDeath events. That makes sense, but you might have a good reason to do it the other way and I would like your opinion before I continue.
Codex (OpenAI's "Claude Code"), suggests to edit SimpleDamage.cs OnImpactInternal() and set the missing properties after damage is calculated.
 
Are you running the latest version? This looks related to this:


With that said, calling the methods explicitly will also work. I will take a look at that setup though because I would not expect the context to be null if it also has the SimpleDamage module.
 
Hey Justin and thank for your quick reply. I have send a message to Cheo regarding the topic u referred to.

I was just wondering if there was a specific reason why you implemented the integration the way you did? I am afraid to implement it another way than yours and then find out later, that I should have done it your way. Using the Health component instead is very pretty different approach. Maybe you didn't do it that way or similar, because it's a problem when updating the asset to a new version?
 
The only reason is that not every project has health so I used the module system. There's no disadvantage to using the health callback but I couldn't depend on that because not every project uses health.
 
Back
Top