#multiplayer

1 messages · Page 715 of 1

chrome bay
#

Use the HUD to manage widgets, don't just spawn them arbitrarily

#

Or you'll end up with an unmanageable UI when it starts getting more complicated

pallid mesa
#

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 🤣

atomic barn
proud galleon
#

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?

pallid mesa
#

but on DC servers, everything processed in the server will be secure (101)

proud galleon
pallid mesa
#

what's your model?

#

or game about?

#

does it run in dc servers or listen servers?

proud galleon
pallid mesa
#

okay listening, tell me

#

🤣 what a bad joke

#

what kind of game is it?

#

Coop vs PVE?

#

pvp?

proud galleon
#

bad joke

#

like a muck you can break a stone cut the wood fishing

#

There will be money, levels and items

#

very classic game

pallid mesa
#

is there pvp in which money/levels and items influence the battle?

proud galleon
#

no

pallid mesa
#

so mostly PvE

proud galleon
#

yes

pallid mesa
#

is trading items a thing?

proud galleon
#

Maybe

pallid mesa
#

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

proud galleon
jovial pike
#

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

past seal
#

I am trying to play audio from a singleplayer menu and then have it persist into the multiplayer lobby. How would you do this?

latent heart
#

Audio playing cross-map?

past seal
#

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

latent heart
#

Probably because the audiocomponent would have been deleted with the world

#

And you'd have a different one.

#

Maybe

pallid mesa
#

makes things much harder, so for starters, it's an unless.

solar stirrup
#

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.

latent heart
#

Does the printed messages not tell you why it's not valid?

solar stirrup
#

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

latent heart
#

Maybe it's being marked for kill in between that check and the replication?

solar stirrup
#

I highly doubt that's possible, I don't destroy actors in the rep graph

#

Pretty sure replication is at end of frame too

latent heart
#

No weird threading going on?

solar stirrup
#

Nop

#

Well, I really hope not lmao

#

But not in my code at least

latent heart
#

Probably not then.

#

Edit the engine code and fix it? 😄

solar stirrup
#

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

latent heart
#

Yes you do!

#

Are you doing anything specific with this class and replication?

#

Anything that isn't required

solar stirrup
#

Don't think so thonk

#

I'm gonna build the server and attach a debugger directly to try and get more valid data

latent heart
#

Are you sure it's the object that's causing the error, not a reference to it in another object?

solar stirrup
#

pretty sure it's that actor since it's when it's trying to replicate it

latent heart
#

Are there references to it anywhere?

#

When and what is causing it to be destroyed?

solar stirrup
#

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

latent heart
#

I know, it should just invalidate the reference.

#

But you never know, something is wrong! 😄

solar stirrup
latent heart
#

Add some sort of breakpoint to the methods you've posted to see why it isn't being removed from replication.

solar stirrup
#

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

#

(╯°□°)╯︵ ┻━┻

latent heart
#

😦

#

Good luck!

solar stirrup
limber gyro
#

do the RPC calls in the CMC have to be unreliable?

thin stratus
#

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

limber gyro
#

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

thin stratus
#

No idea. Doubt. Last time I had to learn this I had to read through the CMC and do it myself.

limber gyro
#

oh boy...

thin stratus
#

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

limber gyro
#

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

#

?

thin stratus
#

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

limber gyro
#

the tuts already have that thankfully im just not sure its enough

thin stratus
#

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

limber gyro
#

any chance u can share that code somewhere?

thin stratus
#

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

limber gyro
#

i feel like ive bitten more than i can chew

thin stratus
#

Yeah it's not fun :D

limber gyro
#

how long did it take u?

#

just out of curiosity

thin stratus
#

Hm, I think a day + additional bug fixes later on?

#

Might be less by now

#

But I also had experience with the CMC

limber gyro
#

i have 0 experience

thin stratus
#

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

limber gyro
#

im questioning my decisions right now, all of a sudden the corrections dont look so bad haha

thin stratus
#

:D

#

