#multiplayer
1 messages · Page 715 of 1
when I want to create a widget I just forward it through a special ULocalMessage which orchestrate widget requests and then forwards them in order to the HUD class
could certainly skip the ULocalMessage step, but it's a nice handler when you want to broadcast a widget to everyone
ie: "x peep captured the flag"
smells to UT code, I know 🤣
Thanks for the suggestion
What is the most logical and easiest method for cheating protection? For example, if we write the codes in gamemode, how much are we protected?
if you are doing Listen Servers you are not protected at all unless you implement kernel level ACS
but on DC servers, everything processed in the server will be secure (101)
So what do you think I should do to be protected?
listen
okay listening, tell me
🤣 what a bad joke
what kind of game is it?
Coop vs PVE?
pvp?
like a game
bad joke
like a muck you can break a stone cut the wood fishing
There will be money, levels and items
very classic game
is there pvp in which money/levels and items influence the battle?
no
so mostly PvE
yes
is trading items a thing?
Maybe
well this is somehow an important question
because for PvE games without PvP factors... you really can get away with letting people ruining their own experience by cheating as long as it doesn't affect other players
your bets if you want to achieve a secure multiplayer environment is to try to integrate the easy anti cheat that comes with EOS
but that depends on what your budget and time is for that
we are only 3 developers and frankly we don't have a lot of money. how do you think easy anticheat. I've never used it before. do you think I could use it?
how would I add replication to the following blueprint to open door? I appreciate any help I could get, thank you.
Top image is door bp, bottom image is player bp
I am trying to play audio from a singleplayer menu and then have it persist into the multiplayer lobby. How would you do this?
Audio playing cross-map?
Yes exactly, i tried using level blueprint + gameinstance but it did not work
Or the persisting did work, but then the clients music would not stop when i called the Stop Audio function in the audio component
Probably because the audiocomponent would have been deleted with the world
And you'd have a different one.
Maybe
makes things much harder, so for starters, it's an unless.
Day 328, I find myself trapped on this endless, hellish landscape. Every turn brings a new dead end, to which this maze seems to have an infinite reserve of. Navigation seems impossible, as the architects apparently have a distaste for documenting the paths they craft.
Does the printed messages not tell you why it's not valid?
BeingDestroyed & PendingKill
crash dump was a little lacking in the memory dump department, but that's what I gathered
Are there any scenarios where an actor marked for destruction doesn't get removed via RouteRemoveNetworkActorToNodes()? Because it's still being replicated for some reason
Maybe it's being marked for kill in between that check and the replication?
I highly doubt that's possible, I don't destroy actors in the rep graph
Pretty sure replication is at end of frame too
No weird threading going on?
last ditch effort yea
but nobody else complains about it so, I have to be doing something wrong
and I don't wanna annoy Jambax lmao
Yes you do!
Are you doing anything specific with this class and replication?
Anything that isn't required
Don't think so 
I'm gonna build the server and attach a debugger directly to try and get more valid data
Are you sure it's the object that's causing the error, not a reference to it in another object?
pretty sure it's that actor since it's when it's trying to replicate it
Actor destruction isn't stopped by references anyway, it's being explicitly told to die via DestroyActor
From what we've gathered this crash occurs when a wounded player gives up
Which destroys em
I know, it should just invalidate the reference.
But you never know, something is wrong! 😄

Add some sort of breakpoint to the methods you've posted to see why it isn't being removed from replication.
that's what i'm gonna do
just gonna debug everything
that's like one of the last showstoppers we have for our next update
(╯°□°)╯︵ ┻━┻

