• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code How to replace KFHumanPawn with mutator?

Thanks I didn't notice that the SetPawnClass is overrided in KFPlayerController that's why DefaultPlayerClassName doesn't works.
Damn it, I don't even wanted to modify pawn to keep compatibility, and now I will have to modify controller to do that.
I must fix my mod to make it work correctly online without using any custom pawn and controller >__<
 
Upvote 0
I post a simple solution if someone having trouble to change pawn:

1) in mutator:

Code:
class MyMutator extends Mutator;

function PostBeginPlay() {
    level.Game.PlayerControllerClass = class'MyPackage.MyPlayerController';
    level.Game.PlayerControllerClassName = "MyPackage.MyPlayerController"; // just in case
}
2) in my player controller, override setpawnclass as YoYoBatty said (Level.Game.DefaultPlayerClassName to change directly the pawn is obsolete in this game because of KFPlayerController):

Code:
class MyPlayerController extends KFPlayerController;

function SetPawnClass(string inClass, string inCharacter) {
    PawnClass = Class'MyPackage.MyPawn'; // your pawn class here
    inCharacter = Class'KFGameType'.Static.GetValidCharacter(inCharacter);
    PawnSetupRecord = class'xUtil'.static.FindPlayerRecord(inCharacter);
    PlayerReplicationInfo.SetCharacterName(inCharacter);
}
I don't recommend to change the pawn or controller without a really good reason, this will break the compatibility with other mutators that doing the same.
 
Upvote 0