Higherping and dash spam will look really bad really fast :D

#

Lots of teleporting

limber gyro
#

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"

thin stratus
#

If you want to learn it properly, start at TickComponent

#

And explore all paths

limber gyro
#

will do

thin stratus
#

In the end it works like this:

  1. Client performs move locally, saves it into a List of Moves.
  2. Client sends Server all info to perform the Move (excluding what the Server has Authority over, like Speed) and the EndLocation.
  3. 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

limber gyro
#

im copy pasting that an putting it in a comment

thin stratus
#

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

limber gyro
#

im under the impression that its not a diferent movement mode

thin stratus
#

e.g. PhysWalking

limber gyro
#

since all move is blocked and its just doing the dash

thin stratus
#

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

limber gyro
#

from what i understood those mess a lot with physics stuff

thin stratus
#

They don't actually

limber gyro
#

and im not even touching that

thin stratus
#

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

limber gyro
#

do u think i can get away with not messing with that?

thin stratus
#

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

limber gyro
#

its literaly just a set position on 2 interpolated points

thin stratus
#

Yeah but in the CMC you don't set location

#

You apply the offset

#

So it's LITERALLY not just that :D

limber gyro
#

so i cant do set position in the cmc?

#

oh god

thin stratus
#

I wouldn't

#

You usually calc the distance it should move in the current frame

#

aka Velocity (* DeltaTime)

limber gyro
#

can i do "StopMovementImediatly()" or whatever that functio nis called

thin stratus
#

Yes

#

That sets Velocity to 0

#

Your dash just needs 2 variables

#

EndPoint and Duration

limber gyro
#

ye but that is gonna feel weird for the player because its gonna break momentum

thin stratus
#

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

limber gyro
#

but thats is going to allow a change in direction midway no?

thin stratus
#

You are overriding CalcVelocity

#

So that's up to you

limber gyro
#

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

thin stratus
#

That's what I wrote, yes

#

Or rather, not "don't set it", but calling Super::CalcVelocity

#

So the normal code can run

limber gyro
#

is that gonna work with ramps tho?

thin stratus
#

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

limber gyro
#

what did u run in to?

thin stratus
#

Which goes into PhysFalling

limber gyro
#

dashing off a ramp should be no issue for me

thin stratus
# limber gyro what did u run in to?

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

limber gyro
#

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

thin stratus
#

Yeah, just think about what might need to be saved in the SavedMoves to replay it

limber gyro
#

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

thin stratus
#

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

limber gyro
#

ok so theres a function called "getPredictiondata_client" in the tut that sets the maximum error

#

maybe if i increase that

#

those would stop?

thin stratus
#

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

limber gyro
#

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

thin stratus
#

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

limber gyro
#

i dont think there will be anything affected by the dash, hopefully there wont b

#

i mean variable wise

thin stratus
#

Then how do you know how long you still have to dash? :P

limber gyro
#

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?

thin stratus
#

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)

limber gyro
#

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?

thin stratus
#

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

limber gyro
#

im gonna give it a shoot

#

see what comes out of it

thin stratus
#

Yus

limber gyro
#

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

thin stratus
#

No biggie. Take your time, it's really not easy and it's fine if you need a week (:

real ridge
#

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

thin stratus
real ridge
#

sorry

compact talon
#

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.

fathom aspen
compact talon
#

Ah, I always forget about Discord's pinned messages. Thanks, I will check out those two first.

harsh wigeon
#

if i call a url, can i call a map on it ?

past seal
#

what gets instantiated first, gamestate or the level blueprint?

burnt tundra
#

Does anyone have idea why client and server pawn not possing properly
#cpp message

ancient adder
#

ReplicatedUsing = OnRep_Func Do not fire on Standalone?

latent heart
#

In c++, nope.

#

In BP, yes.

ancient adder
#

ow

elfin hinge
#

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?

chrome bay
#

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

elfin hinge
#

I have this and inside of the is transformed/ is human their respective thing is the second screenshot

chrome bay
#

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?

elfin hinge
#

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

chrome bay
#

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

elfin hinge
#

I do have a data table that I am using so I could add more later

chrome bay
#

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

compact talon
#

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?

chrome bay
#

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)

