#multiplayer
1 messages ยท Page 11 of 1
You literally jumped to a whole new topic without providing context
First understand why this works the way it's
I can help when people provide me with the full context
You just threw a random function without explaining what that is
And you also suppose I know what you're game is about.
See the previous questions by other people how they asked
Likely because you're only setting the variable on one instance of the character. When you spawn an actor, they have their own instance of the blueprint. There are no variables shared between characters for example. Both characters will have their own "Notes 1" variable that can be set true or false.
And if that's the case, you might be using the wrong class to store the variable in if it's something that is shared between all players in the game.
As I suspected, your code isn't doing what you think it is doing. When you're pressing 1, you're setting that boolean to true only for that one character. It doesn't do it for both.
https://youtu.be/hkcXkuYnNyk
I'm running into some replication issues with static mesh actors which are for the most part being replicated correctly.
Within my duplication sequence, I'm spawning an actor using a template. During this process, the initial duplicate has no collision, but I believe that there are still a couple of frames where the client has collisions and therefore causes the other actors to go haywire. I know I can improve the duplication process and its replication, but I feel that there are also some issues with the actors' replication itself. I'm wondering if the actors are going dormant on the server and causing delayed replicated corrections.
There's a fundamental bit of understanding you're missing is all.... Each character has its own instance of that blueprint. When you call these series of events its only happening on the one instance of the character that is calling it.
If you're wanting to have common data between all players, you may want to use the GameState to store these variables. This way you're only having to change the value once and all players can read from it.
If you're only wanting specific characters to have the value set, then you have to get a reference to the characters that should have the value set, and set that value on their instance.
For example, if you pressed 1 on the first player, and pressed 1 again while in control of the second, you'll see that both should now have the proper text displayed, and that's because both players are having the server set their own value.
Does replicated component's functions GetComponentLocation, SetComponentLocation.. etc is network replicated like AActor's functions like SetActorLocation, GetActorLocation() by default?
I have this property in my actor.
UPROPERTY(BlueprintReadOnly, Category = "IK Hold Transform")
FTransform IKHoldTransform;
and i am updating this property to change location, rotation for multiplayer purpose in my actor tick, so my idea is trick that maybe i can use scene component's getter, setter methods to make it progress though it on the network code.
When im trying to replicate a variable with a new value, and then basically on the same frame use the variable its clear that the value is not replicating fast enough to reach clients. Putting a small delay before trying to use the value fixes the issue but doesnt seem like a very solid solution, do you guys have any ideas on a good solution for this issue?
Doesthe pawn owned by a client player on the server and the pawn on the owning clients local machine have their own controller or do they share one?
Check my answer in #cpp
Hi, how can I fix this problem?
You must be using a source build of Unreal Engine, which you can download from the Epic Games Github.
If your project is using a binary build from the Epic Games Launcher, you will need to migrate it to a Github source build.
Do you know what the GameState is?
If not, then read the compendium PDF that was also linked. It explains it all in great detail.
In the world of programming, you have to make up the code that works exactly for you. Other than the fact that you want to have 2 players display the same text, I know nothing about how these variables influence your game so all I can do is make suggestions of how you can proceed and you need to figure out what the right path to take is. There is no predefined answer for what you're attempting to do.
As I've stated, right now, when you press that 1 button you're only setting that boolean on one of your two characters that exist. Your code to display the value reads from the first known player character (the Get Player Character 0 you're calling) and when running on any particular client, it's usually the character they control, but in a listen server, that can sometimes be the wrong character. So your text display is not reading the value you think you're reading. If you put a print string after "Get Player Character 0" you'll get two prints, but they'll be different for the server and the client, guaranteed.
If you need to have specific characters have those booleans set, then you need to figure out how to get references to any of the characters that need to have the value updated. How you get those references is up to you - I don't know what conditions you may have for setting that boolean on any specific character.
If you need to have all characters have those booleans set, then there's no point in having them on the character, and you may as well use the GameState instead to store them as this can act as more of a "global" actor that everyone can read from. You'd RPC like you are right now in your character, but then when running on the server, you get your gamestate, cast to your custom class, and set the variables. Then you'd just need to change your text bind to read the values from the GameState instead of your characters.
hey, is it possible to make an event in blueprint that, when called from the client, runs both on the owning client AND the server?
cause afaik run on server will make the client call it on the server only, run on client will do the opposite, and multicast will run it on both server and client but also on all the other clients
Bump
No. Just have the client call a function or event before callling the Run On Server event.
okay, thanks
Hello ๐
Does anybody know if it's possible to make a client stay on the current map if the Server Disconnects?
I'm running a Listen Server setup and when the game ends and the Server Player returns to the Main Menu, the Client is automatically booted out. Preferably, at this point, the client should be able to stay here as long as they want without being booted.
If this is not possible, what would be the best way to handle this gracefully?
It is possible - it'd be a matter of host migration pretty much
Just kind of a PITA to handle
Ah i see!
Any info on this anywhere?
Hi guys, my name is Miroslav, I'm currently working on my internal project...
I've spent 50+ hours trying to get the dedicated server working but can't find a solution :/
I've downloaded source, generated files, built with VS for dev server, dev editor and dev client, cook the content and everything else there is but still when I connect to my server it throws the error and shuts down for some reason..
I'm using SGK kit with Character Customizer, but the crash log throws nonsense (at least I don't know how to fix) because when the game is compiled and launched no errors are being shown...
Here's the crash log, if someone can give any valid information where to look at and how to fix I would be more than happy to send a friendly gift via PayPal, thanks! ๐
The errors indicate that is likely a problem originating with that character customizer plugin you're using. Does that plugin come with support? If so I'd suggest reaching out to them for help as this is not a generic issue that we can help out with, but perhaps someone here is using the same plugin? I dunno...
Anybody have a clue on team voice implementations outside of subsystems? The VOIPTalker is cool, but doesn't seem to support muting people or similar. Is there any other alternative that doesn't require an epic / steam account? Steam is fine, but the audio quality is atrocious.
I guess I haven't taken a look into the VOIPTalker replication yet. So maybe I could just overwrite a function.
There might be a way to integrate discord into your game with c++. I believe they have an API.
I should have formulated it better. Any account haha. I would also take tips on making the Steam version sound good.
Sorry, I've yet to add voice to my game, can't really suggest anything but Im pretty sure some games use discord as their voice service.
Store the int in the gamestate. When input is received on client, run on server event that will update the value on the gamestate
Clients can read the value from the gamestate
A struct is just a container for a group of variables. You can change the boolean values on the server, but you may want to use https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/Engine/FFastArraySerializer/ so its faster to replicate.
Base struct for wrapping the array used in Fast TArray Replication
Also you said "to all servers" but that seems incorrect. There's only one server where the game instance is running. (even though you might have more than one physical server running its own instance of your game with clients).
Okay then use a replicated boolean and make it so ONLY the server sets the value.
(something happens) Server Event --> set (replicated) boolean to true. Server then replicates this actor's bool value.
You can then have another actor blueprint use the new value from a reference back to that original actor where the value was changed.
If I remember, @oak prawn you're trying to have a variable (on a character) change so that another variable on a widget can reflect that change. But the issue is that you are not understanding WHY it fails the way you currently have it setup. The answer was already provided. You need to use the GameState to store those booleans and read them from there using the widget. Currently you're only getting and setting the boolean for Player 0.
Look at the diagram on page 10 of the PDF.
Quick question - I'm reading a lot here that says Lyra is 'trash' and built haphazardly. I'm wondering if anyone can shed some light onto that. What about Lyra is bad?
(in terms of using it as a basis for a multiplayer game)
Is it possible to override an RPC function in a child class? When overriding the _Implementation function, it causes a stack overflow. When trying to override both the _Implementation function and the base server function, it won't compile as it wants the base server function to be implemented in the .cpp file, unlike normal. I tried doing some google searching but couldn't come up with anything
Call Super with _Implementation
Thank you!
For the most part such comments don't accurately represent the situation. Lyra is not designed as a basic/simple framework where you can just load it up and immediately begin extending it for their needs, rather it is focused more at what epic considers modern best practices scaling to the most advanced projects. As a result there is a significant learning curve when you start extending certain aspects of it and some of the "best practices" epic deployed are not necessarily well fitted for some kinds of games. Also, Lyra should be considered a 0.9 release, some of the concerns are likely to change with the upcoming 5.1 release.
I see! So it's not that it's bad, it's just more niche/not robust. That's really good to know.
I have another question, one that has been burning for a while.
Anybody have a ballpark of how many actors (or, in this case players I guess) can be replicated before things get wonky for your average internet connection? Like I'm wondering about battle royales with up to 100 players. Is there a reason for that cap? What about much more, like in the case of MAG or PlanetSide? (I'm assuming there is some kind of best practice guidelines here)
Final addendum to this question - do things like NPCs bog down multiplayer games significantly?
I really appreciate all the help here. This has easily been the best educational discord server I have ever joined
There is not a simple answer to that question. It depends on many factors, not the least of which is how many actors syncing per time internal (average/worst case) and how much data is being synced. There are many tricks you can do to reduce this, but things get more complicated the more abstractions you deploy. Also in UE 5.1 they are releasing a prototype replication system which is claimed to be designed to improve this situation at scale.
Hot.
Thank you so much!
Do I have to replicate changes on acceleration, ground friction and such other non-replicated variables in CMC?
Let say an ability in #gameplay-ability-system changes movement speed, but to efficiently simulate the movement I need to change other values too
And if it's client, I assume it has to send server an RPC to replicate the changes, no?
Hi everyone! I am trying to learn the engine and I have put a ton of hours into tutorials, read the compendium, created a very basic game where a character can kill the other but now I am stuck. After hours of searching it seems like I am just bad at searching so here I am. I want to learn how to use the game framework the right way in Multiplayer. None of the tutorials I found are actually showing what it means to "store the game rules" in the Game Mode. What does it mean that Game state should hold how many players is alive? To focus this to an example I am trying to make tank trouble but in ue. Say a tank is hit, it sends an event dispatcher saying so. Should this go to the player state? Should the player state have a boolean of being alive and react to this change? Do I need to create another event dispatcher from the state to be picked up by the game state? Do I go through each player state and bind them to an event in the game state to react to each death? Is this too many questions? I am stumped, everything I do feels like the wrong way. Is there a tutorial out there that can show me the way? Or anyone willing to answer some of my questions? Thanks so much and so sorry for the long text
Game Mode isn't really about handling game rules, it's more about handling players joining/leaving the game and respawning. The Game Mode would likely keep an eye on the Game State to know what it needs to do.
Game State is definitely more about where the game currently stands - team scores, objectives completed, match time remaining etc. As I mentioned above, the Game Mode may want to keep an eye on the GameState and the Game Mode may not necessarily want to respawn a player if their team has run out of "lives" which would be a value you could store on the Game State.
Player State is used for storing data about any specific player, like their name, their kill/death counts, or they have a certain cosmetic they want applied on their tank, perhaps their currently selected tank class or anything specific about that player that would need to persist between respawning.
Your player's controlled Pawn then would be used to store anything transient but pertinent about the pawn, so like it's current health status, perhaps its remaining ammo.
Your pawn can tell the game state that it was defeated, and if you plan on having different game states, then perhaps create a base game state which you can later child that has some common functions built into it like when a tank needs to report that it is defeated. Then when your tank is defeated, it just needs to cast to the base Game State class to report it was defeated.
Not sure if this even fits here, and i know it's a lot, but i'm quite stuck on this and it's making playtesting my game impossible, so here goes
These are both glitches happening with my star wars fangame, which I cannot as hard as I try to track down.
Both of these only seem to happen in the packaged build as far as I could tell, and are very inconsistent and hard to replicate, I cannot pinpoint a cause
I know there's a lot of context missing but if anybody is willing to help, i'd be happy to show the code, send the code, or even just get into vc and try and fix it because this has gotten bad enough to the point of halting progress.
Sometimes, when the host player's ship crashes, the game will terminally freeze and stay like that, kicking all clients out
-It only seems to happen in the host computer as far as I can tell
-It seems to happen about once every 15 crashes, and only if the ship loses both wings before crashing (I think??? it's hard to tell due to how rare it is)
In a game, client players will get a random massive FPS drop spike
-It seems to stop when the host dies and respawns (maybe again, hard to tell since it actually needs playtesters???)
-Rejoining might also fix it?
-I haven't been able to establish a pattern whatsoever because these two bugs are so game-breaking its hard to properly playtest
I have logs from the packaged build and I can get more, but I wasn't able to get anything from them
Thanks to anyone willing to help in advance
Aaaah, thanks so much for contextualizing. That really helps. Especially the edit at the end.
Hi There,
Can anyone redirect me to proper document for network optimization.
So I thought I'd give multiplayer a try, and whilst I understand the theory behind replication, I cannot seem to crack it programming wise.
- Local player calls Empty Inventory
- Empty Inventory does a simple check and then calls Server_EmptyInventory (UFUNCTION(Server, Reliable))
- Check to make sure the owner is Authed(Server)
- Call Client_EmptyInventory(UFUNCTION(Client, Reliable))
- Check if inventory is empty and add an onscreendebug message.
InventoryItems - TArray (UPROPERTY(Replicated)
However, the local players inventory is never emptied. Shouldn't this be replicated back from the server? I was using a ReplicatedUsing function but since the InventoryItems is a TArray and can constantly change (Add,Remove, Sort etc), I don't think that is the way to go about it.
void UInventoryComponent::EmptyInventory(AActor* Owner)
{
if (!InventoryItems.IsEmpty())
{
Server_EmptyInventory(GetOwner());
}
}
void UInventoryComponent::Server_EmptyInventory_Implementation(AActor* Owner)
{
if (GetOwnerRole() == ROLE_Authority)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Server Emptied Inventory!"));
InventoryItems.Empty();
Client_EmptyInventory();
}
}
void UInventoryComponent::Client_EmptyInventory_Implementation()
{
GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Red, TEXT("In Client_EmptyInventory"));
if (InventoryItems.IsEmpty())
{
const FString Message = "Your Inventory has been emptied - " + GetOwner()->GetFName().ToString();
GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Red, Message);
}
}
Property Replication and RPC's are not syncronised - there's every possibility the RPC will arrive and/or execute before the inventory is emptied
InventoryItems should be a replicated property
Then you remove the client RPC altogether and use the ReplicatedUsing callback
Ok, so thatโs where I went wrong. Trying to tie RPCs and Replication together ๐
Basically remove the client RPC, and use the OnRep callback and you'll be fine
I found where the problem is. Since my game is installed as a gamemodebase, it does not share keys with other players. I assigned a new gamestate and a key in it and now my problem is solved. Thanks everyone. This hassle-free code may be of use to someone
Hello everyone, I'd like to ask something. I'm using a motion warping component to make a vault ability. The ability is done and works perfectly on the server, but when I test it in the client, most of the times this ensureMsgf is being called. I'm trying to find why is this happening, but up to no avail. Do someone knows some of the reasons?
ps: When I remove the motion warping notifies from the animation montage, the msg isn't called, but then the motion warping doesn't work. So the issue is over there
and this
An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.
Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe
00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...
Glad youโve solved it by using the gamestate.
@graceful flame thanks for everything
any downsides in giving my AI pawns a playerstate? ๐ค
I know it comes as false by default so I want to know if there is an obvious problem in doing so ๐ค
Additional replication required that may not be necessary. What's your use case?
my GAS system for the player is on the playerstate, AI needs the same system. Usually AI puts the GAS inside the pawn but I just wanted to not have duplicated code in my player pawn and my ai pawn ๐
maybe I can override some of the player pawn and keep the pawn logic and just change where I get my ASC ๐ค
or I can also live with the extra replicated data. This won't be an AAA game ๐
oh boi, datura is been writting for a hot minute now, I opened pandora's box ๐ฐ
Playerstate is usually replicated to everyone and is always relevant, and that would include the ASC, so it is just a lot of extra replication for very little gain if you were to put it on your AIs, especially if you plan on having lots of them.
The only time I can think of it being useful to have a playerstate for AI is when you're using bots - then they can have the same data that a player would normally have with their own playerstate.
How GASDocumentation did it was on the pawn, and there was a common base character between players and AI, but then they split off from there where AI Characters would have the ASC on the pawn. The base character class can be where you keep most of your shared logic between players & AI.
It can also be the place for a common function for getting the ASC where on the AI you return it from the component directly attached to the AI, but for players you get the playerstate's ASC.
yeeeep, what I was thinking ๐ฆพ
One thing to be aware of is that when the player disconnects the player state is usually despawned(which destroys the ASC with it), you can turn that off to have it stick around via overrides and stuff though
Hello everyone, I'd like to ask something. I'm using a motion warping component to make a vault ability. The ability is done and works perfectly on the server, but when I test it in the client, most of the times this ensureMsgf is being called. I'm trying to find why is this happening, but up to no avail. Do someone knows some of the reasons?
ps: When I remove the motion warping notifies from the animation montage, the msg isn't called, but then the motion warping doesn't work. So the issue is over there
ghost ping?
I was wondering if this is a common issue with ASC not being duplicatable and able to be saved for the inactive duplicated PlayerState that sticks around after the player disconnects. A while back someone here asked about that: #multiplayer message
And he ended up not duplicating/copying anything of the old original PlayerState but kept it around. Why the attributes of the ASC can't be duplicated/copied is what I wonder about?
The answer given there, about non uproperties will be lost in the process isn't the one I guess. At least I managed to copy non-uproperties and transient ones with no issues
How can I display the names of every player in the lobby with a widget?
Because i'm having trouble with getting the widget to know other players apart from the local player (0)
The GameState contains the Player Array which is a list of active Player States (which is where you should store your player names). To display them all, you'd just loop through the Player Array and get the Player Name (a variable that is on the base PlayerState that you should use).
If you're trying to display the name above the player's head, then you can get the playerstate from within their controlled pawn and again, read the Player Name variable.
I did this but it doesn't show it on the text, the text is binded to the variable btw
The player array is a custom one which I created its not unreals default one
Didn't I tell you why it won't work if it was on the PlayerController: #multiplayer message ?
- Player Controllers are not replicated. There is no means to reference other player controllers other than your own on a client, so getting an array of Player Controllers won't yield anything fruitful for clients as it'll be null references.
- You're still trying to access said array by an index anyway, which is still not the appropriate way of doing it as you don't know who that particular person is at that specific index.
Can you clarify how you're trying to display the names of the players? Again, is it a name over their head or a list of players?
Is there any way to custom serialize a value to something else that isnt net serilize in struct? for example float between 0-65535 down from 4 bytes into an int16 for 2 bytes but recieved on client back to the float?
I am not sure as to why but I am trying to do something when the player controller possesses a pawn and it seems to be calling it twice. I am using the OnPossess event because I was using the BeginPlay with the same results, its as if its creating two player controllers and I am not really sure why. I assume it has something to do with a server version and client version but no matter what I can't get it to only fire once. Does anyone have any idea why?
Likely because OnPossess on the player controller fires once for the client and once for the server.
Same with BeginPlay.
You can differentiate which by using some checks, like HasAuthority, or IsServer
I actually did try to use the hasauthority thing to check it but it still fired twice with authority and not at all with remote. I figured this was the case though, gonna have to do some research to figure out why but I this did help confirm why its firing twice so thanks!
Yeah I'm pretty sure it's always called on server. I've seen people addressing this issue a few times here but I never tested it. I would start by breakpointing OnPossess and look at the call stack
If it's the same call stack then that needs further research indeed
Update us with the results if you come to find anything ๐
Quick question: Is it possible to disable/enable replication of a variable by a bool?
Like conditionally replicating a variable if a boolean in CDO is set?
I have a RegenRate rate float for a weapon, and I only want it to be registered to replicated variable list if bReplicateRegenRate is set
I think you can define your own custom condition
is anyone else getting the error Assertion failed: isValid() Sharedpointer.h from the dedicated server console after turning off 'run under one process' and making changes to the code
How can I execute functions only on a server that have a return value?
RPCs can't have return values if that's what you mean
Ping-pong
Call an RPC back with the result/return-value
Why canโt RPCs have a return value?
Because that defies what an RPC is
RPC is called on one end and executed on another end
So it's return value will be on the other end anyways
Hey, i've been fiddling around in lyra for some time now, i was wondering if any1 tried to get pawn possesion/unpossesion working. I can't figure out why the simple character switching (between 2 pawns) seems to not be working. The Player Controller seems to be assigned properly both on server and on client yet the characters lose their ability to move after first switch.
Thanks for this
bump 
I know the answer is probably not, but is there an easy way to control with a bool if a bunch of events are triggered on client or server, other than creating duplicate events for every action?
That's a very broad question, but a generic answer goes like: Have all the events as regular functions and depending on your boolean value you call either a server/client RPC that encapsulates them all.
So you end up having two RPC events that call them all
That's what I though... So I guess the long way is the only way to do it
Thanks ๐
anyone know why my dedicated server exe not appearing after building
with top-down view and mouse cursor enabled how do I sync cursor so that GetHitResultUnderCursor on the server get same result as on client?
GetHitResultUnderCursor won't work on the server as the cursor only exists on the client. All you can really do is RPC to the server the data that you need (I wouldn't necessarily replicate the entire hit result unless that is what you need).
why not entire hit result?
Extra data that you may not necessarily need.
but what about "don't trust client" approach?
There's some things you have to tell the server. You can do some verification on the server to make sure whatever the client is passing isn't bogus.
I see. Thank you
I am looking for how to assign player starts to specific players. More specifically, not just a random player start. And really it's just for one of the players (in this case the host of the game on a listen server)
My solution, which is similar to what I saw other people doing on the forums, was to turn off the default pawn and spawn my characters on the game mode. Since the game mode is server-only, this ensures characters are spawned by the server (which is important). You can add a tag to the specific player start you want so that after you find it in the game mode's begin play, you spawn the player there. Then use the PostLogin event to get the controller to possess the pawn.
How do I get the player start in the game mode?
I tried to make a player start variable, then getting all actors of of class with tag, getting the first element of that array (0), and spawning actor of class at that transform, and possessing it
I got an error that it 'accessed None when trying to get the array item
sounds like it didnt find the playerstart
you should always validate references
and hopefully have some fallback
I connected the 'player start' variable connected to an 'is valid class' and it comes through true
I'm not sure if I did that bit right exactly. It is checking after specifying the tag as well; if that makes a difference.
Also, I'm not sure if I even made the variable properly. The variable in the game mode is a player start class reference, with the default value being 'PlayerStart'
Pretty sure you can't do this. Dedicated server needs to be launched at execution, it can't be launched from open level.
Console Command ?
Hello, I have this issue where I want the players head to shake when they sprint. I have setup an anim notify when the animation steps down. On the notify event I play a camera shake on the player however it plays a shake for all players in the game
How can I have it so only the sprinting player has a camera shake?
Same thing. Once the game is running you can only open a level as standalone or listen server. Dedicated servers normally have their own separate executable and you'd have to start that executable on its own.
Dedicated Servers are also normally headless - so they do not have any window open and the game isn't being displayed while they are running. You can set it in the command line so you can see the logs while it is operating.
It's not that it's impossible to start a dedicated server from within the game when it is running, but you'd need some C++ to make it execute as a command line operation, not from open level or console.
My guess is you're experiencing this because you're using GetPlayerController 0 or something similar somewhere?
Yeah
I use get owning pawn
then cast to character
I added is locally control which worrked
but it seems the event is called twice
when I do a print string
It would be. The animation is likely being performed on all clients, and if it's a listen server, the server too.
I spawned actor, trying to call server RPC on it from client but got warning UNetDriver::ProcessRemoteFunction: No owning connection for actor ... so I set owner after spawning to player controller and now I got no warning but RPC is not called ether
Turns out the anim notify itself is called twice
idk why
there is only 1
Yeah so anim notifies are playd twice idk why
But are you seeing
Client1: Hello
Client1: Hello
or
Client1: Hello
Server: Hello
?
Hello
Hi everyone,
We are using playfab for our multiplayer services.
We are working on the name tag functionality. In our case the name of the players which joins after player โXโ is visible to player X and names of the players joined before the player X are not visibile to player X
Where are you setting the player names? I'm assuming they are being displayed in a widget?
Text widget in third person blueprint
Yes
Iโm able to get names of the player joining after player X but not of the players joining before it
Are you using steam?
EOS?
Where does the name come from? It comes from somewhere then gets set into player state, is that correct?
Is player name a string that you prompt the user for then save?
For my game since I'm using steam, I get the player name and steam avatar from Steam API then I store it in a struct which I use in other blueprints such as GameInstance and PlayerState. The name is shown as a widget component attached directly to the character and its value is set using a replicated variable bHasName which uses repnotify so that other players can see the name.
When they first load up the game they have to authenticate and after doing so I can access their name and avatar from Steam which is then stored.
Found an issue with replication after building it in Shipped mode. Why the engine behaves differently in that mode when it comes to replication? Is Development build it works as intended. I have an array of structure and I insert there like 90 records. After that whole actor stops to replicate its values, also no RPC goes through that contains this particular property
It's both on the leaderboard/list of players and over the head
So I should be getting the player character in the gamestate instead of the controller?
Which are you trying to tackle right now? They are both handled a little differently.
This is in the list/scoreboard widget
Ok the list is fairly simple.
Your widget just needs to get the GameState, and from the GameState get the player array. You probably do not want to use predefined variables like what you're doing - you can easily construct text fields within the loop, and populate them with the player's name and then add those newly constructed widget objects to a vertical box.
Wouldn't that still not work as it's technically the same thing?
I guess the play array is replicated?
Is the bind event necessary?
I don't know what that event dispatcher is for, so I couldn't say.
I can't answer that. I don't know what it does.
How could I get the player character within the player array?
There's some variables I need inside the characters
Would it be "get pawn"?
Ah k awesome
omg
thank you ๐
it works perfectly.. i spent 3 days trying to figure out why it wasnt working with player controllers
Will this keep updating or do i need to manually update the variables
Nothing is usually "automatic". If you have players dropping in and out of the game or changing values, you'll need something that would update the list. That could be where someone suggested you use an event dispatcher.
Hm
One more question..
How could I get the players steam name (which is located in the player controller)
And display it on the widget too?
It shouldn't be stored on the player controller, it should be stored on the playerstate.
if i modify a fastarrayserializer element on beginplay and mark it dirty,
PostReplicatedChange gets called with an empty TArrayView<int32> ChangedIndices
What about UObjects though?
They don't have PreReplication()
Probably I'll be fine if I call the function from AActor outer ๐ค
They don't because like everything networking is done via actor
James has a blog post on how to add networking support to a uobject though
I have a replicated UObject, but couldn't think calling their custom PreReplication() from AActor before replying to siliex
Boilerplateโข๏ธ goes brr
Boilerplateโข๏ธ
Oh kk got it
Would you be able to go over the player name over head?
That one's roughly about the same. On the pawn itself you can get a reference to the playerstate, thus you can pull the playername from it. You then would feed that into the widget component that would store their name above.
The difficulty with this however, is when to actually make the call to populate the value into the widget as you need to ensure that the playerstate is appropriately replicated first as begin play of the pawn may happen before the playerstate is replicated, same with the name values themselves.
Does anyone have a link to this?
Thank you! Iโve picked up bits and pieces of this info but this seems a much better resource.
If I make a small (hobby-like) multiplayer game, how much money do I have to prepare or spend for hosting the game?
How can we (as a player) know whether or not the game model is listen-server or dedicated server?
For example, I am playing War Robots, how can I know its model?
@whole grove : Do you have any idea? ๐
You can look at your outbound connections to see if they're going to some server IP address, probably AWS.
This might be a strange question, but I have set up a way to replicate container inventories to the player by using a view component on the client, the view gets a list of items on the server that's in the inventory. These are UObjects with custom replication implemented.
I noticed that when I open a few different containers it seems that the items are already on the client after it's been replicated the first time, even though they hold no obvious references to them. Is there any way I can check to make sure that they are no longer replicated/relevant and get collected?
Basically running between two different containers I expect them to behave as if it's the first time I open them each time, but it appears the item objects exist on the client after the storage has been closed
Folks, if we develop multiplayer games, can they be run in both listen-server mode and dedicated server mode? Code once and run every where?
I am wondering whether or not the code in each mode is different so we have to create two versions. ๐
You need to make slight adjustments, but with good practices it's mostly the same
In particular you need to think about the listen server player, where they are both client and server at the same time, which matters when relying on things like OnRep functions.
Oh ok. Thank you very much. I have not learnt multiplayer parts deeply yet. ๐
There's also going to be concerns for larger worlds and performance and so on
The map name comes before the additional options string
So you have A and B flipped
Are multiplayer games with listen-server mode also commonly used for mobile devices?
Mobile devices selected as the hosts will be overwhelmed. ๐
Should be doable with few players.
Most uses dedicated server.
Has anyone worked with FCharacterMoveResponseDataContainer ?
anyone have a good method for handling variable fire rates on a weapon with prediction? Specifically, if the client mispredicts fire rate, how do you deal with the server correcting that? Just void any shots that were too fast and refund ammo? Auto-fire any shots that were missed from a client predicting too slow and the server taking rtt to respond and correct it?
I would think not. You are correct in your assumption about the host's device being overwhelmed, and the matter that not everyone has decent cellular network coverage/speeds so if they end up being host it could be a laggy and packet loss nightmare if they're not connected through Wifi.
ROLE_MAX doesn't look like it's used very much (searched within 15198 .cpp files in the UE source from \Engine\Source) and there's no specific comment in the documentation about it. Safe to say, I think you'd want to use ROLE_AUTHORITY anyway as it's known that if you have authority over an actor, then you're the instance of the game that spawned that actor, which is the highest authority anything should have really.
in listen server when the host change level the client also change level anyway to fix it ? like changing the host ?
That would be something known as host migration which is not something the engine has built in. There are plugins for it, but it's not something that is seamless using Unreal's networking system.
any other way ?
Beyond coding it yourself no.
is there any c++ function or macro for changing host ?
As I said before, the engine does not have anything built in to support host migration.
There is however a few plugins for it that you can purchase
You have to use a source build of unreal engine to use dedicated servers
how many gb is it
Yes
About 150-200gb total
omg+
After you install the dependencies
Not really worth it imo. If you have build infrastructure and are using UGS it's fine but it's sort of a pain otherwise
any other way to get dedicated servers
No
if the client fires faster than its supposed to be, simply ignore rapid shoots server side and refund amo. If the client is shooting slower than it should, just accept it
if i set an actor property to replicate. Is it 100% sure that when that actor property replicates, the replicated variables in that actor itself would be updated by the most recent properties by the time the actor property replicated?
Pretty sure that's a no. When an actor reference is replicating, you're only replicating the reference of that actor, not its properties. Any properties it may have may still be replicating even when the reference already has been replicated.
I spawn character inherited from ACharacter on the server, auto possessed by ai, and for some reason I can't call RPC from Client for this character, it is owned by the player controller on the same Client, any ideas how to fix it?
Thank you.
Thank you.
In my case the names are showing up. Only problem is that the name of player which joins afterwards not visible in multiplayer
Only few players are able to see other player names in multiplayer
is it normal for an empty 3rd person dedicated server to be 1.74GB ? ue5
You seem to be using multicast. Use OnRep instead as he told you
FWIW SetOwner is called on server
Welcome to UE ๐ฅณ
Should be working fine. Try routing the RPC inside the PC then
You can always route RPCs in your client owned actors to achieve what you want. But anyways what are you trying to achieve?
in this case I am making character control rts-like. So if I click some where I want character to move/attack/pickup/etc. based on what I clicked and if route this through PC then this logic goes in PC and not in character where it belongs
I just don't get why is it seems to be impossible to just set owner and call RPC's
You can. You pass that pawn in the RPC. So it looks like this: MyAwesomeRPCInsidePC(TargetPawn)
As long as the TragetPawn is replicated then it will work fine
Imagine every actor you want to call a client/server RPC on has to be client owned?
Does that seem to you a good design?
yes
It's bad
I need max 3-4 actors for client
Doesn't matter. In general that's a bad design
I don't get it, can you show how it would look if I want to call char::MoveTo(location) ?
TargetPawn->GetOwner()->ServerMove(Self)
why SElf?
I assumed you're in the pawn class
You will be in the PC class probably
So it will look like this there:
ServerMove(TargetPawn)
You do that after you click which done client-side
and ServerMove is a PC function?
Yes
I see. Thank you
Hey guys. I'm spawning actors (armor) on my AI, and setting them to the master pose component. For the server this works fine, but for the client the Master Pose is not being set - the armor is spawned, but not following the characters. Any suggestions on how to fix this?
I've set the armor actor to replicate, & replicate movement (just to debug), and also the component skeletal mesh to replicate.
SkeletalMeshComponent doesn't need to be set to replicate
You are doing this on server so it's normal
Hmm okay ๐ I mean, the component spawns so that makes sense. Just the master pose that is the issue
Use OnReps
After you SetMasterPoseComponent on server, you also set a boolean value to true, say bHasSetMasterPose
Make it a RepNotify variable
I'm actually doing it all on MultiCast, should I be doing it on the server instead? I mean, the Server calls the Multicast, so essentially the server triggers it, correct?
And inside the OnRep function you SetMasterPose
That's bad
Spawning actors should be done by the server, makes sense
Will give it a shot in a bit and get back to you ๐
Read first link: #multiplayer message
Thanks for the link! ๐
so what's the solution for late joiners if a montage is currently being played? how do I keep the montage in sync even for them?
Hi! Does anybody know, why UObject might not get replicated (or recieved by a client maybe) with a client log spamming with warning :
08-27 16:49:57.492 5258 6572 D UE4 : [2022.08.27-13.49.57:492][792]LogNet: Warning: UActorChannel::ProcessBunch: ReadContentBlockPayload failed to find/create object. RepObj: NULL, Channel: 129
Background: I have an array of UObjects(2-3 of them each player) inside UActorComponent. Component replicates uproperty array, and replicates uobjects, using ReplicateSubobjects() function. Everything work fine in editor, even if I start PIE with separate server process. But if I build server and an app, client prints warnings above and does not recieve these objects on it's side.
4.26 from Source (both client and server, ofc)
You would probably need to replicate the time remaining so you play the montage at the correct offset
I'm doing this but the game state isn't valid by the time this actor replicates
The GameState has to be valid by the time any actor calls BeginPlay on client
I'm not sure
That is ticked by default I guess, so probably not. And again, you are guaranteed a GameState has replicated only when BeginPlay is called on client. That comes after all the OnReps has been called and PostNetInit
so you mean I should replicate on begin play for late joiners instead of rep notifies?
I'm not sure what's your end goal there, but if that works for those who joined in time, then go for it
You can't have both. You should stick to one approach
when i try to click my own cube it is working fine and i get true
but when i try to click any other player it is not working
The OnClicked event only triggers on the client. So you may be setting the "Box" variable true on the other player locally, but you have no means of actually seeing the value when you press K on their end as they haven't received that signal.
there's no way to do it? i want to set the value to true in my own player when i press thier cube
Then you need to get a reference to your character and set your character's boolean to true.
as same as widget. i tried to set my var to true when i press thier widget it is working but the cube isn't
Does anyone have experience with interpolating a UProjectileMovementComponent? From what I can gather from the docs, I set the interpolated component to the visual component of the actor, in my case a skeletal mesh, and then I set bInterpMovement to true.
ProjectileMovementComp->bInterpMovement = true;```
From there I need to use ```ProjectileMovementComp->MoveInterpolationTarget()``` inside of ```PostNetReceiveLocationAndRotation```. But the movement of the projectile still looks jittery on the client. I have tried supplying MoveInterpolationTarget with the ReplicatedMovement location & rotation as well as using GetActorLocation/Rotation, both don't work for me. What should I be doing exactly?
there are several ways to do this
One of them is basically storing the montage start timeframe using a synced clock
and when a late joiner joins the game
on the onrep for the interaction time variable
.
you can compute wjere the montage should be at
I'm doing that (maybe) but the game state sometime gets created after the onrep event(s), but idk maybe its because i'm not testing in standalone mode
thats normal
in such case a very easy fix for blueprint users is having a timer that repeats until the gamestate is valid
basically your timer will simply check if the gamestate is there
and once its there
u can proceed with logic
hey guys, i am trying to get my project to working properly but i can't find a solution to this error
how jittery? what's your update rate?
To use On_Rep events on Uobjects, do I need additional functionality besides overriding GetLifetimeReplicatedProps, IsSupportedForNetworking, CallRemoteFunction, and GetFunctionCallSpace?
I have a uboject class that derives from another uobject class I created called NetworkObject that implements those functions. Then in the problem Uobject class I'm replicating it in GetLifeTimeReplicatedProps and have it set to ReplicatedUsing="OnRep_XXX".
The outer AActor that spawned the uobject is replicating the uobject class and also implements ReplicateSubobjects (and I get a successful OnRep_UObject call in the AActor class). But I can't get an integer to trigger the OnRep event inside the Uobject class. Here is all (I think) of the relevant code: https://pastebin.com/ZMNsL5vk
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
There's no such thing as "An authority client". There is the server (which can be a client too if its a listen server), and there are clients.
Authority is based on where the object is spawned - so if you're spawning on the server, the server has authority, if you're spawning on the client, the client would have authority.
If you're running something currently on the server, and you want a client to do something, you'd have to use a "Run On Client" RPC on a client owned actor (like the PlayerState, their controlled pawn or PlayerController) and if you want them to spawn an actor, then you'd call a Spawn Actor node on that Run On Client RPC. If you're wanting to spawn something only on the server (including Listen Server hosts), then that actor can't be marked to replicate.
There is no such thing as non-authority clients. Authority is granted to an actor based on where that actor is spawned and "Clients" are not actors. The term client is used to describe an instance of the game that is connected to a server.
If you want an actor to be spawned on every single client, excluding the listen server host, then you probably need to start while running on the server itself - the server can communicate with all the clients and run a Run On Client RPC on one of their owned actors (PC, PS, Controlled Pawn) excluding the listen server's owned actor, and in that RPC spawn the actor. Keep in mind, that each client would then have an individual actor that the server and other clients cannot reference. The clients would "have authority" over the actor they spawned as it was spawned on their end.
If you want an actor to be spawned on every single client, including the listen server host, with the same idea that each client would have an individual actor that the server and other clients cannot reference, you cannot use a replicated actor as you're spawning on the server which means there would be a replicated actor sent out to all the clients as well, but I believe you can disable replication on a single actor using the "Set Replicates" node after spawning it. How you spawn it would be the exact same, through an RPC on an owned actor of each client, including the listen server.
Did you ever solve this problem? I am in the exact same situation, switching to a car, driving around, swithing back and the not able to move around.
When players bump to each other, they start pushing the other player away from them in Event Tick event until set distance with AddForce. Issue is that when client X pushes away client Y. Client Y can experience slight movement stutter and if I understand it correctly, it's because CharacterMovement component has its own Client side prediction and when server starts changing Server side CharacterMovement position, the difference is large enough for the client to experience this stuttering. What is the smart way of fixing this issue?
if I've got a replicated property that I want to condition via COND_InitialOnly, must I set it during construction? Or will it be fine if it's right after construction?
Either way. Though in the latter it has to be set in the same frame the actor was spawned in
Awesome, thanks for that insight ๐ช
If the NetMode is listen server then you'll need to call the OnRep explicitly after you increment that variable, as it doesn't fire on server
If you haven't figured it out yet, that means you are accessing a null value. He's pointing you towards the function. See why that happening and fix it
#volunteer-projects is a good start
Question if I setup a dedicated server how can I run it so people can connect with out me using port forwarding can I use something like Amazon AWS if I already have EOS setup in my project?
EOS has sessions right? If so, you'd set it up so on begin play of your dedicated server's game mode it starts hosting as session. Then you'd need a means for your players to look up the sessions and join them.
I am wanting the player to join the dedicated server straight away not to search for one
You'd still need the dedicated server to post up a session I believe, otherwise you'd have to configure AWS to port forward for your server. You also still need some way of getting the session data to the client. It doesn't have to be a search, but it is definitely something you have to return back somehow.
Ah ok I think I understand
The problem I having though is that it is never called on the client. I just have it removed for now from the server just to test to get it to call on the client.
From a quick look at James post: https://jambax.co.uk/replicating-uobjects/ It doesn't seem to touch on that. Seems like you'll need to do it yourself and that's in case it's doable
Excuse me for being a noob. Where does OnPossess of the APlayerController class get called when the game starts, on the server or on the controlling client's local machine?
Server
And would it's remote role then be autonomous_proxy if it was called on a listen server machine, and simulated_proxy for all clients on the server?
A listen server has no remote role. It has a local role and it's always authority
For other clients it will be autonomous as it only exists on their owning client
Woah. So even though Controllers derive from AActor they are different in their remote role role from other classes Derived from AActor. Something like a class the derives from ACharacter, if it were someone using their machine to play the game and be the listen server, would have the remote role of Auto_prox on the server, but all clients on the server would have remote role of authority. But you're saying a controller playing as the listen server would have no remote role, but all clients on the server would be auto_prox. Why is a controller so different in that sense?
I didn't say client controller would have a local role of autonomous. It's authority. The remote role is autonomous.
Because controller != pawn
Pawn is replicated to all while controller is only replicated to owning client
Oh I understand now, I think I was trying to do things a bad way. What is the point in a game that all player pawns have been spawned and possessed and the game is just in session? Would it be the pawn's BeginPlay?
Nope. The pawn is possessed at a later stage. The event for that is called Possessed (in bp)
There is no such a thing a global event
It's per pawn
So you will need to keep track
I left it at the default of 100, shouldn't that be enough? Also, I got it to work for the most part, I had to call MoveInterpolationTarget before calling the super implementation which sets the actor's root component location, which makes sense as doing it before would have mean the OldLocation used for interpolation would be the same as NewLocation.
void AWeaponItem::PostNetReceiveLocationAndRotation()
{
const FRepMovement& LocalRepMovement = GetReplicatedMovement();
FVector NewLocation = FRepMovement::RebaseOntoLocalOrigin(LocalRepMovement.Location, this);
ProjectileMovementComp->MoveInterpolationTarget(NewLocation, LocalRepMovement.Rotation);
Super::PostNetReceiveLocationAndRotation();
}
The issue i'm having is when it collides with something, like the ground, it will clip into it before clipping back out. So while the movement is smooth it does some weird stuff.
Increasing the net update frequency doesn't help either.
No. From what i was able to figure out while reading trough code there are 3 issues you need to solve to get posses/unpossess to work correctly in lyra:
-
Pawn Cosmetics Component needs to check what you're switching to, and act accordingly, at minimum - it shouldn't remove the mesh from the character on unpossess but should refresh it on possess(). This probably requires an extension of playerstate to manage and replicate what pawns are currently belonging to what player. In Lyra ASC exists on PlayerState so ***i assume that the right way to do it, is to hold that info there ***
-
LyraPawnExtensionComponent::HandleControllerChanged() probably needs rework too, or im dumb (Most likely I am, since changing pawns proves to be a problem ). Anyway, from what i can see, while possesion/unpossesion happens, ability system component on player state gets uninitialized?. I'm hoping Epic will sooner or later document/tutorialize such basic features. But from the limited knowledge i have writing games and multiplayer i guess what should happen is ASC should stay active all the time, or, should be reinitialized after pawn change. I have no idea if that is all that needs to happen, and i don't have a lot of time to look at it or explore it further.
-
But most def something funky is happening in unpossess chain in general -> i thought that maybe my vehicle class was to blame but same shit happens when i switch between lyracharacters even locally. Switching trough the network is a comepletely diffrent issue, and i guess has to be addressed as well.
TLDR: It looks like a lot of work, so my final thought is that surely im missing something, and there is a better way to do it (like controlling server authored vehicles trough abilities or something). I would love to get pointers if any1 has any. Other than that, i dont have time to deal with this. I've moved on to different stuff, aint gonna waste time running experiments on codebase like this.
Okay so simulating physics on the UpdateComponent (a box collision) fixes that issue, and now I just need to change it so it can't rotate as that's the functionality I want.
I just didn't really want to do that because i've had so many issues with the new chaos physics clipping through geometry ๐ฉ
Basing your game on lyra seems like such a hassle. I think it's a good learning resource to take bits from but using it as a base sounds like such a headache.
Yeah, but at the same time i thought this was about giving community a solid codebase to build upon. I hate reinwenting the wheel, and since ancient times of UDK, Epic has a big problem with writing tools that are easily extendable.
like the game feature plugin seems like an great idea, but holyshit extend upon it, and your project starts to look like a bubble wrap of bubble wraps
Well yeah, don't use something as complex or as extensible as that if you don't need it...
Lyra exists more as an example of how a large experienced team can work on a project rather than a starting point for some small game being done by an individual. There's bits and pieces that are useful there, but it's way over the top for most people here.
The engine itself is already a solid codebase to build upon, and many of the assumptions in Lyra are either too generic for most games (resulting in lots of complexity) or too specific to Lyra itself (meaning it isn't reusable). Don't just take a massive sample project and assume it'll work for whatever you're doing.
Id agree, if we were talking about something else than switching pawns at runtime
There's probably some system in place you're not aware of that's restricting you, that's the issue that comes with basing your game on a large project like lyra.
Lyra is an example of AAA complexity if nothing else.
My biggest problem with it is that Epic made it seem like something that was easy to get started with, and if you act like you're doing nothing but modding an existing game it sort of is. But most people coming to Unreal are trying to create their own games, so this attitude about it doesn't make sense (or they did a bad job of explaining who the target audience for the project is).
It's very valuable to look through the source code and see how the people who made the engine would structure a complex game, and some of it helped me out. But yeah unless the game you're making is going to use most of the features in it you're going to be wrestling with the codebase trying to understand every corner of it to achieve something simple that you could do effortlessly in a blank project.
Hey folks, I'm hitting an issue with the CharacterMovementComponent. For some reason, my character rotates on the client but not on the server. I've tried controlling the rotation from the client both by calling Controller->SetControlRotation(NewRotation); and by using AddControllerYawInput. I assumed that both these things would properly end up eventually RPCing the rotation to the server.
For some additional context, I have things set up so that when I right-click somewhere the angle from the character to that location is calculated and then on tick, it's lerping towards that angle.
I'm using bUseControllerDesiredRotation set to true and bOrientRotationToMovement set to false (but I've also tried the other way around). I also tried setting bUseControllerRotationYaw. Not sure if it is relevant but the character is simulating physics.
Any idea what might be going on or next steps to try? I'd rather not have to dig deep into the CharacterMovementCode yet again...
I think bUseControllerDesiredRotation and bOrientRotationToMovement should be set to false
@molten matrix
Has anyone run into issues with NetMulticast not working? It doesn't fire on clients. We've done a lot of debugging and have also been looking into jitter from the CMC, which is not properly replicating to clients. We've created a workaround using client/server functions but NetMulticast isn't working
If you're calling it from the server it should work. If you start from the client, you need to use a Server RPC first then do the multicast
I didn't do teh debugging on this myself but I'm told that they ensured it was firing from the server
๐คท
yeah, that's kinda where we are. I was just curious if there was an issue anyone knew of
Make sure replicate movement is set to true
yeah, we did
I'm really not srue
at the moment we're fine, but it's weird and I'd like to figure it out
Is this blueprints or c++?
Hmm. Same result unfortunately
What kind of setup is your character? Is this first person?
Top-down
When you add a param to an OnRep function, is that param the previous value the client had for the variable, or is the server sending it's own previous value before replicating?
the old value would be the client's old value
okay neat
Is it possible that my problem here has something to do with the fact that my AActor outer that is trying to replicate the problem uobject is a child actor of an AActor that also implements ReplicateSubobjects and GetLifetimeReplicatedProps? The parent AActor is replicating a UObject class and a TArray<UObject> that is working fine. Its the child AActor that is having problems replicating its subobjects (the uobject is replicated, but its properties are not being replicated)
Ight been stuck on this problem for 2 -3 days now
I have a player customizer before you enter a session you can build your character (apply pants even change the colour of each limb) it all works fine
i join a game and everyone that joined before me is blank and everyone that joined after me i can see
the first player the joined (the server) can see everyone the second player that joined can see everyone except the server and so on
basically the event "colourfix" is run on server so it gets the event to run on the server then that goes to another event multicast so it shares it from the server to everyone els
i have played around with it
i have done just run on server
i have done just multicast
ok umm nvm i just fixed the skin colour now i got to do pants
but
i might no how to fix it
i dont know how but i tried multicast again but a little differently and it just works
You have missed this: https://vorixo.github.io/devtricks/stateful-events-multiplayer/
that explains why my old multiplayer game it works and this one doesnt
thank you soooo much man
yep it fixed it thanks man only one little problem but i should be able to fix that
Hey all! I'm seeing this in my client logs and players report they can't move on spawn sometimes LogCharacterMovement: <character> is stuck and failed to move! <location information> Actor: <some other player controlled character> So if i'm reading this right it seems like characters are stuck because they are colliding with other characters when restarted? I just have a deathmatch arena game mode and use the default restart player gamemode function. I'm thinking i need to override this function and check if its ok to restart the player or not. Does that sound correct?
Possibly weird question: is there a way to spawn an actor on the local client (for prediction purposes until the actual actor is replicated), so that calling HasAuthority() on the client returns false as it would with replicated actors?
99.7% sure that's a no. If the client spawns something locally, the client would have authority of it. What would be the use case where you would need it to not have authority?
Gotcha, the usecase would be me being too lazy to replace my HasAuthority checks with GetNetMode() < NM_Client checks. My problem is that I mistakenly used HasAuthority checks everywhere just to test if we're the server (so far only spawned replicated actors)
XD
As soon as I tried instantiating the same actor class on the local client for prediction purposes, HasAuthority checks returned true and it was running code that it shouldnt have
Ofc you can override it to your liking. Though the thing is that by default it spawns players at PlayerStarts and if there are not enough of them this issue could happen.
100 is great enough, in fact the point is that you could reduce considerably the net update rate as interpolation should do the smoothing out part for you.
Have you disabled simulation on clients?
because what can happen is that the simulation fights against the interpolation therefore you end up having rollbacks coming from interpolation
however the interpolation wont do miracles
if your projectiles are fast
small
and such... it will be enough
but for such cases you probably wouldn't use actors
Im broadcasting a delegate in my gamestates OnRep_MatchState. I want all binding actors to be spawned before they receive the broadcast. Is there any way I can ensure that this happens?
Concerning issue number 1, basically the best place to do it in lyra is to edit ULyraControllerComponent_CharacterParts::OnPossessedPawnChanged(APawn* OldPawn, APawn* NewPawn) in code.
its really simple as well, you just have to move code around
That helped remove some of the extra jitteryness, thank you!
// In BeginPlay
if (!HasAuthority())
{
ProjectileMovementComp->bSimulationEnabled = false;
}
Looks very good now
Turns out I was incorrectly trying to set simulated physics on the root component to false on the client instead of that bool
I thought since that was the updated component it would make sense to do it like that
๐
does gamemode's PostLogin gets called for ai bot controllers?
How to make players push each other out of the way based on previous velocity? How to improve this blueprint? ๐ค
It doesn't, you can already tell that's the case if you look that the param passed to it is APlayerController*. For AIControllers HandleSeamlessTravelPlayer is called in case of a seamless travel if it has a PlayerState. Logout(not BP OnLogout) is also called in case it has PlayerState.
Yes. Bind the delegate inside the actor's BeginPlay client-side and broadcast the delegate after Super::OnRep_MatchState
Thanks for responding! I have enough playerstarts but the one that is picked is always random so its possible there is another character just passing over it at the time another character is spawning. I think overriding restart function seems the best option in this case.
Yes, RPC to that client (through their PC, PS or controlled Pawn) and while running on their client, set that actor hidden.
Or just make sure you're running on the client in general when doing it ๐
Authoritative instance of what?
No. For a listen server you can't use Set Actor Hidden as it replicates. One potential way of doing it is hiding the root component if you're using a character - This shouldn't replicate.
And if it's just something happening locally, like on a button press, then there's no need to RPC.
For example, this works without replicating that the full actor is hidden, so it can be used by the listen server host and by clients, and it'll only hide on their end.
I can see that you have spent more than enough time on that little issue. It should not be that difficult! In one of Epics videos about input tagging they say in a way that Lyra are prepared to control another pawn, a vehicle for example. I have searched the forums, web, videos and still I have nothing on this particular problem. Controlling another pawn and then back to your originating pawn. I hope some clever Lyra guy reads our messages. It would be a BIG expansion of Lyra to get this solved.
ive looked into it a bit today as well, was able to solve the dissapearing pawn issue by changing ULyraControllerComponent_CharacterParts::OnPossessedPawnChanged(APawn* OldPawn, APawn* NewPawn) function a bit
simple fix really, just moved execution so everything is happening only on possessed pawn. (so an unpossessed pawn even if abandoned, mantains its character parts untill its being possessed again, then the refresh happens)
Controls are still unknown though
the issue is definitely happening on unpossess, and is not network or actor class related
as it happens even if you unposses and possess the same pawn
Everything in Lyra is done by tags, which is actually pretty neat and clever - and confusing. As I understand it the original pawn have abilities applied, for example it has input tag ability applied. But when the pawn loose control it also loose its abilities. So when the pawn is in control again you have to reapply all the abilities before the pawn works again. The reason that another pawn work fine being possed is that it is not a Lyra pawn with abilities, it is just a ordinary UE pawn.
What IS GOOD DEV GODS!
In this video I'm giving a boring lecture about Gameplay Ability System. Its a very high level overview and is not meant to be an indepth lecture as that could take a couple of hours easy. There is some good information and good references in this video so try not to skip it but I understand if you do!
If you have any qu...
This week on Inside Unreal, Technical Writer Michael Prinke will guide us through a tour of the Gameplay Ability System! We'll set up Graystone from Paragon with a couple of gameplay abilities in the Third-Person template.
ANNOUNCEMENT POST (contains project files and resources)
https://forums.unrealengine.com/unreal-engine/events/1850699
TRAN...
I believe that the solution is in these two videos. I just have to watch them multiple times. The Intro to Gameplay is VERY usefull for understanding the ability system and how Lyra handle tagging.
but afaik movement isn't handled by an ability
I mean, there is a possibility that lyra pawn does check tags to toggle it
my health bar widget isnt updating the percent of the bar when the enemy takes damage, any reason why? heres my BP
the health bar stays at 100%
does it need to be RPCd?

health value = Maxhealth - dmg,
You should be updating health directly inside of the widget fam
health value = always x - y
should be : health value = health value - damage afaik
Looks good, just need to remove this. You only need to divide Health by MaxHealth to get your value between 0 and 1.
it still wont update the widget itself for some reason
does it need to be inside the widget?
hell naw
Let's see what your code looks like right now.
Nothing has to be anywhere. But there is obviously a better place for things
I can put my entire character code in widgets if I wanted. Doesn't mean I should ๐
check if your cast is failing
Is there a way where Server can call an Event that will only trigger on chosen Clients from the same blueprint which is owned by the server?
Server Event checks all clients, if they meet given criteria, server will call an event that will be triggered only on chosen clients
You can loop through the player array, run your checks, and then have them fire a "run on owning client" event if they pass the criteria
do widgets replicate to all clients if the properties are set to replicate?
Widgets don't replicate
the problem is that this Blueprint is only owned by the server, so the calls won't trigger on clients
how do i get my widget to replicate to all clients?
You dont. What are you trying to do?
multicast would be bad
well, if i damage a mob i would like the other clients to see the bar decreasing as well
I'm confused
Their health variable is replicated right?
yes
In the widget blueprint, you can either get the owning player pawn -> cast it to base character -> get health value -> update it every 0.X seconds
Or you can use a rep notifier event with a dispatcher inside of it that sends the new value of the players health. And then listen for that dispatcher inside of your widget
I'll show you if you're confused
Maybe I don't understand how it works, this is clear explanation what I'm trying to do:
BP_Object is in the scene by default
This BP_Object has Server Event in which server checks all clients, and if they meet certain criteria, then Event X will be triggered locally on these clients.
My understanding of Run on Owning client is that this will only trigger on server, because BP_Object owner is the server.
The only thing that comes to my mind would be that Server will store all clients controllers/IDs/.. into an array and send this array via Multicast, then each client checks if this controller is his local one and if yes then this event will trigger.
Because if I'm not mistaken you cannot call an event on a specific client, you either do Multicast to everybody or you only trigger it on the owner, which can be only 1, but you need to call it on a bunch of specific clients
what I'm hearing is you want the server to tell specific clients to fire an event right?
yes!
@regal geyser
So basically the only way is to actually run that event on players controller/pawn. If for example I want this "BP_Object" to start flickering for X seconds and then stop via TimerHandle, is it smart to call this Fire Event on client's controller with reference to this BP_Object, and this controller would call an event on this BP_Object => StartFlickering? Or is this just completely dumb. Because I would like for the logic that needs to happen inside this Fire Event be completely inside this BP_Object
best way to do death? I was thinking of using an onrep uproperty bool death and call onrep death->destroy actor when health <= 0
it's probably best if the players check if they meet the criteria themselves, and then once they believe they have met the criteria, they will ask the object to start flickering, after that the object (server) will check if that player has truly met the requirements, and if they have... then it will flicker
that's is the best way to avoid going back and forth
and sending unnecessary traffic back and forth
Yes that sounds way smarter ๐ Thank you so much for your time!
You don't call destroy inside OnRep since that is client side
You do it server side
And for a general example see ShooterGame. Or Lyra. Hasn't looked at the latter myself
Lyra will make your head spin the way ALS does lol, I wouldn't recommend recommending that one
Haha fair enough. Stay away then!
should I RPC destroy actor?
destroying actor on the server automatically destroys it on clients
no further action is required
You are already on the server by the time you check if the pawn is dead. RecieveDamage (done on server) -> health <=0 -> Destroy
You my freind just described client prediction
In a very simple to understand way congrats

Only when a client wants to destroy an actor it has to ask the server, by which the server then does it?
indeed
server is the boss
the event has to be running on server
is this not fired on "any damage" ?
its fired on onrep health changed
insert a "Has authority" node, and then on authority call Destroy actor
if that doesn't work then your code logic is most likely flawed. clients shouldn't be setting rep notifies for replicated actors
That check is useless as it will yield false always as you're client-side on replicated actor spawned by the server
@dim trail Do my messages go unread?
You don't even RPC
has authority macro inside of a rep notify won't always return as client mate
How do you trust the client saying his health is below zero
that's what I mean, is he not setting the variable on the server to begin with?
Unless that's run on server which is done only manually
Well he doesn't provide full screenshots
Only parts
If you are using the legacy damage system you should be calling a function like ApplyDamage that does the damage and the function that listens to the damage is called RecieveDamage. Both are run on server as this is all authority stuff. You can also look at the new stuff offered by GAS. No matter what option you end up with, the workflow is one
Never trust the client saying the health is zero and RPCing to server. While you can do a check if the server health is zero there, it's still not the workflow you should be sticking to, but the one I mentioned above
defeats the purpose of the server checking anything if the client is trying to set everything
Oh yeah right. Forgot to mention that even the variable like Death shouldn't be set there. It's also set on server.
I know this question has probably been asked multiple times, but I'm struggling to have the server browser display the current player count in listen servers using the OnlineSubsystemSteam in UE5.
Based on information i've found it should be using something like SearchResult.Session.SessionSettings.NumPublicConnections - SearchResult.Session.NumOpenPublicConnections. Yet this always appears 0. I've also seen suggestions on using the SteamAuth but no demonstrations on exactly how to use it.
Any suggestions on what to attempt or where to look?
That's nothing answerable
Depends on too many factors
You will need to make your game and figure out what server specs you need by profiling
Hi, I'm trying to have it so when a player steps inside the sphere overlap it shows a widget indicating that something can be interacted with, if I have it without the IsLocallyControlled check, as soon as any player steps into the sphere all players can see it, but it should only be visible to players within that sphere, if I include the IsLocallyControlled check it works properly when playing in the editor but if i play through steam the server player cant see any of the indicators but clients can, any ideas how I can get this to work properly?
fwiw, using IsLocallyControlled is correct
Interesting.. do you know why that would give me different behaviour in the editor than when I play through steam?
No, sorry
Could someone point me to a good way to implement Voice Caht on Android without relying on the OSS?
Hi all, hope this is the right channel.
If I set an array variable to replicate with a notify function, the notify function is not called when elements are added to the array. Is that the expected behaviour, and if so how would I call a function on the client when the server updates the array and it replicates the change?
Adding to the array does cause the notify to fire. Are you sure you're adding the value while running on the server?
I think only the server doesn't receive the Notify itself, but clients do.
I'm doing something wrong then. I thought the server was adding an element to the the array and the client was not running the notify function. Will go back and check my code. But just so I'm clear, the server adding an element to a rep notify array should cause the client to run the notify function?
Thanks for the fast response Datura, I really appreciate it. I'll go back to my code and try to figure out what I've done.
Is it possible to dynamically replicate Uobject properties at runtime? Iโve followed this exactly: https://jambax.co.uk/replicating-uobjects/
But it only works upon the first replication of the Uobject by the AActor outer. After that, when a replicated property (such as an int) is changed within the Uobject, it is not updated on the client.
Does anyone know why my client can't move their character on a LAN session? I assume it has something to do with replication but I'm not sure.
Got there a question about the OnRep system.
Say i have this here
void Foo::BeginPlay()
{
// if has authority
OnRepVarOne = Something;
OnRepVarTwo = SomethingElse;
}
Is it guarded that OnRepVarOne would be send first and then OnRepVarTwo or could this happen in any order ?
Also another question related to that.
Is there any way to like.. wait for the update on a OnRep variable ? I feel like i'm in need of that, but only at the start of a game
Set local booleans in the onrep, call an event in the onreps as well that checks if both booleans are true before proceeding.
Yeah, i see how that could work.
But i'm not quite sure how i could make it wait properly.
while(HasGotUpdate == false)
{
// Do nothing
}
Seems pretty weird as it would block the whole game thread
Hello guys
Would I be losing too much if I do not use the unreal Character class, in terms of online gameplay ?
Like I'll be starting a new project, that's supposed to be a fighting game, and I'll not need some stuff that's inside that class, so I'm thinking on creating my own "character class", but I read online that this class has some online functionality so I'm a little afraid of miss something by not using the Character Class. Ow I never done an online game or anything related to it before, but I read a little bit about how the online system works inside unreal.
Yeah, you'd lose the whole CharacterMovementComponent which has all the replication logic in it just as client side prediction.
And this class is a monster
yeah that's the thing, I read about all this replication and things that's on this class, to be honest I don't quite understand everything, but it seems like a lot of complicated stuff
I'd say better deal with that instead of trying to make your own here tbh.
At least if you don't have the experience to do that
ok, I'll stick up with the character class and try to modify what I need
Don't use a while. Just do a check if both booleans are true.
If they're true, do whatever you want to do next.
That would mean i need to have that inside of the Tick or similar.
Is there no proper way to wait inside BeginPlay ?
No it doesn't. Use the OnRepEvents to fire another function. That function then checks the booleans.
I guess i should specify my case a little bit more.
The problem here is that i need to wait that a seed got replicated. And only if the seed got replicated the player can start to locally generate the procedural world
OnRepFunction1()
{
Boolean1 = true;
CheckReplicatedBools();
}
OnRepFunction2()
{
Boolean2 = true;
CheckReplicatedBools();
}
CheckReplicatedBools()
{
if (Boolean1 && Boolean2)
{
DoWhatYouNeedWhenBothRepsHaveBeenReceived();
}
}
Maybe i'm just thinking wrong here.
My problem was mainly the chance that the player spawns while the world is still empty, but i think i could just do it differently by making the actual player only spawn once the world is there
Anything? This is literally the last obstacle between right now and my game being complete.
quick question is UE_SERVER macro automatically defined when running inside a dedicated server?
Way to little information for people to be able to help.
You will have to debug it yourself a bit and post your findings. From the little info you provided this can literally be everything
And yet people wonder why their questions are left unanswered
Yeah that's a prime example for that feedback thread
I assume so, yes
At least I never did anything special to utilize it
I saw some conflicting information online, some people saying you have to define it
Small note, in CPP you can use OnRepFunctions for multiple variables
Same OnRep function that is
Right, it might be faster for you to just try it
will do
Heck that's new to me. They must be of the same type I guess? In case you want to use the old value...
Iโve debugged it as much as I could. Basically all I did was start a session on a listen server and when i start the game everything goes smoothly for the host but when the client joins, they canโt move, look around or do anything. Inputs still work but the player and camera keeps getting teleported back to itโs spawn position. Thatโs all i can tell you i literally know nothing about networking in unreal.
Could be yeah, but might work with no params on different types
I saw that ages ago on UT
They used it for the same thing. To ensure 3 different variables are set
At some point a struct is preferred though
Surprises me that you are close to release of apparently a multiplayer game but you know nothing about networking.
But anyway, if it teleports then the client tries to run while the server doesn't allow it. Does the same happen with a fresh and client character child?
Auto correct ftw
Fresh and clean character child*
in PvP FPS games with projectile weapons, how is replication of projectiles usually handled? Right now in my project I'm just using a server RPC from the client to spawn projectiles but it's not ideal because of the delay between firing and the projectile actually spawning.
I was thinking of having the projectile physics/hit detection be done all on the client, and have a "fake" projectile on the server act as a visual just to show that the client fired their weapon, but I imagine there are better ways of doing it. Is there a more "standard" way of going about it?
That's sadly a pretty heavy topic
You can go quite deep with this
What you are doing atm is usually the start
UE has no actor spawning precition
You can do something like UT does (check its source code) for slower projectiles
They spawn a fake one that they then sync up with the replicated one
syncing up on the server?
Yeah to match the client somethingsomething
Haven't look at it in a while
For faster projectiles you can check if you can't just fake the projectile visually and use a line trace for the actual shot
Depends on the game design though
that's probably what I'll end up doing then
But you will then also run into the problem of ping
Where you gotta decide who you want to favor
The shooter or the one being shot at
By default you probably pref the one being shot at
Because locally you fire at a ghost that is long further (if running) on the server and even further on the client
So you gotta see if you need to do some rollback stuff on the server to see where the client was when being shot at
But that's pretty deep down the rabbit hole
yeah, not surprised
A good example of this is Dead By Daylight. The Killer often hits you even though you are "far" away when having a high ping
Cause bhvr favors the melee hit against the long gone simulated character
Feels unfair for one side
But nicer for the other
Kids have it too easy these days! Back when I was playing Team Fortress (yea the Quake 1 mod version) and I had dial-up internet running along with 300 ping, I just shot where I thought they would be on the server.
Is there a reliable way of getting how much time has passed between the client calling an RPC and the server seeing it?
That would probably be helpful if I attempted rollback
Hm, I mean you can send RPCs back and forth fwiw
With timestamps
And then use half the RTT to figure out how long it takes
I do that for a more in sync timeseconds variable
Should be some examples on Google for thay
That*
Not sure what the CMC does
It might hook into the net driver or so to confirm timestamps. You can read through its source too
cool, that gives me a direction to go in, thanks
The game is not for the public itโs just for me and my friends. Also Iโm not sure what you mean by a character child.
I implemented something similar for a slow moving projectile in my game. I have the client spawn one with all visual and SFX so it doesn't have input delay then I call upon the server to spawn a real one which is used for collision detection with pawns. I set the client side one not to replicate and adjust the owner see / no see. The client projectile becomes hidden shortly after being launched and the replicated server one which is visibile to everyone except the owner eventually becomes visible to the owner who launched it. So the end result (most of the time) is an instantly launched projectile that can sometimes visually teleport slightly (depending on amount of lag) after its been fired. Since its already travelling away from the camera its much smaller in the viewport so when projectiles swap visibility its not as noticeable.
The gotcha with this method is if your projectile has any sort of tracer / trail effect. The teleport will be more visible. My projectile doesn't have a smoke trail or anything like that.
RPCs are messages send from the server to the client, client to server or server to all clients.
Usually you use a Server RPC (RPC from owning client to server) to request smth. Like "I want to dodge" then the server either does this, or refused to do so.
In your case you just have setup Server RPCs, so the client's likely won't notice the value changes on the stamina.
What you want is basically have the stamina being replicated and using a RepNotify to react to the change. The RPCs you might only need to request changes to this value from the client, but maybe this is not needed, maybe your stamina drains as a response to smth that already is being evaluated on the server.
How ever if, for some reason, you need to send an RPC from the server to the client, you need to mark it as Client (to send a message to the owning client) or Multicast to send the RPC to all clients (I think + the server, but I always mix things up)
Thank you!
So the function DecreaseSpeedBoost must take place on the server and the variable SpeedBoostTimeLimit must be ReplicatedUsing=OnRep_SpeedBoostTimeLimit
And in OnRep_SpeedBoostTimeLimit the same body of DecreaseSpeedBoost func?
the on rep function basically just needs to process the change, so most likely notify your UI you can use it to also control your gameplay, but as Replicated variables are not replicated all the time, an RPC to toggle of the gameplay effecting stuff like flying might be better
Thank you!
One more questions, on the widget I need to make any changes? As I read the widgets are only on the clients and not created on the server, so all the chances to the widget should work !?
I don't know your code, but if the widget just reads the value already you might don't need to change anything, if you properly inform it that smth has changed
Thank you! It reads SpeedBoostTimeLimit from the pawn
Hey guys
i tried playing a packaged linux build on editor and i get this error
pls any idea?
Do you guys recommend projectile or line traced based shooting for a gun? In the past I've seen people claiming that projectiles have better performance, but that's just doesn't make sense to me so I'm asking.
It doesn't make sense at all
But it's also highly dependant on other factors, like how good your implementation is, etc.
for example him
That's nonsense
I don't know of a single game that simulates projectiles as rigid bodies
IKR
Some people have really weird opinions on optimization
Yeah, traces are wayyyyyyyyy faster
You can run thousands of traces per frame
You don't want thousands of projectiles
They have upvotes too. Amazing.
Aren't traces using the physics system anyway?
Embree traces go brrrr
Yo is it actually possible for a client to update a RepVar's value on the server without an RPC?
No
I need a function that runs clientside but then updates a repped property for server
RPCs is the only form of communication from client->server
well that's not true but i'd guess at the only reasonable one outside control channel messages
Yes, that's what I mean
ya cool, thx
Is there any way to "spoof" a spectating player being the owner of the pawn they are spectating so that properties that are only replicated to the pawn owner are also replicated to the spectator? I'm trying to do first person spectate, and the first person skeletal meshes are only visible to the owner.
I'm curious if there's an easy way to do it like that, or if I will have to do something more complex.
You should be able to get the spectated pawn from the ViewTarget and set the visibility of his 1P mesh to true
iirc SetVisibilty replicates, so you might want to try using SetHiddenInGame
Yeah I can do it manually I suppose, I figured i'd have to. I'll also need to make sure any animations/FX being played are networked to the spectating pawn.
If that's true I will have to, since even when not spectating the player actively I need the animation code to still be run, but the mesh not be visible unless actively spectating
Otherwise you can swap and it won't be playing the active animation
Correct. You do that only when in spectating mode. Should be easy to handle
And for a general approach if you want some data to be replicated to owner and spectating players you should consider using proxy actors that are relevant to them where they can pull data from
Also note the spectator pawn is local only. So say you are playing sound fx, then you can't RPC to it. You can however, play it locally when it happens on the spectated pawn
is there a way to make the web browser plugin replicated amongst multiple clients ?
Probably by using an actor that can replicate its state to everyone and then using OnReps to update what is being displayed.
"Play it locally when it happens" What do you mean by that? If it's something that originates from the server, I would need to send an RPC right?
any chance you know of a demo or example of that im new to replicating widgets
You can't replicate widgets. You'd have to replicate through a different actor. Same thing with any inputs into it - would have to be RPC to the server through a client owned actor to make changes to that actor that everyone could then see.
Well not really easily do-able tbh cos you'd have to sync up the inputs in the site too and clicks
you'd have to make some kind of listener for javascript events probably and forward them to the other clients
sounds like a massive pita tbh, either that or you have some sort of shared VM for the browser and then just push changes to the DOM over network to each client
both sound equally as annoying
Do you think it is feasible to have a dedicated server to run a 40x40km world
I imagine it would depend on actor density across that map, and how you manage actors and replication in general. Take Minecraft for example, any single player's world is huge (60000km2). The only way it manages to do that is because it's not having it all loaded and running all at once.
Right. You send an RPC the spectated pawn, but you can't send it to the SpectatorPawn because it's not replicated. Though you should be able to call a function from there (client-side) that executes on the SpectatorPawn
You can hold an array of all PlayerStates belonging to spectators on each spectatble pawn to easily access them
Ah okay I was thinking something else. I can handle most of the stuff in the actors that get replicated anyway, like the player pawn and the weapon actor
Thanks for the advice @fathom aspen, I followed your tutorial too for setting up the engine way of spectating ๐
it looks like it handles "onlyownersee" by default too, I didn't notice before because the meshes were off screen
I see the fp meshes just no anims by default
Oh nice that it does ^^
Hmm, that must be investigated. Wasn't implemented with FPS support tbh
So I either change the title or make it supported
It gets the basics down, I wasn't expecting a full solution. On another note, is there a better way to check if a player is a spectator besides something like this: GetLocalViewingPlayerController()->StateName == NAME_Spectating
Ah awesome! I should have just searched the docs for that exactly my bad xD
I was using google instead and got nothing
Yeah it never leads to you anything useful heh
Seems like i'll still have to go through the controller to get the PS though, unless there's some kind of GetLocalPlayerState function
I meant for getting a handle on it locally, that's something I haven't had to do yet at least
GetLocalViewingPlayerController()->PlayerState
does anyone know how to fix the server crashing immediately when i disable 'run under one process'?
Ah that's not a function you would want to use xD
Unless you're doing local multiplayer (split-screen)
In online mp you only have knowledge of your own local controller on client
On server you have knowledge of all, but eh that's still not what you want
Cause it will be returning the listen server's local controller in case such one exists
Hey so I have a system setup where the player looks at wherever you're aiming (its an fps game) however I need to be able to toggle the player looking at where the cursor is because for instance if the player is holding a shield I don't want them to be able to look up with the shield etc but they can look up just not moving the shield
I am using a blueprint project and I recently started making some test games to try out multiplayer in the hopes that when I know more about how everything works I can do a real project. Ran into an issue while making a parkour game:
using the net mode "play as listen server" or "play as standalone" the host can wall jump but if there is another player they cant. Playing both as clients neither can wall jump. I am using a line trace and then setting the velocity based on the direction that the player hits the wall but I also tried using launch character which also did not work. If anyone can offer some help that would be great, thanks. (If important I am using 5.0.3)
If something works when "play as listen server" on the host instance and "play as standalone" but not "as client", that's an indication that you're not replicating something you need to. Movement by default is server authoritative, meaning, you can't really move your character unless the server knows about it, otherwise the server resets it. The Character Movement Component has some basic stuff for movement already replicated, such as moving around, jumping... Jumping off of a wall is a bit more complicated.
You'd have to RPC to the server somewhere after you've checked if the player can wall jump on the client, and then let the server check if the player can wall jump, and if so, perform the launch of the character.
okay, thank you.
values that are set in the constructor will still be replicated to clients, correct?
and if so, if I replicated them with COND_InitialOnly, they would be sent to clients when they log in right?
anyone know how to fix the youtube autoplay feature when using the web browser plugin
lol
You sure? The description led me to believe it was ideal
This is in the context of a rep notify
on a pawn
I never truly count on the documentation really
LGTM
Always look at the implementation
local controller with viewtarget
And anyways think about it. How do you access another controller that isn't yours if you're on client
Local can be server, but usually it's client
I'm not trynna do that, I'm trying to get my local controller in the context of a pawn, I know I could also just do getfirstplayercontroller too
I heard there would sometimes be issues with that with steam networking? All heresay though
So GetController would be enough
That function is nice though because it returns null if i'm not the owning controller or a spectator
That is your controller again
That function makes no sense if you're doing online mp
Which you seem to be doing
That function is there because they wanted a way to get the controller of the player spectating my pawn
I see, so since there's only ever the 1 player controller since it's clientside and no spitscreen, even Pawn->Controller will return the local player controller and not null if it's not the owner?
Yes. If it's the owner
Okay, but it seems P;awn->GetController will return the local controller regardless of the owner?
Ideally if you want a way to tell who's spectating you from the spectated pawn I would have an array of PlayerStates spectating that pawn
And based on them I can access a lot of stuff
Hmm okay
No. Will return the controller possessing the pawn
It's also the owner
Aight so I need to use GetFirstPlayerController
Since that happens under the hood when possessing the pawn
That returns your local controller even if it wasn't possessing your pawn
Though it must be used client-side
That's what I want ๐ This is for use inside an OnRep function so I can call animations if I am spectating that pawn
Yes. They will be part of the initial bunch
im trying to create a new game mechanic in my 2d game, can anyone help me? (also what channel do i send this in)
You seem to be playing the sounds on the server. Such cosmetic stuff should be done on client instead
Use the Remote pin instead and debug
#paper-2d if it's related to the 2d stuff
Or either #ue5-general #ue4-general
Any idea why when using ServerTravel , Only the host travel to the new map but other previously connected clients stay at the same map ?
Shouldn't be the case. I find traveling in PIE weird sometimes so it could be it
If not show code
What actor that code is in?
Ok. Then I would debug. Other than that I can't spot anything sus
But a lot of things could be not working as you expect
No worries. This is useful if you haven't tried debugging before https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/Blueprints/BP_HowTo/Debugging/
I'm not an expert in sounds but this isn't not how I would play sounds. Instead I would have a multicast firing from the character that is shooting bullets (sound of a firing gun) and another multicast fired from the bullet actor when it hits something (sound of a hitting bullet). Both will fire fine as long as they are being fired from the server
Along the way I would debug and not count on PrintString
Even if it worked, it would play sounds only for the players in question. The shooter and the one being shot at, at best
That's not what you want
You want all relevant connections to be able to hear the sounds
This proves that my earlier message was dietered 
Reread what I sent you
No. That defies what a multicast is
Use a client RPC then
Get Other Actor, check if that is a player character
And fire on it the client RPC that plays sound
So the client RPC is inside your character BP not bullet actor
I'm finding that because only Client->Server RPCs can be issued in the PC owner chain, we are ending up with practically all the functionality in the game in the PC class/or broker ActorComponents attached to the PC. Are there any resources demonstrating a manageable approach?
Well there are three: PS/PC/Pawn
And you can always make them own other actors, or attach components to them as you said
I don't see the issue in that. It's just how things work
Just a heads up, you want to avoid pulling values across execution paths, especially so in Multiplayer. The values from the OnOverlapBegin event are only valid on anything connected to its execution path and trying to use them on the separate Multicast event could result in unexpected behavior. The only reason it may be working right now is because that OnOverlapBegin also gets triggered on clients if the actor exists on clients, so it's pulling values from the last OnOverlapBegin event that was triggered on the client. If there's data that you want to pass through to the clients, then you use the RPC and add inputs to it so you can pass those values from the server to the client. So that being said, you may not even need to use an RPC for this - the clients themselves could be detecting the overlap event and playing a sound - and you could check if the "other actor" is locally controlled, and if so, play the sound - this way only the client whose character was hit would play the sound.
What would the c++ equivalent for this be? https://docs.unrealengine.com/5.0/en-US/BlueprintAPI/Online/Session/GetPinginMs/
Damn, that gotcha with BPs. I had doubts and I tend to avoid doing it all the time.
But yeah, you're right, for his case an RPC isn't needed, this was built with a multicast in mind, and the bullet can hit anything really (not characters specifically) so that was a quick fix. It's always better to avoid RPCing when things can be done locally ๐
That is a function is cpp
There is one in PlayerState, if what you mean is GameFramework actor classes
APlayerState::GetPingInMilliseconds()
that's what I was looking for, thanks
thank you
anyone know how to go about randomly assigning players a role before the start of the game? for example like among us 1 player is assigned the role and abilities of a killer and everyone else is normal. or what this process is called so i can try to find some documentation on it. ive been struggling with this for a few days now. thanks
You can opt to defer spawning a Player a Pawn when they join a game.
This is common for games that require extra setup before allowing players to actually play.
PostLogin is called by the GameMode when a Player joins.
You can use this to do stuff like assigning them a team or any pre-play setup they require (like what you are asking).
You can then spawn and possess them a Pawn depending on your needs.
This would mean that you would leave the DefaultPawn field empty on the GameMode, as you want to give them a Pawn of your own choosing later on.
Hi guys, little question how good i need to be to get a job in network programming in unreal engine?
@dapper jewel This is better asked in #career-chat
Look through the pinned messages in this channel.
@fossil spoke thank you
thank you, would this work also if players have their characters that want to choose?
The point is that the GameMode isnt deciding the Pawn as soon as the Player joins via DefaultPawn
You (as the developer) have to do that yourself instead.
When appropriate.
That might take the form of a Character Selection screen for example
got it thanks
Hello to all! Just some theory question. How network code of Gang Beasts works? Or Party Animal. Any ideas how did they make client prediction, lag compensation for fully physic-based games? Because i can't even understand how to replicate simple ragdoll in UE without input lag.
Those games are made on Unity, the difference between physics in UE an Unity is that Unreal doesn't have a constant tick rate on it's physics engine so it's ultra non deterministic, so far haven't seen any physics replication in UE that was looking good. I think chaos was supposed to solve this but I've yet to look at it
Yeah I'm pretty sure physics in unreal aren't replicated. You can keep the ragdoll in a predictable location by setting the restraints of how far it can go from it's root though, found that one out recently
Chaos support fix phys frames. At least must support ๐ at least in docs =))
Hm. Can you tell me more details about it, maybe i can use it some how.. For example to reduce input lag.
I'm failing to see how that will help you with input lag
Hmm let me think.. Client send "attack" to the server and starting simulation of ragdoll hit with kind of slow mo. Then after receiving at least 3 snapshot of simulation from client we can start to interpolate next ragdoll movements.
We can simulate it on the client till predictable location for example.
I don't know actually. Just thinking how can i compensate lag in my case.
Other idea is to use "long" attack animations. When attack starts we send command to server with attack type and anim start time. When server gets this RPC it will know when animation has started and exact hit time and location. We can cut few frames from animation (lag compensation) and start it from specific frame on the server. Once the hit has happened Server starts ragdoll simulation and sending of snapshots to the Client.
Kind of fighting games networking style.
By the way i'm pretty sure that Unity also using non-deterministic physic engine. So why it better for phys based games? Fixed frames not guarantee same ragdoll behaviour. I think ragdoll unpredictable at all. That's the main problem. Please correct me if i'm wrong.
Also i tried to turn on Physics Sub-Stepping, but i didn't mention any difference in ragdoll simulation. Shall i do something extra for it? Maybe it can help me to make ragdoll at least little bit more predictable to reduce deviation
I'm trying to get the host to spawn in one spot and the players to spawn in another. 5 spots for the players and 1 for the host. I've got it set up so that if the player has authority they should go to the player start that is for the host, and if they don't then they spawn in the player starting pool. But everyone seems to have authority and spawn in the host spot
Why? lol
Hi man! Can u help me? I make game with multiplayer, and i need make a text with player nick top of his head, and i have: Client and server not replicated, how fix this?
Because they all have authority on server. Use IsLocallyControlled instead to tell if that's the host
Well they haven't spawned yet. Use IsLocalController on the PC
First things first dont use GetXXX(0) nodes in multiplayer
Also don't use multicasts
You are doing stateful stuff, that means you should stick to replicating properties
Also you have PlayerInfo replicated but it's in PlayerController, which means it's only replicated to owning client and just that (not to all)
Instead you use the PlayerState to store PlayerInfo which ia replicated to all
Use the search tool of this channel. This has gone over too many times
Also see pinned messages they have some juicy stuff you don't want to miss
Can I show you what I've got set up currently and get some direction?
I won't say no
Again my answer still counts
In GameMode you're always server
So that HasAuthority is useless
That makes sense
Take the PC pin and get IsLocalController
Branch it
True - listen server player
False otherwise
Also why the heck you have RPCs
GameMode isn't replicated so there is no sense in having RPCs there at all
You're always on server there
I was following a tutorial on youtube and that's what they did and it was working somehow
Yeah not amazed at all
YT stuff
They work because they are executed as normal functions
But it's bad practice that shows you don't understand what's going on
You'll also have trouble with this bit of code. The players could end up spawning on top of each other.
Also, just because it's working, doesn't mean it is what you should be doing. RPCs are avenues for clients to potentially "cheat" or cause problems with the game. By leaving the "Assign Role" RPC available as Client->Server RPC means that any client could call it if they wanted, set their role as host which would bugger up your remaining spawning logic. This is something that the server itself should determine.
@fathom aspen i do:
@fathom aspen That's true. I don't really understand it too well. I'm trying to get it to work and then deconstruct it a bit to understand it better, while also making progress toward my project. I learn better by watching and following along, so I'm trying to rely on less than ideal youtube tutorials lol.
@sinful tree I knew it could have the problem of spawning on top of each other. I just did that up quick to test it out. I've got to go back and fix it up so that they don't do that. I don't know the ideal way to do that. I was thinking of getting those player starts in an array and then removing them after a player spawn there. But I don't know for sure.
But wow... I didn't know about the potential for cheating. That is pretty concerning. I'm not really sure of an alternative set up. I'll have to do some more digging and try to figure that out.
lol damn youtube tutorials
You just "fixed" one point and left all the others @dim light
Reread what I sent you
GetXXX(0) its ?
Yes?
The alternative set up is to not use an RPC there as it's not necessary. You're already running on the server since you're using the Game Mode which exists only on the server.
The alternative approach seem legit. Removing the PlayerStart that you use to spawn your player in should be good.
Sorry, thanks, i try, using search tool be hard for me, i bad know English....
Though you will have to make sure that you store them in the array once @left flicker
So, might be a stupid question... Should I just set the 'Assign Role' event to not replicate then?
That can happen if you're the host as their is only one
Yes
The tutorial, he did set it to replicate "just incase"
I know, it's hard to pick the words but you'll get over it over time. I use it all the time, that's why I rarely have to ask
_< NOOOOO
That means this person has no idea about multiplayer.
That doesn't make it legit. Try keeping away from YT tuts for realll
There is no "Just in case"
If you need to, then you do so, if you don't know you need to right now, you can always do it later if necessary.
You have pinned messages in this channel. Should be enough. The compendium has been my favorite so far
Ye) English its anwser for all programming question ) Thanks!
@fathom aspen I need to init pawn in PlayerController or in Pawn? And need set pawn Ref to PlayerState ?
Do it directly inside the pawn as I say in that forum link I sent before
There is no need for level of indirections here
The issue though is that you can't guarantee the PlayerState has replicated in time when you need that info
That's why you use a function that listens for such a thing: OnRep_PlayerState
If you're using BP only you'll find yourself lost cuz that is not exposed to bp
And for multiplayer you should be using cpp instead
I have to go for a bit, but just really quickly before I do; After they spawn, they share a camera (the host has it's own and then the other players share one). And I did have it working before, but it doesn't seem to be working properly now The host gets the appropriate camera, but the players don't take to theirs. I'll try to sort it out later, but any feedback is always helpful. I'm sure I can figure it out either way.
Level blueprint isn't replicated, so the HasAuthority check I think always returns authority. Nope, they return as remote on clients.
But in your case to workaround that, inside BeginPlay you do a SwitchHasAuthority check and use the Remote pin to get the pawn and set the info when it's there @dim light
Yeah I remember it being so last time I fiddled with it. Though I still believe it's not replicated
This Role system ughhh
I think the issue is that the possession of the player's pawn happens after the begin play of the level on the client, and thus forces the camera on to the pawn. Putting a small delay on the remote path appropriately had them move and stay on the second camera.
Yeah, the begin play of the pawn happens after the begin play of the level. Having no default pawn prevents the camera from changing from what was set in the level blueprint.
Yeah the timing is the issue there and overall the level BP has always been sus. Instead I would do it inside an initiated event after they all spawn that traverses all the players and does that accordingly
You would still need to somehow reference that camera actor inside the bp in question
Nothing wrong with using Get Actor of Class with Tag in this particular instance if it's only done once at the start.
So I've been using this documentation as a reference point for how I tune my NetUpdateFrequency for actors, and I'm wondering if a value of 10 is just too low for player controlled characters. I mainly ask because the CMC relies on FRepMovement struct for simulating the movement of simulated proxies. At a value of 10, you only send FRepMovment every 0.1 seconds meaning everything in between updates is predicted and therefore larger deltas in the mis-predictions.
Iโm trying to figure out the best way to organize/implement class structure for my game. Itโs a sports simulation type game similar to Out Of The Park baseball, so it seems pretty heavy on the data side, with so many classes that a player needs to be aware of at once (I think) (players/coaches/conferences/teams and related statistics).
Initially I had all of these as uobjects as I know I did not want hundreds and hundreds of actors when uobjects would work fine enough. After having some trouble replicating them and discovering this discord and reading that for the most part I should be using structs instead of uobjects unless I need inheritance (which I donโt), Iโm at a bit of a crossroads in terms of how to implement multiplayer functionality. Especially since I canโt just totally convert my uobjects to structs because then I canโt run UFunction RPCs on those structs like I can UObjects. So here are the options I see:
-
Donโt try to replicate everything or really very much at all. Use RPCs to retrieve the data when it is needed. (Server RPC GetTeamAStatistics() โ calls Client RPC SendTeamStatistics(TeamAStatistics)). This feels clunky and seems like it would have a lot of near duplicative code, as I would need a different Server RPC and different ClientRPC for each context of requesting those statistics. (I could be wrong about this last sentence).
-
Keep my Uobject functionality, but move stored data into a separate struct that can be replicated by an actor. This would mean calling server RPCs on the Uobject, which would then manipulate the properties on a struct that exists within its outer. This is what I implemented last night, and it seems to work, but feels clunky. Example of trying to change a property -> ParentOwner->DataStructInsideParentOwner.Number++;
-
Get rid of the uobjects altogether and replace them with structs, with all the data and functionality. Since I canโt have RPCs on the struct, move them to the structs owning actor. The RPC would be called on the actor, which would then call a (non-UFunction) function on the struct with all the actual functionality. Essentially the Actor owner would just be a conduit for all the actual functionality and properties living on the structs. I thought of this option as I was thinking this through, and seems like the best option, but I havenโt implemented it / tried it yet and I am not sure it would work.
Is there ANY way to send RPCs to a specific client depending on a server side condition, no matter how hacky it is? There are some situations where I have to do a multicast but really it's a waste of bandwidth because only a few players need the information, if any at all. To my knowledge you can only send RPCs conditionally based on owning clients and nothing else.
I think back to coding in garrysmod where I could just do net.Send(Player) and wish there was something like this
Unless I'm misunderstanding something about RPCs, it seems like a really basic feature that should be available as standard.
Could you send some type of playerID as a parameter for the multicast, then in the multicast check the clientโs playerID against the parameter, and only run the code if they match?
sned it over the player controller of the player?
If you know who the player is that it needs to go to, then you should be able to RPC through that player's PC, PS, or Pawn.
@marble gazelle @sinful tree Wow so simple I'm surprised I didn't realise it.
Thank you
in the end: just needs to be a Client RPC for the owning client ๐
A little annoying to have to use the PC as a proxy, would be nice to keep the code somewhere else but it's fine I guess
Yeah for a normal client rpc
yeah, for normal client RPC it can be any actor that is replicated and owned by the client or a component on this actor
I want to send to specific clients, so like looping through all pcs on server, checking a condition, then only sending to those
then give your PCs a component that wraps this communication for you \o/
I will do something like this ๐
I've been doing multiplayer stuff in Unreal for a little while now and it kind of works, but I basically "wing" it, instead of applying patterns. Here's my question: What does the general pattern look like for something I'd like to run on all clients and the server, regardless of the client or server initiating it?
How I'm doing it right now (it works, but could it be more simple?):
And yes, I've read the networking compendium/bible, but fail to take away BP-only relevant patterns for basic scenarios like this. That's what I need help with. Thanks in advance
Technically what I'd do is Input > Line Trace > Check if Something was hit > If So, Run On Server > Line Trace > Check if Something was hit > Perform whatever needed task on server.
Generally speaking you probably wouldn't want to multicast an interact event. The thing you're interacting with would have its own state to replicate / properties to change / destroy itself etc.
An example of applying this would be a door. Would what you said about own replicated state still apply?
If I only have the event run on server, the door (in my example) only opens on the server (it doesn't replicate).
Lots of examples of opening doors in this channel already, but yes, the door itself would handle whatever replication it needed. You wouldn't need to do a multicast of the interact event itself.
Alright, thanks!
Hey, I'm storing a int inside the player game instance (to choose the max players for a lobby), then I would like to change the value inside the game state, because this class manage the lobby timer etc. I tried to access to the game instance inside de game state, but of course I can't, any other way?
You need to RPC the value from the client to the server using one of the player owned classes, like player controller, player state or pawn.
So when the server wants the value, you'd RPC to client on their playercontroller lets say, that event can then pull the value from the game instance, and RPC back to the server the value, again on the playercontroller, then when running on server you can set the value in the gamestate.
Anybody have good suggestions for tutorials / courses for multiplayer games?
I'd straight up pay a pro to teach me how to make an optimized wave mode multiplayer game
Check this channel pinned messages
thanks man, working fine
ur a wizard, thank you!
I've been spinning my wheels for the past day trying to get any sort of online working between packages on two separate machines. I've tried Null and Steam, but at this point I'd be happy if I could just get LAN working, but no matter what I do, the FindSessions node returns an empty array.
I've tried almost everything I can think of, but nothing on my router yet. Would I need to set up some kind of portforward, even just for a LAN connection?
Hello All,
I have a question related to "Set Actor Location". The short version is that it seems if I call "Set Actor Location" in a "Run As Server" event on a client controlled actor..it is being completely ignored. The same "Set actor location" call that happens immediately after, on listen server controlled actor works fine.
Movement replication is otherwise working just fine.
I assume there is something fundamental I am missing that explains this however I haven't been able to pin that down. My assumption is the server should be able to move actors wherever so its surprising to me.
Where are you calling the โSetActorLocationโ server function? And is it the player pawn or another type of actor?
Normally yes, the server has authority over any actors that are spawned by the server and can set the actor's location. So long as those actors are set to replicate, then the position of that actor should be updated whenever the server calls Set Actor Location.
Hi There !
Set Actor Location is being called in custom event set to Run As Server inside the character blueprint. Yes, this is the players pawn.
Sorry if I use any terminology incorrectly.
This is some example code I've tested with on a first person character that is marked to replicate and is spawned by the server, and both the host and the client can move themself around to the different start points by pressing the E key.
Thank you for sharing that.. I wonder if its because I am passing the character to be teleported as a parameter into the event.
The first "Set Actor Location" Is using the character passed into the event as the target. (This is the client player pawn)
The Second Is using a reference to self as a target. (The self is the server and is working)
Note: I just manually typed in locations for each to debug this.
I will keep poking at it. Appreciate the responses that at least validate that I am not crazy ๐
I wouldn't recommend passing the character reference through - this would allow clients to call this RPC and teleport anyone they want to teleport rather than perhaps an intended target. You'd probably want to validate on the server who you're pulling.
Ah. Ok. That is great advice.
At the moment this event is only ever called by the server and never by the client. But I suppose there may be other ways a malicious actor could abuse this?
