#multiplayer
1 messages ยท Page 91 of 1
what does it do?
It checks whether the currently executing code is running on the instance that has authority over the actor. Replicated actors exist on both the server and clients, so the overlap can be detected on both. If the actor was indeed spawned by the server, then Has Authority (Authority) will ensure that only the server is executing the code.
However, if the actor was spawned on the client, then the client would have authority of the actor, even if it is an actor marked as replicated as it would only exist on the client.
I'm having a big cheating issue on my multiplayer game that is running through dedicated servers. Any ideas for what I can do about getting an anticheat?
anticheat software alone won't do much if the gamecode has inherent exploits
without knowing what the cheats are we can't offer any advice
Main ones are, people are speedhacking/phasing through walls
Phasing through walls is probably the biggest issue.
you can turn on the engines built-in speedhack protection, which is off by default.
assuming this is character movement
I also suggest a custom engine build which disables the fixed timestep mode of the engine
How would you go about preventing phasing through walls/ specifically actors
There's not really any reason a cheater should be able to do that unless the server is blindly accepting their position
or theres some function they can call/spoof which allows them to teleport
Those two steps above are basically essential for any UE game though. Any "off-the-shelf" cheat for UE games will basically include those hacks by default, they don't even need to be specialised packages for your game.
The fixed timestep thing is relatively recent
AFAIK anyway.
Where would I find the built in speedhackprotection?
Have a look at GameNetworkManager.h - it contains a bunch of config variables you can enable. In 5.2 they start at line 191
Movement Time Discrepancy settings for Characters (speed hack detection and prevention)
It's not perfect, and it does increase server processing time, but it's better than off by default.
Awesome, thanks!
actuali when a client do it crashes any solutions?
If you are running multiplayer only server can call possess.
?
what to do?๐ข
it's muliplayer only
@sinful tree
i need to client call possess
You cant do it on multiplayer. The server must. The client can trigger the overlap but possession can only happen on the server.
any other ways to do it?
like another possess
@sinful tree ok ty
but that crashes don't break my project?
Ask the Server to do it, then wait
(via RPC). Seems silly though, just listen for the overlap server-side instead.
huh?
Is calling an RPC on the target machine (calling a server RPC while already being in server for example) same as calling a regular function or is there a networking overhead happening anyways?
i don't know what RPC even is
I'm trying to (in my mind a seemingly simple thing) have a player press a key which brings up a widget on all connected player's screens. For some reason when the key is pressed it's only making visible for the player who pressed the key. First image is on the Player Controller. Second image is in my HUD class
Any clues appreciated
It is seemingly simple if you would know the basics :D
๐
Let me ask you 2 questions
- What is special about the PlayerController in regards to Multiplayer?
- Can and should the HUD replicate?
Although the second one would be HUD not Widgets I geuss
Spoiler: If you can't answer this, I will point you to the network compendium
hmmm
- A unique PlayerController is assigned to each connecting player. It is on the Server and Owning Client.
- The HUD only exists for each player separately
Good, so then let's check your code.
What are you again doing on your PlayerController?
You are performing 2 RPCs as far as I can see.
One of them is a ServerRPC, one is a Multicast.
Given your answer for 1., what could be wrong here?
hmm. So it's firing it once for the server and again for the other clients?
So is it toggling it on and off again?
Nope, you just wrote that the PlayerController only exists on Server and OwningClient
What do you think will the Multicast achieve here?
Ah. I thought that having a custom event set to server would then send to all clients with the next custom event set to multi cast.
No. A ServerRPC will send the call from OWNING Client to Server (so this only works on Client owned Actors, which the PlayerController is).
And a Multicast will send the call from Server to all Clients that have an Instance of that Actor. Since the PlayerController doesn't exist on anyone but the OwningClient (and the server), the Multicast is only calling on those two.
from your compendium I understood that the Player Controller being on the server and the owning client meant that you could ask the server to multi cast to all player controllers
The Multicast works depending on the Actor you call it on.
If you want it to call on Everyone, it has to be called on an Actor that exists on Everyone.
So the ServerRPC in the PlayerController is fine.
But now you have to get a different Actor and call the Multicast on that.
Any idea what Actor you could use?
so that would be GameState, PlayerState or APawn
Pawns aren't necessarily on everyone
Yeah, GameState would probably be the best option
If they become non-relevant they will not receive multicasts.
Pawn could be out of relevancy range, correct
The Multicast calls on everyone locally
From there you can get the PlayerController and then the HUD
The other problem is your RPC usage in the HUD class
- The HUD only exists for each player separately
That was your answer. The Multicast in your HUD is redundant
And not on the server at all.
Well, ListenServer it does, but only for the Server itself counted as a Client
ok gotcha, thanks for the help. I'll probably come back crying here later today
A general way to do things is to route server rpcs through the player controller and multicasts back through the gamestate. But multicasts are, in general, a bad idea unless you have a very good reason.
In the majority of cases a replicated state is probably better.
Yeah Multicast only makes sense if you are fine with players who connect late to not get the result of the Multicast
Basically I'm trying to end the game with a Widget that will pop up for everyone with a messages as to which team has won
If the Widget has to show for them too, then it's better to run this through some variable that is on the GameState, repnotify and doing the widget in there
Like if you wanted some ingame chat, that might be okay with a multicast because late joiners don't care. Or something.
But multicast also happens instantly and will clog up your network if you use it too much. Normal replication happens over time to avoid that.
For this it would probably be better to use some sort of Replicated Variable. For example a Struct that has the State of the Game (E.g. Ended) and the Winning Team in it.
In the OnRep of that you can check if the game ended and show the Widget
As well as passing the Winning Team with it
The idea of ServerRPC in PlayerController and then GameState for replication to everyone stays teh same
Just that it wouldn't be a Multicast
The benefit of this is that people who join late or reconnect will get the Widget again
Actually thinking about it, I think the Replicated Variable makes more sense, as there are two different conditions for the two teams to win the game.
- Where a player crosses over a threshold
- Where the player is captured by the opposition
Yeah that can also go into the Struct fwiw
ok I'm putting Structs on my list of things to learn about
btw, I'm a stupid artist with a game idea. This is breaking my brain a little but I almost have the core loop complete and am champing at the bit to start doing some artwork ๐
Don't call yourself stupid. (:
haha, when it comes to Replication I think it's fair to say that I am
The fact you're an artist, but have the wherewithall to a) think of a game idea b) try to put it into practice and c) actually get to the point where you're learning how to program, especially multiplayer programming which is very difficult, just means you're actually quite smart.
Aw thanks man, appreciate it. It's very slow going but I'm getting there. I've saved this conversation with you two as it's definitely helped clear up a couple of fuzzy notions I've had about how all the pieces fit together.
i SEE
I see
Thats interesting
I'll definitely consider it after this project as I can reuse that code for almost all multiplayer games I decide to make
does anyone have any idea as to why servertravel does not work? on pressing the button the server transitions to the new level but client does not
when game is over I force use SpectatorMode but when I use seamless travel back to the game menu, nothing loads and I think controllers break, any idea why and how to fix it ?
Hi. so if i want to replicate SK Mesh variable in actor class and its owner is playercontroller which replicate condition should i use?
Owner has no bearing here. Doesn't matter who does or doesn't own the actor. You just simply replicate it like normal. Probably with an OnRep/RepNotify though so you can update a skeletal mesh component when the asset value arrives on client.
oh ok, repnotify is called on client right or both?
I hate networking, why does it have to be so confusing?
you need to create a ClientServerTravel function run on client and call it from server like MyPC.ClientServerTravel();
K, thanks. Do you mean run to on client or multicast?
run on client
but im not sure about execution order, should server or client call first.
Thanks
I think run on server, and then call the events on the clients
But will the clients stay connected?
not sure about that but might be somehting about bSeamlessTravel
Depends on if you're in BP or not. Setting it from a Set node in BP will also call it on the server. But normally it's only called on clients when the value arrives and changes what the client already has.
Also, ServerTravel here should be fine. Are you testing this in PIE or Standalone, or built game?
Im testing this in pie, does that make a difference?
AFAIK servertravel won't work in PIE unless stuff has changed recently.
so setting it to repnotify is like replicated? just repnotify notifies when it replicates, what about replication condition. options seems not understandable
there should be like bNetdirty or something that if the value is changed it'll replicate
Conditions are for different types of replication. Like SkipOwner would be used if you never wanted that value to replicate to the owner of the actor. You use that for letting the owner simulate it on their end but still replicate it to everyone else. None just means it replicates to everyone.
so in my case replicating to everyone means only to my player? because this replication is doing in actor that has PC as an owner
if my understanding is correct PC only exists 1 per client so replicates to all mean only to my player
@kindred widget SEAMLESS Travel
ServerTravel alone works fine
Also there is a console variable that enables SeamlessTravel in PIE (Experimental)
Oh, neat, will have to look that up and test.
If the property is on the PC then yes, because PC exists only on owning client
But if the property exists on an actor that exists on all (as you are implying), then no, replicating the property to everyone will literally replicate it to everyone (think about this like replicating a property on Pawn with no condition and Pawn is usually owned by PC... the property would be replicated to all)
This depends on if the property is on an actor owned by the player controller, or ON the playercontroller. As stated before, the owner does not matter here.
I see, thanks for clarifying. been not sure about this for a long time, never had a chance to test it myself
Technically everything of a client's is owned by the controller in some form. So if that were the case, nothing owned by a client would ever replicate to any other player, including their pawn.
I see, so everything that replicates to clients their root owner in owner chain is from PC/GameState/PlayerState ?
Hmm? Not sure what you mean by PC/GameState/PlayerState? By default a client owns two things, Their PlayerController, and PlayerState. The PlayerController owns the PlayerState. PawnPossession also changes ownership, so any time a player possesses a Pawn, that client is set as it's owner via setting the owner of that Pawn to be their possessor's PlayerController. You are free to extend this by making a weapon actor and setting the possessed pawn as the owner.
GameState has no owner and never should. Anything replicated with no owner is technically owned by the server as far as RPC/replication goes.
i spawn an actor on server (not replicated) and set its owner to PC on PC's beginplay would my actor get replicated if my actor class is replicatable?
Yeah, if it bReplicates=true, then yes
Worth noting there is a default implementation of this you can see. GameMode spawns the player's default pawns. GameMode is not replicated.
I mean if we spawn an actor on non replicatable like in GameMode (not sure) then we can't get the actor to replicate, so we need to spawn it on any actor that can replicate ?
๐
No. The sole requirements are that it is spawned on server, and set to replicated.
If it doesn't replicate to the client, then try setting always relevant as a test to see if relevancy is the cause.
ahh it becomes more clearer now, thanks
Is it possible to get the player controller from Other Actor 'On Component Begin Overlap'?
OtherActor->Instigator->GetController
what's difference between these two setting on an AMyActor ?
SetReplicates(true);
bReplicates = true;
You can just set the variable where you call this event and remove this event
You're already calling it from server, you don't need to multicast it again and filter for the server
ahh ok, this is just for example. i need to set the mesh later in the function
I mean, if you're not going to use the Remote part of the authority switch then you still don't need the function to be an RPC. I'm not entirely sure about your aim but from the naming of the function, it shouldn't be an RPC
actually the function pass in Character and i need to the mesh on server and replicate to client, or i can just also set it on client? because idc if the mesh needs to be the same on both sides
Hi WizardCell, that seems to return Controller not Player Controller. Is there a difference?
Just want a quick nugget of guidance. I have gameplay setup and menu for joining in online subsystem setup and working correctly.
I need to create a lobby so that the players wait in the lobby before joining the gameplay and the host can exit after 3 minutes if the client didn't join. Can someone tell me briefly how should I go about doing so( in C++)?
Just cast to player controller.
When we open a map with listen option, does it run another executable for the server on the background or is the game package comes with the server stuff itself and runs in the same executable?
instead of running Standalone, the game will run in ListeneningServer
its just with added hosting capabilities, its the same executable
for DedicatedServer builds, you will need to build them from source code
Got it, thanks
Anyone?
this is what I just did yesterday
Good news @untold rose , I scrapped the whole game state system as it wasnโt working out, I gotta learn more there but for now what I did was create an actor in the level that spawns when the level is made and all it does is hold the variable for the array and has an event that can be called when the lap finish is confirmed. Only issue now is that when I add the player controller to the array, it adds two controllers instead of one
this is a very long process
you need the array of players, hold them in lobby
This would be no different than just loading into a map when someone connects. Just in this case, your map is just a UI lobby.
What part are you confused on?
The only confusion I have is about transitioning players into gameplay. Should I just travel to the Gameplay level from lobby and it will spawn default pawns? The players in lobby are just a show right?
And also I should use OpenLevel when in Lobby to transition to Gameplay Level right?
Use seamless travel
It keeps your players connected to your server and Steam also requires it
To set seamless travel I just need to set the bool in gameplay mode right?
Yeah
Okay. Thank you so much ๐
But player start of gameplay level will be used right?
Because I use them to position characters
As long as you set them up
Already did. ๐
But if no player start exists, I believe it just spawns at 0,0,0
Yeah
I have everything done, just this step of adding lobby
Just a general question, lobby can be just a floor on which players run, right?
Got it
What does it mean to build from source code? In building dedicated server contex
Clone the repo from github and then build the engine from that.
(Or if you have access to Epic's P4 server, use that)
I'm not using github, is there something I need to be aware of when creating dedicated server? As long my game package and compiled. It's good to go?
Your only choices are to clone from their github or get access to the source through their P4 server.
SetReplicates(true); for an actor should be in constructor or beginplay?
Oh f do you mean clone the unreal engine on github
constructor
I hope they are compatible with my plugins...
Yes.
don't it need an already init actor?
Thanks
A "source" build is just a build of the engine that you compiled yourself from the actual source code of Unreal. Obtained via github or their P4 server.
A launcher build is the one you download from Epic
I downloaded source build one but switched to 5.1. I guess I need to download 5.1 from github to run dedicated server
APawn does set bReplicates = true in its constructor
Yeah using launcher build atm
Btw are u guys using version control? Is it even viable? My project is 80gb..
ofcourse
Hmm maybe the wrong section to ask
But github have file size limit?
Like 2 gb or something
hi ! yes after a specific amount you need git lfs (large filestorage system or smth like this)
Azure Devops has free, unlimited repo size, with git lfs as well.
bReplicates = true; != SetReplicates(true);
if I do SetReplicates(true) in constructor, I get this warning SetReplicates called on non-initialized actor NNNN. Directly setting bReplicates is the correct procedure for pre-init actors
I just use P4V for my source control. You can set up Streams and Branches where you don't need to make duplicate workspaces
then just set bReplicates ?
it doesn't replicated the actor sub comps
you need to specify each component to replicate
if the actor has static mesh, it needs to be like mymesh->setreplicates..... particularly
but SetReplicates(true), give warning but it replicates all comps in the actor class
just set them to true right after you create your actor comps
PostInitializeComponents
also probably never replicate everything ๐ซ
Replicate the smallest amount of stuff that you can.
The ultimate goal of networking is to do as little of networking as possible.
if an actor is replicated, all of its child actors will also be replicated?
ex:
AItemBase() is repliacted
and
AItemWeapon : public AItemBase
will also be replicated?
or it need to set replication particularly?
by default they will inherit it too, so yeah they will replicate
its mean I have somewhere else broken code which needs to be fixed
Is this correct so far?
This is within the gamestatebase
I also need to show the player state wins in text, is this correct?
what are you expecting that delay on tick to do
Check if any of the two players have won a round
that is about as incorrect a BP graph as you could make
k
Lose the tick. What are you trying to do, detect if one of the players has won a round (whatever that means)?
yes
What's the trigger to check? When should you check?
Delete all that too
Lose the multicast. Death and winning and damage should all be on the server
ok
What was wrong with the round wins check?
Everything
thats not helping lol
First off fix your damage setup
What is the win condition, one of the players goes to 0 hp?
yes
ok so after event any damage, just check if has authority, if true, then process the damage
If false, you can do a damage popup or whatever but leave that for later. Get it working right.
Damage -> has authority -> deal dmg to hp -> did you die? -> tell the GameState (call an event on it)
AnyDamage will only execute on the server anyway
lol i never noticed that
That's what the icon on the event means ๐คฃ
You can set it to, I think it's like BlueprintAuthority specifier in the UFUNCTION
Which player died?
do I need to get the player that died/the killer with the inputs?
Game state wants to know who died
fr fr
I thought that was a suggestion/guideline, not that it'd actually not run on clients
I don't know if the generated code that happens with the specifier actually limits it to be honest. So it might not work like that with your code without your own checks, but the built-in damage stuff is server only.
At least last I checked back in like 4.23 or something like that ๐
Cus its on server
ye got it
does that ruin the code?
or it does it twice or something?
It's just gross and unnecissary and I'm not sure you're still not doing a multicast
You can multicast the play sound etc
but it might be better to repnotify that
but that's just decoration, get the core of it working
show the ENTIRE THING in one screenshot
๐ค
Just to be clear, the multicast effects the server host right?
Or its because it was ran from a server initially?
multicast runs on everyone
got it
That looks fine, the death sound will play on host only but that's whatever
why?
ONLY the multicast will run on client
You probably want run on owning client for your sound events
so this way I did this it will only play the sfx for the host?
unless you want everyone to hear the damage sounds
the hit sound would run on all as it's multicast
the others will only run on host
ok good
and you're mixing playerstate and pawn together in the player died event but that's whatever
so what happens to a pawn when they die, is dead a state?
or do they just get deleted instantly
I haven't done that atm
k that's fine
how can I get the other player's round wins within their state to show up on a widget
i mean i guess it can be
Is this a binding?
yes
that'll work for the local player
the other player(s) will be in GameState.PlayerArray
but how can I get the specific player
which one?
wouldn't that also get the local players state round wins
its a lobby of 2 so the other one the player is against
Like this? or not ?
presumably I need to filter out the local player
I don't know how to do that tho
can we use GetLifetimeReplicatedProps in character class?
does anyone know how to filter the local player?
i want to teleport my pawn into spawn and it works correctly but in client side it teleports then it backs to last location what to do?
Do subsystems go weird with multiplayer in PIE? I have a GameInstanceSubsystem with a TMap that I'm adding to during BeginPlay. The entries in the TMap seem to be disappearing when I launch PIE with 2 or more players, but works just fine if I only have 1.
You should have two separate subsystems with two players. How are you testing that the tmap is disappearing?
Has anyone got this issue before and now a solution:
Old World Map_Lobby not cleaned up by GC! Object CameraActor /Map_Lobby:PersistentLevel.CameraActor_4 is being referenced by IpConnection /Engine/Transient.IpConnection_0:
So how can I get this part of the code to not show up on every player's hud?
As it's currently in a server event
hi
i need help about this:
i teleport my pawn into somewhere and it works correctly but in client side it teleports then it backs to last location what to do?
Are you applying the new position from a server function or client?
Moving pawns should be done on the server actor
from pawn
You should call the SetPosition in a server context
On the Server Pawn reference
Can we see your code?
You only need to execute the teleport ie the function that sets the position on the server
as location is already replicated
Ok ty
I have a server only game state component registering data on the TMap during Begin Play. When I later try to retrieve that data for the server the TMap is empty.
Same code works fine when PIE is single player, In multiplayer the TMap is empty when I hit the breakpoint near the server retrieval.
Don't do it on every player's computer
When you're doing multiplayer you have to ALWAYS keep in mind which computers the code is going to be running on in whatever specific thread of execution you're writing
That's odd. I've never experienced that and I love my game instance subsystems. You're 100% sure that nothing else is messing with them that the client joining could cause, and that your breakpoints are all in server code?
My subsystem is a loot table subsystem, and the TMap is loot tables that have been registered. I've wrapped all access to the subsystem with this call: static ULootTableSubsystem* GetSubsystem(UWorld* world);
I'm not seeing anything go through that call that would be clearing entries
Though I do see one oddity in the debugger when registering the tables
I have a watch entry of UnrealEditor-Engine!GPlayInEditorContextString and its value is L"Not in a play world"
Then when I attempt to retrieve the value of the TMap, I have the world L"Listen Server"
The extra odd part is this pattern is the same regardless of the number of players with PIE, yet the table is only found with 1 player in PIE
What Data is saved in that TMap?
TMap<FName, FRegisteredLootTable> LootTableMap;```
Also PIE might only be creating one of those for both players
Cause you play SingleProcess
In PIE (if not disabled)
Not sure though
I'm only expecting the server to have the data, but maybe Single Process is messing it up
I would test Standalone fwiw
But how can I do this code from the same line, do I create a normal custom event without the server/clients etc?
I'll see if I can get that working. I haven't been able to get clients to connect with PIE and unchecked single process. Maybe because my project is based out of Lyra?
Either an OnRep or a run on owning client event
All the code before this is running on the SERVER ONLY because it's being kicked off by Event Any Damage
So you're on the server, and only on the server, until you call some sort of RPC or set a replicated variable that is responded to elsewhere (RepNotify)
So you can't go from a server rpc to a non server one?
Don't think of it like that
you can call a multicast or run on owning client RPC from the server
This event chain is on the server
so just call it
Hello everyone. I've been using Unreal Engine for a while, but just recently I started playing with multiplayer. I'm trying to wrap my head around what lives where, how it gets replicated, etc. What I'm currently struggling with is the GameState. It is created by the GameMode which lives on the server. The documentation mentions that the GameState is replicated to the clients by the server, but the GameState is not marked as Replicated anywhere in the GameMode? What replicates the GameState?
You have to mark GS as replicated.
It's just saying that GS lives on the server & the client
As opposed to the GM which only lives on the server
The gamemode doesn't need to tell it to replicate, it already does by default per the constructor of AGameStateBase.
(I couldn't remember if it was replicated by default or not & I am not on UE to check)
I do not see the AGameStateBase constructor.
Silly me, I found it.
It looks like it's not present in the AGameStateBase header, but it's present in the .cpp file. I guess the Generated files contain the constructor declaration.
hi
any body knows how to replicate set material node
Thanks everyone.
If you wanted to have a persistent ID for a player that is triggering an event, what would you use? I initially thought it would be the Player Controller but I'm struggling to get that consistenly from an 'On Component Begin Overlap' Box Collision placed in the level.
how persistant?
I'm trying to have my UI show whose turn it is, so I create it in the first image, and in the second image I have a gamestate event dispatched that gets called on the UI to show whose turn it is, but for some reason Get Owning Player only ever gets the server's playerstate and I can't figure out why.
how can i send data from the client GameInstance to the server? no matter what i do it seems to always take the value from the server GameInstance
how would i go about that though?
basically i want to make it so clients can set their name in the main menu, and after joining a server i want it to send that name over
and since client and server have different game instances i tried to use that for storing the name
An easy way is to store it in GI, then when the client gets their PC, do a server RPC of the value.
PlayerState already has a player name variable that you could look into as well.
thats basically what i want to do
i just dont understand how to get the clients game instance instead of the server one
player
You're just getting the local GI and then setting it to some name.
If you're running this in single process mode - that may be giving you some screwy results.
im setting the player name to the variable i stored in the GI
And then you're just reapplying it
When this code runs, it will use w/e the name is in the local game instance.
Because the game instance only exists on each machine.
You have no access to another client's game instance.
And again - there is also a PlayerName variable inside of the PlayerState already.
There may be some function inside PlayerState to be able to set it with a custom value.
yeah but i want to get this to work first
You have to send the server the name through a Server RPC.
The Server would then tell all connected clients to update the name on their sides with either an onrep variable or a multicast.
like this?
No
Because all that's going to do is get the GI on the server and then send that value to the MC update name
The SV_Update Name event is running on the server, not on the client that has the name that you selected.
im just guessing lol
Read Cedricks network compendium
Once you start thinking about what machine the code is executing on, it becomes a lot easier.
i understand what machine the code runs on, i just dont understand how i can retrieve the clients value in an event while still being able to send it to the server
because if i do this i dont think it will launch the event on server
You have to pass that value from the client to the server
The only way to do that is through a server rpc
but where would i call that rpc from?
For the 3rd time
If you want to keep it in the character, there may be an event that gets called on the client side for them as well.
if I'm using AddReplicatedSubObject, and I want to change which owner is replicating the UObject, can I first use AddReplicatedSubObject from the new owner, and then RemoveReplicatedSubObject from the old one, or it doesn't matter which one I use first?
Should I spawn particle emitters only on the server (since its being spawned) or should it be spawned via multicast since its visual only?
Does each player have a game state, or is it server side only?
Multicast
Game state is server only, however, each player has their own player state
Perfect. Thanks
Oh.
That explains the issue I'm running into. lol
AI behavior trees only run on the server right (or at least should)?
Hey I have an "owning client event" that sets visibility of a weapon when the player scopes (so you dont see the weapon mesh through the scope).
This works fine for the clients, but when the server does this, the visibility of the weapon gets set on all clients too. Why does this happen? The weapon component is not replicated
Is the weapon itself replicated? If it's visibility is being set to false by the server, and it replicates, then it'll set for all clients.
Where would you recommend I run the update system for Multiplayer? (When the client enters the server, the upload variables system of the previously made actions in the game.)
for example game instance, gamemode etc
The weapon is a child actor class attached to the player pawn. The component is not tagged as "replicate" but the child blueprint class of the gun is replicated of course. How would I handle this then? I want all other clients to see the server's weapon regardless of if the server "client" has it visible or not
Can you not just use "owner no see"?
You can also make it a custom event and have it run only on owning client.
That should also do it.
Yeah thats what I'm doing now that not working
Oh interesting.
I can try the "owner no see" nodes
The fact that the weapons are replicated are the issue. It's running on the server, which is the owning client, but then the server is triggering an event on a replicated actor, which triggers it for everyone.
hmmm
Hmm. Honestly not sure.
I'm definitely not an expert though. It's probably pretty simple.
Maybe the owning client event needs to be on the weapon.
Its probably not an ellegant solution, but I could maybe multicast and set the visibility to true on the other clients again
So you have a ToggleVisibility event running on owning client on the weapon, then the server could trigger it instead of directly setting the visibility?
Maybe that would work. I'll do some testing. Thanks!
This would definitely not be ideal every time someone ADS in the game, but it would work. /shrug
Hehe true
Any one used playfab?
Moving it to the weapon worked! Thanks again
I feel like my networking knowledge just leveled up. Lol thanks for XP
I encountered a very strange problem. Can anyone help?
I listen in the Tick method of custom UtickableWorldSubsystem class
If it is currently a server, and there is a new Player Controller joining it, then spawn an Actor on the server, and set the OWNER of this Actor as this Player Controller.
On the client, I can see the replicated Actor, but when I want to call the server RPC, whenI check connection by using the Actor-> Getowner (), sometimes it is Nullptr, it will cause I can't call server RPC. Not happened every time, but there are quite equivalent the probability.
Does anyone have any idea? Many thanks!
maybe you are trying to set owner before the actor finished spawning ๐คทโโ๏ธ
If you want server lists and lobbies, do you implement those with Steam/EOS/etc.. or code some of that yourself?
A Server list is just a collection of sessions of your game that is aggregated by some service.
Steam is a platform that agregates sessions.
EOS is also a platform that agregates sessions.
These platforms can be queried for sessions.
You would need to perform that query and build the Server list within your game.
I'm trying to have my UI show whose turn it is, so I create it in the first image, and in the second image I have a gamestate event dispatched that gets called on the UI to show whose turn it is, but for some reason Get Owning Player only ever gets the server's playerstate and I can't figure out why.
I think the problem is how did you call "On Turn Changed"
Thanks, trying to determine what I need to do vs what those platform provide.
rq how do I replicate rotation?
I think I might know how but while I do that I'll see what you guys can tell me
disregard
figured it out
This is in the game state:
the player in turn macro:
and then onrep:
Probably you cant replicate the event to server becasue it is a gamestate class. Client doesn't owning it on network.
Don't use "Getters" by index.
You can't reliably do so in multiplayer.
The playerstate is key.
You can use an index, but you use that index to access the Player Array (which is the array of playerstates)
If you want to have players in different order, then you create and maintain your own array of playerstates.
The owner of playerstate is the controller, so you don't need to maintain anything for that other than getting the playerstate who's turn it is, Get Owner of that PlayerState, cast that to your player controller class.
how does fortnite handle their day and night system?
how are they sync between players
does epic have a special system that handle their day and night system
What's the special d&n system in Fortnite? I haven't played it much, sorry.
It's probably just a replicated variable that happens periodically and otherwise the clients keep the time updated locally
I've noticed that after I replicate TArray of UObject's in 5.2, UObject is added to the array on the client side a little later than array element is created, and so, functions are being run with invalid, null object for this particular index. Is there a way to do something with it?
Would e.g. using FastArrayReplication fix it? Or Is there a way for ReplicatedUsing to tell me what changes were made?
like this?
That's better yea
I'm getting confused right now, added a print statement of a reference to self in the player controller on begin play
and on the client, the print statement says it's controller 0, not controller 1
Player controllers are only replicated to owning clients. So when a client checks what their player controller is, it's always 0.
that would explain why get owning player in my widget is always getting the local controller
but when I get the playerstate, it should get the actual playerstate, right?
It's not great to use the index getters at all.
In a widget, you can get the owning player of the widget (which would be the local client's playercontroller) and then get the playerstate.
like this
but for some reason when I do this, the get owning player -> player state always says player state 0
so then the UI never changes to reflect that it's player 2's turn
Don't rely on index of those things...
When you're comparing objects, then it'll know whether it's the right one or not.
so this comparison should work
Yes
for some reason it's not
You're comparing what the local player is, comparing to the replicated version you're broadcasting from gamestate.
So if it's not the local player's playerstate, then it should say "Waiting for turn".
that's what it should do, yeah, but it's never saying Your Turn for the remote client
You probably have a different problem: You're calling Run On Server events in the gamestate.... That's not possible from clients.
so is it an issue with the event dispatcher?
Clients can only call Run On Server events on actors they own.
or the turn logic or something
should I not do the event dispatcher from the gamestate if I want the player's UI to change when their turn changes?
No, the dispatcher is fine. You cannot call those events from a client and expect them to work. You have to call the Run On Server event on one of their owned replicated actors, such as their controller or playerstate, once running on the server, you can call the functions you need to call on the gamestate that you want to have replicated effects.
So these, you can't call from a client if they exist on the gamestate. It will fail as the client doesn't own the gamestate.
yeah that is never called on the client, it's only on the gamestate
I believe it's called from the gamemode
and then the event dispatched is called on a repnotify from the gamestate
When is start game called?
I haven't looked at this in a while lol, I don't think this is the optimal way to do a countdown at the beginning
but it functions
and here's where the countdown is called
Ok, so the first player (likely the host) turn has ended. How do you signal that they've finished their turn to move on to the next player's turn?
The player clicks to flip a tile, which calls a multi cast on the gamestate to flip the tile for everyone
endturn is called after that
Clients cannot call multicasts.
And they cannot call RPCs to gamestate at all
This is ok.
sorry thats what I meant
the client makes a request to the server
Don't do this though... This is kinda bad.
๐ฌ
The multicast does execute on the server, so it technically would call the run on server "End Player Turn".
I wouldn't put it there just for clarity of what you're doing.
gotcha
You'd be better off putting it the server call either before or after the multicast call.
And I'd probably do the cast check prior to the multicast as well, just so you're not multicasting if you don't really need to.
ie. You only care if the touched item is a BP_Tile.
So only multicast if it is a BP_Tile, and pass through the touched component.
makes sense
so back to the UI thing, I'm still not sure what broke the turn validation that updates the UI
weirdly enough it used to work and then randomly stopped working at some point as I was adding new features and I have no idea when
but on every player, when I run this from the widget
I get the same playerstate 0 every time
no matter the player
So at the beginning when the game has started, the first player is seeing "Your turn" and all other players are seeing "Waiting for turn" right?
Again, don't worry about the index, it's useless.
yes
right okay
but yes
and when the first player does his turn, it's the second player's turn
all the functionality works
it just doesnt get represented visually
Do you see that the first player sees "Waiting for turn" after the turn has ended?
yeah
But the second doesn't see "Your turn"
right
or any other additional players
but it's because the event dispatcher is passing the playerstate from the gamestate
and that playerstate does have the corresponding index
but the owning playerstate in the widget doesn't
so this never returns true for anyone other than playerstate 0
You are passing the object reference of who's turn it is through a replicated variable and that variable is being fed through the event dispatcher. That's what this part is doing.
Is the value coming off of the "OnTurnChanged" event in your widget changing?
Yeah
I have this print statement
and for "In turn" it shows Playerstate 0, then 1, then 2, etc.
for each turn
and then "Playerstate" only shows Playerstate 0
This one here you mean?
Yessir
Okay, so my check is not the way to do it
right
okay so then all I need to do is use a different check to validate whose turn it is
Checking if they are == should work as you are passing a reference to the object, and the == should check if they are equal.
Iโm not sure what could be causing it to not work
Not sure is generous, I have no clue lol
This works flawlessly on my end after pressinging page down at least once, but at least the text changes correctly.
(Ignore the other text displayed ๐ )
But isnโt this the same implementation I have o.o
wtffff
anyone know what this error is?
LogWindows: Error: Assertion failed: PawnOwner->GetLocalRole() == ROLE_Authority
looking to get help with this thread https://forums.unrealengine.com/t/client-ragdoll-state-mismatched-between-server-all-other-clients/1197615 another niche bug with unreal
Hello, I am working on a multiplayer game, we have ragdolling on command as well as a velocity threshold that triggers ragdoll on impact. We seem to have a major issue with the state of a player being mismatched even by the server and every other client, what happens is the client that gets โragdolledโ, they get back up, they see everything norm...
Sounds like you could be trying to do something on a client that is only meant to be done on the server.
Sounds a lot like your code is at fault. Without sharing the responsible code section, no one can really help you here.
oh im trying clientsideprediction and it fails whenever it starts listen server
also the clause was different, it was supposed to be role<role_authority
In Assertion is usually a check to make sure a given condition is really true.
Here it's that PawnOwner->GetLocalRole() has to be ROLE_Authority.
Right, then it should be pretty clear now or?
for now i just made sure that the client prediction data returns only when its run on clients and if its server it simply returns a null
is that a way to get through this or should i be doing something else
You can check how the CMC does it :P
i probably should
makes sense, would you like to walk through the code with me via debugging? looking to pay someone at this point
Guys, I can respawn Character, but I can't update what's already in the game.
For example, if there is someone at the Level, how will the newcomer get the updated information of those who are at the Level before?
Guys, can someone ask me a little question about a bug that I'm getting
I have a problem in multiplayer... I'm not sure if it is just me, but is it alright if someone could answer this for me? When using the join session node, it works in the editor just fine, but in the packaged project, it does not work, instead taking you back to the same main menu level eventually.
I thought it may just be a problem with the actual node itself but after trying it with the advanced sessions plugin, it was still happening
If you are using the advance session in shipping mode it will give you problems since it only works in development mode. To make it work in shipping mode you must make some configurations with steam
Usually be ensuring that the Data you want to keep synced is inside a replicated actor and the data is marked as replicated.
Also you have an RPC in your GameMode which is giga wrong :D
Respawn Player is started by PlayerController.
Where exactly is it wrong?
Re-read the RPC and Ownership section of the network compendium
You can't execute ServerRPCs on Actors that aren't owned by the Client the calls them.
And the GameMode is double wrong cause it only exists on the Server.
The RPC has to be in the PlayerController
Step 1 and Step2, the system works, are you sure for that
You are chaining RPCs
The PlayerController one is enough
There is no need to call a ServerRPC when you are already on the Server
And on top, the GameMode doesn't exist on Clients. RPCs are redundant in it
And yes I'm sure, I'm working with this engine for a few years now
RespawnPlayer does NOT need to be an RPC
And also shouldn't
The PlayerController array in your GameMode also doesn't need to be replicated
There is nothing it can replicate to
I got this system from Unreal Engine's official site tutorial.
That's why I was surprised.
So it's 100% the same. i didn't change anything
You are following that stupid Unreal Engine YouTube tutorial
yeah
Yeah it's garbage
I called them out years ago
I can link your the thread
They never cared to redo it or at least take it offline
Then the system is completely broken. But I built everything on it.
Hey everybody, most of you might know, that Iโm in love with Multiplayer things. Thatโs why I wrote my Network Compendium. Today, I gave someone on the Discord Server some help, while he was fighting with the โBlueprint Multiplayerโ tutorial on the Unreal Engine Youtube Channel. He posted me some screenshots and I was kinda confused by what I...
For your own sake, read my Compendium that is pinned
And avoid that tutorial
oh, I built everything on bullsh*t. It's really sad and a waste of my time.
Btw Why does this whole system work, what kind of trouble do you think I will have in the future?
Oh, now I remember. "cedric-neukirchen" is your website. I learned a lot from you, really thank you.
You even replied when I opened a thread on the forum years ago. I remember it all now hahaha
By the way, which path should I follow for the basic logic of the Update system? When someone enters the game, it really confuses me that I pass on the knowledge of what happened before in the game.
After almost 7 years, I have no clue anymore what is all wrong with that tutorial.
I would suggest just not basing your stuff on it.
What you are talking about is State. **State ** should almost always be replicated via Replicated Variables.
If something has to react to the State Change, especially when joining late, they should be OnRep function.
That State is usually placed in e.g. the Character (what Mesh, Color, etc.), GameState (what Team is leading), PlayerState (how many Kills, Deaths, Assists, PlayerName, etc.).
If they are replicated, they will be up to date when your new Player joins.
There are sadly also a lot of OnRep Functions for already existing stuff in the Engine. E.g. OnRep_PlayerState in the Pawn/Character class.
And those aren't available to you in BPs. You can either make your own setup if you need that, or learn C++ (which is kinda requirement if you want to really do multiplayer games).
Thank you so much. My last questions, Is OnRep Functions are RepNotify mechanism and OnRep functions work automatically when someone enters the game?
When someone joins the game, is it necessary to run a function called EveryoneUpdate (RunOnServer) and reflect what the user has, or do I need to save all Player data to PlayerState and automatically reflect it?
You don't need to run an event "EveryoneUpdate"
OnRep functions call for connecting players when they receive the new data of that variable
You should store the State Data in the Actor that it belongs to
So where do I run this RepNotify so what will be the trigger?
Like, Event OnPostLogin > AllPlayerControllers (Array) > Loop > update everyone with Repnotify
No
OnRep calls automaticlaly when the Data of that Variable replicates to the Client
That includes poeple that join
OnRep is also only needed if you need to call a function based on that data
If it's just plain "This is how many kills the player has", then it's enough to just mark it replicated
There is no need for you to call an event to send updated data
Ok, now I understand better.
I'm taking your time, I'm so sorry, can you briefly summarize this?
What I wanted was to select a character by pressing the button in the Lobby, save it. When I enter the game, it spawns whatever skeletal mesh is. (Set Skeletal Mesh)
In other words, by pressing the button RunOnServer > Multicast, Set Skeletal Mesh works.
But when someone else enters the game, it sees its default mesh, because it does not update.
Which way do you think I should follow for such a system?
That is basically what I just said: State has to be done with OnRep
You are experiencing a bug from not following that.
Your State here is "SkeletalMesh"
In other words, "State" is everything that changes and then remains like this for everyone until changed again.
Such as "what skeletal mehs someone has"
Multicast, Set Skeletal Mesh works.
By using a Multicast, you only fire that event ONCE.
And only to the players in relevancy range and connected
Let's ignore the need for RunOnServer etc., if you want to fix this you have to remove the Multicast and create a variable, e.g. "CurrentMesh" of type SkeletalMesh.
You set that to RepNotify
And in the OnRep function (gets auto generated) you call SetSkeletalMesh
And then instead of the Multicast, you just set the CurrentMesh variable (after the ServerRPC)
That should already fix your issue.
Don't use Multicasts for things that require to be uptodate for people who join late or are far enough away (literally distance based) that things aren't relevant for them.
The summary of this work I should read more and watch and learn. Despite all this effort, it is really stupid not to know about them and to use Multicast instead of RepNotify. Thank you so much!
It's not stupid. This is really difficult for beginners.
And it doesn't help that Epic has that video up.
All it takes to learn multiplayer is to sit down and read the Compendium + literally just trying around in the Editor.
There will be a gazillion more issues in your future game dev life regarding multiplayer
This here is just the very very very beginning :D
Thank you for this pep talk ๐
Im not using the steam assets though
I'm only using the advanced sessions, not the advanced steam sessions and the thing is, it didn't work even before adding in this plugin
LogScript: Script Msg: Found a session. Ping is 55
LogOnlineSession: OSS: Join session: traveling to {ip address}:7777
LogNet: Browse: {ip address}/Game/Main/MainMenu/L_MainMenu
LogInit: WinSock: Socket queue. Rx: 32768 (config 32768) Tx: 32768 (config 32768)
LogNet: Created socket for bind address: 0.0.0.0:0
LogNet: IpConnection_2 setting maximum channels to: 32767
PacketHandlerLog: Loaded PacketHandler component: Engine.EngineHandlerComponentFactory (StatelessConnectHandlerComponent)
LogHandshake: Stateless Handshake: NetDriverDefinition 'GameNetDriver' CachedClientID: 5
LogNet: Game client on port 7777, rate 100000
LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 0.02, Realtime: 14.04. IpNetDriver_7
LogNet: Initial Connect Diagnostics: Sent '10' packets in last '10.014697' seconds, no packets received yet.
thats the logs for it
but i still don't understand
Can it be that the player literally times out?
It gave me problems when I used the advance session when I was creating a prototype in shipping mode. It only connected when I used it in development mode
since then I use connections with aws
aws?
amazon web services im guessing
thing is I only want the game to have LAN capabilities
it works in the editor
but from two pcs it doesnt work
with aws you can also create a lan connection
A good option would also be to use the EOS system
Question guys how would i best do AI for multiplayer Npcs, like have a parent class with the logic replications and whatnot or should i keep em seperate for each npc ?
It depends on what type of npc, if for example they are village-type npc with a very similar pattern, I recommend that you make a state factory
If, on the contrary, it contains a more complex behavior, it uses the state tree system.
hm state factory state tree
i mean
this is how im doing it now and im guessing there is a better way or more functionall way
whats the proper way to move player characters on the server, and i mean server only?
What do you mean moving the characters to the npc?
just move player characters based on their inputs but only from server
for some reason there is a line in movement component (or somewhere close to that, i dont remember exactly) that applies InputVelocity only if local machine is owner of that pawn
keep in mind that the default movement of the players is replicated therefore the other players will see that the character moves
something like that iirc
so basically if i change InputVelocity on the server it doesn't actually move character
yes but server just doesn't want to move character, i understand that it will be replicated if character is moving
what you want is for the character to only move on the server. If a customer presses an input?
yes, move on the server, and client only get replicated movements
what you can do is perform the function of moving in a multicast and within the multicast you have to say that if it is the server that is moving and if it is other players that it should ignore it with that you already have it
i already have GAS ability that perform movement, and its server only, but it just doesn't work
you can do it with node is server
I have something similar to what you say but I apply it to animations
it is executed on the server, but movement component doesn't move character based on inputs if character is a proxy as i understand
to optimize the performance of connections
keep in mind that each character has an autonomous proxy
as i understand on the server all characters are SimulatedProxy and i need to somehow make them AutonomousProxy?
In Unreal Engine 4 (UE4), "Autonomous Proxies" refers to objects or characters controlled by the player in a multiplayer environment. In a multiplayer game, each player has an autonomous proxy that represents their character in the game world.
The term "autonomous" refers to the ability of each proxy to independently make decisions and take actions on their own client. Each client has its own autonomous proxy that makes local decisions based on player input and server updates.
In a multiplayer environment, the authority is on the server, which means that final decisions about game state and actions are made by the server and then replicated to the clients. However, autonomous proxies on clients have some autonomy to perform local predictions and actions before receiving acknowledgment from the server.
For example, when a player presses a button to make their character jump, their standalone proxy on their client immediately performs the jump action before confirmation from the server arrives and is replicated to the other clients. This provides a more responsive gaming experience and avoids the feeling of lag due to network latency.
It is important to note that while standalone proxies perform local actions, the server has final authority and can override or correct actions taken by standalone proxies if they differ from the server's decisions.
In short, "Autonomous Proxies" in UE4 refers to characters or objects controlled by players in a multiplayer environment, who have the ability to make decisions and perform local actions before receiving confirmation from the server. This allows for a more responsive gaming experience and reduces the feeling of lag due to network latency.
I hope my clarification helps you understand it better.
@grave notch Well the CMC is build around the idea of locally predicted movement.
If the Character is client owned and you want to move it from server side then you can only really set Velocity directly
Or location fwiw
But the Input stuff remains locally
thats kinda weird, what if i change that part of the code where it checks if it should perform movement based on InputVelocity (it checks local owner, but instead i can just check authority?), would it work in theory or it would break everything?
Guys, I have 2 Door_BPs in my scene.
When one opens the door, the other client can see that the door is opened. And each door works independently and flawlessly.
But if I open the door when there is no client in the game and the client has come, the door appears to be closed.
I solved this problem with RepNotify method. But I have another problem.
Only the last door I opened opens. (Because that actor is the last to be set.)
If I create multiple separate Door_BPs the problem is solved but it's a tedious process because there are many doors on the scene.
btw I press f key and send a line trace, I'm using interact. I get the angle of the door in Door_BP. and there are RunOnServer > Multicast > RepNotify
Well the solution is correct, you should use RepNotify functions to replicate a state for a late joiner or a player that becomes relevant again for replication. But it feels like you should change your design a bit. You should have your boolean that represnts if the door is open or not in the door itself, so each door instance can store its own state, instead of storing only the last door that you interacted with on somewhere else
static FAutoConsoleVariableRef CVarWithArrayOnRepFix(TEXT("net.WithArrayOnRepFix"), GbWithArrayOnRepFix, TEXT("If true, attempt to prevent issues with Arrays not receiving OnRep calls until their size changes if their Archetypes have different values from instances in levels."));```
this seems to fix arrays not replicating
While doing server travel or using OpenLevel we use an url. We add the parameter listen to it to signify that it's on listen server. Let's say I open lobby level and now I am going to gameplay level, do I need to add "listen" to the url again?
I was reading this article https://gafferongames.com/post/udp_vs_tcp/ so that I could try to understand the use cases for UDP and TCP in multiplayer games. It was published in 2008. Is this a good reference, or did their use case change over time?
So I just try some experiment with Replication Graph today, looks like the graph calculates its grid distance base on player's camera location, not character or controller's location
Is there any way I can change the default 2D grid so they use a location offset to the camera position instead of the camera's location, in a RTS game?
Actually, that's what I did. I am getting this Boolean from inside Door_BP.
There is Actor variable here, if I do not RepNotify, the system does not work, but if I do, only the last actor opens the door because it is the last Actor set.
I guess I didn't quite understand what you were saying. Could you give some more details please?
Because in RTS camera is far away from the battle field, and I need to check if the actor is far enough from the point that camera is looking at, not the camera itself
Where is this multicast event OpenTheDoorW_Multicast created in?
I have a question. Basically I figured out why the multiplayer wasn't working, it was because the ports weren't allowed in the firewall. So my question is, would UPnP work? and if yes, how do I use it in unreal engine
because the thing is, I want it setting up automatically rather than me having to go there and doing it for each device its on
In Character_BP
I press F key, then send a line trace (if == tag is true), I run the Interact, this interact opens the door in Door_BP by making call and bind events. (As seen in the photo below) Then I am running RPCs + Multicast thanks to Bind Event Open The Door
Well if that's the character, it means you're not storing doors' open state in door class, you're storing it in your character and you're storing only the last interacted door's state
You should create your replicated boolean in the door blueprint, when you interact with the door, you should change the boolean inside of that door object
And on the RepNotify function of the boolean, you should change that door's rotation in there, so when a new player joins, they can get the replicated value of the boolean and change the state of the door accordingly
Also your open door function is multicast, if you're going to set your replicated variables in it, it can just be server RPC, when you set your boolean on server, RepNotify function will run on everyone, like multicast, so you don't need that function to be multicast
Thank you so much! It worked.
this GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const needs a method to be declared in .h file or not?
hey guys when im using server travel for all clients im using a transition level between load
but how do i put a loadingscreen instead or something like that ?=
In this UE5 Tutorial we will design two Levels from scratch and a Level Transition with Loading Screen between.
๐ TIP a Custom Amount:
https://www.paypal.com/donate/?hosted_button_id=JN9EL84MVX5ZE
๐ Download FREE PS1 Style Assets and more:
https://www.starkcrafts.com
๐Wanna support and exclusive Content?
https://www.patreon.com/starkcrafts
...
This engineer-oriented talk about assets loading management for good performance and smooth transitions by Epic Games' Support Engineer Axel Riffard goes over different methods to craft beautiful and highly optimized loading pipelines for your game, be it single or multi player.
Learn more about Unreal Engine at http://www.unrealengine.com
ty
Get your character from one level to the next with a box collision.
This video is the basic and quick way to transition.
In this video we use a box collision to trigger the next level.
Keep in mind if you have a lot to load it can look weird while loading so you can also add a loading screen.
Here's how with a quick additional step.
A bette...
๐ฎMaking a game? Check our store: https://www.unfgames.com/
๐ฅBecome a Member here: https://tinyurl.com/joinunfgames
๐Best resources to learn Game Dev*: https://tinyurl.com/resourcesunf
Questions? Let us know in the comments!
๐Learning...
holy moly
Store: UE4 Marketplace Link | Itch.io **Doc: Documentation & FAQ ** **Download: Executable Demo **(Google Drive) The whole example project is available as an executable demo. Videos: Playlist Latest Update: May 29, 2018 - Version 1.04 This update adds a Pawn Handling feature that provides full control over Spawn Location and Pawn Type in St...
I'm pretending to be google.
ok i can take the hint
๐
yeah i acctualy googled it a few days ago but with no luck tbh i dont remeber why now since it seems super easy
To be fair, I did include the words "transition level" in my search
lawlz
That makes more sense, I rmbr not finding much with just loading screen lol
Man he looks so happy to be doing that video.
He is sad because heโs having to learn Assembly at the time lol
xD
Wrong reply but eh
ok so if im understanding it correctly a loadingscreen is basicly a seperate widget that u apply before transition and disable when entering yes ?
question, how would i apply it to all "remote" players "all players"
I think it's one you apply in the transition level itself, but I may be wrong.
So I know about adding a widget for a load screen then travelling to the transition level and finally to the next level but it defaults to a camera at 0,0,0 before anything is loaded. What's the trick to keep the loading widget on the screen before showing the level environment?
Currently I have an object at 0,0,0 with a world space widget inside it showing the same loading screen. I then carefully hide the 0,0,0 object with other assets used on the level so it isn't seen during regular gameplay. Is this the best practice to hide the ugly asset popping and texture loading stuff?
It seems that even when I used a world space widget at 0,0,0 to mimic a loading screen it doesn't load in fast enough. The best way might be to just have a plane or cube with a material that looks like a loading screen instead.
If you test with the "bad" network conditions the loading delay is much more obvious.
Best solution seems to be a 0,0,0 cube with a two sided material that has some sort of loading animating material on it that is consistent with whatever loading widget material you show the player when they complete a level or whatever and need to transition to the next one.
<@&213101288538374145>
hye guys, im having an issue that only happens in the server, if im playing as a client it works fine, so heres the issue: when i shoot at a character my projectile sets a timer for that character, in the client that timer runs normaly from 0.3 to 0, but in the server its always at 0 even after it was just changed.
im thinking that the variable is probably not being updated in the server but the collision that trigger the variable change happens in the server so it should change the value in the server right?
Show code
Hello, why does a Replicated Actor Component doesn't accept inputs? I added the component on server side to the player's pawn
Gamemode get all players - for each -> Execute AddMyComponent for player's pawn
inside my player pawn the AddMyComponent event is set as Execute on Server, the component is marked as Component Replicates
Are you sure you actually have players when that executes?
Does the component get added? Does it replicatE?
Have you tested any of that?
Also marking "AddMyComponent" as executes on server won't do anything if it's already being run by the server (because the game mode doesn't replicate at all ever, so that loop can only run on the server)
in a sec, was having dinner
in the character base class
{
phisicalAnimationTimer = 0.3f;
direction.Normalize();
phisicalAnimationDirection = direction * 15000;
}```
in the proejctile class:
if (character)
{
AProjectArenaPlayerState* state = Cast<AProjectArenaPlayerState>(character->GetPlayerState());
if (state)
{
//client stuff
if (state->team != team)
{
FVector direction = character->GetActorLocation() - BulletOwner->GetActorLocation();
character->ActivatePhisicalAnimation(direction);
}
}
} ```
again in the character tick:
if(GetLocalRole() != ROLE_AutonomousProxy && isDead == false) // we dont do this in our own machine to not get aim punch, only on other chharacters
{
if (phisicalAnimationTimer > 0)
{
phisicalAnimationTimer -= DeltaTime * 1.0f;
MeshThirdPerson->SetAllBodiesBelowSimulatePhysics(FName("spine_03"), true);
MeshThirdPerson->SetAllBodiesBelowPhysicsBlendWeight(FName("spine_03"), phisicalAnimationTimer, false, true);
MeshThirdPerson->AddForceToAllBodiesBelow(phisicalAnimationDirection,FName("spine_03"),false,true);
}
else
{
MeshThirdPerson->SetAllBodiesBelowSimulatePhysics(FName("spine_03"), false);
}
}```
i can confirm with break points that the if is being hit, the issue is that the timer is 0
basicly the idea is that the the hit makes the timer go to 0.3f and then it does a physical animation in that small window
yes, I did a Get Component By Class on client-side and is there, I also checked in the editor and is spawned on both Server and Client 0 world for the player pawn
It's probably an input issue then. ๐ฆ
cause this works just fine

help
So where, in your code, does the server change that variable?
Is it activated by user input? I.e. a mouse button?
i am assuming since that even happens in the server that the server would know
event'''
This event?
i mean, its working on the client, it just doesnt work on the server, so is the server reseting the value?
ye, its suposed to be happening on a raycast or on an onOverlap
and for example, the on overlap happens on the server correct?
And have you checked to see if the overlap is actually working on teh server?
i have
everything happens on both the server and client. The server just updates the client every so often.
The client does not update the server.
How?
becase the other stuff gets triggered
and i actualy see the value change
it just gets reset to 0 on the tick
im just a bit confused with the architecture i guess
ok so my first assumption is that the server is changing the value back to 0
Which triggers this? Have you checked to make sure this is executed on the server? (By checking netmode)
because i didnt call that change with an RPC
an authority check if enough?
should i call is server?
GetWorld()->GetNetMode() != NM_Client is a good check
i can check it real quick
k i will use that
will be back in 2 mins
jsut gonna test the thing
if (GetWorld()->GetNetMode() != NM_Client) { UE_LOG(LogTemp, Log, TEXT("It's run on the server!")); } directly after if (character) {
ok with that check its not running on the servers
so i am assuming the value change was only on the client
now im even more confused lol
i was under the impression that those kind of events would happen in the server
Overlap events will happen on the server, but only if your client is actually telling the server where it's going.
so i guess i have to RPC it
You should use ACharacter. It's automatic for that, I believe.
Has lag compensation etc.
thats the character movement class no?
Yes
im aware of that
If you need any kind of human-model-based networked movement, use the CMC
yes character movement component
so i got it to work on the server with the rpc
now it doesnt work on the client, is there an rpc that runs both on the client and the server?
is multicast a proper option here?
No
Multicast is for the server talking to every client
What did you change?
Show me the new code.
i just made that function an RPC
nothing more
and it worked on the server
and didnt work on the client
basicaly it got inverted
which makes sense
i figured that out, but isnt there a more elegant way to do that?
No
aww come on, there has to be
i cant stand ugly code T.T
im gonna need to have 2 identical functions?
thats just awfull
Oh wait
It's pretty common to have identical-like functions in networking
stop it, i can only take so much
why isnt there an RPC that executes on the client and then on the server?
it makes sense to have something like that right? im not crazy...
Only execute #1 if you're a remote client.
Because most stuff doesn't work like this. The actual "move_actual" part might be different on the serevr and client.
For movement it's going to be very similar, but for shooting? Might be totally different.
writing 2 functions for the exact same thing feels like an abomination
i dunno man, if the only solution i guess im gonna have to take it
It's not really for the same thing.
They are wrapper functions.
The body of the stuff, in this case, goes into a single function.
{
phisicalAnimationTimer = 0.3f;
direction.Normalize();
phisicalAnimationDirection = direction * 15000;
ServerActivatePhisicalAnimation(direction);//we need to call a server version so that this effect also occurs in custom games for the player that is the server
}
void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
phisicalAnimationTimer = 0.3f;
direction.Normalize();
phisicalAnimationDirection = direction * 15000;
}
ended up doing it like this
it works
ive never been so unhappy after fixing a bug
That's replication of the function, though. Don't do that!!
????
As in, you've copied the actual code to a second place.
so whats the best solution then?
You don't need 2 copies of the code.
Add another function which both of those call
void Move(...)
{
if (Client) { ServerMove(...); }
MoveImpl(...);
}
void ServerMove(...)
{
MoveImpl(...);
}
void MoveImpl(...)
{
// do move here
}```
function()
{
ActivatePhisicalAnimation();
ServerActivatePhisicalAnimation();
}
like this?
wait
im failign to see how that is not the same thing
You have the code to do the move in 2 places. YOu have exactly the same code in 2 places.
That is a potential bug waiting to happen
ye and i was trying to avoid that
That's why you wrap that one bit of code in another function (BlahImpl) and then call that from each place, instead of copying the code.
ok i get what ur saying now
What you have is: ```cpp
void Move(...)
{
if (Client) { ServerMove(...); }
// do move here
}
void ServerMove(...)
{
// do move here
}```
Or so
let me think about this
cause im calling those functions in the projectiles and those are spawned in the server
void AProjectArenaCharacter::ActivatePhisicalAnimation(FVector direction)
{
DoThePhysicalAnimation(direction);
ServerActivatePhisicalAnimation(direction);//we need to call a server version so that this effect also occurs in custom games for the player that is the server
}
void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
DoThePhysicalAnimation(direction);
}
void AProjectArenaCharacter::DoThePhysicalAnimation(FVector direction)
{
phisicalAnimationTimer = 0.3f;
direction.Normalize();
phisicalAnimationDirection = direction * 15000;
}
This is what Daekesh is saying.
ye, thats what i figured, it was just taking a bit longer than it should because ive never seen that pattern and im a bit sleepy
btw - your physical word is spelled incorrectly ๐
hahah happens
when english is not ur first language u sometimes make mistakes
heck i make mistakes even in my own language hahaha
Not quite, because you'd need to check if you're a client before calling the Server... method.
But mostly yes.
You know he'll be back in an hour asking why it happens twice on the server ๐
We'll cross that bridge when we get there!
now ur just beating me down ๐ญ
Hehe
void AProjectArenaCharacter::ClientPhisicalAnimation(FVector direction)
{
if (GetWorld()->GetNetMode() != NM_Client)
{
ServerActivatePhisicalAnimation(direction);
}
ClientPhisicalAnimation(direction);
}
void AProjectArenaCharacter::ClientPhisicalAnimation(FVector direction)
{
phisicalAnimationTimer = 0.3f;
direction.Normalize();
phisicalAnimationDirection = direction * 15000;
ServerActivatePhisicalAnimation(direction);//we need to call a server version so that this effect also occurs in custom games for the player that is the server
}
void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
ActivatePhisicalAnimation(direction);
}
does this look alright?
== NM_Client
Because you want to check if you're on the client ๐
But no
Where is ActivatePhysicalAnimation ?
1 moment
Also Client prefix typically means it is a client RPC. Not sure if that is the intended purpose though. Just a heads up.
imma call it local than xD
void AProjectArenaCharacter::PhisicalAnimation(FVector direction)
{
if (GetWorld()->GetNetMode() == NM_Client)
{
ServerActivatePhisicalAnimation(direction);
}
ActivatePhisicalAnimation(direction);
}
void AProjectArenaCharacter::ServerActivatePhisicalAnimation_Implementation(FVector direction)
{
ActivatePhisicalAnimation(direction);
}
void AProjectArenaCharacter::ActivatePhisicalAnimation(FVector direction)
{
phisicalAnimationTimer = 0.3f;
direction.Normalize();
phisicalAnimationDirection = direction * 15000;
}```
the thing is, i need to call the server rpc when im a client running as server
thats where the error was ocurring
So also check if you're a listen server.
running in the client everything was fine
i know thats how it works in theory, but in practice thats not what was happening
The "Server" method isn't "only run when you're on a server" it's "SEND this to the Server"
or maybe im missing something
i know this
So the code I sent there will work ^
so why was the error ocurring when i was the server?
the physical animation timer value not being set
this?
What you had before was wrong.
Because you werne't telling the server that you were moving.
cause i changed the names
ur code does indeed work
im still confused tho
GetWorld()->GetNetMode() == NM_Client, this is suposed to run when im on the server
And it would?
That little snippet is saying, "Only send this server RPC if I'm a client"
exactly
If you're the server already, you don't need to do a server rpc
so only the local version runs
No?