compact talon
#

I see, I will try and look up replicating properties - haven't heard of it before. Thanks

solar stirrup
#

@chrome bay mind if I pick your brain about the rep graph for a sec?

chrome bay
#

ye sure

solar stirrup
#

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?

chrome bay
#

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

solar stirrup
#

Are there any edge cases where it doesn't remove an actor when it's destroyed? sus

#

Yeah I fixed that one heh

#

This one's different vaultsweat

#

I might just remove that ensure tbh

#

And just have it log to the output log

chrome bay
#

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

solar stirrup
#

pain and suffering

#

Do dependant actors not get removed on destroy D:

latent heart
#

No luck with the breakpoints?

chrome bay
#

They should do I think

solar stirrup
elfin hinge
#

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

solar stirrup
#

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

chrome bay
#

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

elfin hinge
#

Could we hop in a call?

chrome bay
#

cant atm srry

#

Should look something like this in Blueprint

#

Since it's Blueprint, the OnRep will be called Server-Side as well.

graceful flame
elfin hinge
chrome bay
#

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

graceful flame
#

As a beginner, I think there's a tendency to rely on multicasts for pretty much everything.

compact talon
# chrome bay (RE <@100687652856037376>)

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.

chrome bay
#

Yeah, I blame tutorials from newbs on youtube who have no idea

chrome bay
latent heart
#

The blind leading the blind, huh?

graceful flame
#

Should I be doing a Multicast with "is dedicated server, false" for visual and audio effects? Or would that be best handled another way?

compact talon
chrome bay
#

Yeah if it's a dynamic mat instance it won't work, they are locally created only

thin stratus
#

You gotta replicate the Params then

chrome bay
#

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

latent heart
chrome bay
#

Except we only replicate the FName ID's since the tables are global, and we enforce the ID's to be short

compact talon
#

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

chrome bay
#

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

compact talon
#

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

chrome bay
#

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

compact talon
#

Interesting, how do you tell a datatable handle or param to replicate? Do you just make a variable of that type and hit "replicated"?

chrome bay
#

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

compact talon
#

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

chrome bay
#

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

compact talon
#

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

chrome bay
#

AFK for a bit

solar stirrup
#

went the nuclear route, w/e

#

once I figure out why some actors don't get removed i'll revert that

elfin hinge
#

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

thorny saddle
#

hey folks is playerstate clientside only?

pallid mesa
#

net compendium helps in these matters 😄

pallid mesa
#

🤣 all the gotchas you went through...

solar stirrup
#

Probs will post some tutorials on my blog

#

Maybe

#

Already did one

pallid mesa
#

you'll get my recommendation for sure

solar stirrup
#

Thanks

#

Github Pages doesn't exactly make me rich heh

#
  • domain was 12 euros a year so I just grabbed it for 10
pallid mesa
#

hey what's wrong with github pages 🥲

solar stirrup
#

Nothin, it's awesome

#

Especially since Jekyll works with it out of the box

pallid mesa
#

my blog is pretty ugly...

solar stirrup
#

Meh, it works fine

blissful saffron
#

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?

jovial pike
#

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

blissful saffron
#

Are you asking how to replicate the door actor movement?

obtuse field
#

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

plain spade
#

Is it a good idea to keep something like money shared between players on a game instance, or on a player controller?

obtuse field
plain spade
#

Sorry, I'll clarify

obtuse field
#

Bcs. If you just want to implement money system, go for the player state

plain spade
#

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

obtuse field
#

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.

plain spade
#

I'll try that, thanks!

jovial pike
#

@blissful saffron yes replicate door opening movement from client to server

blissful saffron
blissful saffron
# obtuse field Anyway, I still need this

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

jovial pike
#

Maybe I said it wrong, just basic replication based off that blueprint. @blissful saffron

