Announcement

Collapse
No announcement yet.

Multiplayer Question

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

    Multiplayer Question

    Using a simple Custom-Kismet-Node I want to access the unreal-script that gives a player Flying ability around a level. The core code is invoked from the CheatManager.uc which invokes a GotoState in PlayerController.uc... I've copied the code into a self-contained Custom Node file, and it compiles ok. But it doesn't match the behavior of the 'Fly' console command. The only active code appears to be this: SetPhysics('PlayerFlying'). The problem is, it doesn't offer the CTRL / C key altitude control that 'Fly' has, so its impossible for the player to navigate. There's been a lot of requests for this feature in past posts stretching back a long time, so I know someone has solved it... Please help...


    Custom Kismet Node
    Code:
    class F_UTSeqAct_Flying extends SequenceAction;
    
    
    event Activated()
    {
    
    	local SeqVar_Object ObjVar;
    	local Pawn Target;
    	local vector X,Y,Z;
    	local PlayerController PlayerController;
    	local WorldInfo WorldInfo;	
    	local float DeltaTime;
    	
    
    	//ignores SeePlayer, HearNoise, Bump;
    	
    
    	// get the pawn(s) that should enter the vehicle
    	foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Target")
    	{
    		Target = GetPawn(Actor(ObjVar.GetObjectValue()));
    		
    		
    		WorldInfo = class'WorldInfo'.static.GetWorldInfo();
    		DeltaTime = WorldInfo.TimeSeconds - 1.0; //- LastCameraTimeStamp;
    
    		PlayerController = WorldInfo.GetALocalPlayerController();
    		PlayerController.bCheatFlying = true;
    		GetAxes(Target.Rotation,X,Y,Z);
    
    		Target.Acceleration = PlayerController.PlayerInput.aForward*X + PlayerController.PlayerInput.aStrafe*Y + 
    
    PlayerController.PlayerInput.aUp*vect(0,0,1);;
    		Target.Acceleration = Target.AccelRate * Normal(Target.Acceleration);
    
    		if ( (Target.Acceleration == vect(0,0,0)) )
    			Target.Velocity = vect(0,0,0);
    		// Update rotation.
    		PlayerController.UpdateRotation( DeltaTime );
    		if ( PlayerController.Role < ROLE_Authority ) // then save this move and replicate it
    			PlayerController.ReplicateMove(DeltaTime, Target.Acceleration, DCLICK_None, rot(0,0,0));
    		else
    			PlayerController.ProcessMove(DeltaTime, Target.Acceleration, DCLICK_None, rot(0,0,0));
    			
    		PlayerController.CheckJumpOrDuck();	
    		Target.SetPhysics(PHYS_Flying);
    		
    	}
    	
    }
    
    defaultproperties
    {
    	bCallHandler=false
    	ObjCategory="F"
    	ObjName="Flying"
    	VariableLinks(0)=(MinVars=1,MaxVars=1)
    
    }
    PlayerController.uc -> State PlayerFlying
    Code:
    Begin:
    }
    
    state PlayerFlying
    {
    ignores SeePlayer, HearNoise, Bump;
    
    	function PlayerMove(float DeltaTime)
    	{
    		local vector X,Y,Z;
    
    		GetAxes(Rotation,X,Y,Z);
    
    		Pawn.Acceleration = PlayerInput.aForward*X + PlayerInput.aStrafe*Y + PlayerInput.aUp*vect(0,0,1);;
    		Pawn.Acceleration = Pawn.AccelRate * Normal(Pawn.Acceleration);
    
    		if ( bCheatFlying && (Pawn.Acceleration == vect(0,0,0)) )
    			Pawn.Velocity = vect(0,0,0);
    		// Update rotation.
    		UpdateRotation( DeltaTime );
    
    		if ( Role < ROLE_Authority ) // then save this move and replicate it
    			ReplicateMove(DeltaTime, Pawn.Acceleration, DCLICK_None, rot(0,0,0));
    		else
    			ProcessMove(DeltaTime, Pawn.Acceleration, DCLICK_None, rot(0,0,0));
    	}
    
    	event BeginState(Name PreviousStateName)
    	{
    		Pawn.SetPhysics(PHYS_Flying);
    	}
    }

    UTPlayerController.uc -> State PlayerFlying
    Code:
    state PlayerFlying
    {
    	ignores SeePlayer, HearNoise, Bump;
    
    	function PlayerMove(float DeltaTime)
    	{
    		Super.PlayerMove(DeltaTime);
    		CheckJumpOrDuck();
    	}
    }
    CheatManager.uc -> Fly
    Code:
    exec function Fly()
    {
    	if ( (Pawn != None) && Pawn.CheatFly() )
    	{
    		ClientMessage("You feel much lighter");
    		bCheatFlying = true;
    		Outer.GotoState('PlayerFlying');
    	}
    }

    #2
    His walking state is probably still in PlayerWalking, try setting it to PlayerFlying.

    Comment


      #3
      This has no effect: Outer.GotoState('PlayerFlying')
      Physics is already set to Target.SetPhysics(PHYS_Flying);
      Is there anything else I can check? Thanks!

      Comment


        #4
        Code states have nothing in common with Physics states. SetPhysics won't set the state stack to 'PlayerFlying'. However, states can trigger some additional code on entering so calling GotoState('PlayerFlying') might actually call SetPhysics(PHYS_Flying)... which is the case for the PlayerFlying state of the PlayerController.

        Node
        Code:
        class F_UTSeqAct_Flying extends SequenceAction;
        
        event Activated()
        {
            local SeqVar_Object ObjVar;
            local Controller TargetController;
        
            // get the pawn(s) that should enter the vehicle
            foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Target")
            {
                TargetController = GetController(Actor(ObjVar.GetObjectValue()));
                if (TargetController == none)
                {
                    continue;
                }
                
                TargetController.GotoState('PlayerFlying');
        
                // because PlayerController clears the velocity when bCheatFlying is set
                // we have to apply that flag here as well
                if (PlayerController(TargetController) != none)
                {
                    PlayerController(TargetController).bCheatFlying = true;
                }
            }
        }
        This should work with the UTPlayerController and PlayerController based classes.

        Comment


          #5
          Originally posted by RattleSN4K3 View Post
          This should work with the UTPlayerController and PlayerController based classes.
          Thank you so much RattleSN4K3. It works flawlessly Server side. I will study it to see if it can be adapted to Clients. Let me know if you any have pointers on that... Cheers!

          Comment


            #6
            Probably using TargetController.ClientGotoState('PlayerFlying') in addition.

            Comment


              #7
              Thanks RattleSN4K3. After amending it slightly it compiled as:

              PlayerController(TargetController).ClientGotoState ('PlayerFlying');

              ...But no luck, the clients are still excluded... So hunting for a solution still...

              Comment


                #8
                The Flying node reliably works on the Server even for a client based player objects. So is there a simple way to pipe a message from a client, telling the server to trigger the Flying node for a specific player? If so, this will get around the Client problem...

                Cheats are invaluable for multiplayer testing i.e. Slomo, SetSpeed, Fly etc.
                Why didn't Epic include a Cheat option for beta testing within 'World Properties' / Editor INI file etc?

                Comment


                  #9
                  RattleSN4K3's 'Fly' code above works on the Server, but not the Client. How do I force Replication?
                  https://forums.epicgames.com/threads...1#post31834577

                  ....Hoping that a replication guru such as Wormbo can help (thanks in advance)....

                  Comment


                    #10
                    *** Bump ***



                    .....Wormbo???

                    ... Anyone???

                    .....Please...?

                    Comment


                      #11
                      Code:
                       RattleSN4K3's 'Fly' code above works on the Server, but not the Client. How do I force Replication? 
                      https://forums.epicgames.com/threads...1#post31834577
                      
                      ....Hoping that a replication guru such as Wormbo can help (thanks in advance)....
                      You place the variable you wanna replicate in the class you want to replicate from. Of course you should do it from the server dimension. " so use reliable server function " .

                      something like

                      Replication
                      {

                      if(BNetDirty && Role == ROle_authority)
                      bMyrepVar;
                      }

                      Use repnotify and call a client function then , to go the the clients dimension.

                      Comment


                        #12
                        Solution may be Repnotify pattern

                        http://udn.epicgames.com/Three/Repli...RepNotify.html

                        http://www.sanzpont.com/chosker/eliu...o-all-clients/

                        Comment


                          #13
                          Thanks for the links Neongho!

                          Unfortunately, its more complicated than just variable / animation replication, as you can see from RattleSN4K3's code snippet above. Yes there's a variable being set for cheating, and yes player physics is being changed which is animation related, but its also necessary to change Player STATE on all clients. If all of these steps aren't met, then the 'Fly' cheat won't work on clients...

                          Comment


                            #14
                            Can't believe this has never been solved.... Anyone at all ever enabled cheats in Multiplayer, for testing or gameplay...?

                            i.e.

                            Fly.... SetSpeed.... Slomo....

                            Comment

                            Working...
                            X