#multiplayer
1 messages · Page 186 of 1
same problem as before
?
try using a lerp on the select
not according to this
btw are you trying to make the door open on both direction
this is also wrong, for the closed thing
like where the character is facing?
as well as what I got rn
ah I see
[This tutorial is filmed in Unreal Engine 5, but will work for later versions of Unreal Engine 4]
In this tutorial we will be making the door we created in a previous video open away from the player. We will be using a dot product to power this. We also make sure the door closes correctly instead of jumping around.
Fixed models (sorry about th...
this might help
saving this for future use XD
yea yt helps alot
it certainly does
but not with multiplayer as much
ive noticed XD
ive been having trouble with ragdoll and literally ive seen nobody make a video about ragdoll and multiplayer but one person
and they used the most basic ragdoll like set physics and thats it
oh man hats off to you
youtube isn't really good but sure
I avoid that or try too XD
it is for some topics
and mileage varies by who your watching
yea with basic stuff its really helpful even with ai
def have to be...selective
and tbh for something like opening a door
thats fine...you might have to tweak it for multiplayer
but hey you can get a working concept to test off
for doors just use rpc and it should work but for latency you might wanna try other stuff
you can select on enum
drag off enum and hit select
then feed the output into the multiply
yea I know, but there was the same issue as before
Show your current code
Do RPCs replicate parameters?
What do you mean?
An RPC is a message being passed across the network to a particular connection.
The Params passed with that message will be received by that connection.
When the message arrives.
I'm using Wait Gameplay Event to call a client RPC because I want the payload client side, but it's empty.
Did you verify the Gameplay Event contained data at all?
Nevermind. I made a mistake by setting a breakpoint on the RPC instead of 1 node deeper. The data is there. Thanks!
anyone would like to check this issue out?
ALS community got ragdoll working in multiplayer afaik
How are collisions handled as far as authority? I have an object placement feature that should feel responsive in terms of placing an object. If it is blocked, they cannot do it. But imagine the case of someone placing a cabin with sheep wandering around. They are in the clear on the client, when it is placed on the server, a sheep has since wandered into the area. Is the client running collisions on the server and will they know that it then isn't possible?
they got a discord server?
Prob but you can just download the repo and look how it's done
u mean the als v4 assest? problem is its for 5.0 i got 5.4
if its the als v4 then ill download it and look how its done
Typically you will want the Server to verify the placement first before actually performing it.
If this is multiplayer. Then you will want the Server to do the placement anyway
You dont want the Client to have authority over placement.
If you want responsiveness, you might want the Client to predict valid placement and then get corrected by the Server if the Server rejected it (because of situations like your scenario with the sheep).
community version, goes up to 5.3
The Server would tell the Client it failed and to roll back the prediction (remove whatever the Client placed in anticipation of it being successful).
ok ill try it out
Synchronize physics in project settings. Physics is not synchronized by default and cannot be made deterministic easily
its already sychronized
i looked at the als but im not sure where they implemented the ragdoll i just seen ragdoll start in the c++ files and some in the anim blueprint i dont know how they made it work on multiplayer exactly
ill try making an interface for ragdoll and add it to the character and see if it works that way
Guys what do you think about making a Dead by Daylight game as my first multiplayer game ?
What would be the difficulty of doing that type of game compared to other multiplier games?
Make it even smaller scope
it's already small for a game, how can I make it smaller than that ?
dead by daylight is by no means small
Take like a simple arcade game and make it multiplayer
I'm not sure to understand, how is that game not small ?
Because it isn't, it's a game made by many developers.
If you wanna learn multiplayer, focus on the multiplayer aspects and keep the scope extremely small, so you don't get overwhelmed by the other mechanics
The answer is still vague
Small games are games like Punch the Monkey, Tic Tac Toe, Pong, Asteroids, Tetris
Those games aren't fun
Then pick another game at that size, that is fun. Dead by daylight is a big scope
to me big games = Battle Royals, MMOs, Open World, etc...
Then you're extremely naive
?
Just because a game has a small loop, doesn't mean it's small. Fall guys loop is extremely small, but the game itself requires a lot of work
FAll guys there are so many players to handle compared to a Dead By Daylight game
there are different minigames, levels, etc...
scope != player count
I know but I guess it requires more work in terms of optimization compared to a game with less player
We're talking about just the amount of work you still need to do to achieve something like DBD, it'll shadow the multiplayer aspects that you actually want to learn
that's why you wanna keep the scope small, to just focus mainly on multiplayer
What about a simple prop hunt game ?
Prop hunt sound reachable
Prop hunt is reasonable, but it all depends on how you approach it. You could create a Dead by Daylight game, but dumb it down to the bare essentials of gameplay, cutting all the fluff like customization/unlocks/progression and graphics, only focusing on the absolute bare minimum to make the gameplay loop work.
It's probably more complex to program, but if the idea motivates you more then that could be a good reason to try. If you fail you still learn something.
Honestly. I would focus less on making a clone of a game and focus on learning how to design portable systems that can be dropped into any game. EG a replicated inventory system, a generic AI tree with reusable behaviors, learning GAS and making some generic attribute sets, cues and ability bases, etc etc etc. These small tasks are a lot more rewarding due to their reuse and the understanding they'll give you than focusing on a specific game type. Specially since you'll be able to simply drop a lot of this in multiple projects and throw together prototypes for a lot of different game types.
I'd recommend this approach, making building blocks will make it a lot easier to make a project
I know that sounds obvious when said like that, but a lot of beginners that I know/knew would make massive interconnected spagetti that was inefficient, hard to port to other projects and impossible to change without breaking something else
I actually disagree, making a clone of a game is probably one of the best ways to learn because you essentially absorb knowledge of why they did things, you run into difficult challenges that you otherwise might not and you have strict requirements which if you're not making a clone you don't have
for an inventory system for example it's much easier to immediately understand where the pitfalls are if you're just copying the minecraft one
whereas you can overlook a lot of things if you're building it kinda detatched / sandboxed
I agree with Snaps.
Although I can see the benefit of both approaches. Whatever gets you to make something, you'll learn from it either way.
i mean dbd was in dev in 2015 with only like 30 people, definitely way more than a solo dev obviously but still not a huge team over at bhvr
If you're trying to learn how to multiplayer though, it isn't the best option. Once you have a good foundation of knowledge and libraries, then it could be a attainable scope but not before
I'd stick with Prop Hunt, plenty of clones out there (even FNTASTIC made one)
Anyone know where I can find an in-depth guide on unreal engine multiplayer with blueprints?
the compedium is the most useful guide you can find.
And as the guide also state, blueprint multiplayer is limited.
I just don't think it's healthy to focus on copying the game. Copy their systems? Maybe. Go for it. But without the emphasis on SYSTEMS, they don't learn much except how to cobble shit together and make my life as a UI person terrible when I have to clean up their mess just to be able to make UI work.
Thanks, does it elaborate on the limitations?
the lack of features is your number one concern
for example, the character movement component
Ah, so there are no work arounds?
nope
Say a sprint system, if you want a responsive one, you will have to go cpp
you cannot do it in blueprint
Time to learn cpp ig
you can make card games or turn based game with blueprint
or yea learn cpp and unlock unreal features
going pure blueprint is just experiencing trial unreal
Is it more difficult to make games with cpp in unreal?
damn
learning is not my virtue, everyday is a struggle
but I think that goes to most people here
Guess I should start learning now so I can start working asap
it's not a must
I dont struggle lol
What would be easier?
you certainly do, and you been saying none sense all the time 😄
in terms of making the game
no ??
Why not?
is doing any kind of authority check in the GameMode class redundant? since it only exists in the server
yes
watch del goodie cmc and you will find out.
That doesn't explain why. It explains how CMC works, but you have access to that in BP.
Sure, you can't modify lower level netcode, but do you need to for sprinting?
This is not about Lower Level NetCode
The CMC has an internal prediction system, where any kind of predicted data has to go through the ServerMove function, and a lot of stuff needs to be added to custom SavedMoves so the Client can properly replay Moves they already did when receiving a correction.
That is all out of range for Blueprints.
@maiden flame
Oh, thanks for explaining.
Does GAS handle some of this for you with flags? Or is it still too incomplete in BP to properly replay moves for custom events like sprinting?
The main problem I had with sprinting seemed to be corrections during packet loss, rather than latency, when trying to use the CMC inside the editor alone.
Predicting sprint in BP works fine with latency when testing it now, but even for default movement the CMC breaks down when there is packet loss.
How to replicate Event? I'm calling from the server, and I would like clients to execute
GAS has its own PredictionSystem and thus is basically more or less incompatible with the CMC.
If you can't mark the BlueprintImplementableEvent also as an RPC (via Client or NetMulticast) then simply make it two functions.
The RPC and the Event and the RPC call the Event.
I see. Either way, I wouldn't say it's impossible to make sprinting in BP only. You can get prediction working with high and variable latencies, assuming there isn't any packet loss.
Does the method of adding custom SavedMoves, to properly replay Moves, help to solve disruptive corrections during packet loss? I don't know if you consider this part of properly replaying moves, or if packet loss is a separate concern.
PackageLoss is not really fixable. The replaying would only make sure the correction isn't that heavy. In BP only, sprinting will always cause a correction on start and end .
So I want after the begin play of the AHUD to increment a value from thhe game state for each player that basically get`s an AHUD, why when I try to print it, it gives me 1 for the client and 1 for server?
Basically, how can I get a refrence or to know when the HUD is done for each player?
the client can send a RPC to the server when the HUD is ready
tried that didn`t work
what exactly "didnt work"?
you mean from the hud, get owning player, and from there to increment it?
or what?
and what do you mean by the client can send a rpc, what doees the server do in this case?
where are you storing this value to be incremented on the server?
game state
Why do you want to do this? If you want to increment for each Player that has joined, you could use the PlayerArray on the Game State
hmm
I need basicaly to update each players minimap
but the map gets created first
and the hud after
and I don`t know how to manage these things, because the player spawns but the hud is created after
Assuming there's no packet loss, I don't see those corrections in my setup. I'd be happy to share.
I am just so annoyed by blanket statements about BPs, so I'm sorry for being salty xD
I mean, you are free to think that whatever you do fixes it.
This is not a blanket statement. I'm working with this shit engine for 10 years.
Well, no, I'm trying to understand better also.
Does your Sprint setup involve changing the MaxWalkSpeed on the CMC and use an RPC to tell the Server to update it and then replicate it back with some OnRep variable?
Try spamming the sprint key a bit
I did, and even changed directions suddenly to throw it off
And use p.NetShowCorrections 1
Still works solidly at 0 packet loss
Oh, I'll try that
But visually it's not like disruptive or unresponsive
Yeah, that makes sense
But what am I missing for it to be considered functional and not stuttery or unresponsive? Because it seems smooth, so all I'm saying is that it isn't impossible
I'm assuming the corrections that are problematic are the ones that feel janky
Well for one, if you would start sprinting and the Server corrects you back, the Client won't replay the moves properly, cause the MaxWalkSpeed isn't controlled by a Flag in the SavedMove
Basically the client doesn't know it sprinted
exi bro you have any ideea why on the hud begin`s play I set a variable from each playeer controller when it finished to true, but in the game state when I go through each player with a loop and wait until next tick operator it will show me only true for server and false for client, why is this happening?
HUD is local only?
yeah, isn`t it?
each player has it`s own hud right??
Yeah, but are you checking the variable in the GameState on the Server?
Not sure what your actual setup here is
basically what I am trying to know, is when the AHUD for each player is created,
how can I Know that?
PlayerController creates that. You can check Source Code for that
what is source code?
yeah
I need to know when the AHUD is ready in order to do an operation on it, do you catch what I am saying
As far as I can see, the HUD is created in PostInitializeComponents
That happens more or less during the spawn phase of the PlayerController
So anything post- BeginPlay should be fine
you mean to make an event, and after the BeginPlay ends to call this new event?
I mean that you can access the HUD from the PlayerController at any point after BeginPlay called
oh ok
Sorry for being pedantic, but I'm only getting jittery corrections with packet loss. Otherwise, spamming sprint while changing directions suddenly doesn't produce any disruptive corrections by the server.
I will see what I can do abouut it
You mean you get corrections but none that feel disruptive?
As I understand, the CMC is doing some smoothed corrections, but none are jittery even at high latencies. Not at the start, during, or end of the sprint.
Yeah sure, if you are fine with whatever you have there, then go for it
A CMC implementation would have basically "no" corrections. Package Loss is a different story.
Yeah but basically i need to know the moment when the hud appears so I can immediatly call another function
Thanks for clearing up the picture a bit, I appreciate your insight
BeginPlay of the HUD itself
You won't have access to anything else in BPs
If you need more, override "SpawnDefaultHUD" in C++ in your own PlayerController
Yeah bro, and for the second player it doesn’t acces a boolean in order to make it true
Why is that?
Idk what you mean
I am calling this in game
that boolean Hud appears get`s true at the end of begind play of the AHUD
for the server it get`s to true, but for the second player it never gets to true, why
What is calling that function?
You can't access the HUD of other Players, you are aware of that, right?
neither as the server ?
hmmm but I don`t really acces it
How are you setting that boolean then?
in the end of the AHUD but I am geting the player controller, and for that I am getting the get owniing player controller
Yeah but that is all local
Nothing of that will replicate to the Server unless you send a ServerRPC telling the Server that the HUD exists
fwiw I tried to implement a "root" mech while attacking in my game without writting a custom CMC class and it was very janky. you can test it yourself by changing your sprint to instead of increasing the speed, decreasing it to almost 0. then while you are walking you press to sprint and you will see the big jump in corrections
its very noticeable in 100-200ms emulation
You can do a real hacky client-authoritative sprint
just tune your movement such that half input is walk and full input is sprint
Just tick "AllowClientAuthoritiveMovement" and be done with it.
Then proceed to ignore your players asking to take care of the cheaters.
what "net role" does an actor have if its the owner ?
im on a component of a character
thanks
I guess still Authority
Don't think the Server has AutonomousProxy for their own Character
Unsure atm
Do i need two copies of a map to set one for Editor and one for Server?
or can i use one copy of a map for both?
i mean for packaging
coming back here, how do I do that?
where you want me to create the rpc
man I am so fucked
with this
@nocturne quail You need only one map. Not sure what you are trying to do.
Honestly, I have no clue what your end-result here is supposed to be.
Usually this whole thing with "Is HUD ready on Client" is totally not needed.
I thought server needs its own copy of the same map to load
and the clients will load its own map, the same copy of the map that server will load
Yeah but why would that need a duplicated map?
okay so my whole problem is that sometimes the client doesnt get the struct of the generation of the map, and thats why I need to know when the hud is ready in order for it to get the struct and create the minimap
Are you using RPCs to send that to the client?
Why can the HUD/Minimap not just ask for the Data?
You usually solve this by going both ways.
few months ago i watched a video where they duplicated the map
- Let the HUD/Minimap ask for the Data when it gets created.
- Tell the HUD/Minimap about the Data when it replicates.
- Fails if the Data hasn't replicated yet and will be caught be 2.
whhat do yoou mean by ask for the data?
Yeah just get the data when the HUD gets created
the minimap from the server can vary with the one from the client
it`s noot always the same
well basically this is what I am doing
I store the data in game state, and after in the Hud begin play I do an get game state, cast it , and take my data
maybe if the server map will not have the sky, shadows, sunlight and more cosmetics sfuff?
this is on the begining of the gamee, the problem... is not in general, sometimes it doesn`t spawn shit for the client, sometimes it does, but i want it to spawn all the time
You only need one map.
Is the Data in the GameState replicated?
yep
the clients need to watch the sky and lightnings
Missty, you only need one map.
so i can disable those things for server right?
Then what stops you from marking it as RepNotify, and telling the HUD, in addition to what you do on BeginPlay, that the Data is there?
and use one map
The Server, if Dedicated, doesn't run that stuff anyway.
yeah i will make dedi server
what to mark as RepNotify ?
The Data
the map get`s spawned before the HUD is created
it will not load but it will include them in the build right?
I cannot send it like because the hud doesnt existt when the struct is made
That doesn't mean that the Data replicates instantly
You handle this as if Ping doesn't exist
Yeah, but you can still not split the maps.
So just forget about it.
oh, it will automatically send to the client right?
even if it connects laters, if I am not mistaken?
Yeah that too
ok, I will try it out, if I don`t succeed I will come again here and cry 😥
Got it, Thank U for helping me with this, i'm really bad at cosmetic things of Unreal
You need to store info for each player either in Player State or Player Controller to show for each of them their own stats / info.
Just create map in the Player Controller, so each player will get their own version
If you create it once then they both are trying to access the same map
@thin stratus it looks like my character on client side isnt ROLE_Authority (using GetOwnerRole)
so ROLE_Authority looks the sames as HasAuthority()
Help is appreciated...
https://www.reddit.com/r/unrealengine/comments/1d7czff/triyng_to_differentiate_actors_from_the_same/
Reddit
That stuff is done via a DotProduct.
The two directions you want to test with are:
- Player Forward Vector
- Direction between Players (normalized!)
If one is standing behind the other, e.g. Player 1 behind Player 2, then you will get:
- DotProduct > 0 for Player 1
- DotProduct < 0 for Player 2
I would assume you want to consider both, cause otherwise you don't know that Player 2 is not facing Player 1
Done it, but the code reverse it and they cancell eachother.
That's the way to do it though
Yeah I saw the post. The answer remains the same.
I know, just checking.
Thanks, but both players give me negative always.🥺
Then you are doing it wrong. You gotta share your code then.
GIve me a sec, appreciate the time.
is doing any authority check in the gamemode class redundant?
it is, why would you do that
i was just wondering if there was any case where that would be usefull
game mode is server only
Didn't you asked that already? Just saying.
i did, i just didnt get an answer
or maybe i didnt get an answer in time and didnt see it
It was answered but anyway it is redundant
Hard question:
Why would you want to use a Client RPC and how to use it? cuz in roblox for example, I needed a player variable to access that specific client but it's strange to me that that can work without it
if you call a client RPC in the server it will run on the client
reread my questions
can be used for a few things, are u looking for a specific example?
yes and how it work under the hood (but in a simple way)
well it could be used to send data from the server to the client to save a match for example, for a local match history
under the hood im not quite sure how it works, u need an owning connection to send RPC's so thhrough that connection that RPC is sent to the client and does whatever you want it to do
How do I update a value in an archive that was serialized few steps ago?
int16 SomeInteger = 0; // Value is unknown here
Ar << SomeInteger;
// Serializing other properties and figuring out the value of "SomeInteger"
// Now I have the actual value of "SomeInteger", How do I go back and set it in the archive?
I tried Tell() and Seek() but looks likes they're not implemented or I'm using them incorrectly because Tell() always returns -1
I've read that they should be avoided
it depends
you cant just call them freely, specialy if they are reliable
u gotta be aware of bottle necks
ofc, it's server to client ONLY
not a client to a client
in any case if you call reliable RPC's too much u can overload the reliability buffer and cause issues
Yeah well Client to Client would go against the basis of Authority-based Multiplayer.
ClientRPCs, the same as MulticastRPCs, can be used for any kind of non-state, one-time event that the Client should execute.
Is that possible? since I'm using a Listen server type so I don't really care about authority or security
Telling a Client to gracefully leave the Game.
Telling a Client to show some Hit Effect.
Telling a Client to show some UI Effect.
Telling a Client to close a UI Menu.
Etc.
im gonna take the chance since Cedric is here and ask this, so i have a dash in my CMC where i just set the velocity, the thing is ,that dash is not frame rate independent, whats the best way to make it so?
No.
@thin stratus
basicly i just set the velocity to whatever i want somehting like "velocity = 99999"
like a vote kick thing, only 1 client leave...
For example yeah.
/** Notify client they were kicked from the server */
UFUNCTION(Reliable, Client)
ENGINE_API void ClientWasKicked(const FText& KickReason);
Basically what UE already does in that example.
where is that from?
Source Code
I mean, what class, the GM?
Another example would be if you have some sort of Chat System where you can send messages to specific players or a team.
PlayerController
Not sure. Low FPS cause a spike in speed?
its actualy the other way around
OMG that's so true, it would be an RPC on multiple Client, not just 1, how to do that tho?
so im probably better of doing a 1 time aplication of force than doing it continuosly?
You run a client RPC on actors owned by each client that need to receive the message.
umm what does that mean?
but it's from the server to the client
The only way to execute a client RPC is to execute it on an actor owned by a client.
A controlled pawn possessed by a client is owned by that client. Running a Client RPC on that pawn will only send it to that one client.
so each player would own their own chat Actor or Component and then Client RPC would work?
Theres no need for a chat actor, u can just run the rpc through the player controller
if i am not mistaken
Or a component, yes.
player controller is replicated, so how do I know that it's owned by the client?
and not the server
i think the old official ue4 tuts did a chat just like that
is there a list somewhere?
well sorta
Because player controllers are assigned ownership to the client they were created for.
what about the Pawn?
u take a look at the architecture
Possession assigns ownership.
the pawn is also owned yes
PlayerState is owned by the PlayerController it was spawned for as well.
oh i didnt know that, i tought that the playerState was just something floating outside
so the player state is client owned?
but replicated
Yes
player state exists in both the client and the server
Just don't confuse the word owner here.... Ownership doesn't mean that it's created by the client, or that the client has authority over the actor or component.
@sinful tree With a bit of C++ you could theoretically make a limited Multicast.
By abusing a GroupActor that is only relevant for the people in the group.
Then you can send the Chat Message to the Group through that Actor.
But weeeell
Still has the other issues of being a multicast though, yea?
Yeah, though instead of sending one ClientRPC per GroupMember
so what does it mean then?
It's being assigned as something the client has some control over in the network sense - it allows the client to send server RPCs on that actor/component and to receive client RPCs on it.
If the actor isn't replicated, then RPCs can't be used on it at all.
so client RPC work on the PlayerController, PlayerState, could you name them all?
PlayerController, PlayerState, Possessed Pawn & any actor or component that has one of these actors as an owner or are in the hierarchy of their ownership.
PlayerController is considered the "top level" and is what allows a player to RPC to the server at all. PlayerState happens to be owned by the Player Controller, so your clients can use RPCs on it. Same with the possessed Pawn - it is owned by the PlayerController, so RPCs work on it for that particular client. If you created another replicated actor and set the owner as the controlled Pawn, then you'd be able to RPC on that new actor. As soon as that Pawn is de-possessed though, the ownership of that new actor would still remain to that pawn, and since you no longer have ownership of the Pawn, you wouldn't be able to RPC on that new actor anymore.
okkk thx
That's only one dot product
If you want to know if one player is behind the other, you need two
DotProductOne = Dot(PlayerOne.Forward, DirectionToPlayerTwo);
if (DotProdcutOne > 0)
{
/// PlayerOne is facing PlayerTwo
}
DotProductTwo = Dot(PlayerTwo.Forward, DirectionToPlayerOne);
if (DotProductTwo < 0)
{
/// PlayerTwo is not facing PlayerOne
}
if (DotProductOne > 0 && DotProductTwo < 0)
{
/// PlayerOne stands behind PlayerTwo
}
what if i manually set the owner in the server? say for example i have "randomBoxActor", if i set it owner to something that is connected to the client could it send an RPC?
Yes
thats interesting
As long as it is replicated
The other thing is, you don't necessarily want to keep swapping around ownership of actors. Like, you wouldn't change ownership of a "Door" in your game so that your client could RPC on the door.
You're better off having something handle the interaction of the player that would be owned by the client to begin with, then have that thing RPC to the server first, then the server doing the thing with the actor the client is not owner of.
Yeah, the issue is that both players think are the other one and the code flips and returns the same for both, even if they are negative and positive.
Doesn't really make sense. Even if you perform the Dot stuff for both Players, with PlayerOne and PlayerTwo being inversed, it would result in the same.
Or rather, the other player would have inverted results, cause they are not facing the first player.
I know, i does not make sense, but is what happens every time.
FOrget about the event, is just to screen shot
Has anyone gotten online beacons ( https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/OnlineBeacons/ )
to work with the Steam Online Subsystem.. I've followed the tutorials on how to set up beacons and i got it to work with the regular OnlineSubsystem but as soon as I add the following lines to my defaultengine.ini , the Beacon fails to init
**LogNet: **Warning: Failed to init net driver ConnectURL: 192.168.1.138:7787/Game/MainMap:
LogBeacon: AOnlineBeaconClient::InitClient failed
Hey, do y'all usually use the server or the client as the target for emulating network latency?
I think it depends on what you're doing with those items. If the player is going to be in control of all of those things, then it would be useful to give the player ownership of the actors they control.
It would be, at least manually going through and updating ownership. You should create some kind of object to unite all of those objects together, like an "equipment handler." Or you could give the players an actor component to handle that, like an "equipment component."
I need to bind an event dispatcher on sv side?
How do you mean?
I have an inventory
And i use an event dispatcher for inventory changed
Sv has the inventory logic
Event dispatchers and delegates are not replicated; they only fire locally. If you want to broadcast something on a machine, you'll need to bind it and broadcast it on that machine.
It sounds like an OnRep might be better for your situation though. OnRep functions are automatically fired on all machines (except the server)
(Unless you're in BP)
i'm on bp
Then the OnRep events will fire even on teh server.
But if i bind it on client, can they cheat?
No
Client
I am not a big fan of the built in packet emulation tbh, I always have used clumsy instead
You want to wait until all players are loaded in before doing anything?
Can you reword your question?
You can use the game state's player array to check how many players have joined the match
Anyone has some sort of knowledge about networking with DAs ?
I'm using an interface for this system, it takes the DA in the actor and stores it inside a component, then the actor get destroyed
How would that be done with the Data Asset and getting it to replicate?
Does the Host know beforehand how many players are coming into the Session?
Or is it dynamic?
Replicate the data asset's path, TSoftObjectPtr<UPrimaryDataAsset>, and then load them locally on each machine
Do I need to override that function that gives the path?
Depends; are you using primary data assets and loading/unload them manually, or are you just using regular data assets and loading them all when the game starts?
loading them at the start of the game
(that's the default
I think)
If the Host knows how many are coming, you can just wait until that number of Players has joined..
In PIE you can query the number set by the Editor settings relatively easily.
I cant remember off the top of my head how you do that
But you can get the number of "clients" being created by the Editor
Then everyone has access to the data assets already. If you have a data asset object variable in your character class, for example, you can just get that object locally for whatever value you need. If a data asset has variables that are changing and you want to replicate those changes, that's a different story. Data assets might not be the best choice in that situation, unless you want to replicate whatever functions are actually doing the changing
DA will never change.
Just setup an editor specific code path, that might poll the current joined players and initiates it when enough have actually joined.
🤷
Editor specific code isnt unusual.
Good; then you can just get them locally.
As its different in many ways to normal play
no multiplayer setup needed, right?
someone told me that I had to use some kind of pointer and other stuff
I dont know what your setup is, not easy to suggest a place to handle it.
GameMode maybe?
🤷
Firstly, try finding out how many PIE Clients are being created.
Then use that number to poll
Think about what pieces of information you need, how to get them, then how you need to use them.
If you have a class, AMyCharacter, with a variable, UPROPERTY() TObjectPtr<UDataAsset> MyData, and that character gets spawned on every machine (as it should be), you can just call MyCharacter->MyData->MyProperty whenever you want to get data from it. Everyone has that data asset.
the problem tho that I'm not sure if it requires a multiplayer setup is this:
the DA gets added to an array when a player interact with an actor... (the values in the DA never change tho)
What class is the array in?
TArray<FItem> ItemsArray;
FItem contains 1 DA and some variable
But what class? Like a character class, a player controller, etc.?
it's a component inside the player's character
Is ItemsArray being replicated?
How are you adding to the array? A struct is a bit of an unusual choice to represent an item
would it be better to use a class?
I'd either create a UObject to represent the item during runtime, or make the item itself represented by a data asset.
Regardless, the key to getting this replicated properly is making sure every machine can make the same struct.
I didn't implement it yet but I'll use an interface that goes from the actor interacted with to the player's component's function called 'AddItem', the DA will be copied and other things
If the player fires something like "PickUpItem" locally to pick up an item, and that calls a function like "AddItem" on the server, then you can just add the item to ItemsArray on the server and replicate it. Then the new item, including its data asset, will be available to everyone once it gets replicated.
I highly recommend looking into the FFastArraySerializer and FFastArraySerializerItem structures for managing your inventory. They're fantastic for replicating structures like this, and they're used everywhere for handling inventories.
but should I use a class instead of a struct
It's really up to you. You can do this either way
Can the interface be client only? or server?
Your interface should only be triggering locally: your player presses a button; they do a local line-trace for an actor; they cast that actor to the "interactable" interface; and once they confirm they've actually interacted with something, that's when you tell the server, and the server handles what happens next
even the line trace is client only?
You can ask the server to do the line trace instead if you want, but traditionally, that only happens on the client.
Shooting a gun works the same way: the client performs the trace and tells the server what it hit
that's what I will do since I'm using a listen server type
Well in that case the listen server is acting as the client. If you only line-trace when interacting on the client, and you interact on a listen server, it will still do the line trace locally; "locally" just so happens to also be the server in that case.
Client -> LineTrace + "interactable" interface -> Calls a Server RPC (input is the player's character to know which one to do the change) that calls the AddItem to Inventory of the player's ref from the input -> function runs for everyone (right? server will run and add it for everyone?)
You shouldn't need the player character as a parameter if it's the one calling the function. And the function itself won't run for everyone; if you're replicating the ItemsArray, then the function only needs to execute on the server to update the ItemsArray. If the ItemsArray is replicated, it will be updated for everyone.
true, I'm dumbn
thx for the help, I'll try to implement it and see if it works!
Good luck!
@sinful tree Hey man, I just found out that pure p2p where all players are standalone apparently is not compatible with unreal engine. Multiplayer in UE works only in an authoritative state where there is always a server and there are clients. That means I will need to launch a dedicated server for lobbies and parties as well I guess
There is no P2P within Unreal's networking for its gameplay. It is always client->server. A listen server is a client that is playing the game but also acting as the server.
A dedicated server is an instance of the game that is purely running as the server (no graphics, doesn't have a player playing it)
Lobbies/Parties come before a client is connected to any server.
So, this means for pre-match lobbies like in COD where they used to yell at each other back in the days I have to use dedicated servers as well?
could you elaborate how you can have players waiting in the same lobby if not connected?
You're not connecting to a server. You're using Online Subsystems to communicate.
So, let's say you clicked on "Join Game" in your game, you'd have it communicate to the Online Subsystem that you want to find a game. It can do some matchmaking for you, and then send you details about the "Lobby" it found for you. You then have that client set up any UI as you want to represent what the Online Subsystem tells you about the lobby and you'd have it set up to bind to further messages to know when players leave or join that lobby, and you'd have a button to "leave" that lobby which communicates back to the Online Subsystem that you want to leave, or you can have a button to communicate that you're "ready" or any other data you may want to send through to the lobby. The Online Subsystem will relay this kind of data to other listeners of that Lobby so they too can know what the status is of the other players in the lobby.
Again, this is all before a client has actually joined an Unreal server. It's all client-side.
Ah I see
well good that I am currently working on aws gamelift flex match which is responsible for matchmaking 😄
That means I don't actually need the matchmaking or p2p of Steam for all that
@sinful tree he means a pregame lobby like the valorant warmup game
I don't mean a playable one
a menu ui one
like in cod back in the days for mw or so
sure, but it is the same concept for the most part
What can I do to ensure my Door retains its state for late-joiners?
- I have a door actor
- The door has a RepNotify enum "DoorState" with Open & Closed
- I set the value of DoorState via a server RPC
- When the value is set on the server, the OnRep calls a function, which animates & rotates the door 90 degrees
Everything is working as intended, except the door will be closed for late-joiners. The late joiner can still walk through the door; which tells me the server is still holding the correct state but the client isn't getting the memo.
I'm not sure GameLift has the concept of Parties/Lobbies for players though. Sure, it can launch your instances for you but if you wanted to have an actual "lobby" where you can have players chat with eachother or select characters but still see the status of the other players before the game starts and your actual server is started, you probably would still need to use Steam or some other system to route those kinds of communications for you.
if it's all client-side before the game starts, then what would I need Steam for?
Sounds like you're doing it right. OnRep Enum. OnRep sets the rotation of the door.
You need some way to communicate between the clients.
gamelift does not have parties/lobbies. It has matchmaking and dedicated servers
If you want the clients to know about eachtoher.
An example would be like... Dead by Daylight. The survivors can all see eachother's avatar and some of their build details and they can't see the hunter, but the hunter can see all of them. The players can all ready up, and when all ready the match will start, or they have to wait until a countdown finishes if there's someone who didn't ready up. This is done VIA a lobby system where there is no game server running to keep them updated, but they are all listening to the lobby data. If I remember right, there's also a chat system available too.
oh and the online subsystem steam is then utilized for that
instead of using the default one
Is DoorState replicated?
it's repnotify I guess, like they said
oh, good point
Yeah, RepNotify.
I am using a timeline for the animation and I can't put that timeline in the RepNotfy function, but instead I am calling a graph event from that RepNotify function. Would that cause issues?
what about the mesh itself?
is the actor blueprint replicated
Yes, the mesh is replicated. I can see everything moving as expected while playing as client.
I'ts only broken for late-joiners.
The mesh doesn't need to be replicated, just the actor. You're controlling the mesh locally VIA the OnRep.
Do you have any replication conditions on the DoorState variable?
print out the doorstate value for all clients. Those in-game and those joining later
see if the value is the same
if not, then you know where to fix
I am not sure if I understand what a replication condition is; but here's my code:
Too much being replicated there.
Don't need to replicate the timeline and the meshes.
Yeah you're doing what I did don't need to have timeline replicated
the lobby data is in this case what exactly? Because matchmaking from my understanding only tells the client which lobby to go to and who is there. It is not responsible to allow clients to communicate in there and see each others skins. Especially not understanding this part as this is only handled on the client side
If all you're wnating to do is have players click on a button and it eventually puts them into a game without them seeing any details about clients, then you don't need a lobby/party system.
I do want them to see details
I just don't see how a client side system will allow them to communicate
Then you need a lobby/party system. And something has to communicate the data between clients as they are not going to be connected to eachother.
The Online Subsystems can do this.
the online subsystems need a server or don't they?
Online Subsystems are external to Unreal.
It has nothing to do with playing a game.
Or hosting a game.
but I need to know how to utilize them inside of Unreal
Yes.
I know the common replication methods for unreal
And those have nothing to do with the Online Subsystem.
but all these usually communicate with a server
It's like another system you communicate with.
yea then I am in need of guidance xD
any tutorial or so you can suggest?
I assume that's a more complex niche type of thing that won't be easily found on yt or in forums
The idea behind an online subsystem is that steam will handle some communication logic for you. For example, you can assign players a state and ask steam what that state is (e.g. ready, not ready, in character selection, etc). You can get access to steam's friends interface, etc. Steam even allows a voice chat!
So far I used voip talker in unreal engine for voice chatting but it was not very nice
I got the idea of it now but I need to know how to use it
Well again, it depends on what you're going to use - if you are using GameLift, I don't know if they have something that can represent a "Lobby" for players wanting to join games that can facilitate communications for you without requiring players joining a server. You could technically build your own system using Lambda functions and using REST calls, with a little bit of DynanoDB. Otherwise, yeah, you'll have to look into using Steam Lobbies, or Epic Online Services or other such offerings to help facilitate such communications.
With Steam, it looks like they call it Steam Matchmaking...https://partner.steamgames.com/doc/features/multiplayer/matchmaking
To be clear, a steam "lobby" does actually live on servers, its just that steam handles that for you. With gamelift you will have to host a dedicated server on your own
so a steam lobby like the one we are talking about is not actually client side only
A steam lobby cannot feature a playable experience like a warmup match or anything of the sort, you need a proper server (p2p or dedicated) for that
Gah, it was something silly.
The default value on my DoorStatus enum was set to "Open" whereas the meshes starting position was set to closed.
I've also stopped replicating the timeline and components, thanks for the advice.
You can pretend it is
It's client side in that they're not connected to an Unreal server.
and thus not connected to a gamelift dedicated server
internally it is a server, but its steam hosted and you cannot do anything with it. OSS will handle everything there. For all you care as a game dev, it is client side
perfect
and once again, no playable games or anything is allowed, only simple communication.
Do get a playable game you need all the unreal networking stuff, which means a proper listen server
I don't want more than that
OSS is disconnected from unreal's stuff
as long as it can do friends, voice chat, text chat maybe and update the selected skin
Then OSS will be fine if your game is only on steam
yup, all of that is possible. I have done all of those with OSS besides voice chat.
it is, although I wonder what other options I have, to make it universal without having to code it myself. I mean gamelift doesn't have a service for this so I got to go with EOS or OSS
i can't implement both tho, can I?
you can, but they wont interact with each other
or do I need to make a second project and change it up to EOS
no, you dont need a second project.
as far as I know epic games and steam games now do cross play
I think the entire point of online subsystems is they're supposed to be platform agnostic, you just use a common interface to communicate to all of them, if they implement such functionality.
I'm not sure. I have experience implementing for Steam and Xbox, they do not interact.
Sure, but i mean, OSXbox will only allow you to use xbox friends, and OSS will only allow steam friends, etc.
maybe before 2022?
Yea
I found that mid 2022 it was changed
ah yea sure, I meant cross play as in playing in the same match
on the same server
oh like 2020
I havent done much with EOS, when I tried the best way was third party plugins
like late 2021
nowadays it's more robust than before from what I have heard but yea
OSS is my first station either way
If you are going down the OSS route and are blueprint heavy, then I suggest you look into the advanced sessions plugin - it may well save you a couple of days:
https://forums.unrealengine.com/t/advanced-sessions-plugin/30020
wayy more, it was a pile of frustration then, at least for me. Again I have no recent experience with EOS
Oh I got this already since a year haha. Thanks tho!
Alright
so now I have a match plan and know that I know a lot less than I thought I know
that being dropped, thanks to you all for the help!
By the way, some unsolicited advice
Please set up budget notifications and restrictions on AWS!
AWS is notorious for random huge charges from unexperienced devs
no, I'm sure other tutorials exist though
haha yea, alright gonna check it out
I know google has a hard cap if it notices something might have been made as a mistake
at like 50$ or so if it's made in a few seconds through a looping function or whatever
but I will def check on aws
thanks for the reminder
And if you host anything on S3, make the name as unique as possible, they have a stupid "bug" they refuse to fix, where anyone can try to put something in it and you get charged for the attempt even if it was rejected
simple storage service
Lets move this back over since this channel is not where this should be
sure
I remember being charged $5 by AWS one month because of a bunch of "alarms" that were active because even though I had a GameLift fleet it wasn't active and just because it wasn't set up to scale it threw those alarms, and because I didn't clear them out, I got charged for having active alarms on a system that wasn't even turned on... Like... What?!
Ah yes AWS has a lot of “gotcha” pricing 😂
Yup, some free tier confusion got me when I started. Been making sure to read all the fine print on AWS since
yeah they have a good free tier but they charge for a lot of stuff you gotta be aware of XD
I'm trying to rotate a character to face away from a wall on collision. On the server this code works, but on the client the Actor is still facing their original forward vector. I have verified the client is calculating the same transform as the server, and even the debug sphere I'm drawing for Look At Target is in the correct location on client, but the actor won't face it. Any ideas? Some quirk of rotation? The CMC overwriting?
If you are using Control Rotation to orient the Pawn, you may need to set that on the Client.
I'm using Get Control Rotation for movement, but movement is disabled during this code.
This is a wallsplat situation, so the player has no control.
The control rotation value will still affect the character
Get Control Rotation is same on server and client, 0 if I splat them without touching the client, and if I rotate the client camera they stay synced. Is there something I can disable to quickly test how this affects the situation?
It was Orient Rotation To Movement. Thanks!
Hey, i have a problem, I've added sprinting to my game yet when i play as a client, it no longer works, an image of code is attached, any idea why this is happening? Any help would be greatly appreciated.
There's literally no net code
You must customize the CMC to replicate sprinting. Examples here: https://github.com/Vaei/PredictedMovement/
Hi,
What do you guys think about my approach for frame-independent hitboxes?
- First i bake the bone position, which i want to trace into a curve using a AnimationModifier.
- A custom "Hitbox" ability Task is triggered in the ability (client predicted)
- The "hitbox" task starts a timer with a fixed tickrate (also ticks between frames/ multiple times per frame)
- I evaluate the previously baked curves and trace spheres on the baked bone positions (relative to skelMesh)
- I also trace between the last position and the next position to get rid of gaps in the hitbox
I would love to get some feedback on this. The main reason i did it like this was, because i wanted the hitboxes to always be deterministic, no matter if you have 10 or 100 fps.
It also helps with desync because the hitboxes will be the same if framerate differs between server and client.
There was a talk on this at Unreal Fest Gold Coast last week. It had a similar concept; pre-bake the animation hit box animations frames, and ensure each frame was calculated if there was a lag/jump between ticks.
Not sure when the videos for that will go live, usually 2-3 months
Just remember if you are talking about melee fighting it’s not just the attacking character, you need to apply the logic to all units in the radius of the attacker, so each frame is a calculation of both sides.
Thanks. Thats really good info, i will definitly look into this as soon as the video is up
Yes thats the plan anyway 🙂
that JoinServer query don't support to get list of server launched using the command line?
"J:\UE-5.3\Engine\Binaries\Win64\UnrealEditor.exe" "J:\ARMA\ARMA.uproject" Oklahoma -server -log -nosteam
void UARMAGameInstanceBase::JoinServer()
{
SessionSearch = MakeShareable(new FOnlineSessionSearch());
SessionSearch->bIsLanQuery = true;
SessionSearch->MaxSearchResults = 10000;
SessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
SessionInterface->FindSessions(0, SessionSearch.ToSharedRef());
}
void UARMAGameInstanceBase::OnFindSesisonComplete(bool Succeeded)
{
if (Succeeded)
{
TArray<FOnlineSessionSearchResult>SearchResults = SessionSearch->SearchResults;
UE_LOG(LogTemp, Warning, TEXT("SearchResults, Count , %d"), SearchResults.Num());
}
}
If you were to make a game and squeeze as many players into a single session as possible, how important would a push configuration be? Reading Iris source it seems Epic is aiming to transition completely to push config (at some point), but did anyone actually tried how big of a difference does it make with high player count?
Servers like that are DedicatedServers and those do not use Presence. So if you want to find those you gotta put that to false.
How are Booleans replicated? Does it take up an entire byte for just the 0/1 or something else?
Yop, if you have multiple you may want to serialize them together.
I was considering using a Bitflag instead
How can i refresh inventory when i pickup an item without close it? (Multiplayer)
If you have a repnotify for when an item is added, I would call an event that the UI listens to
hey, is it possible to have two players on one screen and controls on same keyboard. Setting IMC for 2nd player controller does not seam to work out of the box
i don't have an repnotify
i have an event dispatcher
who trigger when inventory changes
is there a working sample project for iris?
I'm doing it correctly?
SessionSearch->QuerySettings.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
How are you responding to the new items in the Inventory? How are you replicating these items?
If you change it to a repnotify, then you should be able to call the same event on the client
Im trying to access a client (player controller) from the postlogin event in game mode, but apparently I cant, despite saying that it will trigger whenever a player connects.
so, how should I pass over some game rules I have set in the game mode over to clients?.
Look at this, all items got refreshed when i pick another
Where are you calling the update?
how store and read replicated variables in game Game State in blueprint ?
I meant on the client
On inventory widget
Can you show some code?
If I wanted the player to communicate state info to its controller. Would a delegate be the recommended way to go about that?
Or could that introduce some latency
https://blueprintue.com/blueprint/qkbkm5dy/ (InventoryWidget)
https://blueprintue.com/blueprint/_c0avfrl/ (Pickup Item)
https://blueprintue.com/blueprint/g1cjl_3j/ (PlayerController)
I’ve set up a team selection widget at the entrance of the lobby. This widget displays the number of players per team and offers two buttons to choose a team. For example, it might show that the blue team currently has 5 players out of a possible 10, while the red team is full with 10 out of 10 players. When a player clicks the blue button, they are added to the blue team’s player array, which is stored in the game state. Now, how can we set and retrieve these variables in a multiplayer context, both as a client and as a server?
GetGameState->CastToCustomGameState->Get/Set
hey, I have an actor, that updates dynamic material instance in tick, and it works nicely on host/server side, but doesnt seem to work on client's side. I tried logging to screen in tick, and that only works for server side too. Not sure if im not understanding something correctly here? Variables replicate correctly, methods also seem to be called correctly, so it's only tick that doesnt seem to work, any ideas?
Hey guys, I'm losing my head over this one since yesterday... I can't get to pass a Data Asset loaded from disk from server to client, I'm using Get Assets By Path and on the server it works fine, but when I try to inspect what the client receives its just Unknown|Null 😐 maybe it's not possible? Or is there another way?
You sure the actor is replicated?
Any code you can share?
i just doublechecked, and seems like the tick is working fine actually, but i still have an issue
void ACanvasPuzzleLinkedDoor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (bIsDissolving)
{
UpdateDissolveEffect(DeltaTime);
}
}
thats tick
void ACanvasPuzzleLinkedDoor::UpdateDissolveEffect(float DeltaTime)
{
if (!DynamicMaterialInstance) return;
ElapsedTime = GetWorld()->GetTimeSeconds() - DissolveStartTime;
Alpha = ElapsedTime / 6.0f;
EasedAlpha = FMath::InterpEaseIn(0.0f, 1.0f, Alpha, 2.0f);
DissolveValue = FMath::Lerp(0.52f, -0.4f, EasedAlpha);
DynamicMaterialInstance->SetScalarParameterValue(TEXT("DissolveValue"), DissolveValue);
if (ElapsedTime >= 6.0f)
{
bIsDissolving = false;
this->Destroy();
}
}```
Thats the method i want to update in tick
private:
UPROPERTY(Replicated)
float ElapsedTime;
UPROPERTY(Replicated)
float Alpha;
UPROPERTY(Replicated)
float EasedAlpha;
UPROPERTY(Replicated)
float DissolveValue;
UPROPERTY(VisibleAnywhere, Replicated, Category = "Components")
class UStaticMeshComponent* DoorMesh;
UPROPERTY(Replicated)
class UMaterialInstanceDynamic* DynamicMaterialInstance;
UPROPERTY(Replicated)
bool bIsDissolving;
These are my values in .h, and GetLifetimeReplicatedProps is set
all the variables seem to replicate, this->Destroy() happens on both sides. Only issues is that the material isn't getting updated, even though bIsDissolving is set to true. I tried to show a message on screen, but it only shows on server side, so im not quite sure how to check if I even enter that method on clients side
idk why it didnt format it to c++ :c
how can i known if a client is listen server ?
Anyone else getting no results when trying to find sessions with EOSPlus?
GetNetMode() == NM_ListenServer?
i will build a DedicateServer.exe , the question is where i should call CreateServer ?
i can only think of level blueprints when the server is launched it should be calling this function to start a session, right?
#if UE_SERVER
void UARMAGameInstanceBase::CreateServer()
{
FOnlineSessionSettings SessionSettings;
SessionSettings.bAllowJoinInProgress = true;
SessionSettings.bIsDedicated = true;
SessionSettings.bIsLANMatch = true;
SessionSettings.bShouldAdvertise = false;
SessionSettings.bUsesPresence = false;
SessionSettings.NumPublicConnections = 10;
SessionInterface1->CreateSession(0, FName("MySession"), SessionSettings);
}
#endif
OR maybe in the gamemode?
Have a look at AGameSession class. That's not so well known. It does however offer a lot of cool stuff. One of those being a RegisterServer function you can override (in your own Child Class of AGameSession).
In your own AGameMode Child Class you can then go ahead and override GetGameSessionClass and return your own.
e.g.
void ACustomGameSession::RegisterServer()
{
/// Do your Session Code.
}
TSubclassOf<AGameSession> ACustomGameMode::GetGameSessionClass() const
{
return ACustomGameSession::StaticClass();
}
@nocturne quail
will test it now , and also i need to restrict it for server only? using #if UE_SERVER macro
Only if you want to exclude the code from Client Builds
this is what i want, because client should not be stepping in server code 😄
Guys what's the correct way to pass variables created in GameMode object to a client player controller? I'm always getting a null on the client side
GameMode doesn't exist on clients
On the server, just set a variable value in the controller and onrep it.
how to get camera location on server ? i want the camera to be controlled by client . CameraManager.bUseClientSideCameraUpdate is true but still not get updated
is this a good start to test high ping in PIE ?
also, what does Run Under One Process really change ?
A continual 500ms and 10% packet loss would be completely unplayable, but your game should hopefully be able to recover from a burst of high ping & packet loss like this.
When playing in the editor running under one process means there's only a single game instance actually launched, so it wouldn't technically be a real multiplayer game as the engine would be simulating connecting to itself, and it wouldn't necessarily behave as if it was different instances of the game connecting.
just at least use the network emulation settings
thanks
idk if i should test with this untick, i guess i prefer doing some real testing with a build
I asked this in the GAS channel, but i'm getting some issues with spawning a projectile and network replication, because the projectile's rotation only follows the client's location and yaw rotation, and the pitch is not included (the projectile just goes straight forward, and doesn't account for the player looking up or down). This only really happens when I have an external actor spawn the projectile, when the actor being controlled by the client does it, the projectile correctly shooting in the direction the player is looking.
what even is the context of this
GetPlayerController(0) on the client will be fairly okay as long as split screen is never a consideration but I typically avoid it
I'm not sure why you're not just passing the player controller or pawn around in the event
that event comes from somewhere right
OnClicked
this is why context is important
what BP am I even looking at
what broadcasts the event, from where
oh wow it is, though it's dependent on specific FKeys, and the player controller is the thing that actually broadcasts the event in the first place. yeah, I don't think I'd rely on this in particular since the least they could've done is add the PlayerController to the event as a courtesy
not the most sophisicated system since it just uses GetHitResultAtScreenPosition to work out what's in the middle of your screen
I guess it works, it's just ugly. When I've worked on interaction before I just did a sweep when the use key was pressed and then send that data to the server if there is
And since it was a sweep, there was some sorting logic if two interactable things were close together
I suppose that is also an important detail, but the in-engine functionality isn't particularly difficult to copy
GetHitResultAtScreenPosition really is where the sausage is made, the hit result would contain the component you're clicking on
and GetHitResultUnderCursor*
I wanted to trigger an OnRep then destroy the pointer in the client function but seems I can't use it this way
please elaborate
well everything was working great with equipping items but for destruction I had
Player->EquippedChest->Destroy(); Player->EquippedChest = nullptr;
The client doesn't get called until the pointer is nulled so too late to replicate, destorying the mesh
maybe just a client function would work better here and instead of OnRepUsing just keep the pointer as replicated then handle it on the client
I'm not sure I'm getting a sense for the problem?
just for destroying the armor meshes when the player unequips and item and to have it replicate
the equipping part works fine, everything replicates as expected
right now it's double click in the widget > Server returns the item to inventory > if successI would want to trigger the OnRep for the client to destroy the mesh
and the OnRep is on what?
all the equipped bits, in this case EquippedChest
why not just do cleanup in EndPlay?
hmm? the player is just changing armor
oh I thought you meant the instance
oh sorry no
I'm still not sure why an OnRep of the EquippedChest variable wouldn't do what you expect
well in order to trigger it I need to change it to something right?
it's not tho.. ok good to know it should
are you testing in listen server mode or something?
I was under the impression that you had to handle it in the OnRep
right but on the client side the mesh was never destroyed
this is why I ask if you're testing in listen server mode
because from the serverside, OnReps would need to be called manually
I mean the editor is set to listen server but checking this on the clients
well the first "client" is the server
yes, I get that. I have it set to 4 and checking on the non listen server clients
but calling destroy on the object on the server won't replicate correct?
well it's a replicated actor, the actor will be destroyed on clients too
it's not going to affect the OnRep
did you add a breakpoint to your OnRep?
yes and logs etc
does the client "predict" the nulling of the value?
because by default, OnReps only get called when the client value differents from the server
COND_Always will make the OnRep get called whenever the server value changes
no it doesn't predict yet but I think that might be a good way to approach it
also thanks for validating that the destroy() should be replicating, I need to take a closer look at what's happening inside the actors I think
Brickadia kinda did test it with high actor/object count, and "with some change" they make the execute time went from 420 millisecond(ms) to 460microsecond(µm), so yeah, I think higher player count will kinda work the same.
So what would be the best way to detect an overlap event and then wait for a specified time before processing the event again?
I have a melee weapon striking another player and I want the beginoverlap to only be called once.
for a given "swing" of the weapon
Hello, I got a lil question about optimization
Is it a good practice to set every relevant variable to repnotify?
I just found out that the servers tries to sync them every tick
So I was wondering if it would have an impact on perfomance if you set all your variables on repnotify instead of event driven
Just set a Bool that gets reset when the Swing is finished?
Dont process any further overlaps if the Bool is true.
What do you mean "repnotify instead of event driven"
"the servers tries to sync them every tick"
What do you mean by that as well?
It seems your understanding of how Replication and Replicated Properties work is faulty?
Sorry. I meant to say just replicated
RepNotify is simply telling the Property that when its value changes on the Client, it should call its corresponding OnRep_xxx function.
It has nothing to do with performance.
let me reword it
Would it be better to have all the variables replicating every tick or would it be better to sync them on events?
So properties are only ever updated by the Server to Clients (replication), if the Server identifies their value has changed.
They are not updated every frame.
They are evaluated on the NetUpdateFrequency time for the Actor they belong to.
ohh
This is the default "polling" method for property replication.
The alternative is called "push" model.
Which is only available in C++
You as the programmer mark a variable as having been changed
So the engine doesnt have to evaluate that itself (which costs cpu time).
Then it sends that value to Clients.
That is how you would achieve an "event driven" approach to managing the replication of a property.
Please take the time to read the Network Compendium
It is the first Pinned message in this channel.
I got another question
Sure
Gib a min
Why is this variable is not passing down to the client?
Im trying to pass a reference from a actor from the server to a client
Enemy is invalid on the Client?
ChosenPokemonActor?
yup
Why are you passing it through an RPC if its already a Replicated property?
Its not replicating cuz its marked as invalid
The is valid is going throught not valid
That didnt answer my question.
Because it isn't replicating
Ok
I just did that as a desperated attempt
Does the Actor have bReplicates enabled?
yup
When do you call this RPC?
The Actor might not have been created on the Client yet?
That might be the case
How do I force the client to wait for the actor to spawn on the client?
Well that would probably be a good use for OnRep for the property instead of passing through an RPC.
The OnRep would be called on the Client when the Actor is received.
I'll try that right now. Thanks for your help so far
I need help understanding replication. I've made the simplest game I can possibly think of. Any advice on what I should do would be appreciated. I don't understand how to get the other players number to be displayed.
Game: Highest number
Description: two players enter a number, whoever enters the larger number wins.
This is more complicated than it seems.
You'll need to utilize the PlayerState to store data that should be replicated about a particular player as it doesn't look like you have a Pawn.
Replicated variables only replicate from the server to clients - clients setting replicated variables will only set them locally on that client. This means you'll need to send a server RPC on a client owned actor, like the owning client's PlayerState, to send the number the player inputs to the server and the server can then set the value in a replicated variable for other clients to receive.
In order to display the value of any particular player, your UI will need to know about all the different PlayerStates. It's usually best if you create a widget for each PlayerState that exists and have it keep reference to the PlayerState it was assigned so that you can read values from that PlayerState. To complicate things further, all PlayerStates may not exist by the time you're trying to create these widgets to display their values as "Begin Play" doesn't fire all at the same time everywhere and there is latency involved with multiplayer games - to overcome this for now, you could have a widget that you construct and in that widget's OnConstruct, you can delay 3 seconds, and after that delay, get the Player Array from the GameState, and create a widget for each playerstate - feeding in the reference of the playerstate to the widget you're creating.
If you want to know which playerstate is your local one in a widget, you can get the Owning Player of the widget and compare it against the return value from a PlayerState's GetPlayerController function. If they match, then that PlayerState is yours, and you can customize the widget based on this condition.
is it possible to call an event to happen when two players collide into each other
I know the CMC has an event for this, or at least it tells the character about it. But not sure that's exposed to BPs
im trying to call the event to ragdoll when two players hit each other when sprinting
i tried using actor behin overlap then used the player as the other actor but it acted on everything not just the players
then just... don't trigger if the other hit actor isn't a player? seems pretty straightforward to me assuming it passes that in
nvm i fixed
always something stupid that causes not to work i basically i made the cast to player as pure
only thing is that it records the hit event only on the player that is hit not also the player thats doing the hitting if that makes sense
Hitting how
this is what i meant
like only the character that is getting hit is going into ragdoll state while im trying to make both of them go into ragdoll state
this is the event hit its inside the same character blueprint that is on the other actor
Maybe because you only rag doll if velocity is greater than 400
that doesnt change anything
if you look at the video the one that is running when their velocity is greater 400 it causes the ragdoll event but it only happens on the other character that is standing
Yeah you're right my bad
actually i removed the velocity but now it only happens on the client screen that both players go into ragdoll state
If you do a print does it print for both? Does the hit event fire for the one you're controlling
thats what ive been trying to do i want the event to fire to the player controlling too
not the other actor
Probably need to ragdoll before the cast too maybe. Gets confusing when they're both the same character
What's the replicate graph
the ragdoll replication works completely fine on everything else and the code from movement state in after is the same i used when pressing a button for example
i think it doesnt have to do with the replication but the event hit it self
im basically trying to make it that if 2 players are running above speed 400 and they collide into each other they go into ragdoll state
i tried it this way but got this weird glitch
Start with printing a string on event hit if the other thing is a character, confirm the hit is happening on both
What are the rules. Do you want both characters to ragdoll if either one is going above 400?
basically if they are both running
Or do both need to be going above 400?
How are you testing? If they are both running, you can't drive two characters at the same time.
i tried it with two clients and the collision works perfect but when its the server doesnt go into ragdoll state
The server version of which character? There are two characters on every machine
the server as in the player on the main screen
Ragdoll should be a rep notify btw
like in this video
Knocked down is state
the server goes into ragdoll only in the client screen
Back up and do it like this:
Hit -> if other thing is a character and self is going fast, set enum on other thing to ragdoll
Enum should be repnotifh
In enum repnotify, switch on enum to set ragdoll or not
That would effectively be "knock down other guy if I'm going fast"
You got to remember the event hit happens everywhere. When two characters hit each other, there are four event hits that fire. Two computers times two characters
You can switch by authority to proceed with the hit, but try what I sketched out first. It might work as a poor man's prediction
ok but when you say enum should be rep notify which one are you talking about is it the movement state on the code i showed earlier? because that already has rep notify
Then why aren't you using the rep notify? Just in the rep notify, set weather to ragdoll the mesh or not. Then all you need to do to make the thing ragdoll is set the enum.
Although you gotta make sure it's not instantly getting out of ragdoll, idk what your code is for that.
thats what the ragdoll state is in the ragdoll movement
What's the on rep function?
its set when the player is in the ragdoll state
Repnotify
It being set to ragdoll should be what makes the character into the ragdoll State.
Show the rep notify function.
When you set a variable to repnotify it creates a function
The function basically is "what to do when this enum changes"
So keep that energy. You are now in ragdoll, make the thing ragdoll.
Just call your ragdoll event on the ragdoll switch I believe. Off the switch of the replicated variable. Not sure if it'll work correctly with the other stuff and seems overly confusing
this the results i got when i used print string on event hit other actor is character
on the input action to activate ragdoll it works perfectly and i used the same code logic to activate the code on other stuff like on landed event and it replicates perfectly too but im not sure why its not working on event hit
thats why i was thinking i might need to implement something different to the event hit so that it works on the server and the client
if i use the same code on the input action and put it in the event hit it only works for the clients but for the server it doesnt go ragdoll in the server screen
so i tried it with the server hitting both clients and the server only goes into ragdoll when it hits a second player/client like in the video
I'm not able to run events on server when they are called from Widgets? I need to do it trough Player Controller?
Here on button click I'm calling to the Building (actor that I want to be destroyed).
Inside Building I have event Cancel Construction.
Server of course can delete his building, but clients can't. I guess I just cannot call to rpc from widget? Or like the Building actor cannot call to server?
Not enough login credentials to launch all PIE instances, change editor settings
are anyone able to help me with this? Im not sure what exactly to do here. Im playing with 2clients with the server listen mode.
Fixed. Basically the event Run On Server must always be called from Owning Client, and I think that the engine doesn't treat Widget or Actor as Owning Client. I just moved the event to Player Controller and I'm sending in reference which building to destroy. Simple as that.
hey guys did a tutorial and was doing so well bu tlast hurdle, cant get any session to show up in my server broser any idea? it never seems to find any servers when i create them, its def not failing it seems to hit the for each loop and end , i guess it cos the results is 0?
Can OnRep be missed ? Or does the server send a call until noticed by client ?
are TOptional networkable in 5.4?
Clients will eventually get the value
They're supported by the engine iirc, so probably. Try it and see™️
UHT will whine if it's not supported
Hey
im getting access none on my player hud wb wich is created on the player controller and"works"
on clients. tiups :/ ?
oh wait mb
how to create Join and Host Server?
this question can't be answered in 300 lines of text
you have to watch tutorials how peoples are doing it.
Local listen server/join
Local dedicated server/join
Nat listen server/join || Custom master server
Nat dedicated server/join || Custom master server
Steam listen server/join
Steam dedicated server/join
Packaging Server || Seperate
Packaging Client || Seperate
Packaging Server/Client || Together
these are some core things you need to learn
also look at EOS, AWS etc
sometimes the players don`t spawn as they should, any ideea why this is happening?
try putting 2sec delay when spawning a new connected player
2 sec ain`t a bit to much?
start testing from 0.2sec
its annoying because sometimes my player gets spawned under the world
this means the player start is missing or at bad place
put player start with +100z on gound, let the player fall on ground
yeah i am doing that
still not all the time respecting what i have in here
it`s so annoying because sometimes my player still gets spawned badly afffff
i put them to spawn face to face
and sometimes they spawn almost in same place
if they spawned at same place, it means they are not getting the correct available player start
you should mark a player start to not be used if it was already used
yeah maybe you are right,
I addeed this and it seems to be working as it should now
Hello I want to make a lobby system in which I can invite other players and start the match. My game will have dedicated server so I wanted to know that can I use play as client in unreal engine for testing lobby
Also I want to know is it possible to make a lobby and test it by using play as client instead of play as listen server
I've come across an odd issue I've not seen before - I have some code to play a montage during an auto fire timer. Nothing new there; however, on the client everything looks normal. On the server, though, it waits to finish playing the montage completely before firing the next bit of code resulting in a very slow fire rate server side (where it matters). Has anyone seen this before or know where I can have it NOT do that?
debug your firing logic
I have and the only thing I notices is that the code fires normally if the montage call is not there. The issue is the server waiting for the montage to finish before executing code. I don't see anywhere where that should be the case.
It's almost like it's firing on the OnCompleted pin, when it's not.
that Fire Anim only calls on Server, how do you know it was called on other clients and it was working fine?
Checking from different net modes with 2 players in PIE, and that call comes from a multicast. On the client, it's all good...on the server, it's slow as it waits for the montage to finish first. Very odd behavior I've not seen before.
if the server is waiting, the clients will also wait, else something bad with your code
You'd think - but the client is not waiting. Just the replication layer and server. Again, if I remove the montage call completely, everything fires at speed and is all good. It's just the presence of the montage call that slow it down. Not sure if it's a bug, or what.
How did you call FireAnim? can you post the code?
you should call ServerFire if !Authority
the second mistake, you should not check for Authority in Multicast events
server calls multicast already on all clients
when you Fire: Checkif HasAuthority,
yes -> MulticastFire
no -> ServerFire
The MC fire event calls the Fire event - not the other way around. If I did as you suggest, no code would ever execute.
Even so, and I did try it, the code still waits on the montage to finish before firing again.
post new code
I even tried plugging in the montage directly to (tried both) the server fire call and the MC, and it still waits.
IGnoring all other variables.
you don't understand the concept of multiplayer replication, you need to watch this video to get learn
https://youtu.be/OhrijWnJdyE?t=116
Check out my Patreon: https://www.patreon.com/user?u=60713904 Join the {GDR}; Discord server and download my free project files: https://discord.gg/dUm3ZtYDuV
Buy me a coffee: https://ko-fi.com/bluntstuffy
Follow me on Twitter: https://twitter.com/BluntZombie
This tutorial is mostly about how to setup a multiplayer framework in Unreal Engine 5,...
if I use EOSPlus with Steam for crossplay, is it a requirement for the steam account to be linked with some sort of Epic account?
basically EOS without EAS
This multicast has an issue. NetMulticasts are broadcast to clients as far as I know. You're executing on the server only the multicast, but what about the server itself? You switch authority in the multicast after checking if locally controlled, meaning only the server player will execute fire on the multicast when you're trying to send it to all clients. From what it sounds like, none of your clients are playing the anim so they're not locking up like the server? My thoughts.
And anims will stack on top of each other if they have too many frames so if you're rapid fire then it won't play the next anim until the first one is done. I'm assuming you're using an animnotify for the bullet and effects?
Unless I'm wrong and there's a way to interrupt your anim using the fire function
I was able to identify the problem, and did remove some of the authority nodes as they were not needed. The issue lied in the fact that my CanFire macro was being called twice (elsewhere than what is shown) which was causing my montage issue. Once that was removed the code ran as expected.
Could someone please tell me why server player is returning false on is locally controlled?
despite being a player
where you calling the function
whats the best way to avoid using this delay?
Make it event-based
A character doesn't exist only locally, it exists on other machines that take part of the world
be more specific
Instead of relying on time, make it so that there is an event that is fired when your system is ready that you listen from UI
It's created on Possessed event of pawn that calls a client rpc to create widget. The client's pawn isn't spawning in time.
Listen for OnPossess event client side, and spawn the UI based on that
IIRC BP OnPossess is server-side only. C++ has AcknowledgePawnPossession, and it's called a bit differently in BPs
sorry i see IIRC alot but I dont know what that stands for
If I Recall Correctly
oh ok lol
Nothing multiplayer related 😄
anyway I've solved this before but would like to know the BEST way
I'm starting a new project than my main project
Listen for C++ AckPosession, and create all your stuff based on that. Alternatively you can create it from CH's BeginPlay when IsLocallyControlled
im not doing c++
Alternatively you can create it from CH's BeginPlay when IsLocallyControlled
But the best one is the former. It's a shame that it isn't exposed to BPs, it doesn't take anything. I personally don't see any limitation relatively to that
I typically have put the widgets on the controller but it shouldnt really matter right?
Im assuming CH means character
I know, but the server also have its own character and it is returning false
Because it's not locally controlled
Kinda, depends on the use case though
Correct
I see
so what can I do to run this code only run on the characters that each player controlls including the character of the server?
What do you mean by that? Do you understand what "controlled" mean?
Let me reword it
for my understanding, controlled means the actor that accepts your inputs
Exactly
So, I want to run this code on the actor that you control on your "copy" of the game
Are you familiar with terms simulated proxy and autonomous proxy?
Not really, I havent heard of it. But if I have to guess simulated proxy means the other actors that the server syncs with you