eternal canyon
#

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

jovial pike
#

How would that look in blueprints? @eternal canyon

nova wasp
#

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

jovial pike
#

Im just new to the blueprints so its hard to visualize. If you could explain the order of nodes thatd be cool. @nova wasp

calm pewter
#

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:

  1. 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)
  2. Once the array has been filled up, it uses a for-each loop to pull each struct and call a server side event
  3. This server side event immediately calls a multi-cast event
  4. 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

blissful saffron
#

How would you suggest I go about handling one character whose ability picks up another character and throws it?

blissful saffron
#

I guess just attaching the picked up character to a socket on my lifting character wouldn't be too bad

silent valley
calm pewter
#

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.

silent valley
#

Yes this is a thing. Soft referenced objects must be loaded before use.

calm pewter
#

Hm, so is it an issue that I am not loading it soon enough?

silent valley
#

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.

calm pewter
#

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? 😛

silent valley
#

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

calm pewter
#

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?

silent valley
#

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.

calm pewter
#

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

silent valley
#

You don't have much choice IMO!

calm pewter
#

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..

silent valley
#

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.

calm pewter
#

Just out of curiousity, how long to async loaded objects remain available - or is it until you specifically unload them?

onyx belfry
#

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

silent valley
onyx belfry
#

they wont help of

#

ofc

onyx belfry
lime leaf
#

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..

silent valley
#

Yeah this sounds like a very fragile system. Generally you would use the default values, and anything else should be replicated.

lime leaf
#

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..

silent valley
#

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.

lime leaf
#

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

chrome bay
#

You can't assume other actors are valid though, even initially

lime leaf
#

@chrome bay I know..

chrome bay
#

Delays are by far the worst way to solve any race condition

lime leaf
#

@chrome bayI am looking for good ways to solve race conditions I guess 🙂

chrome bay
#

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

void nest
#

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?

chrome bay
#

@void nest Unpossess the character, attach it to the vehicle, possess the vehicle

#

Inverse when leaving it

void nest
#

Yeah but i tried that

chrome bay
#

And turn off character movement when the character is "seated" or whatever

void nest
#

It still creates jitter when you reposses char

chrome bay
#

Shouldn't do

void nest
#

Yeah also did that already :/

#

As soon as i use attah detach it breaks

lime leaf
#

Mmm, one could make OnRep variables for initialization sequence too, then when "OnRep" kicks in.. at least you know the object itself is replicated..

void nest
#

To turn of char movement i use deactivate right?

chrome bay
#

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

void nest
#

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?

chrome bay
#

You'd need to attach the capsule

void nest
#

i attach the whole actor

chrome bay
#

And disable it's collision too, and make sure the movement component isn't applying gravity when seated etc

void nest
#

k ill have another look at it

chrome bay
#

Depending on your setup you could also just stay in control of the pawn. HLL vehicles work that way

chrome bay
# lime leaf PM me the link if you do.
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

lime leaf
#

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..

chrome bay
#

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

lime leaf
#

Yeah I guess I've ended up just making c++ actor classes for things that could be subsystems..

chrome bay
#

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

lime leaf
#

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

chrome bay
#

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

lime leaf
#

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..

chrome bay
#

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

river dome
#

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?

solar stirrup
#

You cannot run server RPCs on actors you don't own, so you should route the "Fire" RPC through your PlayerController

river dome
#

So does this mean all my logic for firing my weapon should be in my player ?

solar stirrup
#

No, but you'll need to route any Server RPC through it

#

You can keep the actual logic in the other actors

lime leaf
#

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..

river dome
#

So i call my weapon to fire -> The weapon calls the player controller again to spawn the projectile?

burnt tundra
chrome bay
#

Then it'll work fine

#

No idea what you're passing in as the owner there

river dome
chrome bay
#

Is it a replicated actor spawned only by the server?

river dome
#

Sorry for the noob quesiton but how do i know? 😄

chrome bay
#

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

river dome
#

Okay how do i do that? 😄

