Force reload of player mesh/skin?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Alex2

New Member
Jul 25, 2003
9
0
0
Visit site
Is it possible to force network clients to load the correct mesh for another player? For example, if a player changes their model mid-game, the change does not take effect for the other users until the player dies and respawns.

I change the players settings mid-game using:

Code:
Pawn.Skins[0] = Material(DynamicLoadObject("PlayerSkins.AlienMaleABodyA", class'Material'));
Pawn.Skins[1] = Material(DynamicLoadObject("PlayerSkins.AlienMaleAHeadA", class'Material'));
Pawn.GibGroupClass = class<xPawnGibGroup>(DynamicLoadObject("xEffects.xAlienGibGroup", class'Class'));
Pawn.SoundGroupClass = class<xPawnSoundGroup>(DynamicLoadObject("XGame.xAlienMaleSoundGroup", class'Class'));

VoiceType = "XGame.AlienMaleVoice";
VoiceClass = class<VoicePack>(DynamicLoadObject("XGame.AlienMaleVoice",class'Class'));
Pawn.VoiceType = VoiceType;
Pawn.PlayerReplicationInfo.VoiceType = VoiceClass;
Pawn.VoiceClass = class<TeamVoicePack>(VoiceClass);

When playing on a listen server, the changes take effect right away so it looks like the variables are not replicated. Actor.uc contains:

var(Display) array<Material> Skins; // Multiple skin support - not replicated.

so obviously Skins is not replicated.

Am I going to have to basically kill the player and respawn?

Thanks

Alex
 

Alex2

New Member
Jul 25, 2003
9
0
0
Visit site
I want to maintain the players score etc, so reset won't work. Reset seems to reset everything and puts the play into spectator mode.

Alex
 

Alex2

New Member
Jul 25, 2003
9
0
0
Visit site
When a player kills another player, the mesh / skin for the player that made the kill (and who is not dead) needs to change.

Inside the main gametype (extends DeathMatch) file, NotifyKilled has been changed to execute the code I listed above to set the killer's mesh, skin etc.

Making the change client side sounds like a good idea, but I'm not sure how to go about that yet.. Any suggestions?

Thanks

Alex
 

Alex2

New Member
Jul 25, 2003
9
0
0
Visit site
I tried using RestartPlayer, but it's not working as expected.

In my game, if I do:

Code:
(Controller P, xPawn Pawn)

Pawn.destroy();
P.SetPawnClass("Engine.Pawn", "Komek");        // Alien
PlayerController(P).ServerReStartPlayer();

It works on the listen server, but the client isn't getting the new class type for ITSELF. It DOES see the other players with the correct model. It's the network client that doesn't see itself correctly. I can see this with 'behindview 1'.

I know the code is executing for the player based on log entries on the *server*.

Am I missing something?

Alex
 
Last edited:

Alex2

New Member
Jul 25, 2003
9
0
0
Visit site
I finally got it working. It's based on the bForceDefaultCharacter code. Thanks to TNSe in #unrealscript on EnterTheGame.Com irc.

I have my game, a xPawn (xMyPawn) and a xPlayer (xMyPlayer).

In myGame:

Code:
xMyPawn(MyPawn).SetSkin(True);

In xMyPawn:
Code:
replication
{
	reliable if(Role == ROLE_Authority)
		SetSkin;
}

simulated function SetSkin(bool Yes)
{
        local xUtil.PlayerRecord rec;

        if (Yes == True)
          rec = class'xUtil'.static.FindPlayerRecord("Komek");
        else
          rec = class'xUtil'.static.FindPlayerRecord("Rylisa");

        Species = rec.Species;
        RagdollOverride = rec.Ragdoll;
        if ( Species.static.Setup(self,rec) )
          ResetPhysicsBasedAnim();
}

That will make the player change their model. Other clients will not see this change. For that, I did:

In myGame:

Code:
C.SetPawnClass("Engine.Pawn", "Komek");

or

C.SetPawnClass("Engine.Pawn", "Rylisa");

There is one more problem. If a player changes models, a network client may still see the old one. If the player that changed becomes non-relelvant and then relevant, the player will see the correct model. If you hide around the corner for 6 seconds and then go back to the player, it will have the correct model..

To get around this, I did:

In myGame:

Code:
for ( C = Level.ControllerList; C != None; C = C.NextController )
{
  if ( C.IsA('PlayerController') )
  {
     xMyPlayer(C).SetSkin(MyPawn, True);
  }
}


In xMyPlayer:

Code:
replication
{
	reliable if(Role == ROLE_Authority)
		SetSkin;
}

simulated function SetMutantSkin(xPawn MyPawn, bool Yes)
{
        local xUtil.PlayerRecord rec;

        if (MyPawn == None)
          return;

        if (Yes == True)
          rec = class'xUtil'.static.FindPlayerRecord("Komek");
        else
          rec = class'xUtil'.static.FindPlayerRecord("Rylisa");

        MyPawn.Species = rec.Species;
        MyPawn.RagdollOverride = rec.Ragdoll;
        if ( MyPawn.Species.static.Setup(MyPawn,rec) )
          MyPawn.ResetPhysicsBasedAnim();
}

It all seems to work. Maybe there's a cleaner way but it works!

Alex