do the RPC calls in the CMC have to be unreliable?
They should be yes
Cause most of them run per frame, which would fill the reliable buffer very quickly and break almost all other replication
Thank you
@thin stratus by the way, do you happen to have any sort of obscure tuts on the CMC? i can only find tuts for simple stuff
im trying to do a dash that interpolates the player position between 2 points but i can only find stuff with the launch function
No idea. Doubt. Last time I had to learn this I had to read through the CMC and do it myself.
oh boy...
It's also not very simple to do a dash in the CMC sadly
You'll have to extend the SavedMove stuff
To add your DashInput
my best guess is that i would need to set the flag and do the interpolation in the tickcomponent function, is that correct at all
?
And all Data needed for rollbacks
Yeah it's not only that
You have to also do the stuff where the CMC allows the client to replay moves on correction
Which requires the SavedMove to be extended
To hold the additional flag and all info required to reply the move
the tuts already have that thankfully im just not sure its enough
Otherwise, if a correction comes in, your dash is f'd
Last time I did that I kept a DashState struct around
With all info I needed
any chance u can share that code somewhere?
If you interpolate from "Start" to "End, you need to save those two values
Nope
Was for The Ascent iirc
And you also need to save how far you were with the interpolation each move
So that it can replay properly
i feel like ive bitten more than i can chew
Yeah it's not fun :D
Hm, I think a day + additional bug fixes later on?
Might be less by now
But I also had experience with the CMC
i have 0 experience
Yeah I mena that depends on you
You can start by reading through that one single wiki page that shows some of the code for extending the cmc
With SavedMoves
And work from there
im questioning my decisions right now, all of a sudden the corrections dont look so bad haha
:D
Higherping and dash spam will look really bad really fast :D
Lots of teleporting
i got that part down i think, the videos on youtube do a decent enough job of exmplaining what you need to override
and how it works
they dont explain however how everything works together, more like " override this for this"
will do
In the end it works like this:
- Client performs move locally, saves it into a List of Moves.
- Client sends Server all info to perform the Move (excluding what the Server has Authority over, like Speed) and the EndLocation.
- Server performs Move and compares EndLocation.
4.1. If Location is nearly the same, Server sends Acknowledge back, which the Client saves on the SavedMove (this is communicated via Timestamps)
4.2. If the Location is not the same, Server sends Correction with all information to get back to a "Clean" state. Location, Velocity, Rotation, etc.
4.2.1. Client will throw away all Saved Moves that are older than the Correction, apply the Correction, and replay all new SavedMoves instantly so you don't get teleported backwards.
That replay part is why you might need to save some extra info into the SavedMove for your Dash
im copy pasting that an putting it in a comment
On top of that comes a lot of Interpolation Code, that no one really cares about, as well as all the MovementMode stuff.
Depending on how your Dash works, it might be a different MovementMode
Or just part of an existing one
im under the impression that its not a diferent movement mode
e.g. PhysWalking
since all move is blocked and its just doing the dash
You need to be aware that PhysFalling and PhysWalking for example are different MovementModes
If you can dash in either of them, then a custom MovementMode sounds reasonable
If it's only on the Floor, then it's enough to use PhysWalking and overriding that
Or rather
Not overriding that, but you can override stuff like CalcVelocity
from what i understood those mess a lot with physics stuff
They don't actually
and im not even touching that
CMC doesn't support Physics
Phys is a shitty prefix
PhysWalking is basically what moves you along the floor
PhysFalling is what makes you fall and gives you some InAir controll
do u think i can get away with not messing with that?
Depends, there are a lot of different functions you can override
Sometimes it's enough to use a smaller one
Really depends on the implementation
its literaly just a set position on 2 interpolated points
Yeah but in the CMC you don't set location
You apply the offset
So it's LITERALLY not just that :D
I wouldn't
You usually calc the distance it should move in the current frame
aka Velocity (* DeltaTime)
can i do "StopMovementImediatly()" or whatever that functio nis called
Yes
That sets Velocity to 0
Your dash just needs 2 variables
EndPoint and Duration
ye but that is gonna feel weird for the player because its gonna break momentum
Yop
I think a good start is to simply override the CalcVelocity function, checking for if you are dashing or not. Calling super if not, and if yes, calcing the velocity based on Duration and Distance to EndPoint
Or rather Distance between Start and EndPoint
but thats is going to allow a change in direction midway no?
so i could do something like, set the dashing flag, and if its dashing i set the velocity to whatever i want and if its not i just dont set it
That's what I wrote, yes
Or rather, not "don't set it", but calling Super::CalcVelocity
So the normal code can run
is that gonna work with ramps tho?
Yes
Cause the PhysWalking handles the ramp already
But that's part of the " + addition bug fixes later "
You'll notice stuff when playing, that you might not have considered
E.g. Dashing off a Ramp
what did u run in to?
Which goes into PhysFalling
dashing off a ramp should be no issue for me
Uff, specific things. In TheAscent the Dash/Roll were calculating a value over time, which accumulated if you didn't actually move. So if you dashed into a Gate that you need to open, it would keep dashing until you open the door (cause you never reach the end value), but then something accumulated so much that if you open the door, you zoom off
Very specific bugs and fun to watch :P
haha
im gonna try and do that based on time maybe its easier no?
like dash for 0.2 seconds and then set the flag back to false
maybe i wont have to send the end position
Yeah, just think about what might need to be saved in the SavedMoves to replay it
from the net tuts the only thing that you do to the saved moves stuct is set the flag
so im assuming that its the same if ur doing it with time
Let's say you want to dash for 1 Second in total.
You dash .5 seconds and a correction happens.
The Client will be placed back to where the correction was, which was .25 seconds into the dash and replay the moves, which is .25 seconds worth of dashing. Your time that is already at 0.5 might now increase to .75 and your dash will end .25 seconds short
Something like that
It's a bit hard to explain
The dash time basically needs to be reset too then if a correction comes in
ok so theres a function called "getPredictiondata_client" in the tut that sets the maximum error
maybe if i increase that
those would stop?
That's not the solution
A correction can happen any time
Even without you changing a single lines of the cmc
Your dashing has to take that into account
i am assuming they will happen regardless, nothing is perfect, im just trying to get the thing working properly without having to lose like a week of my life
Yeah then you need to properly update the state of your dash
May it be "TimeDashed"
Or whatever it will be in the end
A Correction will replay all moves between correction timestamp and present time for the client
That means it will perform the dash again
If there is any state variable that is affected by this, it needs to either be excluded or reset back
i dont think there will be anything affected by the dash, hopefully there wont b
i mean variable wise
Then how do you know how long you still have to dash? :P
ur refering to gameplay state stuff right?
oh nvm
lol
can i hard code the timer in the cmc?
would that be an issue somehow?
You usually just make it a variable you can change in the Settings Outliner in BP
"HowLongToDash"
And then some additional variable that keeps track of "HowLongAmIDashingFor"
Where each Frame of dashing increase the value
Preferably somewhere in "PerformMovement" or so
(which is also a function in the CMC)
yes but if those are in the cmc i dont need to pass them around with rpcs and stuff and i dont have to put then in the saved state rigth?
Eh, they might not need to be send across the net
Not sure tbh
Might be that the Server has to send them to the client on a correction
Yus
tbh the dash is not looking so bad right now, i might have correction 1 in 10 atempts
so even if i fail, its not the end of the world
thanks again for the patience and info
No biggie. Take your time, it's really not easy and it's fine if you need a week (:
guys EOS does not have matchmaking like playfab or ? I am using eos for mp game in developing but I m not sure if Playfab were not better solution
#epic-online-services Ask here
sorry
Does anyone know a particularly good guide for replication? I am trying to make stuff and things aren't replicating how I expect and I can't seem to figure it out. Seems better to try and learn how replication works as a whole instead of asking how to replicate every little thing in my game.
Third and fourth pinned messages in this channel are a good starting point
Ah, I always forget about Discord's pinned messages. Thanks, I will check out those two first.
if i call a url, can i call a map on it ?
what gets instantiated first, gamestate or the level blueprint?
Does anyone have idea why client and server pawn not possing properly
#cpp message
ReplicatedUsing = OnRep_Func Do not fire on Standalone?
ow
Ok, so I am not sure as to how to explain this really but I need some help, I finally got my multiplayer transforming to work almost perfectly, however now it is just a problem with if a player leaves the net cull distance, and comes back in they are reset for the client, I have a bool with repnotify but it isnt staying synced going outside of the netcull distance, so is there a way to call it when the player reenters said distance?
You're only setting the bool server-side and it's replicated?
If so you shouldn't have to do anything - the client will spawn a new actor, and that actor will have the latest state of all replicated properties
RepNotifies will be called if the property differs from the default value
I have this and inside of the is transformed/ is human their respective thing is the second screenshot
Okay so first of all, clients should never change replicated properties
And those properties should only be set on the Authority. You shouldn't have a Multicast setting properties
Those bools are replicated but not ever changed on the Server
In C++ the RepNotifies wouldn't fire at all - but BP Rep Notifies are dumb and work differently
What's the actual goal here?
There is 5 character the player can transform to human and 4 others back and forth based off their chosen one, so I am trying to make it so the player can pick between them, and then transform to their selected character
The simplest thing to do is get rid of all those bools
And just replicate either a mesh reference directly, and set it from the OnRep, or replicate an ID that maps to a mesh somehow
And you only ever set the mesh property on the Server. By default it should be nothing
I do have a data table that I am using so I could add more later
That's fine, you can replicate data table row handles
In which case, I'd even just do that. Replicate a data table row handle, and use the repnotify to change the properties
Been looking into replication and I am understanding it better. My game now allows people to change their cosmetics in game and other players see these changes.
However, if someone joins mid session the changing room doors are set to default (open) so if someone is using it they don't see the door closed. Also any skins chosen by players aren't seen by the newly connected player, they just see the default.
What is the proper solution for this?
It's a stateful change, so it should use replicated properties not multicasts
Golden rule of Multiplayer in UE:
State = Properties, Transient Events = RPCs
join in progress will "just work" if you stick to that ethos
(RE @compact talon)
I see, I will try and look up replicating properties - haven't heard of it before. Thanks
@chrome bay mind if I pick your brain about the rep graph for a sec?
ye sure
I'm starting to despair
sec
this ^
For some reason it's trying to replicate an actor that's been called for destruction. Wouldn't said actor be removed from the nodes beforehand?
Hmm yeah, though I've definitely had cases where it breaks because RepGraph doesn't check for IsValid
I subbed a PR for one of them, it was the player controller view target in particular
Are there any edge cases where it doesn't remove an actor when it's destroyed? 
Yeah I fixed that one heh
This one's different 
I might just remove that ensure tbh
And just have it log to the output log
yeah, guess you'd have to track adds/removes and see why it's being re added
Might be an issue with dependant actors maybe
No luck with the breakpoints?
They should do I think
So, get rid of the multicast and the bools, then button push and they send their selected character to the onServer event that then sets the skeletal mesh? How do I replicate the mesh reference
Only happened during our last playtest
Was consistent though, odd it didn't happen to me
Like we repro'd it 5 times with players
Just mark it replicated, asset references can replicate
But if you have lots of properties being changed and they can all be looked up from a table entry, just replicate the table entry instead
And drive everything from that
Could we hop in a call?
cant atm srry
Should look something like this in Blueprint
Since it's Blueprint, the OnRep will be called Server-Side as well.
This should be pinned.
Alright hopefully this helps thanks a bunch
That setup will work with relevancy, join-in-progress, offline and online etc.
But you could just as easily replace the replicated "Mesh" value with a "Data Table Row Handle", and pull the mesh and whatever else from the data table
As a beginner, I think there's a tendency to rely on multicasts for pretty much everything.
hrm, do you have any examples of how to set it up? I tried setting my dynamic material variable to replicated hoping it would replicate it to other clients and maybe I have something setup but it doesnt replicate fully.
Yeah, I blame tutorials from newbs on youtube who have no idea
If it's a material asset it will replicate the reference
The blind leading the blind, huh?
Should I be doing a Multicast with "is dedicated server, false" for visual and audio effects? Or would that be best handled another way?
I see, it's a dynamic material instance as I want to set the parameters for the material to change the texture (skin).
Perhaps this is why it isn't working?
Yeah if it's a dynamic mat instance it won't work, they are locally created only
You gotta replicate the Params then
For cosmetics, you probably want the data-table approach again
Choose a table and a row-name, and pull the cosmetic parameters from that row
We do exactly that for our system in HLL
There's actually a flag on ufunctions that you can specify to say that this is a visuals/audio thing and shouldn't run on dedicated servers.
Except we only replicate the FName ID's since the tables are global, and we enforce the ID's to be short
I am using a data table, but perhaps I am not using it the proper way. I use it to get the list of selectable skins and if you choose one it pulls the cosmetic from the datatable row and applies it to the dynamic material texture parameter on the player character
That's fine, but what you want to do is replicate the "Data Table Row Handle" they have selected
And in the OnRep for that property, set the mesh, materials, params etc. there
I see, I think I am using the data table wrong then. I am just looping it and feeding the name/content of each row as text parameters into a widget
Couldn't say, but what we do just for example is we have three data tables, one for heads, one for body, one for helmets
And we replicate three FName's, which are just the row names for each table
A client tells the server what cosmetics they have selected by sending those FName's, Server validates their selection (checks entitlements, DLC etc.), then replicates it back to all clients
Then the OnRep looks up the data from each table, and applies it to the character
Interesting, how do you tell a datatable handle or param to replicate? Do you just make a variable of that type and hit "replicated"?
If you have more detailed character customisation, i.e. you want to change the colour of the face or something, you'd need to replicate the parameters and create + drive the materials locally
yeah
They support replication
We just use FNames since the tables are global, but in BP a table row handle is probably easiest
I see, my game is extremely simple and the only cosmetic option is a texture, you cant change name or anything so perhaps just replicating the parameter would be simpler for my solution.
Would that require me to recreate the dynamic material instance each time, as it is only local? I would need to remake it when another player connects
You just make it and cache it in the OnRep, then set the param to the texture
But assets will replicate as their full path name, just be aware
Not much of a problem if it's not changing often
Up to you how to approach it though, the general idea is the same
The reason we use table rows is because many params can be driven from that one value, and we can add/remove other properties later etc etc.
E.g you only have one texture now, what if later you want a texture and a colour etc.
E.g. "OrangeStriped" or "RedStriped", IDK
Yeah, the data table sounds like the best approach. This is my first game though so I am trying to keep it simple so I can learn the basics of making a multiplayer game, then on my second go I can make a more complicated one.
Thanks a bunch for the help
AFK for a bit
went the nuclear route, w/e
once I figure out why some actors don't get removed i'll revert that
Alright its real close now, only problem is I have to figure out how to stop it from transforming the player on clicking the character it is wanting. Other then that thanks a huge amount Jambax
hey folks is playerstate clientside only?
no it isn't, server+client
net compendium helps in these matters 😄
pf... you should write a book about rep graph
🤣 all the gotchas you went through...
you'll get my recommendation for sure

Thanks
Totally not inspired by benui

Github Pages doesn't exactly make me rich heh
- domain was 12 euros a year so I just grabbed it for 10
hey what's wrong with github pages 🥲
my blog is pretty ugly...
Meh, it works fine
If you want one character attached to another character (multiplayer game), is there a certain way to do that that's better? For example, one character will be picking another character up and throwing them. Is there some method that's better for handling that movement on the 'picked up' character where multiplayer replication is a concern?
how would I add replication to the following blueprint to open door? I appreciate any help I could get, thank you.
Door bp top, player bp bottom
Are you asking how to replicate the door actor movement?
Is there any kind of component conditional replication, and replication notification? I would want to replicate certain components only for some players and not the others
Is it a good idea to keep something like money shared between players on a game instance, or on a player controller?
By shared you mean, that more than one player have a certain "coin"?
Sorry, I'll clarify
Bcs. If you just want to implement money system, go for the player state
In my game, whenever you join another player's session, I want the host's money to be shared between all the clients
So you could use their money to buy stuff, if that makes sense
I would still go for the player state. Its the object that doesn't get destroyed then player enters another levels, character being destroyed etc.
I'll try that, thanks!
Anyway, I still need this
@blissful saffron yes replicate door opening movement from client to server
Why are you replicating an actor from the client to the server?
As for the notification, I don't know but I'm sure it's possible. But the replication to only certain players is very normal. There are several ways of doing this, just research how to conditionally replicate. There is a plugin called Replication Graph that handles this as well, which Fornite uses
Maybe I said it wrong, just basic replication based off that blueprint. @blissful saffron
u dont need to rly
unless u need smthn else for your doors
u can just have the client know that the door is opening from the server and have it run the logic locally
How would that look in blueprints? @eternal canyon
instead of replicating the rotation of the door have it send an RPC that says the door is opening
then the local client runs the door opening logic
at least that's what I assume mmmm means
Im just new to the blueprints so its hard to visualize. If you could explain the order of nodes thatd be cool. @nova wasp
Heya all - how is it going?
I've been diligently slamming away at a lot of my dev stuff and finally got to the point where I can begin working on NPCs once more. But I am running into a strange issue where my processes are working just fine on server side but not working on the client side - I wanted to see if anyone would be able to help me figure out what I fumbled on.
I have a simple process in place that does the following:
- On begin play for the parent class of the NPC - The process reads gameplay tags from an array, for each one it finds a matching row in a data table, pulls out the struct and saves it to an array. These structs hold some basic information, but most importantly a soft reference to a static mesh and a name variable (that corresponds with the component it is applied to)
- Once the array has been filled up, it uses a for-each loop to pull each struct and call a server side event
- This server side event immediately calls a multi-cast event
- This multicast event goes to the mesh of the NPC, looks for children components (I have static meshes attached to the NPCs hands), checks to see if the socket name (from the struct) matches the name of the static mesh component. If it does, I set my static mesh to the async-loaded mesh of provided in the struct (and set its visibility to true)
This process works perfectly on the server without an issue.
It does not fire or make changes on the client side at all. I did note that #1-2 both function on the client side and the counts match up.
Any thoughts on what may be having an issue with the equip process?
Doh... I figured it out, I forgot to set my child components to replicate
How would you suggest I go about handling one character whose ability picks up another character and throws it?
I guess just attaching the picked up character to a socket on my lifting character wouldn't be too bad
Not easy to do without getting a bunch of corrections. Look into playing root motion animation, and the animation needs to be played at the same time on server and clients. If you're using GAS it has nodes to help with network playing anim montage.
Hey @silent valley - sorry to bug you, you just mentioned some stuff with animations; and I am noticing something kind of bizarre on my stuff here.
In my editor, if I go and manually open my animations, click through them - whatever. My soft object reference calls to those animations work just fine in the gameplay part of the editor.
If I close my editor, reopen it, it will no longer recognize my soft objects when I am calling from my inputs
It is one of the wierdest things, and I noticed it in past projects that for whatever reason, soft object references seem to not want to trigger on its own without me loading them in some fashion completely unrelated to the game testing itself.
Yes this is a thing. Soft referenced objects must be loaded before use.
Hm, so is it an issue that I am not loading it soon enough?
How are you loading them?
I added a bunch of code that async loads assets during initial boot screen, but I think the better way to do it is via Primary Assets etc.
In my case - for the animation. It is part of a component's function. Once I grab the corresponding data I need, I am sending it to client side and server side functions. The server side calls a multicast (but excludes the original owner - so as to avoid doubling on the animation for the client)
I'm going to go on a limb and say that probably is not appropriate for a soft object reference huh? 😛
Well from experience you can't put hard refs in data tables, they will fail to package.
Somehow you need to make sure its loaded on server and clients before trying to use it.
Or have it as a hard ref on the pawn, etc
Hmm, so would the better approach be to have a client function, pass it as a soft reference, async load it, pass it to my play montage functions on both?
I don't know if that's better! It will take different amounts of time to load on clients and server, increasing out of sync.
You should load it way in advance of actually trying to use it.
Downside is, I have a lot of randomized animations to keep things very fluid and non-static. Not entirely sure if that would be good to load so many as is and let the game kind of bog down from it
You don't have much choice IMO!
For example, the first swing of a longsword could be 1 of 3 animations (currently), then the second swing would pick at random from a grouping of 2 or 3.
Hm..
I think you can set this kind of thing up via Montage too, but either way you gotta hard ref/preload your animations I think.
Just out of curiousity, how long to async loaded objects remain available - or is it until you specifically unload them?
im taking a guess no one will know this but im making a dedicated server for a already packaged game that i dont own, i got connection and all but the issue is that the NetGUID's are not matching so when i possess a pawn it kicks due to the NetGUID being brong so the bit reader and writer always returns null and idk how to get around this
Depends how you load them!
Unless you have the exact source code this won't work.
i know people that have done it before
they wont help of
ofc
i have the games C++ sdk
Hmm, well I figured to ask here. What if you have x number of classes that are c++ but inherited by blueprints for feeding defaults and parameters. And you want to initialize these both on listenserver and clients separately. You need to make sure a class is replicated before calling said init function on a client, how? Is there an OnReplicated() or any other way to do it? Delays aren't good, they work sometimes but if lag makes it fail it is not a good solution..
IDK the perfect way to initialize on client and server a sequence of objects that are inter-dependent.. I made my own "sequence" implementation which relies on fstrings saying what state I am at, and if the state is done, and what is next state.. to try spread things out over several frames.. But sometimes I want to wait for something to be 100% replicated..
Maybe I will add an array to fill with "check if this is valid before proceeding" references..
But as it is now I feel it has the "It works on my machine" syndrome...
My biggest problem might be that my machine is getting old and with 32GB ram and 8GB gfx ram I can't test well multiplayer..
Yeah this sounds like a very fragile system. Generally you would use the default values, and anything else should be replicated.
Yeah.. Some way of "well if this isn't ready yet, use this"
I can add lots of IsValid checks, it works sort of.. for some things..
I don't understand why you would need anything like this.
On server, spawn a replicated actor. Immediately call the init function to set initial state of various replicated vars. This ensures the replicated vars are setup before any replication to clients happens.
When the actor is replicated to clients, when BeginPlay is called you can assume all the replicated variables have been replicated to the client at that point.
Well, lets say you have criterias and upgrades, two objects, class Player_Criterias, and class Player_Upgrades
in those you have classes of type Criteria and type Upgrade
but you want to avoid replication, so you have the exact same set on both
later you have an object that wants to check if a criteria is true to enable something f.ex.
or if an upgrade is done..
That's just a fraction of the system but yeah IDK 🙂
"both" meaning clients and server
You can't assume other actors are valid though, even initially
@chrome bay I know..
Delays are by far the worst way to solve any race condition
@chrome bayI am looking for good ways to solve race conditions I guess 🙂
Literally writing an article about it now because I'm sick of people on YT saying "this is how we fix it"
The solution is you drive everything from on rep callbacks, and the code gracefully handles the cases where stuff isn't valid exactly like you initially said
How would I go about updating the location of my character which uses a character movement component when the character is possessing a different pawn such as a vehicle i want to update the characters location to the location of the vehicle seat. I tried attaching and that kinda works but it then completely fucks up the character movement component once the character leaves the vehicle. Character starts jittering and stuff. So what is a better way?
@void nest Unpossess the character, attach it to the vehicle, possess the vehicle
Inverse when leaving it
Yeah but i tried that
And turn off character movement when the character is "seated" or whatever
It still creates jitter when you reposses char
Shouldn't do
Mmm, one could make OnRep variables for initialization sequence too, then when "OnRep" kicks in.. at least you know the object itself is replicated..
To turn of char movement i use deactivate right?
Just build it right into your custom character movement
But that doesn't sound like the issue tbh, sounds like it's not detaching properly on one end or the other
PM me the link if you do.
wait do I have to detach on server + clients? That might be it. I only detached on server
I thought attach and detach was server replicated by default
no?
You'd need to attach the capsule
i attach the whole actor
And disable it's collision too, and make sure the movement component isn't applying gravity when seated etc
k ill have another look at it
Depending on your setup you could also just stay in control of the pawn. HLL vehicles work that way
UPROP(Replicated) AActor* ActorB;
bool bInit;
OnRep_ActorA()
{
TryInit();
}
OnRep_ActorB()
{
TryInit();
}
void TryInit()
{
if (!bInit && IsValid(A) && IsValid(B))
{
bInit = true;
// Stuff
}
}```
You handle it like that essentially
If you're talking about instance references that you're dependant on
Bit of a strange setup generally speaking though, if there's a permanent dependency between them all
Sort of makes sense if it's something like GameMode->GameState relationship
Ah looks nice. Yeah.. I need to rework the whole system I have..
I have lots of "AI" managers and global grid systems and whatnot that I need to make sure is initialized before the game starts..
If it's for things like managers, subsystems have some utility because you know they are "around" before any actors are spawned.
Then you can push out events when their network data actors are received
Yeah I guess I've ended up just making c++ actor classes for things that could be subsystems..
Nothing wrong with it at all, but if it's for managers I prefer to not store replicated references to them
And just have those actors/data be easily accessible from anywhere
The problem with keeping references is a) the extra replication cost and b) the general volatility of actors in network games
At least if everything is accessing an actor from one known place, it cuts down on the number of sources of race conditions
Ah, well the managers are called sometimes from server sometimes from client, server always overrules but, IDK.. f.ex. for upgrades, to start an upgrade a client might click on their interface to start an upgrade, then the server "manager" of upgrades (Player_Upgrades) gets noticed, and multicast a "start" to both client and server. Then when upgrade is complete, same..
Yeah, hence the upgrades themselves are spawned on client and server, no replication
But the manager class is replicated
And all possible upgrades and criterias are initialized on client and server separately, to avoid replication, you know the sequence is identical so you can use index and multicast
I suppose what I'm getting at is have the manager be replicated, but don't store replicated references to it all over the place - just have one global, easily-accessible getter
Mmm, yeah, I have "Player" everywhere hehe, but Player contains all the managers..
So an object would have a ref to Player, but get the managers from that..
Yeah I can't speak to your setup ofc, but generally I think trying to "get" an actor and handling it when it fails is nicer than storing multiple references, and it reduces the network overhead
Hey guys i am currently having a hard time figuring out how i can own the rifle that i spawn to my player. for some reason only the server is allowed to fire bullets from it. This is how i spawn my rifle:
Now when firing i have a function that calls the server and spawns a projectile however right now only the server actually spawns the projectile:
It seems that my client is not allowed to call the "run on server" event can anyone see what ive done wrong?
You cannot run server RPCs on actors you don't own, so you should route the "Fire" RPC through your PlayerController
So does this mean all my logic for firing my weapon should be in my player ?
No, but you'll need to route any Server RPC through it
You can keep the actual logic in the other actors
I have farms. Once when I was new to replication I had a replication of transforms for every plant.. Clogged up the network properly. Now I do things on server and clients separately, just a multicast to plant a new plant, but growing them is done separately, then when ripe only server picks and make resource packets from resulting crop..
So i call my weapon to fire -> The weapon calls the player controller again to spawn the projectile?
Why is Control possesing randomly ? and not most cases in some clients.
Your player or pawn should be the owner of the weapon
Then it'll work fine
No idea what you're passing in as the owner there
This happens on my player blueprint on begin play
Is it a replicated actor spawned only by the server?
Sorry for the noob quesiton but how do i know? 😄
If you don't know my guess is no
The rifle needs to be a replicated actor, and it should only be spawned by the server
Okay how do i do that? 😄
Look at cedrics compendium to get some ideas
Okay thank you i will look into it 😄
🤣
I've seen the other day a timer set at 0.1, waiting for some vars to replicate
🔫
I hate it so much
The source of endless trouble
Crappy YT tutorials with 500K views telling people to use delays and multicast everything 🔫 🔫 🔫 🔫 🔫 🔫 🔫 🔫
the world subsystem Idea is honestly pretty neat, before you've told me about that I was wiring everything through components 😂
tbf I do use components for some manager stuff still, I have a "TeamStateComponent" that lives on gamestate
i have no idea on why I haven't thought about subsystems before
But that's pretty easily accessible
You forgot "don't use Tick"
IKR
One measly blog post at a time, I shall reverse the damage
For people who cba to read anyway
MP in UE would be so much simpler if there wasn't so much terrible advice out there
the problem sometimes is that people copy stuff from the internet instead of trying to understand
To be honest I figure a single page doc of general good practice and common gotchas - use replication instead of RPC, don't assume timing, pay attention to ownership, rep event in C++ vs Blueprint - would help a lot
yeah, that's kinda what it's turned into now, just a best practices guide
Hopefully it helps a bit. Just taking time to cover everything
that's why I always finish my articles with this:
Right 😄
wdym I shouldn't delay and call a multicast in tick to update values
Honestly it's fair to say that there really is some really terrible advice out there
I helped a few friends out once, they had repeating timers set to values like 0.16667 because they heard Tick() was bad in online tutorials
sounds evident, but people forget about the basics
And now Youtube removed dislikes so that's gonna be even worse lol
Can I hang that somewhere
Even at work I get colleagues that are like 'this part is too slow' and.......... did you profile it? You didn't? Why are you talking to me
"Oh it wasn't that part actually" yeah no shit
I hope your workmates don't get to read this 😄
If they put a bit more effort into telling them what its bad for, what its good for, the users might be able to understand why one should not do getallactoraofclass on tick with a timeline, and a bunch of wastefull stuff
But that would require them to understand it themself i guess, and thats perhaps to much to hope for :p
I hope not my workmates read this, if so I would have to check my head. I am a solodev 😛
Can't go around having imaginatory work mates..
I made a research, but I couldn't find anything helpful
Can someone please provide an updated blueprint on how to make this door open work between all clients/server.?
Or explain how nodes in order?
You need NetMulticast event. It sends rpc call to all of the clients(call it from server). When you open the doors, send an NetMulticast RPC call to open the door on the clients, e.g. play the animation
Using multicast for that (as many others) is a terrible idea - replicate the openness of the door as a boolean, and have all clients animate it locally
If I may ask, why?
Many reasons: larger network traffic is someone spams open/close, missed event if someone joins after the door has changed state, and generally speaking it's fundamentally a state (the door is either closed or open) and not an event
ok, makes sense
For server-to-clients data you should always put replication as a first choice
Multicast is useful for things like do not involve state, like shot effects on a wall for example
That makes sense. Ive been digging deep on tutorials and it sounds like variable replication is the way to go. However.. my problem is im so new I cant visualize how that looks like on my blueprint
Definitley a me problem that I intend to keep working on, but if anyone can throw a bone and draw that out so I can visualize and from there expand
@obtuse field are you able to sketch that out if you get a moment? I appreciate any help ty
Set this on the variable
And you will get this function
It will fire whenever the variable is replicated
Okay, is this in the player character or the door blueprint?
door
So for onrep is door open what is the logic inside that function? I am sorry I am so new
just a regular open door function
you need to check if "IsDoorOpen" is true, then run open door, and then its false, close the door
I appreciate your help. I am still lost. I have my door bp logic with the timeline in it/ I cantt move that node into the onrep function
Is there a way to move a character that has movement component to a location (teleport) when the character is not possessed? So basically I want the server to move the character while it's not possessed. I tried all kinds of things but the character only seems to update its location when it is possessed, when its not possessed it just stays in place, even if the server tries to force it's location to somewhere else. How can I do this?
Like I want to disable the character movement component completely as there wasn't any so the actor can be freely moved by the server.
You can just set it's location like any other actor
@obtuse field where am I going wrong? haha I appreciate your patience
I know I'm not referencing the server or switch
honestly, idk. But first of all, you should somehow organise this code by thinks like collapse nodes etc.
Hello! I just started my first multiplayer project. I know that running a LAN game means one of the player computers will be a server and a player. But how does it work with true multiplayer over a wide network? DO I have to set up a dedicated computer somewhere for other people beyond my network to play?
But, I can see one thing. It seems that you are not calling this function
And to rep notify work, you need to set value from the server
Dumb question but all the information I can find regarding a simple button (press interact input when within trigger box to run event) use action events but I cannot call an action event on the button actor in multiplayer.
Is there any work around to do this within the button actor or do I need to do it inside the player controller?
okay @obtuse field, I called server here but still nothing
no, not here
on rep is called when you replicate the variable
in order to replicate the variable, you need to change its value on the server
@obtuse field ... am I getting closer?
Yes
But you still didn't update Angle on the server
You just set the relative rotation
okay, so thats my issue. How do I update angle on server?
You have this function. Its run on the server, right?
So you just set the value there, in the function that run on the server
yup
now, if you use console log on the on rep angle, you should see output
if you don't see it, make sure that server event is called properly
Gotta kick up the 4d3d3d3
What is wrong with random posses of pawn plz Need help took whole day still no clue.
your possess logic?
@void nest I removed the character movement component, I ended up making a copy of the character blueprint and make my own..
My characters are Colonists, they are totally standalone non-possessed and I have my own movement in making a spline path between points. I wish I had avoidance and stuff but they are so small in-game that noone would notice much..
So basically when a character/colonist is moving from building A to building B, a spline path is calculated with navmesh, if it fails a straight line is used, and voila.. Interpolate spline, minimal processing..
(it is an RTS type of game)
The navmesh MoveTo and all that, turned out too slow for me, I could end up with 1000s of colonists on a 3km x 3km map. I am still wondering if I should make my own pathfinding.. For now my game doesn't have land-units. All air-units and I made a pathfinding for that..
From what I can tell, AddControllerYawInput accepts a raw yaw value, so why am I getting different results with this:
const FRotator NewRot = GetControlRotationOnTarget(AttackComponent->GetLockedTarget());
OwnerPlayerController->SetControlRotation(NewRot);
vs this:
const FRotator NewRot = GetControlRotationOnTarget(AttackComponent->GetLockedTarget());
AddControllerYawInput(NewRot.Yaw);
?
I don't think SetControlRotation is naturally replicated right?
So If I call that on the client, then the server doesn't automatically see it
Well, one is Set, the other is Add.
Ah
very true
So I need to do some subtraction to figure out how much I should really be adding
cool
@lime leaf found another way. I just leave the character where it is and just set the location of the mesh only, then we it gets repossesed i can update the actual actor to the new location. Works well enough for what i need
@obtuse field I deleted the relativerotation because it was in the on rep notify function, still though the same issue. clients and server can open the door but client to server I cannot see the change
Working on the overall game flow of a match right now, and I keep finding myself moving pretty much everything from the GameMode into the GameState. What are some examples of things you guys leave in the GameMode itself? I was thinking of the match state (within the InProgress state I have my own mini-state machine of countdown timer, in progress, completed, where I want play enabled in all three of these), but player UIs should reflect that so I moved it the GameState instead to replicate. I'm having trouble thinking of things that are important to the flow of the match that players won't need replicated down at some poine.
point*
I would suggest you to look at the source code of both classes and see the use differences by yourself
I like to have logic in Gamemode but public data in GameState
They really shoulda called GameMode GameController
GameController/GameState
PlayerController/PlayerState
Would you like to jump on the call in about 40 min?
I think it would be more convenient to help that way
what time is it.. Ill do anything to get this working haha
@obtuse field yes id def jump on the call. I havent been on a call before
Why is my Unreal whining that NavMesh needs to be rebuilt, but only in multiplayer?
@jovial pike Ok, so we can go on feedback and support
HiveMind, if you have a couple of minutes, I'd love to pick your brain as well about something really quick after you finish with them. If you don't have time or don't want to then that's ok too.
question with NetUpdateFrequency. if i reduce this value to 1, will the server check and see if the replicated properties of this actor have changed 1 time a second or does it only send out an update once a second?
The number is how many times it checks each second, that is correct.
roger thank you!
next time, just mention me
And write your question first, If you would do it, I could answer it now
But I can't :d
i'm confused by something. i feel like this was supposed to work
but it doesn't. i thought since im calling that event in the gamestate from the serverside player controller, the multicast should work, but it doesnt
does it not call it in the serverside gamestate?
@obtuse field I Figured it out with your help! Thank you so much again. For those in need of replicated door- heres my solution:
How awkward, "if owning client" only owning client is allowed to make an RPC call to the server for said class? How can I call the server to set a counter, from a caller that doesn't own the object in question with the variable..
I need the client1 to tell player which it doesn't own to increase the value, it just doesn't get called the RPC since the client isn't owning client..
Client1 doesn't own player 0..
I feel dumb 🙂
Hi, im having this issue where my players cant move all the players log says is "CreateSavedMove: Hit limit of 96 saved moves (timing out or very bad ping?)", can anyone help me?
You'd need to rework your logic so that the Client asking the server is doing so on one of their owned classes (usually their Player Controller, PlayerState or controlled Pawn/Character) and once running on the server, you can then move to whatever object you want to manipulate values.
Tried both change spawn input and posses option
Pretty quick question - how can you make an entire cpp & header file not compile for the client, and only the dedicated server build? I want some files completely server-side (MySQL for example) with no build traces whatsoever on the compiled client build
Should be a dedicated macro for that
WITH_SERVER_CODE IIRC
huh.. I've always used UE_SERVER - I wonder if there's a difference?
ah.. so WITH_SERVER_CODE means it also gets built into Game build if you make one of those I guess, and Editor
// WITH_SERVER_CODE is all builds except client only.
#if WITH_SERVER_CODE
but yeh in your usecase I think you want UE_SERVER
Hello everyone,
I hope this is the right channel to ask:
I can't get Lyra to work on a local network. Has anyone done it yet?
I have 2 computers connected using a router.
I can start a game from one PC and see it from the other, but can't join it. It either loads indefinitely or goes back to the main menu directly.
Logs look like that
[2022.05.17-07.51.42:179][ 49]LogCommonSession: OnFindSessionsComplete(bWasSuccessful: true)
[2022.05.17-07.51.42:179][ 49]LogCommonSession: Found session (UserId: DESKTOP-E66, UserName: DESKTOP-E66, NumOpenPrivConns: 0, NumOpenPubConns: 15, Ping: 16 ms
[...]
[2022.05.17-07.51.42:962][ 95]LogOnlineSession: Warning: OSS: Invalid session info for session GameSession in GetResolvedConnectString()
[2022.05.17-07.51.42:962][ 95]LogCommonSession: Error: InternalTravelToSession(Impossible d'arriver à la session.)
Hello,
could anyone please explain me why this happens:
there is a setup: Dedicated Server/Client1/Client2
On client1 I check if it is locally controlled or not. If it is, then I try to run some code. In a PlayerState class I check the LocalRole and it returns Simulated. I expected to get Autonomous because it is locally controlled
Now I am just confused.
What am I missing here?
Autonomous is specifically for player controllers / pawn, IIRC
So, player states are always gonna be Authorative/Simulated?
Pretty sure yeah, like most actors
ok got it thanks.
you could set it from OnRep_PlayerState in the PC
but its kinda pointless, as client condition for LocallyControlled PS is GetOwner() != nullptr
Hi how do you use casting in multiplayer?
I want to cast to another pawn on another client from one client
There's nothing special about casting in MP, works exactly the same
"Cast" in programming means "I have an object of type Parent, but I know it's actually of type Child, and thus I want to access Child properties on it"
So it's unrelated to multiplayer entirely and "casting from a client" doesn't make much sense
Oh okay thanks
Thanks
is there any simple way to filter bits/second instead of per net instance in net insights?
i feel per second is more insightful and readable 😅
I think I am lacking some fundamental understanding again.
What I am trying to achieve is having a UI widget, that displays me stuff from all clients simultaneously, and I want it at the same position.
So player 1 stuff I want on the bottom left (just an example) and player 2 stuff I want next to it, but it should be the same for all players.
Now for testing purposes I am trying to fetch some info from the playerstate.
In my case I get the first player state and log the player id to a text widget.
Now the problem is, for each client the first player state is someone else (themselves), and not the same for all of them.
Even if I go through the game state and the player array list and fetch the first state there, I get a different one for each client.
How can I achieve to get the same no matter who looks into it?
Sorry ifthis is a basic question, im trying to learn multiplayer rn.
But how come when I spawn a 2nd+ player the listen server (or player0) becomes unpossessed
Im just using this instead of player starts since i understand it more and am checking overlaps before spawning at one of a few locations
(This is all running in the gamemode)
In general if you need to replicate 2 variables down when initializing an object, say an enum and a character pointer, is it worth just putting them into a struct and replicating that down?
Just prevents rare race conditions where one gets down first (mostly doesn't matter) but I'm not sure if I'm overdoing it by constantly making new structs for these scenarios
Aren't struct members replicated independently anyway? Hasn't done replication in a while
So that'd work if you need specific properties to replicate at the same time
Fair enough!
They can, AFAIK
There's an Atomic meta on structs
Ah ha.
Supposedly that ensures atomicity
Yeah even in cases where I don't necessarily need them down at the exact same time I've been wrapping into a single replicated struct rather than passing 3 separate vars and them each being replicated down separately
Not for bandwidth reasons just to keep things cleaner- this package of replicated data is here!
Maybe it's overkill but as long as there isn't a large downside to doing this, I'll probably continue
Not really, you might be sending more data than you need sometimes but if you really need all of it at the same time it's fine I guess
As an example it might be passing a pickup type, pickup cost and pickup rarity into a pickup actor
Each could be separate replicated vars on the pickup actor
But it feels nicer to have them as part of a struct
Haven't seen enough similar examples to see what most people would do in a similar situation
There are a lot of cases like that where I'm initializing a generic actor with data driven stuff
And usually I pack that data into a struct rather than individual vars
And it's not static data like from a data asset but stuff calculated at runtime (like the cost would change based on the state of the game, the rarity would be influenced by a random roll etc.)
DataAsset?
Could work as well ^-^
If it's got set values of course
What you can do, if you want them separately, is use onreps to check if each of them have been replicated before triggering your stuff.
Doesn't really help if you want them from an outside source, though.
Sounds like a hassle tbh
Unless your struct fields are gonna be containing a lot of data
and profiling points towards them becoming an issue
As mentioned in the bottom line, it's mostly data created at runtime based on the state of the game
Yeah that does seem like a much bigger hassle (and more error prone) than just packing them into a single struct (But I wonder if people do it this way over a struct?)
More useful for checking things like player states have been replicated, for sure.
Mmm yeah! There are some tricky race conditions over init stuff and I hate calling the same func in 2 places
But it can be unavoidable in situations like that
Where the PS is down before begin play for some players and not for others
If you change properties in the same network frame they should arrive at the same time.
Structs don't replicate atomically unless you implement NetSerialize for them
But since you have a pointer, it doesn't matter anyway - no guarantee the character will be valid when it's first received
Even if the props you changed arrive at the same time though, doesn't guarantee the entire state of the struct is up-to-date. Packet loss/order means you can easily get into a state client-side that never existed server side.
Only way to bypass that is force it to be atomic
And press F for bandwidth
I've ran into many cases where one of the two would come down later (this is in PIE simulating packet loss at 5% though)
The nice thing about using structs to pack replicated data together is that it's guaranteed to come down together
structs are no different to other actors properties
they even get "unfolded" into their internal properties if they are direct members
I guess it's just even convenience at the point then, it's nice to init a pickup with a single struct rather than passing in multiple properties that each set individual replicated properties
Or would you approach it differently?
Say in the example where you are initing a pickup cost, rarity, and type
Store the enum on the pickup itself
It's a generic pickup that gets populated with data at runtime
Rather than having unique actors for 500+ pickup types
That's fine - just replicate the enum
Don't replicate a pointer to it and the enum elsewhere, it has no benefit
And introduces a race condition
Sorry if I'm misunderstanding but basically the pickup itself is replicated and I'm asking whether I replicate the rarity (enum), cost (int32) and type (pointer) separately or as a single replicated struct
Generated
Haven't seen many example patterns to take influence from
But as far as I can see the struct just nicely packs it together
Is the pointer to a runtime instance or a fixed one/asset?
Rather than passing individual properties that set lots of other individual replicated properties
Fixed
That'll be fine then
Cool so if you were designing this pickup logic you'd just have all the init logic in a single replicated struct?
Or would you pass all separately to separate replicated properties?
I'd do one struct, and have an OnRep that initializes it when received
Perfect good to know that's a viable approach!
For good measure, I'd probably force it to be atomic with NetSerialize too
Is there docs on this atomic stuff?
Unless for some reason you would reinitialize it later
I had thought that it replicates only changed properties not the entire struct again
It does by default yeah
If you define a custom NetSerialize, whatever you write is sent each time
So by default say I had a struct with 100 uint8's, if I was to change one of those ints, all 100 would re-replicate down?
Yeah
Yikes
Ok that's good
With NetSerialize, everything you write is sent - which is likely the full struct.
Since you know this struct always changes all of it's properties at once, and they must all be received at once, NetSerialize probably makes sense
Also saves the cost of property headers
Ah I see!
(2 bytes each)
This is what I meant by being replicated independently!
Yeah
Since I always have undefault defaults (so all would be changed when initing the struct) would this behavior happen without me writing custom NetSerialize logic?
Structs use delta replication, even structs contained in arrays
As I have no idea how to even do that
@grizzled stirrup In theory yes, because you changed all the properties in the same network frame
Good stuff thanks!
And AFAIK actor updates should not be split into separate bunches
I guess unless you somehow exceed the max bunch size
Whatever that is
But it would be identical to having 2 separate replicated properties that were both changed on the same frame? I had thought that packing into a struct could avoid one of the props coming late due to packet loss
No it doesn't prevent that
Ok good to know
even if you did you should configure it to be larger then, or reduce the size, not split it
yeah
So in theory if I set all props once on a struct in the same network frame, and one of the props arrives late due to packet loss, the OnRep_SomeStruct func could be called multiple times on a client?
Even FFastArraySerializer can delta-serialize it's array elements now
But the packets are bit larger I've found due to the extra stuff written by it
None of the props will arrive later if you do that
A change made in same network frame will be received at the same time
Ok thanks! I swear I did the same for individual replicated props with one OnRep arriving a few frames later (and had thought that by moving to a single OnRep for the struct it solves that)
But OnReps obviously will be called in whatever arbitrary order
The only case I think that can happen is if you exceeded the max partial bunch size for an actor channel
Which I guess could happen if you had a lot of components, RPCs, properties etc in one frame
In my mind it was that the packet loss caused one OnRep to be dropped but with the single struct OnRep it either all comes down or it doesn't
But either way, USTRUCT() doesn't guarantee they'd be sent together because of how they are unfolded
But in general I think if properties are meant to be used/serialized together, it's good to put them in a struct either way. More of a design thing than anything though
Plus makes it easier to make it atomic later if you wanted to
Good to know that's the way!
I thought that I may be overdoing it
As whenever I'm initializing something that is generic that is inited at runtime
I've been converting that data to a struct
Even if it's only 2-3 variables
Just feels cleaner
Yeah seems fine to me
Thanks for the help!
From that article:
Another guarantee is that, on a frame when an actor is replicated, all of it’s changed properties will be sent at once, and the client should receive and apply these changes within a single frame (with the exception of unmapped properties).
unmapped properties I think is referring to object references ofc
e.g. if they aren't there yet
Would be interesting to see what happens if you exceed the bunch size though... maybe it just stalls forever
Oh
So that answers a question of mine - when an actor is first replicated, all of its properties are also guaranteed to be replicated!
yeah that's a garauntee
But they won't be read-in in the very early phases, like constructor or PostInitComps
What's a good way to update Player State from Game State (I'm getting Player State Array, looping it, and calling an event inside Player State to update the value), but then when I'm calling another event in Game State the value wasn't updated... (UE5)
alo, someone?
Is there a simple way to tag and mask events sent by a client that are then rebroadcast to all clients after verification?
For example, I want to play OnHit VFX on a client as soon as it predicts it hit something. Then I want everyone else EXCEPT that client to play the same VFX once the server verifies and broadcasts it.
I'm not sure how to prevent the sending client from doing the same VFX twice for the event it initiated / predicted.
On what machines is the hit happening? Client+Server or Client+Server+all others?
Is this for a melee hit or physics or a line trace or what?
I think it will be happening on Client + Server. I'm building some interop between GAS and a custom destruction system.
GAS already has gameplaycues
Oh yeah, I remember seeing something about cues some months ago. I'll see if that can solve my problem.
Thanks for the reminder!
Looks like exactly what you're after
Awesome. I should have guessed GAS would have something to handle this. I've been away from GAS for a few months while I built the destruction system.
Thanks for sharing
is anyone here using dedicated server with eos or steam subsystem ?
Prolly 100+ people.
what is the earliest time I can spawn the ui on a connecting client, if i need the controller, pawn, and player state to all be valid? I know controller is created first, but it seems like the pawn and playerstate can spawn in a random order?
Wait for them to BeginPlay() on the client perhaps.
Hello, I'm trying to create a lobby for a multiplayer game. So I have the typical menu/lobby/game pattern. But I have a problem when switch players from lobby to game, I use this blueprint (Start Game is linked to a button for the host in the lobby) but when I start the game, nothing happend (I only have my debug message)
in BeginPlay on the controller, the pawn is not spawned yet. In BeginPlay on the Character and PlayerState, it seems random whether the other one is initialized, not sure if there's a set order there or its a race condition
No set order, one can come before the other since both need to replicate from the server
So it's up to you to wait for both to be ready
okay
take this @vivid seal
hook calls in:
void APPPlayerController::OnRep_Pawn()
{
Super::OnRep_Pawn();
if (UNPPWorldEventManager* WEM = UNPPWorldEventManager::Get(this))
{
WEM->NotifyReceivePawn(GetPawn());
}
}
and:
void APPPlayerController::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
if (UNPPWorldEventManager* WEM = UNPPWorldEventManager::Get(this))
{
WEM->NotifyReceivePlayerState(PlayerState);
}
}
Well, you can get that value you want to display on other clients screen via the OnRep(considering that id property in PlayerState is ReplicatedUsing)
then on BeginPlay u can do:
UNPPWorldEventManager::NetReadyExecute(this, FSimpleMulticastDelegate::FDelegate::CreateUObject(this, &AHud::CreateUIOrWhatever));
Because controllers can't possess more than one pawn at the same time. So whenever you possess the newly spawned pawn, the one who was possessed with the relevant player controller, becomes unpossessed
Finally there's a solution to all this mess!
James will post soon something about this
because initialization is such a mess in multiplayer
You and James are true heroes
Hello, I'm getting a EXCEPTION_ACCESS_VIOLATION error when I try to access replicated values from my attribute set which is attached to my characters. Anyone have an idea what might be causing this? ... I'm doing this the standard recommended way, e.g: AttributeSet->GetMoveSpeed() , UPROPERTY(BlueprintReadOnly, Category = "Movement", ReplicatedUsing = OnRep_MoveSpeed) FGameplayAttributeData MoveSpeed; ATTRIBUTE_ACCESSORS(UMainAttributeSet, MoveSpeed)
yes but noone can give me tip here uh 😄
tbf, there's a specific help section for online subsystems like steam
i just cant find docs or something for dedicated server how to make sessions there... 😄
Is your attribute set valid?
Yes, I'm guessing it has not been initialized yet on the client, is there a way to check this?
I don't know much about Eos or steam. But simply ask an actual question and someone will answer
Where is it created
sorry, doorbell, brb
This is kinda tangentially related to multiplayer, but maybe someone here could help: I'm doing 2d arrays with arrays of structs (thanks ue) and passing them to the client. But making a new struct to hold an array:
I've created a new struct. I go to make a variable of that struct, but it doesn't appear. I've saved/compiled everything involved. I restarted, saw the struct as an option in the variable, but when I chose it the variable didn't change type and the option vanished.
Have you confirmed you're not hot reloading?
blueprint only atm
The struct is in BP?
I'm creating it in my character class constructor: AttributeSet = CreateDefaultSubobject<UMainAttributeSet>(TEXT("AttributeSet")); AbilitySystemComponent->AddAttributeSetSubobject(AttributeSet);
ye
Hmm. Strange
yeah... I was wondering if there was some strange naming conflict
I've had this twice now
because I'm basically doing a naughty
Do you need to do the second function? I thought the ASC detects it automatically
DisplayChunkArray (the struct) containing DisplayChunkArray(an array)
I also tried AbilitySystemComponent->GetSpawnedAttributes_Mutable().AddUnique(AttributeSet); among other things on initializing ASC. To be honest I'm trying everything, so just throwing the kitchen sink at it
just saw I can update/verify I'll try that
This shouldn't be much of a problem.
yeah I didn't think so
but this thing has happened 2x now
so yeah
somethings fuxxed
I only added this after it started crashing
thanks tho ozy
Did you set the attribute set Replicated?
Any 1 with experience messing with the character movement component that can give me a hand?
What's the question
well, im just absolutely lost
i dont even know what could be wrong
no I did not
basicly i wrote some code and its not working and i have no idea why
Hmm. Actually I don't think you need to.
I can try, just a minute
What's the code.
Shivers
Alright.
can you mention at least what is that that you are trying to achieve?
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
im trying to make a properly replicated dash
with prediction and all that jazz
im overriding "calcVelocity" in the CMC
anda passing my vector and a dash bool
ah, my tip for this is take a look at UT, they have two styles of dashes 😄
i already did
you'll learn in your knowledge trip
suposedly the video tut that i was following is using code from UT
the thing is, the video tut is not very good
I mean.... look at the source code of UT yourself, as I suggested
and the only other tut uses basicly the same code as the video tut
I can't tell what is wrong from what you've sent
Did the dash not work, or is there rubberbanding
didnt move at all
You could read it?
a bit
well it doesnt get reset but it should at least work once no?
im just testing
Lol. I hard a hard time so I just skimmed through
the cmc has no constructor so im not doing anything there, i was just "fishing" for movement
if that makes sense
You have a constructor
i was just initializing in the .h
otherwise there are high chances it will be 0.f or trash
It's there. I saw it.
set it to 2.f
imma test with 1 now see if anything moves
and try again
value in single player implementation was 0.2
that's the amount of time you'll be dashing
yes i know
ah oki :3
o ye it moves
haha
its just a bit crazy
well at least i got movement
thats progress
hahaha
the cmc is quite complicated, i have not fully grasped how it works yet
the code btw looks all right
but yes, CMC is very complicated
so you must be proud you got something working on it!
indeed
now try to understand what you are doing
i was expecting to take like a week
Perhaps the most complicated in the game framework
otherwise it'd be pointless
the thing is, they really didnt make it easy for the "end user" to extend the class because of how you have to pass info around
its just very messy and verbose
Yeah the class is a mess imo.
if they at least didnt make it so verbose