chrome bay
#

Look at cedrics compendium to get some ideas

river dome
#

Okay thank you i will look into it 😄

pallid mesa
#

I've seen the other day a timer set at 0.1, waiting for some vars to replicate

chrome bay
#

🔫

#

I hate it so much

#

The source of endless trouble

#

Crappy YT tutorials with 500K views telling people to use delays and multicast everything 🔫 🔫 🔫 🔫 🔫 🔫 🔫 🔫

pallid mesa
#

the world subsystem Idea is honestly pretty neat, before you've told me about that I was wiring everything through components 😂

chrome bay
#

tbf I do use components for some manager stuff still, I have a "TeamStateComponent" that lives on gamestate

pallid mesa
#

i have no idea on why I haven't thought about subsystems before

chrome bay
#

But that's pretty easily accessible

bitter oriole
chrome bay
#

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

pallid mesa
#

the problem sometimes is that people copy stuff from the internet instead of trying to understand

bitter oriole
#

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

chrome bay
#

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

pallid mesa
#

that's why I always finish my articles with this:

chrome bay
#

Right 😄

solar stirrup
#

wdym I shouldn't delay and call a multicast in tick to update values

chrome bay
#

I mean some people can't be helped.. they just want shortcuts

#

But.. such is life

bitter oriole
pallid mesa
#

and... this

#

😄

solar stirrup
#

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

pallid mesa
#

sounds evident, but people forget about the basics

solar stirrup
#

And now Youtube removed dislikes so that's gonna be even worse lol

bitter oriole
#

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

pallid mesa
hoary spear
#

But that would require them to understand it themself i guess, and thats perhaps to much to hope for :p

lime leaf
#

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..

obtuse field
jovial pike
#

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?

obtuse field
bitter oriole
#

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

obtuse field
#

If I may ask, why?

bitter oriole
# obtuse field 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

obtuse field
#

ok, makes sense

bitter oriole
#

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

jovial pike
#

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

obtuse field
#

And you will get this function

#

It will fire whenever the variable is replicated

jovial pike
#

Okay, is this in the player character or the door blueprint?

obtuse field
#

door

jovial pike
#

So for onrep is door open what is the logic inside that function? I am sorry I am so new

obtuse field
#

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

jovial pike
#

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

void nest
#

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.

chrome bay
#

You can just set it's location like any other actor

jovial pike
#

@obtuse field where am I going wrong? haha I appreciate your patience

#

I know I'm not referencing the server or switch

obtuse field
red token
#

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?

obtuse field
#

And to rep notify work, you need to set value from the server

compact talon
#

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?

jovial pike
#

okay @obtuse field, I called server here but still nothing

obtuse field
#

on rep is called when you replicate the variable

#

in order to replicate the variable, you need to change its value on the server

jovial pike
#

@obtuse field ... am I getting closer?

obtuse field
#

Yes

#

But you still didn't update Angle on the server

#

You just set the relative rotation

jovial pike
#

okay, so thats my issue. How do I update angle on server?

obtuse field
#

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

jovial pike
#

yes

#

am I close, or no? @obtuse field

obtuse field
#

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

dark edge
burnt tundra
winged badger
#

your possess logic?

lime leaf
#

@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..

crystal crag
#

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

latent heart
#

Well, one is Set, the other is Add.

crystal crag
#

Ah

#

very true

#

So I need to do some subtraction to figure out how much I should really be adding

#

cool

void nest
#

@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

jovial pike
#

@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

vivid seal
#

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*

fathom aspen
#

I would suggest you to look at the source code of both classes and see the use differences by yourself

dark edge
#

They really shoulda called GameMode GameController

#

GameController/GameState
PlayerController/PlayerState

obtuse field
#

I think it would be more convenient to help that way

jovial pike
#

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

frosty remnant
#

Why is my Unreal whining that NavMesh needs to be rebuilt, but only in multiplayer?

obtuse field
#

@jovial pike Ok, so we can go on feedback and support

crystal crag
#

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.

