How is Lyra doing client-side prediction with a damage execution calc in GAS?

Hi. I’ve been using GAS for a bit, and one of the things that is stumping me is client-side prediction for damage. So in the GASDocumentation, it says:

Execution calculations… can change more than one Attribute and essentially do anything else that the programmer wants. The downside to this power and flexibility is that they can not be predicted and they must be implemented in C++.

This makes sense to me, and when looking at Lyra’s code, we see:

void ULyraDamageExecution::Execute_Implementation(const FGameplayEffectCustomExecutionParameters& ExecutionParams, FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const
{
#if WITH_SERVER_CODE

Which implies that indeed the damage calculation is occurring on the server. However, when shooting at targets with network emulation on, there’s no perceivable lag whatsoever. In fact, it runs surprisingly well when battling AI.

In comparison, my game has horrendous lag when killing AI. I have a similar damage execution (albeit not entirely the same), but the only way I can get client-side prediction is if I turn my damage execution calculation off and use modifiers instead.

What’s happening here? What exactly am I missing? Both my game and Lyra are using AttributeSet delegates to update the UI, so clearly there’s a big difference but I can’t tell.

1 Like

I don’t have the answer to this, just a related question as I’m also interested in the underlying mechanics here.

I wonder if what we’re seeing in Lyra is that the damage on the client isn’t instant, but actually delayed. When damage occurs, there is an immediate indicator on the health bar, with a delayed animation that then drops the health down to the new level.

Perhaps the instant animation is the prediction part, and the health drop animation delay, in addition to the visual effect, is intended to hide the delay of the server updating the client health?

I found the answer to this.

So network emulation was not working correctly on my machine. Lyra is not doing client-side prediction for damage. It only looked that way because network emulation was off, so everything was instant. The gameplay effects are all using a damage calculation, and GAS damage calculations cannot be locally predicted.

3 Likes

Thanks for following up. Good info.