Announcement

Collapse
No announcement yet.

Help with SplitScreen Multiplayer - 2 Errors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [UDK] Help with SplitScreen Multiplayer - 2 Errors

    Hello guys!

    I am trying to implement local multiplayer with splitscreen on my game, I got the barebones working already, just the most basic stuff:





    However, I am having a problem for changing the player mesh. I want to control everything by Kismet, because it is faster, and easier.

    I have used this custom Kismet Sequence Action: https://unrealxeditor.wordpress.com/...sh-via-kismet/

    It works perfectly, but only for player 1 mesh (Player Index 0). I want to be able to change aswell the player 2 mesh (Player Index 1).

    By looking at the source code of other Kismet Sequence Action Nodes, I tried to add a target input to this node, so I can in kismet link that input to the second player variable. However, I think I have done some mistake, because it is not compiling correctly (Unrecognized Member 'Target' in class 'UTPlayerController'):

    Code:
    class SeqAct_ChangePlayerMesh extends SequenceAction;
    
    var() SkeletalMesh newMesh;
    var MaterialInterface defaultMaterial0;
    var() AnimTree newAnimTree;
    var() array<AnimSet> newAnimSet;
    var() PhysicsAsset newPhysicsAsset;
    
    event Activated()
    {
        local int i;
    
    //this will allow us to select player index
    local SeqVar_Object ObjVar;
    local Pawn Target;
    
        local UTPlayerController PC;
        PC = UTPlayerController(GetWorldInfo().GetALocalPlayerController());
    
    //this will allow us to select player index
    foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Target")
    {
    
     Target = GetPawn(Actor(ObjVar.GetObjectValue()));
    
     if (Target != None)
     {
    
          PC.Target.Mesh.SetSkeletalMesh(newMesh);
          PC.Target.Mesh.SetPhysicsAsset(newPhysicsAsset);
          PC.Target.Mesh.AnimSets=newAnimSet;
          PC.Target.Mesh.SetAnimTreeTemplate(newAnimTree);
    
          for (i = 0; i < PC.Target.Mesh.SkeletalMesh.Materials.length; i++)
          {
            PC.Target.Mesh.SetMaterial( i, defaultMaterial0 );
          }
    
          }
    
    }
    }
    
    defaultproperties
    {
        ObjName="ChangePlayerMesh"
        ObjCategory="Change Player Mesh"
        VariableLinks.empty;
    }
    And the 2nd error, I think @Nathaniel3W can help me, as he got too much experience with Scaleform. Whenever I run these functions on my custom ViewportClient (to add 2nd player and split the screen):

    Code:
    exec function DebugCreatePlayer(int ControllerId)
    {
        local string Error;
    
        if(GamePlayers.Length < 2)
        CreatePlayer(ControllerId, Error, TRUE);
    }
    
    event LocalPlayer CreatePlayer(int ControllerId, out string OutError, bool bSpawnActor)
    {    
        return super.CreatePlayer(ControllerId,OutError,bSpawnActor);
    }
    It works, however, my custom Scaleform HUD is replaced by UT3 Canvas HUD. How to fix this aswell?

    Cheers and thanks for all.
    Last edited by NIDAL NIJM GAMES; 12-31-2019, 11:09 AM.
    https://sites.google.com/view/udkultimate/


    #2
    Hello guys!

    After a LOT of headaches, and mainly by reading through many SequenceAction Kismet Nodes Source Code, I have found one that does what I need, because I need a node to change any player mesh (the one from that tutorial is hardoced to change only player0 mesh).

    I have found the UTSeqAct_ChangeTeam has a similar function, it can cast the player index through linking the "Target" input to player variable in kismet.

    So I kinda mixed UTSeqAct_ChangeTeam with the Change mesh node from this tutorial: https://unrealxeditor.wordpress.com/...sh-via-kismet/

    Changed some bits here and there and voila!!!! It is working

    Here is the final code, case someone else needs:

    Code:
    class SeqAct_ChangePlayerMesh extends SequenceAction;
    
    var() SkeletalMesh newMesh;
    var MaterialInterface defaultMaterial0;
    var() AnimTree newAnimTree;
    var() array<AnimSet> newAnimSet;
    var() PhysicsAsset newPhysicsAsset;
    
    event Activated()
    {
        local SeqVar_Object ObjVar;
        local Pawn P;
        local Controller C;
        local int i;
    
            foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Target")
            {
                // find the object to change the mesh
                C = Controller(ObjVar.GetObjectValue());
                if (C == None)
                {
                    P = Pawn(ObjVar.GetObjectValue());
                    if (P != None)
                    {
                        if (P.Controller != None)
                        {
                            C = P.Controller;
                        }
                    }
                }
                // if we got a player, change its mesh
                if (C != None && C.PlayerReplicationInfo != None)
                {
                  P.Mesh.SetSkeletalMesh(newMesh);
                  P.Mesh.SetPhysicsAsset(newPhysicsAsset);
                  P.Mesh.AnimSets=newAnimSet;
                  P.Mesh.SetAnimTreeTemplate(newAnimTree);
    
                  //this will force to use the new skeletalmesh material
                  for (i = 0; i < P.Mesh.SkeletalMesh.Materials.length; i++)
                  {
                    P.Mesh.SetMaterial( i, defaultMaterial0 );
                  }
    
                }
            }
    }
    
    defaultproperties
    {
        ObjName="ChangePlayerMesh"
        ObjCategory="Fursan al-Aqsa"
        bCallHandler=false
    }
    https://sites.google.com/view/udkultimate/

    Comment


      #3
      My custom kismet node in action!





      https://sites.google.com/view/udkultimate/

      Comment

      Working...
      X