Why only one take hit info is used?

This relates to shooter game and the similar

As far as I understand hits taken on server are replicated to non-server players by replicated structures like FTakeHitInfo which contain details like hit damage type , location of hit and other things. The receiving client then reads this info and plays appropriate hit animations and effects.

However my question is why only one variable of hitinfo is used instead of an array , because in one net replication frequency period the actor on server may have received several hits but only the last hit would be replicated as all hits are assigned to same variable.

say if hitinfo has a replication period (Net frequency) less than server tick rate or if a character takes multiple hits in one tick then in both cases only the latest hit will be replicated and all others discarded as they were overwritten by newer ones.

Why is it done so? I assume optimisation maybe, as there is very little probability of taking multiple hits in same tick or net update period.

Do you mean FHitResult? I can’t find FTakeHitInfo anywhere in the source.

It’s not actually a inbuilt engine feature but common practise used in many multiplayer games including the “Shooter Game” sample from epic (See TakeHitInfo.cpp in Shooter Game)

You will get one “on damage taken” event with damage info per damage event.
This is “Event AnyDamage” in blueprint, and OnTakeAnyDamage in Actor.h.

I’m talking about the following in ShooterCharacter.h

/** Replicate where this pawn was last hit and damaged */
	UPROPERTY(Transient, ReplicatedUsing = OnRep_LastTakeHitInfo)
	struct FTakeHitInfo LastTakeHitInfo;

as you can see the comment clearly says last hit , which means only one hit of all in a given tick or net update would be replicated

ShooterCharacter.h is not part of the engine.
If you want to get all the impacts, you must use the OnTakeAnyDamage delegate in Actor, which is part of the engine.

Well duh !

The point is that pattern seems to work ShooterGame. If your game has different needs, use a different pattern.