ocean geyser
#

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?

fossil spoke
obtuse field
#

And write your question first, If you would do it, I could answer it now

#

But I can't :d

normal ermine
#

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?

jovial pike
#

@obtuse field I Figured it out with your help! Thank you so much again. For those in need of replicated door- heres my solution:

lime leaf
#

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 🙂

twin juniper
#

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?

sinful tree
burnt tundra
scenic ruin
#

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

bitter oriole
#

WITH_SERVER_CODE IIRC

silent valley
#

huh.. I've always used UE_SERVER - I wonder if there's a difference?

scenic ruin
#

Seems pretty accurate for the intent, also less letters

silent valley
#

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

twin juniper
#

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.)
jolly sierra
#

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?

bitter oriole
#

Autonomous is specifically for player controllers / pawn, IIRC

jolly sierra
#

So, player states are always gonna be Authorative/Simulated?

bitter oriole
#

Pretty sure yeah, like most actors

jolly sierra
#

ok got it thanks.

winged badger
#

but its kinda pointless, as client condition for LocallyControlled PS is GetOwner() != nullptr

atomic barn
#

Hi how do you use casting in multiplayer?

#

I want to cast to another pawn on another client from one client

chrome bay
#

There's nothing special about casting in MP, works exactly the same

bitter oriole
#

So it's unrelated to multiplayer entirely and "casting from a client" doesn't make much sense

pallid mesa
#

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 😅

devout berry
#

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?

sleek flicker
#

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)

grizzled stirrup
#

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

latent heart
#

Aren't struct members replicated independently anyway? Hasn't done replication in a while

solar stirrup
#

Nope, they're replicated at the same time

#

IIRC

solar stirrup
latent heart
#

Fair enough!

bitter oriole
#

There's an Atomic meta on structs

latent heart
#

Ah ha.

bitter oriole
#

Supposedly that ensures atomicity

solar stirrup
#

Good to know

grizzled stirrup
#

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

solar stirrup
#

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

grizzled stirrup
#

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.)

solar stirrup
#

Could work as well ^-^

#

If it's got set values of course

latent heart
#

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.

solar stirrup
#

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

grizzled stirrup
grizzled stirrup
solar stirrup
#

o missed it yea

#

yeah honestly go with structs

latent heart
#

More useful for checking things like player states have been replicated, for sure.

grizzled stirrup
#

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

chrome bay
#

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

grizzled stirrup
#

The nice thing about using structs to pack replicated data together is that it's guaranteed to come down together

chrome bay
#

structs are no different to other actors properties

#

they even get "unfolded" into their internal properties if they are direct members

grizzled stirrup
#

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

chrome bay
#

Store the enum on the pickup itself

grizzled stirrup
#

It's a generic pickup that gets populated with data at runtime

#

Rather than having unique actors for 500+ pickup types

chrome bay
#

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

grizzled stirrup
#

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

chrome bay
#

Oh I see

#

Is that data fixed, or generated at runtime?

grizzled stirrup
#

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

chrome bay
#

Is the pointer to a runtime instance or a fixed one/asset?

grizzled stirrup
#

Rather than passing individual properties that set lots of other individual replicated properties

chrome bay
#

That'll be fine then

grizzled stirrup
#

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?

chrome bay
#

I'd do one struct, and have an OnRep that initializes it when received

grizzled stirrup
#

Perfect good to know that's a viable approach!

chrome bay
#

For good measure, I'd probably force it to be atomic with NetSerialize too

grizzled stirrup
#

Is there docs on this atomic stuff?

chrome bay
#

Unless for some reason you would reinitialize it later

grizzled stirrup
#

I had thought that it replicates only changed properties not the entire struct again

chrome bay
#

It does by default yeah

#

If you define a custom NetSerialize, whatever you write is sent each time

grizzled stirrup
#

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?

chrome bay
#

Yeah

grizzled stirrup
#

Yikes

chrome bay
#

Oh wait

#

no

#

By DEFAULT, only the one you changed would send

grizzled stirrup
#

Ok that's good

chrome bay
#

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

grizzled stirrup
#

Ah I see!

chrome bay
#

(2 bytes each)

latent heart
chrome bay
#

Yeah

grizzled stirrup
#

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?

chrome bay
#

Structs use delta replication, even structs contained in arrays

grizzled stirrup
#

As I have no idea how to even do that

chrome bay
#

@grizzled stirrup In theory yes, because you changed all the properties in the same network frame

grizzled stirrup
#

Good stuff thanks!

chrome bay
#

And AFAIK actor updates should not be split into separate bunches

#

I guess unless you somehow exceed the max bunch size

#

Whatever that is

grizzled stirrup
#

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

chrome bay
#

No it doesn't prevent that

grizzled stirrup
#

Ok good to know

winged badger
chrome bay
#

yeah

grizzled stirrup
#

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?

chrome bay
#

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

chrome bay
#

A change made in same network frame will be received at the same time

grizzled stirrup
#

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)

chrome bay
#

But OnReps obviously will be called in whatever arbitrary order

chrome bay
#

Which I guess could happen if you had a lot of components, RPCs, properties etc in one frame

grizzled stirrup
#

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

chrome bay
#

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

grizzled stirrup
#

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

chrome bay
#

Yeah seems fine to me

grizzled stirrup
#

Thanks for the help!

chrome bay
#

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

latent heart
#

Oh

#

So that answers a question of mine - when an actor is first replicated, all of its properties are also guaranteed to be replicated!

chrome bay
#

yeah that's a garauntee

#

But they won't be read-in in the very early phases, like constructor or PostInitComps

latent heart
#

Yeah.

#

But when an OnRep triggers, they shoudl be.

chrome bay
#

PostNetInit is good for that though

#

yeah

finite jackal
#

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)

obsidian cargo
#

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.

dark edge
#

Is this for a melee hit or physics or a line trace or what?

obsidian cargo
dark edge
#

GAS already has gameplaycues

obsidian cargo
#

Oh yeah, I remember seeing something about cues some months ago. I'll see if that can solve my problem.

obsidian cargo
dark edge
#

Looks like exactly what you're after

obsidian cargo
#

Thanks for sharing

real ridge
#

is anyone here using dedicated server with eos or steam subsystem ?

vivid seal
#

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?

solar stirrup
#

Wait for them to BeginPlay() on the client perhaps.

native cave
#

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)

vivid seal
solar stirrup
#

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

vivid seal
#

okay

pallid mesa
#

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);
    }
}
fathom aspen
pallid mesa
#

then on BeginPlay u can do:

UNPPWorldEventManager::NetReadyExecute(this, FSimpleMulticastDelegate::FDelegate::CreateUObject(this, &AHud::CreateUIOrWhatever));
fathom aspen
fathom aspen
pallid mesa
#

James will post soon something about this

#

because initialization is such a mess in multiplayer

fathom aspen
#

You and James are true heroes

lament nest
#

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)

real ridge
chrome quest
#

Don't ask to ask

#

Just ask

magic yoke
real ridge
#

i just cant find docs or something for dedicated server how to make sessions there... 😄

chrome quest
lament nest
chrome quest
lament nest
magic yoke
#

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.

chrome quest
magic yoke
#

blueprint only atm

chrome quest
#

The struct is in BP?

lament nest
# chrome quest Where is it created

I'm creating it in my character class constructor: AttributeSet = CreateDefaultSubobject<UMainAttributeSet>(TEXT("AttributeSet")); AbilitySystemComponent->AddAttributeSetSubobject(AttributeSet);

magic yoke
#

ye

chrome quest
#

Hmm. Strange

magic yoke
#

yeah... I was wondering if there was some strange naming conflict

#

I've had this twice now

#

because I'm basically doing a naughty

chrome quest
magic yoke
#

DisplayChunkArray (the struct) containing DisplayChunkArray(an array)

lament nest
#

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

magic yoke
#

just saw I can update/verify I'll try that

chrome quest
magic yoke
#

yeah I didn't think so

#

but this thing has happened 2x now

#

so yeah

#

somethings fuxxed

lament nest
magic yoke
#

thanks tho ozy

chrome quest
limber gyro
#

Any 1 with experience messing with the character movement component that can give me a hand?

limber gyro
#

i dont even know what could be wrong

lament nest
limber gyro
#

basicly i wrote some code and its not working and i have no idea why

chrome quest
lament nest
#

I can try, just a minute

limber gyro
#

i can paste the code here but its quite a bit of code

#

let me set up a paste bin

chrome quest
#

Shivers

chrome quest
pallid mesa
#

can you mention at least what is that that you are trying to achieve?

limber gyro
#

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

pallid mesa
#

ah, my tip for this is take a look at UT, they have two styles of dashes 😄

pallid mesa
#

you'll learn in your knowledge trip

limber gyro
#

suposedly the video tut that i was following is using code from UT

#

the thing is, the video tut is not very good

pallid mesa
#

I mean.... look at the source code of UT yourself, as I suggested

limber gyro
#

and the only other tut uses basicly the same code as the video tut

chrome quest
#

I can't tell what is wrong from what you've sent

#

Did the dash not work, or is there rubberbanding

limber gyro
#

didnt move at all

pallid mesa
#

where are you setting dashTimer ?

#

it never gets reset from what you've sent

chrome quest
#

You could read it?

pallid mesa
#

a bit

limber gyro
#

im just testing

chrome quest
#

Lol. I hard a hard time so I just skimmed through

limber gyro
#

wait no

#

nvm

#

i dont set it to 1 at all

pallid mesa
#

what are you initializing it to?

#

in your constructor

#

excuse my keyboard x'D

limber gyro
#

the cmc has no constructor so im not doing anything there, i was just "fishing" for movement

#

if that makes sense

pallid mesa
#

the what

#

WHAT

#

the cmc of course has constructor!!!

limber gyro
#

yes i know it does

#

it just doesnt in my extended class

#

haha

#

at least for now

chrome quest
#

Wait. ...

#

Huh

#

?

pallid mesa
#
  • huh -
#

I mean, add a constructor and initialize dashTimer

chrome quest
#

You have a constructor

limber gyro
#

i was just initializing in the .h

pallid mesa
#

otherwise there are high chances it will be 0.f or trash

chrome quest
#

It's there. I saw it.

limber gyro
#

so yes it wa 0

#

was''

#

it should be something else

pallid mesa
#

set it to 2.f

limber gyro
#

imma test with 1 now see if anything moves

pallid mesa
#

and try again

limber gyro
#

value in single player implementation was 0.2

pallid mesa
#

that's the amount of time you'll be dashing

limber gyro
#

yes i know

pallid mesa
#

ah oki :3

limber gyro
#

its suposed to be a fast thing

#

kinda like tracer fro moverwatch

pallid mesa
#

yes then set it

#

initialize it, I mean

limber gyro
#

o ye it moves

#

haha

#

its just a bit crazy

#

well at least i got movement

#

thats progress

pallid mesa
#

nice! o/ \o

#

good job!

#

also please, put constructors 😄

limber gyro
#

the cmc is quite complicated, i have not fully grasped how it works yet

pallid mesa
#

the code btw looks all right

#

but yes, CMC is very complicated

#

so you must be proud you got something working on it!

limber gyro
#

indeed

pallid mesa
#

now try to understand what you are doing

limber gyro
#

i was expecting to take like a week

chrome quest
#

Perhaps the most complicated in the game framework

pallid mesa
#

otherwise it'd be pointless

limber gyro
#

well i have a basic idea

#

of how things are working and how the info is moving about

chrome quest
#

There's a lot more to learn.

#

Implementing custom movement modes.

limber gyro
#

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

chrome quest
#

Yeah the class is a mess imo.

limber gyro
#

if they at least didnt make it so verbose