At 12:00 I need a solution of player choosing a pawn to play as in the main menu level and then it uses that value to spawn the class in gameplay level.
For anyone who's having the problem of not being able to control their server's pawn, you need to delay the set mapping context logic on event begin play until after the the pawn has been possessed. I just put a 'delay until next tick' after event begin play and it worked for me. :) P.S. Kekdot, I love you, man. I hope to have the time to sit your courses one day. It's because of you that my idea for a small multiplayer game doesn't seem so far-fetched. I sincerely hope you are doing well.
You're a life savior my friend. Kekdot is a beast in multiplayer. I already learned a LOT of things but I was having that issue and was wondering if I missed something. I viewed this video like 10 times already and you helped me with the problem. Thank you PitchforkGames and @Kekdot for your awesomeness!
Omg guy you saved my life :D i thought that i missed something in the course and i played a lot of time and didnt find the solution. Thank you so Much. These courses are so good thank you so much guys ! You ll maybe make my dream becomes true.
I have never found someone that explains things in such clear detail. Usually when I am following tutorials I am left wondering about edge cases or why they did it a certain way, whenever a question like this pops up in my head you are usually already answering it in your next breath.
The first time I see a TH-camr that actually explains it all perfectly. Even Unreal Engine channel had mistakes using Gamemode class. Some people explain Replication in a good way but not classes or what to do where, Others just did it using bad practice and shared a video about it, But Kekdot is awesome for explaining the replication stuff alongside classes and what to do in which class. So thank you very much for it.
Great tutorial series and explanations. I cannot wait to watch more. I'm following along roughly but I'm doing a c++ project so as I'm following I'm converting it to c++. In case anyone is doing the same or something similar, there is one problem that I came across and I'll share how I solved it in case anyone else might be in the same boat. You will need to do a deferred spawn of the pawn (SpawnActorDeferred), possess the pawn then call FinishSpawning. This is because you want to call the BeginPlay code in the character class after you possess the pawn so the controller can be all set up (If not the controller will be nullptr when the player is spawned). This is using the third person character blueprint
I'm having this exact problem, I can't control the pawn on the server. Can you dumb this down a bit for me please? Are these nodes to be placed before spawn actor and after possess nodes in the game mode function?? Thanks so much!
Yeah, pretty much the problem I had as well where the pawns spawn but you cannot control them. I'm not sure how much you know so I will just explain as much as I can. So in your SpawnPlayer function in your GameMode class you would do everything that was said in the tutorial for this method (around 12:31 minutes I think) except up to spawning of the player pawn. For spawning the player pawn you would do something like this: ACharacter* NewPlayerPawn = GetWorld()->SpawnActorDeferred(BP_Character, SpawnTransform). SpawnTransform would be the random spawn location you get from FindRandomPlayerStart(), ACharacter is your character class and BP_character is a UPROPERTY that you can set in your header file so you can pick a blueprint in the unreal editor. This means that you don't have to hardcode any blueprints in your solution. You would want to do something like this: UPROPERTY(EditDefaultsOnly) TSubclassOf BP_Character; The TSubclassOf from what I read online is so that it makes sure the drop down list when selecting it in the editor will only show classes or blueprints of the type ACharacter. At this point the pawn is not spawned. What I did after this is just check if NewPlayerPawn is a nullptr. If it is then I will just print a message in the logs. After this you can now possess the player: PlayerController->Possess(NewPlayerPawn). This will set up the controller on the pawn. Finally you can call this: NewPlayerPawn->FinishSpawning(SpawnTransform) to finish the spawning. It requires a transform so I just passed in the SpawnTransform a second time. This will then trigger the BeginPlay in the character to trigger as the character is spawned and now that we have a controller set up before the player is spawned, the if statement on line 63 for the input in the Character class will be able to run since the controller variable is not a nullptr. Hopefully this makes more sense. It's a bit messy trying to write code here. I'll write the code below as well, might be easier: // Spawn the player pawn. Do a deferred spawning as you need to possess the player before spawning to run BeginPlay on the Character // If not you will not be able to control the character ACharacter* NewPlayerPawn = GetWorld()->SpawnActorDeferred(BP_Character, SpawnTransform); if (NewPlayerPawn == nullptr) { UE_LOG(LogTemp, Warning, TEXT("SpawnPlayer - Did not spawn")); return; } // Let the player controller possess the player pawn PlayerController->Possess(NewPlayerPawn); // Finish spawning NewPlayerPawn->FinishSpawning(SpawnTransform); Hope this helps
These are awesome 👌 No one gets into explaining why you do certain things contained within a certain class ...and how they work with eachother during launch or game play , the hardest part is figuring out when and where to do something and why I find .... Keep it up , these tutorials are great 👍
honestly at this point I really think you're the best on youtube to teach multiplayer programming in unreal engine, keep doing what you do, your channel will explode at some point
Thank you very much! You’re making world a better place! ❤❤❤ I love how you cover everything in that much detail as it should be. And I love that you use appropriate classes for implementing stuff, not just everything in one can
Good work creating such detail tutorial and thank you. I like your tutorials because other tutorial only explain what the blueprint does however your tutorials not only explain that but also why is it implemented this way and what are the best practice moving forward. Hope to see more wonderful videos from this channel.
I'm using version 5.3 and I had an error, the server and clients could not move, I solved it like this: 1. open "BP_thirdPesonCharacter" 2. right click on graph -> write: "Event Possessed" 3.connect the event "Event Possessed" to everything that comes after Event BeginPlay For Example: yours Event BeginPlay connected to sequence, connect "Event Possessed" to sequence too OR you havent sequence, connect the "Event Possessed" to everything you are connected to Event BeginPlay I hope everything worked out for you and I helped you solve this problem a little faster) good Luck!
I fixed mine by double checking to see if my spawn player function was using the player controller I created; for example mines was BP_PlayerController on the input value.
Can't figure out why, but my characters does not move (I can do all my other coded actions) and I cannot move the camera. Also the HUD works when I first spawn but when I press P the hud stops calling values to the progress bars.
Hi, I had the same problem and this is how I fixed it. In the BP_ThirdPersonCharacter I copy 2 nodes, the Add Mapping Context with the IMC_Default as its Mapping Context and the Enhanced Input Local Player Subsystem. I paste these 2 nodes to the BP_Player controller of this tutorial. On the Event BegingPlay node line, after SR_SpawnPlayer I added the 'Add Mapping Context' that was copied. To the input of that node I connected the 'Enhanced Input Local Player Subsystem' that was also copied earlier. Now to this node Input I connected a Get Player Controller. This is what fixed the bug for me. I know your comment is old so you probably already found a solution. I comment this incase someone in the future gets the same bug and they are looking at the comments for a posible solution. Good luck!
Hi! I've followed this exactly and I'm having issues. For some reason, after spawning, actor components won't automatically activate for some reason. The character movement component is fine because I'm using Event Possess but custom actor components won't automatically activate.
Hi, Great explanations. I can't find the video where you was supposed to explain the management of the Datas of the player... Did I miss something, or didn't you make it ? Thanks for everything.
Great Series! I have 5 player start locations and up to 5 players and inevitably 2 players are off the map (black screen not sure where they are). Sometimes it works and I get all five, but its one in 10. Any ideas? Player spawn is implemented exactly your tutorial but with 5 players.
In that case those players don’t have enough processing power to actually spawn properly. This gets caused in Unreal in the case your Player Controller is not initialized properly and then already gets communicated to. The black location you are describing is your x0y0z0 location in your world. (The location a player controller spawns at in case no pawn/character is properly possessed. To prevent / fix this simply move all the spawning code into your player controller. Only call upon the spawn as soon as the player is fully connected in the match. For example, after x seconds, or when af least for example a Player State is properly initialized. That is a good check since the player state is a class that is dependant on both the server and client version. You can do so by making a macro which checks for player state validation (IsValid). Once it is, spawn your character with logic from within your player controller opposed to directly spawning from the OnPosLogin nodes). Note that your issue is mainly caused by either properly laggy laptops/pc’s or when running many (for example 5) PIE test windows on one computer for testing. Either way the above solutions are a safe solution and are ready for a distributable game. Thank you for the $5, appreciate you. Let me know if you require more help. Kekdot
Love these tutorials! However I am still not in the clear what the GameState and PlayerState are going to be used for, wish there was a 7th vid demonstrating their use cases.
Followed this tutuorial exactly rechecked code twice, when play in editor host is able to move around just find but joining client spawns but cannot move.
I cannnnn't wait to learn about Playerstate! I've been struggling simply getting a working chat lobby going with names updated. I'll keep fighting the good fight until it pops. Ty much
Great work, your tutorials are very logical and easy to follow. Question, would it be more efficient to setup interfaces in place of the casts implemented in this series?
@@Kekdot seriously? Why do people give casting such a bad rep then?? I don't know enough about what's going on under the hood with all this stuff so when people are like "casting is bad, X is easy for the computer to do" etc I just take it at face value
Well casting simply pulls a reference of the entire acting you’re communicating with so that you can reach each variable and component of that actor to run logic on (get info, set info, or trigger events). This draws that actor into memory for some time but this will get garbage collected anyways. When using interfaces the engine behind the scene also pulls the actor it’s communicating the interface event with also into memory but skips all variables and actor components. But interfacing itself is also expensive due to handling more like a wildcard event. In all my 8 years of doing Unreal and having many Unreal friends non of us have ever ran into any actual issues using casts. As an indie game it’s truely hard to make the game perform poorly by simply using casts due to garbage collection cleaning up things fast anyways. If you’re starting out with your first games and they are not Call of Duty of Fortnite or The Witcher type products then casts are perfectly fine. As UE referenced themselves: Use cast for direct one on one blueprint communication. Use interfaces for one to many communication. (See the official UE documentation which explains this too) So don’t worry about it! Focus on making your game. Graphics have the biggest impact on your performance. Code won’t impact your performance by a longshot!
Thanks for the great tutorials. Have a question here. Why the BeginPlay event in player controller was triggered twice? Does that mean there are two instances of player controller on the listen server?
Indeed. The player controller exists both on the server and on the owning client. What that means is: When you are the host, you are the server and the owning client in one. So for the Host(server) the begin play wil trigger once. When you are a client. Then there exists the server version of your player controller (which fires a beginplay), and then the Owning Client version of your player controller which also fires the beginplay. (Owning client = your local offline version of your player controller). So when running a listen server with 2 players, then when you print string the beginplay event you’lll see: Server: says Hello Client1: says Hello Server: Says hello on behalf on client one again.
@@Kekdot Thanks for the fast response. Does that also mean if I am playing on the listen server, The game instance on my computer have double instances for all gameplay actors (except game mode and widgets)?
@@pyrochlore Heya, No the existance of every actor is different. In the Unreal Documentation they detail exactly how every actor exists. (Game Instance for example is always only locally, so there is just one version only, and that exists on your offline computer only.) Please see my video here in which I explain this in detail: th-cam.com/video/Hsr6mbNKBLU/w-d-xo.html
Here is how I solved the enhanced input system problem where the clients does not recieve input. 0: This code is on your character... 1: Add the "On Possessed" event. (This is only run on the server) 2: Create a custom event and set it to "Run On Owning Client". (This event will only be run for the player owning the pawn) 3: From "Event On Possessed" call your custom event. 4: Add the enhanced input mapping as usual to your custom event. Hope this helps :)
Thanks for the video! I did have one small issue but I managed to patch it, clients if they are using control rotation would reset their rotation once they were possessed, ignoring the rotation of the PlayerSpawn (which is unnoticeable if the PlayerSpawn's rotation matches a zero rotation). To fix this what I did was call a custom "OnPossess" event which runs on the owning client which sets the control rotation to that of the spawn transform. I hope this helps anyone who also runs into this! PS: If there's a better way of doing this I'd love to know btw, this somewhat patchy but it works
Hi man, your series is awesome and very well explained. I have a weird error in my multiplayer project, first of all I created and uploaded a dedicated server on AWS, when I log in the game the client character spawn attached to another one and the playerController only works as "Multicast - reliable" when I switch on "Run On Server" it gets an error like this "UEngine::BroadcastNetworkFailure: FailureType = ConnectionLost, ErrorString = Your connection to the host has been lost., Driver = GameNetDriver IpNetDriver_4" do you have an idea of what could possibly be? Cause I cant find any documentation about it. Thank you
I had the no spawning and no control issues among others. The fixes in the other comments helped but not fully. The big fix for me was making sure the GameState BP had GameState as parent class and not GameStateBase. So for GameMode and GameState the parent classes have to match, either the Base or non-Base ones. You can easily switch without remaking them, it's the Class Settings button on the top bar.
Yeah classes have to be of the same type. GameModeBase is for singleplayer games. GameMode is for multiplayer. All non-base classes are for multiplayer.
I'm following the whole tutorial exactly how it says but I have a weird bug where the one of my players doesn't move. If I spawn them with the "world settings" and not with the "player controller" everything seems to work fine. Any suggestions? It's always the server window that the player doesn't move
From @macca95 below: Update for anyone having this issue. Open the third person character blueprint, add the even on possessed, plug that into Cast to PlayerController along with the begin play event. Credits to Blackpinned for finding the solution!
What he means is: 1. Open the Character Blueprint 2. Then in the graph type ‘On Possessed’. This will give you an event for when a player controller possesses the character. 3. Now hook both the event OnPossess and event Beginplay into the Cast logic. Let me know if that cleared it up
Have been following the tutorial series and loved it so far! One issue: trying to figure out why my client can move around, but my server can not. I noticed that only one PlayerController is created in my game, but I do not see any differences in our nodes at all.
Same issue here, only one of the characters gets any input at all, but absolutely everything when casting is showing as valid, correct controllers and all, I think it might have something to do with UE5's enhanced input but just can't figure it out at all :/ @@toeyexperience
I've just got the exact same problem yeah, maybe because we started from a ThirdPerson project, not an empty ? Or may it be because of the enhanced input ? (I don't find how to put the camera in AZERTY mode, in the characters inputs it works but not in the basic flight camera, any idea ?)
Interesting, my server input does not work, but with dispatcher it works correctly) if playerstart object have big Z offset relative floor character mesh looks like a little bug)
Nice explanation! However, just to confirm and make it completely clear I have one question. So we are still calling all these event stuff inside a local player controller and we are allowed to access game mode which is on a server only because we set this event properties to execute specifically on a server side? Technically we have all of these code both on server and client, but the part triggering event checks if it is spawned only by client and then, event is executed only on server because we set it to do so? And we must use event here because this is the only way to communicate this call back to server?
Hey, how could I change the code at 10:01 from random intergers to specifc. For example Player 1 spawns at playerstart1 and player 2 spawns at player 2 start? Thanks for your help
I had a question that I can't seem to fix on my own, I want to run the respawn event from the player after damage is taken (I'm using a event point damage) So I cast to the player controller but realized that using Get player controller for the cast only ever gets the server client. Any tips on how to cast to a specific player's controller would be amazing.
Friendly tip: When i would play, my client couldn't move. I looked everywhere for answers and i couldn't find anything! After smashing my head a few times, i realized that i had created a new level to test this. Of course, when you create a new level you only have one player start... When i added another one, my players spawned and both could move. Why does it work now? I don't know but it works and that's what's important haha. MAKE SURE YOU HAVE MORE THAN ONE PLAYER START!
Having an issue where all the clients can move properly. But the host is unable to look / move around. Any ideas what could be wrong? ive checked a few times and it looks like everything is set correctly. I am just using the starting 3rd person character
Update for anyone having this issue. Open the third person character blueprint, add the even on possessed, plug that into Cast to PlayerController along with the begin play event. Credits to Blackpinned for finding the solution!
Thank you so much for figuring this out! UE 5.1: BP_ThirPersonCharacter->EventGraph->RightClick ->Event Possessed->link this to everything after the "Event BeginPlay" of the template.
How do you solve that 2 players spawn in the same place at the same time and destroy or do not allow one of them to spawn? That is why your system should not be "random", but assign a specific player start to each player that enters
why i can just spawn on postlogin clients and not host? when i put there begin play, it will spawn host, but when someone connect, it will launch postlogin on host too(so there will be 2.times hosts pawns)
First off, fantastic tutorial. But do you know how to fix the client rotation. I made a system very similar to this and found this video while trying to resolve the rotation problem on the client side.
Thank you! You would need to set the Player Controllers Control Rotation upon spawning the character. So not the character rotation, since that's not what causes this, but the player controllers Control Rotation is what is causing the client to look towards the 0.0.0 rotation of the World. Let me know if you get it! Otherwise DM me on Discord
There's something very strange going on.. Put in a print string before your spawn character and another within the 'find random player start'. Can someone tell me why my print string in the 'find random player start' function fires 3 times??? You would think the entire event gets fired 3 times, but no.. the print in the spawn player event fires once. And this happens no matter how simple I make it, running only as server, no extra logic in the function, just function start connected to a print string, and fires 3 times. makes no sense
This works if I start on the same level, but If I start my clients on a startup level and then join the server level via open level, they will never see the other clients. Any ideas why?
What if you’re running a dedicated server for your game and it doesn’t need a player controller only clients. Do you still need to send the code to the server?
@kekdot please help, I followed exactly the same steps buy only clients can move after possesing. Host is not moving or looking arround. I can't figure out how to solve this problem.
Sadly it does not work yet with the new Motion Match Characters.. or im too stupid. :D i cannot move the server and it gets synced but im not able to move the client also the unreal engine first person character does not work for me, i just cant control it (in this case server and client)..
lovely, quite a question, i have a car selector ( cause instead of character pawn my game focuses on cars ) directly into the serverlobby Widget. i try as possible to make the car selector transfer the owning client the info like : wish car he selected. But ! for some reasons when i change the car index into the gamemode it's change the pawn for everyone ( even if i splitted the event to make it run on a custom event : run on owning clients) otherwise the fonctions works since the host force the selected pawn. just hard to understand how to make individual selections. that after map transfer spawn the old selected one.
Is there a way to test out your game with 2 or more players on one computer with Steam or EOS? It seems you need to get 2 computers up unless you setup a virtual environment as these services will be expecting you to be running separate steam or epic backends per player connected. With regular NetMode I found it amusing to be using one controller to control two network players running in circles on the same machine. I wish I could use a single steam or epic login backend to run for both players on the same machine even if it's just me playing me. I guess you could play your Steam subsystem against your EOS subsystem but that may complicate build switching of 2 online subsystems unless crossplay can be fully implemented easily here but I digress.
Not sure what I'm doing wrong in my game controller when I try to cast to the game mode from the SR_Spawn_Player event get game mode is always empty and the cast always fails.
Hi! For me it didn't work, when the game starts the camera is at the origin of the map coordinates. If I assign a character in the world settings, it just doesn't move. But any buttons that I assign in the player controller work. Can you explain what's wrong? UPD: The same code worked on UE5.5 But with arrows "Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetLocalPlayerSubSystemFromPlayerController_ReturnValue". Node: AddMappingContext Graph: EventGraph Function: Execute Ubergraph BP Player Base Blueprint: BP_PlayerBase"
I use the MultiplayerLobbyKit from cedric neuenkirchen. On me it doesn´t work. i join from the hosted game to a new level and there the function isnt called. How to handle this with joining the whole players to a new level and query the whole players to select a player controller and spawn the character
So you're still spawning the character twice, and then destroying one of them. You can see this if you remove your validation code, and just have it go straight to spawn actor from class then posses.
Watch again. One question:Why the function begin play in player controller fires once in listen server and twice in client ? The listen server has only one player controller and the client has two player controller, one is in local and the other in server(the latter is duplicated when the client connects to the server). Is that right?
Does anyone know how to fix server and client not being able to move on first person bp? there is no event begin play by default and i tried adding it and then adding event possessed to it but did not work
Check that your GM and GS BPs have GameMode and GameState as parent classes (Class Settings button top bar). Having the -Base parent classes on either will break things. If you want to use Base it has to be Base on both.
Hey guys,
👨🏫 My Patreon link:
www.patreon.com/kekdot
Download Project Files | Premium Tutorials | Courses
💦 Get our Game on Steam | Kekdot Center:
store.steampowered.com/app/1487180/Kekdot_Center/
At 12:00 I need a solution of player choosing a pawn to play as in the main menu level and then it uses that value to spawn the class in gameplay level.
For anyone who's having the problem of not being able to control their server's pawn, you need to delay the set mapping context logic on event begin play until after the the pawn has been possessed. I just put a 'delay until next tick' after event begin play and it worked for me. :)
P.S. Kekdot, I love you, man. I hope to have the time to sit your courses one day. It's because of you that my idea for a small multiplayer game doesn't seem so far-fetched. I sincerely hope you are doing well.
You're a life savior my friend. Kekdot is a beast in multiplayer. I already learned a LOT of things but I was having that issue and was wondering if I missed something. I viewed this video like 10 times already and you helped me with the problem. Thank you PitchforkGames and @Kekdot for your awesomeness!
Thank you I found whole internet to fic this and answer was just in the comment section. 😅😅
Omg guy you saved my life :D i thought that i missed something in the course and i played a lot of time and didnt find the solution. Thank you so Much. These courses are so good thank you so much guys ! You ll maybe make my dream becomes true.
Thank you so much! I've been scratching my head and researching for two days trying to fix this lol
I still get an accessed none on Array_Get_Item on spawn. Any ideas? Thanks in advance
I have never found someone that explains things in such clear detail. Usually when I am following tutorials I am left wondering about edge cases or why they did it a certain way, whenever a question like this pops up in my head you are usually already answering it in your next breath.
Dont say sorry for explaining "too much" your channel is just PERFECT! YOU ARE AMAZING MAN!
You rock chief! Please, do not stop, we need tuts as detailed as yours! Actually, Epic should put them as official docs videos..
Epic need to hire this guy!
These have been the best tutorial videos I think I've ever seen on TH-cam. I'm just starting out with Multiplayer and omg.
The first time I see a TH-camr that actually explains it all perfectly. Even Unreal Engine channel had mistakes using Gamemode class.
Some people explain Replication in a good way but not classes or what to do where, Others just did it using bad practice and shared a video about it, But Kekdot is awesome for explaining the replication stuff alongside classes and what to do in which class. So thank you very much for it.
I've learned more with this series alone than any other online videos I've ever tried to watch, hope you'll blow up you deserve it!
Appreciate you! More coming this week!
Great tutorial series and explanations. I cannot wait to watch more. I'm following along roughly but I'm doing a c++ project so as I'm following I'm converting it to c++.
In case anyone is doing the same or something similar, there is one problem that I came across and I'll share how I solved it in case anyone else might be in the same boat. You will need to do a deferred spawn of the pawn (SpawnActorDeferred), possess the pawn then call FinishSpawning. This is because you want to call the BeginPlay code in the character class after you possess the pawn so the controller can be all set up (If not the controller will be nullptr when the player is spawned). This is using the third person character blueprint
I'm having this exact problem, I can't control the pawn on the server. Can you dumb this down a bit for me please? Are these nodes to be placed before spawn actor and after possess nodes in the game mode function?? Thanks so much!
Yeah, pretty much the problem I had as well where the pawns spawn but you cannot control them. I'm not sure how much you know so I will just explain as much as I can.
So in your SpawnPlayer function in your GameMode class you would do everything that was said in the tutorial for this method (around 12:31 minutes I think) except up to spawning of the player pawn. For spawning the player pawn you would do something like this: ACharacter* NewPlayerPawn = GetWorld()->SpawnActorDeferred(BP_Character, SpawnTransform). SpawnTransform would be the random spawn location you get from FindRandomPlayerStart(), ACharacter is your character class and BP_character is a UPROPERTY that you can set in your header file so you can pick a blueprint in the unreal editor. This means that you don't have to hardcode any blueprints in your solution.
You would want to do something like this:
UPROPERTY(EditDefaultsOnly)
TSubclassOf BP_Character;
The TSubclassOf from what I read online is so that it makes sure the drop down list when selecting it in the editor will only show classes or blueprints of the type ACharacter.
At this point the pawn is not spawned. What I did after this is just check if NewPlayerPawn is a nullptr. If it is then I will just print a message in the logs. After this you can now possess the player: PlayerController->Possess(NewPlayerPawn). This will set up the controller on the pawn. Finally you can call this: NewPlayerPawn->FinishSpawning(SpawnTransform) to finish the spawning. It requires a transform so I just passed in the SpawnTransform a second time.
This will then trigger the BeginPlay in the character to trigger as the character is spawned and now that we have a controller set up before the player is spawned, the if statement on line 63 for the input in the Character class will be able to run since the controller variable is not a nullptr. Hopefully this makes more sense. It's a bit messy trying to write code here. I'll write the code below as well, might be easier:
// Spawn the player pawn. Do a deferred spawning as you need to possess the player before spawning to run BeginPlay on the Character
// If not you will not be able to control the character
ACharacter* NewPlayerPawn = GetWorld()->SpawnActorDeferred(BP_Character, SpawnTransform);
if (NewPlayerPawn == nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("SpawnPlayer - Did not spawn"));
return;
}
// Let the player controller possess the player pawn
PlayerController->Possess(NewPlayerPawn);
// Finish spawning
NewPlayerPawn->FinishSpawning(SpawnTransform);
Hope this helps
These are awesome 👌
No one gets into explaining why you do certain things contained within a certain class ...and how they work with eachother during launch or game play , the hardest part is figuring out when and where to do something and why I find ....
Keep it up , these tutorials are great 👍
honestly at this point I really think you're the best on youtube to teach multiplayer programming in unreal engine, keep doing what you do, your channel will explode at some point
Bro, after hours trying to resolve a multiplayer problem, I got it because of your video THANKS SOO MUCH
Pure gold! Thank you
Thank you very much! You’re making world a better place! ❤❤❤
I love how you cover everything in that much detail as it should be. And I love that you use appropriate classes for implementing stuff, not just everything in one can
I absolutely love how thorough you are!
Thanks so much for this tutorial! Solved my issue of players not generating stats correctly!
Looking forward to the next video in this playlist! Very nice explanations! Helped a lot!
your tutorials are best you can find!
Good work creating such detail tutorial and thank you. I like your tutorials because other tutorial only explain what the blueprint does however your tutorials not only explain that but also why is it implemented this way and what are the best practice moving forward. Hope to see more wonderful videos from this channel.
i really learn alot from this single video rather than doc with 115 pages,thank you and why you guys stop this series?
Your explanation is soo good please make more video like this
I appreciate you going into so much detail, thanks for creating this tutorial series! 🍻
Big Love to Kekdot...❤❤
Best tutorial series I have seen so far. Thank you @kekdot for sharing this with us!
Thank you for giving this level of detail! Thank you thank you thank you!
Excellent tutorials! Already subscribed, and anxious for the next chapters (specially the multiplayer stuff). Thanks for sharing your knowledge!
just want to say I really appreciate this video, thank you for this
its most complete off all yt!
I'm using version 5.3 and I had an error, the server and clients could not move, I solved it like this:
1. open "BP_thirdPesonCharacter"
2. right click on graph -> write: "Event Possessed"
3.connect the event "Event Possessed" to everything that comes after Event BeginPlay
For Example:
yours Event BeginPlay connected to sequence, connect "Event Possessed" to sequence too OR you havent sequence, connect the "Event Possessed" to everything you are connected to Event BeginPlay
I hope everything worked out for you and I helped you solve this problem a little faster) good Luck!
Thank you!!!
Thank you this works.
I fixed mine by double checking to see if my spawn player function was using the player controller I created; for example mines was BP_PlayerController on the input value.
Needed this! Thank you as always!
amazing series! any idea when next episode is coming?
At 14:42 you say the client prints “Hello” twice, but it is actually the server that does it.
Can't figure out why, but my characters does not move (I can do all my other coded actions) and I cannot move the camera. Also the HUD works when I first spawn but when I press P the hud stops calling values to the progress bars.
Hi, I had the same problem and this is how I fixed it. In the BP_ThirdPersonCharacter I copy 2 nodes, the Add Mapping Context with the IMC_Default as its Mapping Context and the Enhanced Input Local Player Subsystem.
I paste these 2 nodes to the BP_Player controller of this tutorial. On the Event BegingPlay node line, after SR_SpawnPlayer I added the 'Add Mapping Context' that was copied. To the input of that node I connected the 'Enhanced Input Local Player Subsystem' that was also copied earlier. Now to this node Input I connected a Get Player Controller. This is what fixed the bug for me.
I know your comment is old so you probably already found a solution. I comment this incase someone in the future gets the same bug and they are looking at the comments for a posible solution. Good luck!
@@abdiasnemo2634 Thanks Mate!
Hmm I followed what you did but I cant control my character 🤔
Hi! I've followed this exactly and I'm having issues. For some reason, after spawning, actor components won't automatically activate for some reason. The character movement component is fine because I'm using Event Possess but custom actor components won't automatically activate.
Thanks bro. Very awesome video. Please keep going and thanks a lot and help a lot😘
Amazing!!! I want more :) :)
I upload a couple vids a week!
Hi, Great explanations.
I can't find the video where you was supposed to explain the management of the Datas of the player...
Did I miss something, or didn't you make it ?
Thanks for everything.
Incredible Series, very well explained, down to the last detail, when is the next video coming out, can't wait
Great Series! I have 5 player start locations and up to 5 players and inevitably 2 players are off the map (black screen not sure where they are). Sometimes it works and I get all five, but its one in 10. Any ideas? Player spawn is implemented exactly your tutorial but with 5 players.
In that case those players don’t have enough processing power to actually spawn properly. This gets caused in Unreal in the case your Player Controller is not initialized properly and then already gets communicated to.
The black location you are describing is your x0y0z0 location in your world. (The location a player controller spawns at in case no pawn/character is properly possessed.
To prevent / fix this simply move all the spawning code into your player controller. Only call upon the spawn as soon as the player is fully connected in the match. For example, after x seconds, or when af least for example a Player State is properly initialized. That is a good check since the player state is a class that is dependant on both the server and client version. You can do so by making a macro which checks for player state validation (IsValid). Once it is, spawn your character with logic from within your player controller opposed to directly spawning from the OnPosLogin nodes).
Note that your issue is mainly caused by either properly laggy laptops/pc’s or when running many (for example 5) PIE test windows on one computer for testing. Either way the above solutions are a safe solution and are ready for a distributable game.
Thank you for the $5, appreciate you. Let me know if you require more help.
Kekdot
Love these tutorials! However I am still not in the clear what the GameState and PlayerState are going to be used for, wish there was a 7th vid demonstrating their use cases.
Followed this tutuorial exactly rechecked code twice, when play in editor host is able to move around just find but joining client spawns but cannot move.
Nice And Clear
Awesome videos!
Isn't it okay to use the get random item node from an array? Seems a bit simpler.
Works too yeah haha
Quick question, can we use the Utility function for Arrays, called "Random Array Item", at 7:50?
I cannnnn't wait to learn about Playerstate! I've been struggling simply getting a working chat lobby going with names updated. I'll keep fighting the good fight until it pops. Ty much
My folks are spawning on each other other. Hm..
Great work, your tutorials are very logical and easy to follow. Question, would it be more efficient to setup interfaces in place of the casts implemented in this series?
You'd still need to cast to that interface to use its functionality
Casts are more performant than interfaces. But sometimes interfaces are easier to use when communicating with many actors at once.
@@Kekdot seriously? Why do people give casting such a bad rep then??
I don't know enough about what's going on under the hood with all this stuff so when people are like "casting is bad, X is easy for the computer to do" etc I just take it at face value
Well casting simply pulls a reference of the entire acting you’re communicating with so that you can reach each variable and component of that actor to run logic on (get info, set info, or trigger events).
This draws that actor into memory for some time but this will get garbage collected anyways.
When using interfaces the engine behind the scene also pulls the actor it’s communicating the interface event with also into memory but skips all variables and actor components. But interfacing itself is also expensive due to handling more like a wildcard event.
In all my 8 years of doing Unreal and having many Unreal friends non of us have ever ran into any actual issues using casts. As an indie game it’s truely hard to make the game perform poorly by simply using casts due to garbage collection cleaning up things fast anyways.
If you’re starting out with your first games and they are not Call of Duty of Fortnite or The Witcher type products then casts are perfectly fine.
As UE referenced themselves: Use cast for direct one on one blueprint communication. Use interfaces for one to many communication.
(See the official UE documentation which explains this too)
So don’t worry about it! Focus on making your game. Graphics have the biggest impact on your performance. Code won’t impact your performance by a longshot!
@@Kekdot Thanks a lot Sir. I've cleared many of my doubts with this single comment of yours.
Thanks for the great tutorials. Have a question here. Why the BeginPlay event in player controller was triggered twice? Does that mean there are two instances of player controller on the listen server?
Indeed.
The player controller exists both on the server and on the owning client.
What that means is:
When you are the host, you are the server and the owning client in one. So for the Host(server) the begin play wil trigger once.
When you are a client. Then there exists the server version of your player controller (which fires a beginplay), and then the Owning Client version of your player controller which also fires the beginplay. (Owning client = your local offline version of your player controller).
So when running a listen server with 2 players, then when you print string the beginplay event you’lll see:
Server: says Hello
Client1: says Hello
Server: Says hello on behalf on client one again.
@@Kekdot Thanks for the fast response. Does that also mean if I am playing on the listen server, The game instance on my computer have double instances for all gameplay actors (except game mode and widgets)?
@@pyrochlore Heya,
No the existance of every actor is different. In the Unreal Documentation they detail exactly how every actor exists. (Game Instance for example is always only locally, so there is just one version only, and that exists on your offline computer only.)
Please see my video here in which I explain this in detail:
th-cam.com/video/Hsr6mbNKBLU/w-d-xo.html
Here is how I solved the enhanced input system problem where the clients does not recieve input.
0: This code is on your character...
1: Add the "On Possessed" event. (This is only run on the server)
2: Create a custom event and set it to "Run On Owning Client". (This event will only be run for the player owning the pawn)
3: From "Event On Possessed" call your custom event.
4: Add the enhanced input mapping as usual to your custom event.
Hope this helps :)
Thanks for the video! I did have one small issue but I managed to patch it, clients if they are using control rotation would reset their rotation once they were possessed, ignoring the rotation of the PlayerSpawn (which is unnoticeable if the PlayerSpawn's rotation matches a zero rotation).
To fix this what I did was call a custom "OnPossess" event which runs on the owning client which sets the control rotation to that of the spawn transform.
I hope this helps anyone who also runs into this!
PS: If there's a better way of doing this I'd love to know btw, this somewhat patchy but it works
hi, really like the explaining, when do you believe the User Interface eposide would be out. REALLY GOOD JOB
Hi man, your series is awesome and very well explained. I have a weird error in my multiplayer project, first of all I created and uploaded a dedicated server on AWS, when I log in the game the client character spawn attached to another one and the playerController only works as "Multicast - reliable" when I switch on "Run On Server" it gets an error like this "UEngine::BroadcastNetworkFailure: FailureType = ConnectionLost, ErrorString = Your connection to the host has been lost., Driver = GameNetDriver IpNetDriver_4" do you have an idea of what could possibly be? Cause I cant find any documentation about it.
Thank you
I had the no spawning and no control issues among others. The fixes in the other comments helped but not fully.
The big fix for me was making sure the GameState BP had GameState as parent class and not GameStateBase. So for GameMode and GameState the parent classes have to match, either the Base or non-Base ones. You can easily switch without remaking them, it's the Class Settings button on the top bar.
Yeah classes have to be of the same type.
GameModeBase is for singleplayer games.
GameMode is for multiplayer.
All non-base classes are for multiplayer.
Please update the playlist!
I'm following the whole tutorial exactly how it says but I have a weird bug where the one of my players doesn't move. If I spawn them with the "world settings" and not with the "player controller" everything seems to work fine. Any suggestions?
It's always the server window that the player doesn't move
Same here ;/
From @macca95 below: Update for anyone having this issue. Open the third person character blueprint, add the even on possessed, plug that into Cast to PlayerController along with the begin play event. Credits to Blackpinned for finding the solution!
@@matthewturner9385 This is confusing. What do you mean by plug an event into a cast? Confused.
What he means is:
1. Open the Character Blueprint
2. Then in the graph type ‘On Possessed’. This will give you an event for when a player controller possesses the character.
3. Now hook both the event OnPossess and event Beginplay into the Cast logic.
Let me know if that cleared it up
Still confused with this, what is the Cast logic? we never open up the character blueprint in this tutorial.@@Kekdot
Have been following the tutorial series and loved it so far! One issue: trying to figure out why my client can move around, but my server can not. I noticed that only one PlayerController is created in my game, but I do not see any differences in our nodes at all.
Did you ever figure out what caused this? I have the same issue.
Hi @yoshedev5290 and @Keebs. , have you figure out what was the issue? I am experiencing the same situation
Same issue here, only one of the characters gets any input at all, but absolutely everything when casting is showing as valid, correct controllers and all, I think it might have something to do with UE5's enhanced input but just can't figure it out at all :/ @@toeyexperience
I've just got the exact same problem yeah, maybe because we started from a ThirdPerson project, not an empty ? Or may it be because of the enhanced input ? (I don't find how to put the camera in AZERTY mode, in the characters inputs it works but not in the basic flight camera, any idea ?)
Same problem here.
Interesting, my server input does not work, but with dispatcher it works correctly)
if playerstart object have big Z offset relative floor character mesh looks like a little bug)
Please show the next video on user interface and data!
my server player spawns but has no controls , but when I try spawning with default pawn class it spawns with the controls
i love you man
Nice explanation! However, just to confirm and make it completely clear I have one question. So we are still calling all these event stuff inside a local player controller and we are allowed to access game mode which is on a server only because we set this event properties to execute specifically on a server side? Technically we have all of these code both on server and client, but the part triggering event checks if it is spawned only by client and then, event is executed only on server because we set it to do so? And we must use event here because this is the only way to communicate this call back to server?
I was thinking the same thing myself, did you figure it out?
Almost everything works fine, the server character is not moving at all? Any idea why? ( I don't get any error msg )
your amazing!
Hey, how could I change the code at 10:01 from random intergers to specifc. For example Player 1 spawns at playerstart1 and player 2 spawns at player 2 start? Thanks for your help
i guess you could just try to give to each of your spawns tag, and then just do switch check by the tags, and get the choosen spawn transform
I had a question that I can't seem to fix on my own, I want to run the respawn event from the player after damage is taken (I'm using a event point damage) So I cast to the player controller but realized that using Get player controller for the cast only ever gets the server client. Any tips on how to cast to a specific player's controller would be amazing.
I have a question, it is possible that the 2 players might spawn on the same player start since the function is just finding a random integer?
Friendly tip: When i would play, my client couldn't move. I looked everywhere for answers and i couldn't find anything! After smashing my head a few times, i realized that i had created a new level to test this. Of course, when you create a new level you only have one player start... When i added another one, my players spawned and both could move. Why does it work now? I don't know but it works and that's what's important haha. MAKE SURE YOU HAVE MORE THAN ONE PLAYER START!
Having an issue where all the clients can move properly. But the host is unable to look / move around. Any ideas what could be wrong? ive checked a few times and it looks like everything is set correctly. I am just using the starting 3rd person character
Update for anyone having this issue. Open the third person character blueprint, add the even on possessed, plug that into Cast to PlayerController along with the begin play event. Credits to Blackpinned for finding the solution!
@@lukemccann95 Thank you. This is actually very important if your character blueprint is mapping input on begin play. It works without the cast, too.
@@lukemccann95 can u explain it easier pls ?^^
I've the same issue but the solution is not working for me :(
Thank you so much for figuring this out! UE 5.1: BP_ThirPersonCharacter->EventGraph->RightClick ->Event Possessed->link this to everything after the "Event BeginPlay" of the template.
How do you solve that 2 players spawn in the same place at the same time and destroy or do not allow one of them to spawn? That is why your system should not be "random", but assign a specific player start to each player that enters
How do we avoid players spawning at the same spawn point? Nobody seems to cover this part of the topic.
why i can just spawn on postlogin clients and not host? when i put there begin play, it will spawn host, but when someone connect, it will launch postlogin on host too(so there will be 2.times hosts pawns)
First off, fantastic tutorial.
But do you know how to fix the client rotation. I made a system very similar to this and found this video while trying to resolve the rotation problem on the client side.
Thank you!
You would need to set the Player Controllers Control Rotation upon spawning the character.
So not the character rotation, since that's not what causes this, but the player controllers Control Rotation is what is causing the client to look towards the 0.0.0 rotation of the World.
Let me know if you get it! Otherwise DM me on Discord
@Kekdot Thank you for the reply! Especially so quickly lol. That solved it perfectly, thank you again.
@bsg8761 Glad I was able to help! Appreciate you watching my videos ^^
Is this the last video in the series? There was mention of the next video to come... but, seems like this is the last one
Well there is also two more rep notify videos I made that are useful. And yeah then I stopped at the moment
There's something very strange going on.. Put in a print string before your spawn character and another within the 'find random player start'. Can someone tell me why my print string in the 'find random player start' function fires 3 times??? You would think the entire event gets fired 3 times, but no.. the print in the spawn player event fires once. And this happens no matter how simple I make it, running only as server, no extra logic in the function, just function start connected to a print string, and fires 3 times. makes no sense
This works if I start on the same level, but If I start my clients on a startup level and then join the server level via open level, they will never see the other clients. Any ideas why?
What if you’re running a dedicated server for your game and it doesn’t need a player controller only clients. Do you still need to send the code to the server?
12:13 But in this case, there is a possibility that 2 or more players spawn in the same spot.
@kekdot please help, I followed exactly the same steps buy only clients can move after possesing. Host is not moving or looking arround. I can't figure out how to solve this problem.
How to take all the connected players from lobby to server map ???
With this setup now, my Health Bar isn't working properly but just on server side, clients still can see the hp decreasing
can anyone help me? I followed all the steps in the playlist why doesn't the server character move?
I had this same issue, couldn't find anything about it but my fix was adding a delay between the spawning of the player in begin play
Sadly it does not work yet with the new Motion Match Characters.. or im too stupid. :D
i cannot move the server and it gets synced but im not able to move the client
also the unreal engine first person character does not work for me, i just cant control it (in this case server and client)..
Hey i encountered the problem that i can not walk arround with the server
lovely, quite a question, i have a car selector ( cause instead of character pawn my game focuses on cars ) directly into the serverlobby Widget. i try as possible to make the car selector transfer the owning client the info like : wish car he selected. But ! for some reasons when i change the car index into the gamemode it's change the pawn for everyone ( even if i splitted the event to make it run on a custom event : run on owning clients) otherwise the fonctions works since the host force the selected pawn. just hard to understand how to make individual selections. that after map transfer spawn the old selected one.
Is it not much better to also create Interfaces for all this BPs, so you never have to cast them?
Is there a way to test out your game with 2 or more players on one computer with Steam or EOS? It seems you need to get 2 computers up unless you setup a virtual environment as these services will be expecting you to be running separate steam or epic backends per player connected. With regular NetMode I found it amusing to be using one controller to control two network players running in circles on the same machine. I wish I could use a single steam or epic login backend to run for both players on the same machine even if it's just me playing me. I guess you could play your Steam subsystem against your EOS subsystem but that may complicate build switching of 2 online subsystems unless crossplay can be fully implemented easily here but I digress.
"In the next video I'll show you how to initialize the UI". Was that video ever released?
So I've attempted this, and now I'm spawning upwards of 100 characters thank to respawns... yippee...
Not sure what I'm doing wrong in my game controller when I try to cast to the game mode from the SR_Spawn_Player event get game mode is always empty and the cast always fails.
Make sure you cast only on the server to the game mode
@@Kekdot That was really helpful. I had forgot to change the Replication mode (SR_SpawnPlayer) to the server. Thank you
Hi! For me it didn't work, when the game starts the camera is at the origin of the map coordinates. If I assign a character in the world settings, it just doesn't move. But any buttons that I assign in the player controller work. Can you explain what's wrong?
UPD: The same code worked on UE5.5 But with arrows "Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetLocalPlayerSubSystemFromPlayerController_ReturnValue". Node: AddMappingContext Graph: EventGraph Function: Execute Ubergraph BP Player Base Blueprint: BP_PlayerBase"
Have you solved the problem?
I use the MultiplayerLobbyKit from cedric neuenkirchen. On me it doesn´t work. i join from the hosted game to a new level and there the function isnt called. How to handle this with joining the whole players to a new level and query the whole players to select a player controller and spawn the character
Can override Choose Player Start in GameMode as well?
Hi. All video looks so good :D I'm learning very well.
by the way can you please tutorial about multiplayer matchmaking system in ue5?
A system like that could only be realized with 3rd party services like Playfab or AWS or EOS. I have no experience with those matchmaking solutions.
@@Kekdot That's too bad. Thank you for the reply!
When sever kills client sever respawn?
So you're still spawning the character twice, and then destroying one of them. You can see this if you remove your validation code, and just have it go straight to spawn actor from class then posses.
My Pawn in server is not moving. Can anyone help?
Watch again. One question:Why the function begin play in player controller fires once in listen server and twice in client ?
The listen server has only one player controller and the client has two player controller, one is in local and the other in server(the latter is duplicated when the client connects to the server).
Is that right?
Correct. The server always only has one PC, all the clients have 2 PC's, a local one and server one
Im having an issue where spawn actor breaks my animations? Im not sure why tho
Does anyone know how to fix server and client not being able to move on first person bp? there is no event begin play by default and i tried adding it and then adding event possessed to it but did not work
Check that your GM and GS BPs have GameMode and GameState as parent classes (Class Settings button top bar). Having the -Base parent classes on either will break things. If you want to use Base it has to be Base on both.
The spawning using beginplay isn't working with the enhancedinput system.
Nevermind, just dumb. Player had a dead check failing.