User Tag List

Page 1 of 3 123 LastLast
Results 1 to 40 of 113

Thread: Come Learn Blueprint Multiplayer with me! (aka Tom's a Glutton for Punishment)

  1. #1
    1

    Lightbulb Come Learn Blueprint Multiplayer with me! (aka Tom's a Glutton for Punishment)

    Update: Blueprint Multiplayer Movement replication is officially good to go! Here's a shortcut to the tutorial post:
    https://forums.unrealengine.com/showthread.php?2107-Come-Learn-Blueprint-Multiplayer-with-me!-(aka-Tom-s-a-Glutton-for-Punishment)&p=19427&viewfull=1#post19427

    Hello intrepid UE4 Blueprinters!
    Welcome to what is assuredly a fiasco in the making!

    I'm trying to make a Blueprint-only multiplayer game. I'm going to start VERY small and try and build from there. I want to share with everybody exactly how, from the ground-up to make an MP game with blueprints. Epic have stated that they want Blueprints to have full network functionality, so here's my personal test-bed for the state of BP MP. I want to share with everybody my journey and get help along the way from those that know multiplayer, replication and anything else better than I.

    About me
    Ive been using UDK/UE3 for years as a tech artist and eventually UnrealScripter. I was invited to the the UE4 beta last year and have spent a fair bit of time in it learning materials, lighting and blueprints. I have a pretty good grasp of all of it, but I've never really tackled multiplayer and replication (it's so scary!). Now I've made a fun game prototype (Drone Wars Extreme! *the name changes daily) and I want to make it multiplayer, but don't want to have to learn C++ to do it. Why? because the game runs great without ANY C++ and I feel that Blueprints are fully capable of creating great games without C++. (Here's a little clip from the other day: https://www.youtube.com/watch?v=eeHsqCM2QyI)

    Where I'm at now
    I've started over for the sake of learning, scrapping all that fancy copter action and going with just a simple Pawn, etc.
    I've created a Blueprint for each of the classes and assigned them accordingly to the gametype:



    Great. You can see I added a big, green arrow to my Pawn (I can see where it is in the world, etc.) There's nothing other than the Static Mesh arrow in there.

    I've also made a simple level that has a few PlayerStarts in it:


    First problem!
    I'm running my multiplayer game from PIE using the fancy Number of Clients setting and a dedicated server (Worst case scenario, ya know?) and immediately, I have a problem. My two players are starting at the same playerstart!


    I don't see any obvious functionality to determine what PlayerStart I should be assigning my players. Also, I'm not savvy enough with networking in UE to even know what class should be handling that sort of thing.

    Can anybody help? Thanks for tuning in! As soon as I figure out an answer, I'll post it here, then on to to the next problem, etc until there's a real, living MP game!

    Files
    Oh, here's the project files. I'll try and update them as we figure all this out:
    https://dl.dropboxusercontent.com/u/618044/BPMP/BPMP_20140404a.zip
    Last edited by Tom Shannon; 04-18-2014 at 01:00 AM. Reason: Added success update #1

  2. #2
    0
    This is a cool project. I'm going to bump since that's currently all I can do to help.

    +1

  3. #3
    0
    Great stuff, looking forward to watching your progress!

  4. #4
    0
    Infiltrator
    Join Date
    Apr 2014
    Posts
    23
    WOW, that video look's amazing, great job. I'm glad that multiplayer will be supported in Blueprints.

  5. #5
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    112
    Good luck Tom!
    Your progress will help me greatly. Also wanted to note that over in another thread Billy Bramer from Epic, when I asked about blueprints stuff for networking 2 days ago, said the following;

    Quote Originally Posted by Billy Bramer View Post
    I can answer this one if the stream doesn't cover it. We have a multi-part video tutorial on this coming soon, as well as a sample map like the other ContentExamples. I finished recording the video early this week. It just needs to be prepped and made ready, so it should be ready to go soon!
    So looking forward to that. I think it will help us both.

    PS: Copter game is coming along great, looks fun. I first saw you showing it off on the ol' UDK forums.

  6. #6
    0
    Quote Originally Posted by Tom Shannon View Post
    First problem!
    I'm running my multiplayer game from PIE using the fancy Number of Clients setting and a dedicated server (Worst case scenario, ya know?) and immediately, I have a problem. My two players are starting at the same playerstart!
    I don't see any obvious functionality to determine what PlayerStart I should be assigning my players. Also, I'm not savvy enough with networking in UE to even know what class should be handling that sort of thing.
    GameMode.cpp.
    Start by making sure ShouldSpawnAtStartSpot() returns false, then create a custom ChoosePlayerStart().

    The default behaviour is to place spawning players at the first PIE player start it can find or, failing that, just the last player start found.

    You should be able to get what you need by checking out those functions in "ShooterGame\Private\Online\ShooterGameMode.cpp".

    Have fun!
    Rule#21: Be polite, be professional, but have a plan to kill everyone you meet.


  7. #7
    0
    Quote Originally Posted by Kris View Post
    GameMode.cpp.
    Start by making sure ShouldSpawnAtStartSpot() returns false, then create a custom ChoosePlayerStart().

    The default behaviour is to place spawning players at the first PIE player start it can find or, failing that, just the last player start found.

    You should be able to get what you need by checking out those functions in "ShooterGame\Private\Online\ShooterGameMode.cpp".

    Have fun!

    Thanks for the insight! I was trolling around the ShooterGame example, looking for where that was handled. There doesn't seem to be anything in Blueprints that is analogous. I'll try and make a workaround in the Game Mode blueprint.

  8. #8
    2
    I think I have a working solution for problem #1!

    Using the knowledge that the Gametype was chosing the playerstart for the pawns in ShooterGame, I tried to access the functions being used in C++. No luck. I did however discover that I cannot use the variable names defined in GameType.h (specifically the PlayerStarts array!) But I could use the function names. While it's probably a bad idea, I've done it anyways :P

    Here's how it works.
    When each player logs in, they spawn a pawn. In the Construction Script, I have the BP_MP_Pawn ask the BP_MP_Game GameType to find a PlayerStart actor in the level whose PlayerStartTag variable isn't set to 'Taken' (the only variable accessible for PlayerStarts though Blueprints, and seems to be replicated.*).

    This is accomplished by casting the gametype to BP_MP_Game and running the ChoosePlayerStart function. This function iterates through the PlayerStart actors in the level and compares the value of PlayerStartTag to 'Taken'. If it's not, it breaks the loop, then sets the tag to 'Taken' (so it will skip over it next time), then returns the PlayerStart actor reference to the Pawn that called the function! The Pawn simply takes that data and sets its location and rotation to match the PlayerStart.

    Choose Player Start function (in BP_MP_Game Blueprint)

    BP_MP_Pawn Construction Script


    Here's proof it worked!

    Them pawns be lookin' at eachother!

    Next up:
    Movin' dem Pawns! Stay Tuned!

    *I could create my own brand of PlayerStart actors using blueprints, as there isn't anything particularly special about the class for this examples particular needs, but that's over complicating things... for now...

  9. #9
    0

    Awww yiss

    Okay, I think I may have learned something about replication. Gasp.

    I got my pawns rotating around. And the SEE EACH-OTHER rotating. Seriously.

    The secret sauce is... telling the server the actor has rotated!

    How did I get here?
    First off, I had learned that you can't replicate functions in Blueprints. Only variables and Events. With that in mind, I set off trying a bunch of stuff.

    What didn't work (Don't do this!)
    My first attempt was pretty poor and didn't work... kinda... Yeah kinda didn't work. That means it didn't work but not entirely! What I had done was set up a Custom Event in my Pawn to send the pitch and yaw inputs from the PC to the Pawn. I was calling that event each Tick from the PC and sending the pitch and yaw as floats. Setting the event to Multicast only seemed to rotate each player locally (as expected, it warns to run it only on the server!), setting it to run on the Server was the opposite: I only saw my pawn rotate on the other clients! Progress, indeed.

    Then, I decided I should have the server send the rotation back to the local pawn. I set up another event (LocalRotate) and set it to OwningClient. This ran after each time the previous event finished and simply took the rotation of the pawn and sent it back to the client. IT WORKED!! But this was complicated AND the Pawn was rotating like it was ratcheted. This is an effect of compressing rotators for net play in UE. It's something very common for games to do as it's purely cosmetic and can take up a LOT of bandwidth.

    Here's how to NOT do it. Again DON'T DO IT THIS WAY (Even tho it kinda works, but sucks)


    And, how it looks in motion:


    (How to do it right in next post)

  10. #10
    0
    How to ACTUALLY do it.
    Rotate the PC

    Rotate the Pawn based on the PC's rotation

    Each Tick, send the server the pawn's rotation.


    And, how it looks:

    Smoooooth!

    Next up: Movement!
    Actually, sleep as the 2-year old is sick and will be screaming at me all night At-Least I figured out some replication in Blueprints today!

    Source Files:
    https://dl.dropboxusercontent.com/u/618044/BPMP/BPMP_20140405a.zip
    Last edited by Tom Shannon; 04-06-2014 at 12:23 AM. Reason: Added source files

  11. #11
    0
    great tread! good luck with your development.

  12. #12
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    85
    Good work! At last somebody's talking about replication ,that's why I abandoned my project in UDK!

  13. #13
    0
    Nice thread, but I wonder is it even necessary to update rotation on every tick?
    I was also checking the spawning and sync movement as well, guess if I found something( I want to have a volume to spawn players in instead of fixed playerStart locations.)

    What I think is(since I haven't figure out how to do the random spawning part), when your input updates the Pawn, in Pawn blueprint where it sets rotation, make the rotation change replicatable by setting Replicate/ReplicateNotify(which creates an function).
    And in the Pawn Blueprint defaults->Replication, there should already have a "Replicate movement", and this should replicate all update regarding transforms of a pawn.

  14. #14
    0
    Quote Originally Posted by PenguinTD View Post
    Nice thread, but I wonder is it even necessary to update rotation on every tick?
    I was also checking the spawning and sync movement as well, guess if I found something( I want to have a volume to spawn players in instead of fixed playerStart locations.)

    What I think is(since I haven't figure out how to do the random spawning part), when your input updates the Pawn, in Pawn blueprint where it sets rotation, make the rotation change replicatable by setting Replicate/ReplicateNotify(which creates an function).
    And in the Pawn Blueprint defaults->Replication, there should already have a "Replicate movement", and this should replicate all update regarding transforms of a pawn.
    I thought the same thing about replicating the movement! But it simply doesn't. Atleast not the rotation. Funny thing is, if you disable that checkbox, this method doesn't work.
    As far as updating every tick being intensive, yeah I could probably put some sort of check in and only update if there's actually been a change in rotation. I might give the repnotify a chance, it's possible way of doing that check easily.

    As for the random spawn, I might go about it by making a blueprint with a volume and having it create X number of PlayerStart actors in the construction script by sending random line traces down, etc. that way you could visualize the possible start locations. Then, rather than sequentially finding a start location, you could get a random int.

    Thanks for the input!

  15. #15
    0
    I've played around your level, and come to conclusion that Pawn and DefaultPawn are classes that does not handle those replication check boxes.
    If you switch BP_MP_Pawn's parent class to character, the movement would replicate properly without any additional event to drive update.
    I think player controller is for when you have something extra, like the mini game example in Input examples.
    (And this would somehow break your script, maybe some graph needs to be recompiled.)
    Edit: by break I mean I can only see one arrow spawned in client 1 window. But when still using your input script,
    I can turn client4 with mouse that sees movement from client 1(also its arrow). all other 3 clients stucked at their location, no arrow to be seen.
    I use gamepad to control client1, and somehow keyboard and mouse assigned to client4 on start play.

    Also, I think we both misunderstand what PlayerController class is about.
    If you check the input example from ContentExamples, you will see that the player controller class has nothing in its graph.
    In the UFO Pawn, it uses GetInputAxisMoveForward/Right/Up for movement and GetInputAxisLookUp/Turn for pitch and yaw.
    Which use the input to drive velocity, and drive camera where and align pawn rotation to camera's view direction.
    Third person obviously use a lerp and velocity direction to drive actor's direction.

    I think if we ever need to build a multiplayer game based on just Pawn, Epic has to either make a insertable movement component that already handles replications,
    or expose some class functions to allow us wiring them.(Have to check those source codes for sure.)
    In the mean time, I think your approach plus some custom variable with RepNotify should get the ball rolling.
    Last edited by PenguinTD; 04-06-2014 at 10:09 PM.

  16. #16
    0
    Thanks for checking that out. I was thinking that might be case as the Pawn class doesn't have a Movement component. Saved me the trouble of checking it out! what's strange is how unchecking it breaks the custom replication I have set up. Something seems amiss there.

    Controller is really a way to separate logic from the Pawn. Take UT for example. you'd want to have basic abilities no matter if you were a walking character or one in a Goliath. So, for me all I'm doing is rotating the controller and using that to drive the rotation of the Pawn. You're right however, if you're not going to be switching Pawns, you only need to put the logic in the Pawn.

    However, take my Quad Copter game. While you'd never switch Pawns in gameplay, I'm planning on having several classes of Copters (Light, Heavy, Balanced, etc.) and I'd want to have almost all my logic in the Controller so that I could have whatever Pawn I wanted and not have to redo the input and control code for each one I make (And keep it updated).

  17. #17
    0
    True to your case, however(yes there is always a however), if you think about your game, which closely mimic the UFO example, shouldn't it be easier to have one generic flying blueprint that has all the logic, expose control parameters(like thruster strength, weight, mesh, etc) and leave the specific( ie animation and material etc) to your types of new blueprint vehicle.

    It certainly is a hack in my opinion to let user directly access keyboard and other controller events, when you can already create custom events in project settings' input bindings.
    This way you can always have character/vehicle separation where W in character binds to MoveForward, and in vehicle binds to Acceleration, and you just use those events in your Pawn blueprint.

    Also, I think it kinda make sense to disable replication for default Pawn class, where they are mostly used for either debugging or spectating purpose(which don't replicate their movement to server/other client anyway.)
    So when you inherit Pawn, there should be a movement component that we can use, and that has to wait for Epic.( Right now only have projectile and rotating movement component that you can add to a bluepriint.)

  18. #18
    0
    This looks good, will follow to see the progress looking to do some thing on my own like this. Keep it up!

  19. #19
    0
    Update, it seems that Pawn might actually do replicate, just that it's own static mesh isn't replicated by default.(And somehow StaticMesh replicate isn't exposed in component)
    Check this question and you can see there is a bStaticMeshReplicateMovement flag available when you blueprint a StaticMeshActor.(For something like physic enabled box/barrel/etc)

    Warning, CODE block ahead, it should still be pretty easy to understand with any kind of scripting experience. Many keywords should be really familiar if you played Blueprint for a while
    Also, here is how DefaultPawn setup it's control, as I predicted, you add those input event binding in Pawn blueprint.(binds to a string you setup in editor)
    These should be your basic setup if you create a new Pawn blueprint. (not from Custom Classes)
    Code:
    void ADefaultPawn::MoveRight(float Val)
    {
       if (Val != 0.f)
       {
          if (Controller)
          {
             FRotator const ControlSpaceRot = Controller->GetControlRotation();
    
             // transform to world space and add it
             AddMovementInput( FRotationMatrix(ControlSpaceRot).GetScaledAxis( EAxis::Y ), Val );
          }
       }
    }
    
    void ADefaultPawn::MoveForward(float Val)
    {
       if (Val != 0.f)
       {
          if (Controller)
          {
             FRotator const ControlSpaceRot = Controller->GetControlRotation();
    
             // transform to world space and add it
             AddMovementInput( FRotationMatrix(ControlSpaceRot).GetScaledAxis( EAxis::X ), Val );
          }
       }
    }
    
    void ADefaultPawn::MoveUp_World(float Val)
    {
       if (Val != 0.f)
       {
          AddMovementInput(FVector::UpVector, Val);
       }
    }
    
    void ADefaultPawn::TurnAtRate(float Rate)
    {
       // calculate delta for this frame from the rate information
       AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
    }
    And rotation related are inherited from Pawn, note that even though it gets player controller to add rotation values,
    but this is entirely inside Pawn.cpp. So in blueprint sense it should be in the event graph(ie, you might have different turn rate limit for different pawn)
    Code:
    void APawn::AddMovementInput(FVector WorldDirection, float ScaleValue)
    {
    	UPawnMovementComponent* MovementComponent = GetMovementComponent();
    	if (MovementComponent)
    	{
    		MovementComponent->AddInputVector(WorldDirection * ScaleValue);
    	}
    }
    
    void APawn::AddControllerPitchInput(float Val)
    {
    	if (Controller && Controller->IsLocalPlayerController())
    	{
    		APlayerController* const PC = CastChecked<APlayerController>(Controller);
    		PC->AddPitchInput(Val);
    	}
    }
    
    void APawn::AddControllerYawInput(float Val)
    {
    	if (Controller && Controller->IsLocalPlayerController())
    	{
    		APlayerController* const PC = CastChecked<APlayerController>(Controller);
    		PC->AddYawInput(Val);
    	}
    }
    
    void APawn::AddControllerRollInput(float Val)
    {
    	if (Controller && Controller->IsLocalPlayerController())
    	{
    		APlayerController* const PC = CastChecked<APlayerController>(Controller);
    		PC->AddRollInput(Val);
    	}
    }
    And here is the binding part(note these won't be exposed in editor, thus we should probably avoid inherit DefaultPawn and use it as sort of debug Pawn. although you can also disable default binding and roll your own and get free movement component.)
    Code:
    void InitializeDefaultPawnInputBindings()
    {
    	static bool bBindingsAdded = false;
    	if (!bBindingsAdded)
    	{
    		bBindingsAdded = true;
    
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveForward", EKeys::W, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveForward", EKeys::S, -1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveForward", EKeys::Up, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveForward", EKeys::Down, -1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveForward", EKeys::Gamepad_LeftY, 1.f));
    
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveRight", EKeys::A, -1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveRight", EKeys::D, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveRight", EKeys::Gamepad_LeftX, 1.f));
    
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::Gamepad_LeftThumbstick, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::Gamepad_RightThumbstick, -1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::Gamepad_FaceButton_Bottom, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::LeftControl, -1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::SpaceBar, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::C, -1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::E, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_MoveUp", EKeys::Q, -1.f));
    
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_TurnRate", EKeys::Gamepad_RightX, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_TurnRate", EKeys::Left, -1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_TurnRate", EKeys::Right, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_Turn", EKeys::MouseX, 1.f));
    		
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_LookUp", EKeys::Gamepad_RightY, 1.f));
    		UPlayerInput::AddEngineDefinedAxisMapping(FInputAxisKeyMapping("DefaultPawn_LookUp", EKeys::MouseY, -1.f));
    	}
    }
    
    void ADefaultPawn::SetupPlayerInputComponent(UInputComponent* InputComponent)
    {
    	check(InputComponent);
    
    	if (bAddDefaultMovementBindings)
    	{
    		InitializeDefaultPawnInputBindings();
    
    		InputComponent->BindAxis("DefaultPawn_MoveForward", this, &ADefaultPawn::MoveForward);
    		InputComponent->BindAxis("DefaultPawn_MoveRight", this, &ADefaultPawn::MoveRight);
    		InputComponent->BindAxis("DefaultPawn_MoveUp", this, &ADefaultPawn::MoveUp_World);
    		InputComponent->BindAxis("DefaultPawn_Turn", this, &ADefaultPawn::AddControllerYawInput);
    		InputComponent->BindAxis("DefaultPawn_TurnRate", this, &ADefaultPawn::TurnAtRate);
    		InputComponent->BindAxis("DefaultPawn_LookUp", this, &ADefaultPawn::AddControllerPitchInput);
    	}
    }
    So maybe there is a way to make a new Pawn class replicated properly.
    I will keep you guys posted.

  20. #20
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    85
    OMG! 1 word -OMG!Whata hieroglyph! I'm kidding
    I know you wanted to help=) but the title says "come and learn BLUEPRINT multiplayer with me" and we want to learn BLUEPRINT multiplayer

  21. #21
    0
    Seeing it in the native code is very informative. For example, knowing that the GameType was responsible for executing the ChoosePlayerStart function helped me in my version of it. Seeing how all this is set up natively should help me make a better blueprint. I'm looking forward to getting back into UE4 in the next few days (darn that work and family, taking my UE4 time!) to try out a bunch of this new knowledge!

  22. #22
    0
    Quote Originally Posted by Korben View Post
    OMG! 1 word -OMG!Whata hieroglyph! I'm kidding
    I know you wanted to help=) but the title says "come and learn BLUEPRINT multiplayer with me" and we want to learn BLUEPRINT multiplayer
    LOL, sorry, I did put warning message in bold.
    The reason being trying to find out how to setup a working multiplayer blueprint kinda needs to read those native code a bit.
    And since I already put sometime into finding relevant info, I also want to keep it in one place in this thread so in the future I can refer back to it.
    I can already see myself rolling the controls pretty soon and hopefully can give you guys a movement replicated Pawn blueprint so people can happily do extend it.
    The good thing about this is that Tom's project is the empty blueprint project, thus as of now it has no asset dependency except that arrowMesh.
    So any blueprint derived from this project can be copied to other project and start to work, just need to replace arrow into something available with engine would do the job.

  23. #23
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    112
    Movement replicated pawn you say PenguinTD? Such a thing would be most appreciated, thanks for having a go at it.

    I'll admit I too am somewhat illogically afraid of the sight of code, and I'm wondering if it would be difficult to "install" your altered replicated pawn, if you are successful in creating it?

    Thanks again for your efforts

  24. #24
    0
    Important Framework diagram:

    It is from this doc link

    Also controller diagram:

    From this doc link, note it has example blueprint to address what's "forward" in moving forward.
    Just post it here for future reference.
    Last edited by PenguinTD; 04-21-2014 at 07:18 PM.

  25. #25
    0
    Quote Originally Posted by Zurael View Post
    Movement replicated pawn you say PenguinTD? Such a thing would be most appreciated, thanks for having a go at it.

    I'll admit I too am somewhat illogically afraid of the sight of code, and I'm wondering if it would be difficult to "install" your altered replicated pawn, if you are successful in creating it?

    Thanks again for your efforts
    It shouldn't be, I think both Tom and I are trying hard to avoid(to some extend) doing any native code and to achieve full multiplayer enabled pawn from default project.(Not from the altered template project where Epic already included additional Character/Pawn classes).
    The goal I have in mind is to simply take this opportunity to learn the framework and understand what can I do with it, and where is the brick wall surrounding our happy blueprint world.
    If anything serious we run into, we can always ask in answer hub and maybe Epic can do actual update that enables pure blueprint based multiplayer.

    So, given that said, the install I have in mind would pretty much just copy the blueprint to your project's game folder and it's ready to use.
    Where all the reference to assets(mesh, material) would be replaced with default Engine provided ones.

  26. #26
    0
    Quote Originally Posted by Tom Shannon View Post
    Seeing it in the native code is very informative. For example, knowing that the GameType was responsible for executing the ChoosePlayerStart function helped me in my version of it. Seeing how all this is set up natively should help me make a better blueprint.
    ^ This

    Helps you devise clever work arounds when things aren't exposed to the Blueprinting system.
    Rule#21: Be polite, be professional, but have a plan to kill everyone you meet.


  27. #27
    0
    Tom Shannon! I commend you on all the work you've done thus far. I'm very keen about getting every thing done in BluePrint as well. The path seems much more exciting to explore simply because I haven't scripted this in-depth with a nodal base system. So this will truly be a beautiful thing to see unfold. I've downloaded what you've done so far and will be working myself to get all the basics done. I've been working hard on other solutions but MultiPlayer has been something I want to dive into as well. Thanks again for sharing!

  28. #28
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    618
    We are working on some materials that should really help people get to grips with networking, BP and C++!

  29. #29
    0
    Quote Originally Posted by JamesG View Post
    We are working on some materials that should really help people get to grips with networking, BP and C++!

    Fantastic thread to follow. Thanks to all of you involved co students for sharing the knowledge and JamesG for awesome work on UE4.
    Rock ON!

  30. #30
    0
    Awesome thread, keep it going! I will contribute as much as I can.

    I have played around with replication a fair amount on my local machine but have decided to move over to a real environment for development of replication (Internet), although I haven't figured out how to make a server listen for another clients connection yet. Any ideas?

  31. #31
    0
    The Rainbow Warrior



    Join Date
    Mar 2014
    Posts
    2,613
    Congrats on finally taking the dive into Replication Tom!

    I knew you and replication had a future together!

    See?

    Now you are leading the pack!



    Rama
    100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

  32. #32
    0
    Supporter
    Join Date
    Apr 2014
    Posts
    2
    This is awesome, thank you posting this. I'm having an issue with the blueprint. I'm trying to add the ChoosePlayerStart into my own game, but I can't get a ReturnNode. I'm new at this and if anyone could point me into the right direction that would be wonderful. Thanks.

  33. #33
    0
    Supporter
    Join Date
    Apr 2014
    Posts
    2
    Never mind, I figured out. You have to click on the function within the graph and add an output, just in-case anyone else gets stuck on this.

  34. #34
    0

    Success!!



    First off: Thanks, everybody! I'm happy that this thread is getting people into thinking about the fine points of Blueprint multiplayer. I'm sorry for not updating sooner. I've been really busy and completely stumped. A bad combo. I was having a huge headache figuring out exactly what client, server, etc. was calling any given function and, more importantly, why.

    Fortunately, Epic posted some AWESOME videos on Blueprint networking. If you haven't seen them... SEE THEM NOW!
    There's a couple hours worth, but they REALLY clearly explain everything from replication to the various ways Blueprints can send and receive data from servers.
    https://www.youtube.com/playlist?list=PLZlv_N0_O1gaG5BW72It4chjhypxIO9ZB

    Thank you Epic for providing such awesome learning resources. I'm blown away. The things people will be creating with UE4 will push gaming far and fast.

    Now, for the good news:
    I've got replicating, physics-based actors playing in multiplayer. Both with a dedicated server and a listen server. I haven't tested outside of the editor, but that's gonna happen tomorrow. I'm writing up a post now, but wanted to let y'all know that there's been progress and that it's GOOD.

    Here's a little preview:


    And, here's the project files for those that just can't wait to take a look!:
    https://dl.dropboxusercontent.com/u/618044/BPMP/BPMP_20140415.zip

    I'll be back tomorrow with the full breakdown!

  35. #35
    0
    Quote Originally Posted by JamesG View Post
    We are working on some materials that should really help people get to grips with networking, BP and C++!
    The videos were a revelation! I was starting to grasp the basic tenants of replication, but seeing them in a simple example was massively important. I'm impressed that even the advanced topics like relevancy were covered.

    For those that haven't seen them:
    https://www.youtube.com/playlist?list=PLZlv_N0_O1gaG5BW72It4chjhypxIO9ZB

  36. #36
    0
    Quote Originally Posted by Rama View Post
    Congrats on finally taking the dive into Replication Tom!

    I knew you and replication had a future together!

    See?

    Now you are leading the pack!



    Rama
    Yeah, buddy! your crazy, rainbow-hued replication inspired me! Thanks for the encouragement.

  37. #37
    0
    Tom, you are awesome, and Epic is also awesome, see that tutorial series clears a lot things up.

    Edit:I also have something half baked, which does not rely on DefaultPawn's movement component and does not have to use the physics part of Pawn class.
    Ideally, there should be a switch to do first person/third person, and a switch to use the physics(move by adding force to set velocity) or just purely roll your own movement(you would have to handle collision response.)

    So far, I can do most of the movement part in later mode, with rotation left to tweak(heavily referencing how the Input example do to the UFO.)
    And Tom's example for 6-DOF tutorial, but you know what, control is indeed a major part of the game, get the feel right needs a lot work.

    Also, I think Tom's player start method can be improved, so you no longer have to rely on a tag( which potentially restrict how many player can spawn on a map, or when Pawn died you used up all respawn point.),
    as I mentioned before, I intended to spawn in a volume, but I haven't get to how to default spawn to a spectator pawn and then possess a player pawn with possibility to choose team. I'll do that once the rotation part is done.
    Last edited by PenguinTD; 04-16-2014 at 12:17 PM.

  38. #38
    0

    How to train your pawn to replicate!

    Hello all. I'm back and I've got all kinds of stuff to share. I'll be posting here, then once everybody's had a chance to take a look and give it a go, I'll publish a nice tutorial to the Wiki.

    Thanks to all who contributed. I'm absolutely shocked how well this works and how much fun it is to play with a frend or two in a game you've greated, even if it's absurdly simply liek this.

    What's been done

    • The 6-DOF pawn I built HERE has been made to fully replicate. Physics and movement are handled completely on the server.
    • A simple attack has been made (Blast Attack!) that uses a physics impulse to blast other pawns away from the player.
    • Tested on LAN and it's very fun :F


    Letting the server do it all

    One of the first big problems I was having is that when Physics Enabled was set to true on the Pawn, there was some really wacky behavior. What other clients would see and what the player would see were quite different. The player would rotate a little and stop, meanwhile, the other clients would watch as the player's representation would continue to rotate as if pushed by physics. If the pawn were on the ground, it would even roll about. Meanwhile, the player's view was totally still, until they moved, then each of the clients would correct for a moment before returning to their physics drift.

    Thanks to the videos posted by Ben earlier this week, I was able to understand that what I was seeing was the server replicating physics and sending that data to the clients while the local player was seeing the result of their input only.

    My solution was bold, but has fixed my issues and allowed me to quickly expand the functionality beyond my original goals!

    How it's done:

    Server-Only Physics:
    I turned off physics COMPLETELY on the local clients. That means that only the server would be doing those calculations. this little line of Blueprint has changed everything for this test:


    Sending input to the server to handle:
    Now, I just had to make Custom events that replicated from the Client to the Server each time there was input from the player:


    And, then do the actions I wanted to the pawn on the server. Each of these custom actions is set to Run on Server and has the Reliable box checked. I figure that input should definitely be replicated reliably, and should be a very small packet to send as I'm only sending the input value:


    Getting the data back from the server to the payer:
    At this point, everything was working really well... At least on all the remote clients. My arrows were zipping all over! However, my local player wasn't moving at all. I'm assuming that because player input generally isn't handled remotely, the optimized Replicate movement propoerty of pawns doesn't bother. So, I made my own!

    After struggling with the jerky, un-smooth replication of position and rotation, I tried replicating the entire transform of my pawn pack to the player. Smooth as butter! I know that this is a very expensive operation, especially at high frame rates, but it's pretty essential for the player to have smooth, fast input. I'll experiment with reducing this workload, but for now this works:


    And, that's it! That makes it all work! Seriously. Here's the entire Pawn's Event Graph (The fancy Blast Attack is there in green. I'll cover that next)


    And, here's video of it doing its thang (Sorry about the low frame rate, it runs MUCH faster and smoother locally)!


    SOURCE FILES:
    And, here's the project files as of the recording of this video:
    https://dl.dropboxusercontent.com/u/618044/BPMP/BPMP_20140417.zip
    Last edited by Tom Shannon; 04-20-2014 at 09:22 AM.

  39. #39
    0
    Quote Originally Posted by PenguinTD View Post
    Tom, you are awesome, and Epic is also awesome, see that tutorial series clears a lot things up.

    Edit:I also have something half baked, which does not rely on DefaultPawn's movement component and does not have to use the physics part of Pawn class.
    Ideally, there should be a switch to do first person/third person, and a switch to use the physics(move by adding force to set velocity) or just purely roll your own movement(you would have to handle collision response.)

    So far, I can do most of the movement part in later mode, with rotation left to tweak(heavily referencing how the Input example do to the UFO.)
    And Tom's example for 6-DOF tutorial, but you know what, control is indeed a major part of the game, get the feel right needs a lot work.

    Also, I think Tom's player start method can be improved, so you no longer have to rely on a tag( which potentially restrict how many player can spawn on a map, or when Pawn died you used up all respawn point.),
    as I mentioned before, I intended to spawn in a volume, but I haven't get to how to default spawn to a spectator pawn and then possess a player pawn with possibility to choose team. I'll do that once the rotation part is done.
    Take a look at my new post above. that should get you up to speed with the movement replication. Its still relies on the built-in replication to get the position and rotation to the other clients, but you'll see how that all works, I think.

    I've also been thinking about the player start issue. My system works fairly well for a racing game, where the player will always want to spawn in an ordered location and only ever once per match (unlike deathmatch for example.) I was thinking of doing a Get all Actors-> Pawn within a certain distance of each player start to see if they are valid, rather than relying on the tag system.

  40. #40
    0
    I kinda get the system down as well, albeit looks different from yours, I don't know if it's correct(edit: by correct I mean I merge input event flow that could have some sort of conflict, but all my control feels fine no interlocking at all, maybe James or other Epic guys could tell us if this is a good/bad approach), but here is what I have for replicated movement.

    **EDIT**: Please note that my control does not use any physics simulation at all, and will go through everything even if my pawn is set to block all. It is because I force update actor location without checking hit event.(I don't even know if you don't simulate physics, will hit event ever emit.) I know we shouldn't reinventing wheels, but this is for study purpose for me, so use at your own risk.

    Here is my pawn setup, that "Use Controller View Rotation" option almost drive me nuts, after check that off all the camera behavior was solved.


    Here is the part to handle movement related input


    Here is OnRep called when force vector is set


    Here is torque input and OnRep Torque



    And finally, the part doing update and some debug input to do a break(I haven't implement damping yet.)


    And here is the result(spawn still using Tom's method, but use teleport):
    Last edited by PenguinTD; 04-18-2014 at 02:55 PM.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •