I believe have some basic misunderstanding of how replication works.
I’m trying to add the death animation to a character, which works on the server, but not on the clients. I’ve read I have to set a replicated variable which will indirectly trigger the animation. But I can’t get it to work, the animation is not played on the clients.
To simplify I’ve taken the TopDown sample to make a MWE of the problem. I’ll add screenshots but I can also upload the project if necessary.
So what I’ve done is set a replicated boolean testvar
on the TopDownCharacter
blueprint. On the ThirdPerson_AnimBP
I’ve added a variable boolean dieffsAnim
and in its Animation Graph I’ve added a state DIEffs
, reached or leaved depending on dieffsAnim
value.
On the event graph of ThirdPerson_AnimBP
this variable is updated on Event Blueprint Update Animation
by casting Try Get Pawn Owner
to TopDownCharacter
and fetching dieffs
and assigning it to dieffsAnim
.
I’ve tried replicating dieffsAnim
as well, but I guess it shouldn’t be necessary.
I suspect the problem lies on the pawn not being owned by the client, but I’m not sure how to handle that.
The pawn dies when I press Q
. On the original project the damage is applied using ApplyDamage, which runs on the server only. Dying has to be on the server as authority, but I feel that I first I need to understand this so I can continue learning.
As you can see, I also change the name of the character pressing M and N, the name being replicated. Each game window prints, say, for two clients on standalone:
LogBlueprintUserMessages: [TopDownCharacter_C_0] Server: falseNone
LogBlueprintUserMessages: [TopDownCharacter_C_1] Server: falseNone
LogBlueprintUserMessages: [TopDownCharacter_C_1] Client 1: falseNone
LogBlueprintUserMessages: [TopDownCharacter_C_0] Client 1: falseMr. M:
LogBlueprintUserMessages: [TopDownCharacter_C_1] Client 2: falseNone
LogBlueprintUserMessages: [TopDownCharacter_C_0] Client 2: falseNone
Shouldn’t all say that one of the characters is called Mr. M?