Bankler
09-01-2011, 10:19 AM
More replication issues...
In my game, I have a quite detailed injury system. My pawn (WPPawn) has a variable:
var WPHealth HealthSystem;
This is a class handling all kinds of injuries the pawn can get. So a pawn HAS A HealthSystem (the class is called WPHealth).
In the HealthSystem, I have a collection of functions to handle logic of different kinds of hits (all this logic should preferably be handled server side if I'm not mistaken). It also has a collection of integer variables, like HPTotal, Stun, HPHead, HPTorso and so on. These need to be accessible clientside so I can show the correct stuff in the HUD.
What would be the best design?
If I only create the HealthSystem serverside:
simulated function PostBeginPlay()
{
if(Role == ROLE_Autority)
{
HealthSystem = Spawn(class'WPHealth');
HealthSystem.Setup(self);
}
}
... I cannot find any way of accessing its variables (or even the healthSystem object itself) when I'm on the client. Because from the client's point of view, the pawn doesn't have a HealthSystem.
If I instead create the HealthSystem on both sides:
simulated function PostBeginPlay()
{
HealthSystem = Spawn(class'WPHealth');
HealthSystem.Setup(self);
}
... the HealthSystem becomes two totally independent copies (both are ROLE_Authority but on its own respective side), and the important variables that I need to be able to read will not be replicated from the server by putting them in the class' replication block.
The Pawn class is huge as it is, so I would prefer a solution based on composition, rather than just putting all the stuff in the pawn class.
In my game, I have a quite detailed injury system. My pawn (WPPawn) has a variable:
var WPHealth HealthSystem;
This is a class handling all kinds of injuries the pawn can get. So a pawn HAS A HealthSystem (the class is called WPHealth).
In the HealthSystem, I have a collection of functions to handle logic of different kinds of hits (all this logic should preferably be handled server side if I'm not mistaken). It also has a collection of integer variables, like HPTotal, Stun, HPHead, HPTorso and so on. These need to be accessible clientside so I can show the correct stuff in the HUD.
What would be the best design?
If I only create the HealthSystem serverside:
simulated function PostBeginPlay()
{
if(Role == ROLE_Autority)
{
HealthSystem = Spawn(class'WPHealth');
HealthSystem.Setup(self);
}
}
... I cannot find any way of accessing its variables (or even the healthSystem object itself) when I'm on the client. Because from the client's point of view, the pawn doesn't have a HealthSystem.
If I instead create the HealthSystem on both sides:
simulated function PostBeginPlay()
{
HealthSystem = Spawn(class'WPHealth');
HealthSystem.Setup(self);
}
... the HealthSystem becomes two totally independent copies (both are ROLE_Authority but on its own respective side), and the important variables that I need to be able to read will not be replicated from the server by putting them in the class' replication block.
The Pawn class is huge as it is, so I would prefer a solution based on composition, rather than just putting all the stuff in the pawn class.