HitResult value reset when passing from Blueprint to C++

I am having a problem with the AddHitResult method from the AbilitySystemBlueprintLibrary.

My (simplified) blueprint looks like this:

It’s pretty straightforward - I’m making an EffectContext], then making a HitResult with a bunch of custom values (I set a bunch of stuff to true, and set vectors to (100,100,100) to make it easy to test - normally this would be passed in from a collision event), then calling AddHitResult to add the HitResult to the EffectContext.

But rather than copying the HitResult to the EffectContext, I end up with a HitResult inside the EffectContext with all default values. If I put a breakpoint on the blueprint and inspect it after this node, then I can see that I have a default HitResult with everything set to 0 and false.

Stepping through the C++ code in the debugger, I can see that the expected values make it into AbilitySystemBlueprintLibrary.gen.cpp

You can see in the debugger there that my values are set to 100 as expected. And the highlighted line in the generated code is just calling AbilitySystemBlueprintLibrary::EffectContextAddHitResult. Then if I move up the stack to that method, the values of my struct are reset:

I think this has something to do with the generated code, because if I do all this through C++ only and avoid blueprints, calling UAbilitySystemBlueprintLibrary::EffectContetAddHitResult works correctly.

Would love some pointers in the right direction here, I’m pretty stumped!

2 Likes

Ever found a solution for this? Experiencing the same issue

For people that will find this exact same issue, I have managed to get it working by not just declaring the context variable and using AddHitResult on it, you have to first Make EffectContext and assign it to the variable, and it only works if you use the make effect context function member in the Ability System Component, like in the image below.

I’m crediting Discord user jekithemonkey for posting their solution on the Unreal Slackers Discord, I have been troubleshooting this for hours and I see many people having the same exact issue online

1 Like

你是我爹