It’s more generic/architecture question, Because I’m quite stuck right now.
I have several Objects right now:
- Ability - Which is replicated to user. It’s active and player needs to provide input to make ability do something.
- Effect - Effect is simple object, that modify actors, that have AttributeComponent. Effects on their own are NEVER replicated back to player. They exist only on server.
- Effects are wrapped into struct FPeriodicEffect. Struct have several properties and one Tick() function, which is used to Tick Effect on server it also contain pointer to Effect (NotReplicated).
- AttributeComponent have TArray<FPeriodicEffect> PeriodicEffects, which store all active periodic effects and right now it is Replicated back to client.
Applying effect looks like this:
Input Press (Client) -> Ability->InputPressed() (check for authority), RPC call is issued if call is not made from authoritative machine -> From Server function there is event Launch OnActionStart(). Everything connected in blueprint after this event is executed on server.
Now the problem is that Effect is applied using blueprints and OnActionStart() event. So it happens on server, which is usually good thing.
The problem is that duration of effect is also replicated from server to client. Locally it makes about 0.03s, which somewhat acceptable.
But over internet that difference will be from from 0.05 to 0.1s at best case, which everything but acceptable.
Any ideas how to solve client side prediction in that case ? I’d like to just run separate timer/ticker on client that will just count and display properties but will not affect anything on server.
My biggest hurdle is the fact, that effect is exclusively created on server, what I’d like to do is to create client version of FPeriodicEffect and just run it on client.
Any ideas how to handle it ? Calling back from server to order client to create it’s own object seems bit redundant, as it still create delay (though less because we need to do it only once not on every Tick). Though this is how I handle it right now.
Are there any Unreal specific ways to handle such scenarios (it also could apply for weapons for example). To simulate world on client send results to server and then server check with it’s own version of world ?