#multiplayer

1 messages ยท Page 164 of 1

thin stratus
#

Everyone will use their own

#

Changing them is like changing a TextureAsset (the actual asset itself)

#

It doesn't magically replicate

lament flax
#

yes, no worries i didnt plan to do this

#

its just intersting that you can

hardy turtle
thin stratus
#

They are Objects, so you can alter them, but you are still altering them as an asset

#

And this doesn't replicate

hardy turtle
#

oh yeah, indeed! you can change it at runtime, i wasn't talking about the multiplayer

thin stratus
#

Yeah but you are using it in a Multiplayer set up

#

The change your client does to that file won't replicate

#

Not even if you RPC them to the Server etc

lament flax
#

there is probably useful cases where you want that behaviour

thin stratus
#

Rarely

#

We only ever had one case where we modified it runtime, in C++

hardy turtle
#

hmmm yeah that's true, so i guess i should pull it from everyone's GI and then notify it to the others, but the replicated pawns should not pull from the GI right?

thin stratus
#

And that was to ensure that all Chests were using the same chance calculation and that getting an item from it changes the chance for the others

#

And even that should potentially not be done via the DataAsset

#

DataAsset is supposed to be ReadOnly

thin stratus
#

And then in e.g. OnControlledChangedEvent -> IsLocallyControlled in your Character, you get the GI, RPC the Struct to the Server and the Server sets it on a RepNotify variable

#

And then you apply the changes in the OnRep

lament flax
#

in what cases DTs are good ?
because for me its just a more anoying version of DAs

specially because it goes through all rows to get the one you want

hardy turtle
#

dude thank you really much! โค๏ธ

thin stratus
lament flax
#

yeah

#

thats why i am wondering some good usecases

thin stratus
#

Eh, there are some, but I can't name any atm

#

Some stuff in the Engine needs them

#

I often use DataAssets, or with the power of C++, turn my normal BPs into "DataAssets" and similar

hardy turtle
# lament flax thats why i am wondering some good usecases

I used one for the character selection and another one for some options such as force feedback and gore, it can be quicker for some stuff to access them and the cool thing is that changing them at run time you don't need to update anything else

#

the only downside is that you have to save their state once you close the game and set it back when you start it again otherwise they get reset to their initial state

thin stratus
#

It's mostly if you really want Spreadsheet like Data for something

#

Aka mostly 1 depth deep stuff like some meta data about an item or so

#

But in almost all cases you could also use DataAssets fwiw

hardy turtle
#

๐Ÿค” are we talking about the primdata right?

#

i'm sorry if i get messy, i have no background in programming ๐Ÿ˜…

thin stratus
#

DataTable - Asset you create from a Struct where you add Rows to
DataAsset - Asset you create from, e.g., a PrimaryDataAsset Class

#

One DataAsset Asset is usually the same as one Row of a DataTable

#

While the Struct defines what data is in each Row for the DataTable, the selected DataAssetClass defines what the DataAsset has in terms of properties.

#

They are pretty similar, and again I would say that one can do most of the DataTable stuff with DataAssets.

#

But there are still use-cases for DataTables fwiw

#

I think there are also things where you can combine multiple Tables into one or so

#

I'm more a friend of DataAssets and the AssetManager, but iirc that needs a bit of C++

#

I like to just ask the AssetManager for all DataAssets of Type XYZ.

#

Also allows for SoftReferences and what not.

dark edge
#

whos gameinstance? The server or clients?

hardy turtle
hardy turtle
dark edge
thin stratus
#

I already wrote that

hardy turtle
hoary spear
#

DataTables are cool, but their editor is subliminal

#

Not being able to edit multiple column/rows at the same time, in any way is horrible

#

not being able to just edit a single cell without opening the row,

#

is terrible

lament flax
#

yes

maiden flame
#

@twin juniper Maybe I misunderstood, but why not use an AnimNotify/AnimNotifyState to sync your hitbox timing with the montage?

lost inlet
#

Do you have that message bound to a hotkey or something

#

The one you just posted because you posted something incredibly similar last night

maiden flame
#

@lost inlet Why is it bad to use AnimNotifies for gameplay in multiplayer? I would like to know as I rely on them quite a bit.

lost inlet
#

But there can be timing differences, especially if you run animations at a reduced rate on the server

#

Because you probably don't need high fidelity animation on the server

maiden flame
lost inlet
maiden flame
#

Hm, I see. Thanks.

lost inlet
#

And reload timings were based on first person animations

#

So since they didn't run, they just used presaved timings. The animation sequences didn't even need to be loaded

maiden flame
#

I'm using AnimNotifies for a continuous hitbox (swords basically), but the server only really needs to know a socket location from the skeletal mesh during montages. Haven't had any issues yet.

#

The timing is consistent, but of course latency will have it's own effect on top.

#

@twin juniper What server model are you using? Not sure why pausing would be an issue for an online game, unless it's a listen server and window focus somehow affects the timers/animations.

#

I don't really know though, just asking. Feel free to ignore ๐Ÿ˜›

hollow eagle
#

Unreal has a way to "run" montages as pure notify data - no animation calculations. If you don't need any animation calculations on the server whatsoever you can just use that.

#

EVisibilityBasedAnimTickOption::OnlyTickMontagesWhenNotRendered will fire off notifies as normal but not tick animation otherwise on the server (since the server never renders).

#

It can still be a bit more expensive than caching notify timings outside a montage (just because you have a bit more overhead for using the animation system at all, and it still ticks rather than doing something like scheduling with a timer), but it shouldn't be much.

#

though I forget if that's the only thing you have to do. There may be some other options necessary to prevent any other calculation of animation data.

lost inlet
#

Looks like for a melee system you'd need the transform data of whatever point you're reading at the notify in the animation

dark edge
#

I mean if you need it you need it

lost inlet
#

Well the melee system that was described

dark edge
#

if you need accurate hit detection and are blending anims all over the place then there's no way around it really

lost inlet
#

Yeah but having it super accurate seems like a whole can of worms in a multiplayer context

dark edge
#

ya it depends

#

WoW works
Elden Ring works

lost inlet
#

I would expect something that is doing super accurate stuff to be somewhat using CSHD

dark edge
#

ah clientside hit detection

#

yeah that'd probably be the source of the hit, but you still want consistency and to be able to sanity check things

chilly haven
#

Hi,
If a game team is shipping multiplayer-only, dedicated-server-only, then they have the opportunity to keep the server code completely out of the hands of the players, by making separate builds for dedi and client, and by using preprocessor directives.
I.e. do not support listen server at all, not even for dev.
Is this common? Your dev team would need to use dedicated servers for all testing, rather than listen servers.

#

But it the most secure approach.

fossil spoke
#

That just makes no sense

#

So of course you would need to test with dedicated servers...

fossil spoke
chilly haven
#

Know of any teams who have done this?

fossil spoke
#

Yes

chilly haven
#

Most AAA teams I know support a listen server for dev. But that may not be the best choice in these circumstances.

#

You can even bundle dedi+client somehow to make it easy for team to use

#

Basically if you are not supporting single-player, nor player-hosting, you should consider this option.

floral fox
#

if i wanted to send location under cursor do i do that on client and send vector as rpc to server?

sinful tree
floral fox
torpid lantern
#

How computationally heavy is "get all actors of class"?

I'm trying to build a "line of sight" check, using a line trace for object. I need an array of actors to ignore; otherwise my sight check will fail if another pawn steps in front of the trace line.

For my use case, I want the trace to only be blocked by a specific object type.

Question: Is there another method of trace that I can use, otherwise is it okay to use get all actors of class every time a player attacks on the server; say 30-40 players @ 30 attacks per min?

sinful tree
floral fox
sinful tree
#

Perhaps you could save some network bandwidth by checking if they actually moved it (position is same as last sent position) and not send the RPC if they didn't move it.

floral fox
#

thanks, didn't think about storing and comparing previous

toxic goblet
#

Hi guys, do some one know how to simulate different weak net envir in editor on two clients? Unreal seems only can simulate same weak envir on all clients. ๐Ÿ˜ฆ I want to apply different net settings per client in editor.

chilly haven
#

Question. For developers creating only dedicated servers and clients (i.e. no listen server, no single player), how do you separate your client and server code?
Do you just litter each module with the appropriate preprocessor defines?
Or do you create separate class instances for server and client (and conditionally compile)?

pallid mesa
#

former

chilly haven
#

was it a conscious choice?

pallid mesa
#

yes, it is the "unreal way"

potent coral
chilly haven
chilly haven
#

Actually I guess there are 3 cases: server only, client only, shared.

toxic goblet
urban moth
#

what is an equivalent for GetFirstLocalPlayerController in BP?

sinful tree
urban moth
warm willow
#

When dealing with UMG or input, is it /in certain cases/ safe to use on client getplayercontroller(0)? I had to use it few times, everything seems to be working okay, but...

chrome bay
#

Not really, the only exception would be if you are working exclusively with dedicated servers

#

UMG Widgets have an owning player so it should be easy to access through that.

lament flax
#

for inputs where i want some hold before doing X

should i calculate the cooldown in client, and only call the final result event on server ?

#

since calling on server each tick might be to much for nothing

chrome bay
#

If it's just about a different input method and doesn't matter for gameplay, just do it client side

lament flax
#

well it will matter in gameplay

#

for example

user has to hold a key for 2 seconds then I call "Use item" on server

#

i dont see an issue if i run the check and add "elapsed time" on server side

chrome bay
#

Timers over network are not pinpoint accurate so you might occasionally fail in the "real" world.

lament flax
#

thats the thing, if user has a bit of ping, 2 seconds might become 4s

#

for the client

chrome bay
#

If it's just for input, it doesn't really matter. If there are gameplay reasons (i.e. it's a firing delay or something), then really it doesn't belong in the input domain

lament flax
#

okay

#

i'll stay with server then

#

i'll maybe to a timer by event instead of adding delta seconds each frame

chrome bay
#

Well you certaintly don't want to be sending an RPC with elapsed time every frame

#

If you must do timing on server, send a "start" and "end" RPC and allow some tolerance to account for network error

#

You can just use timestamps

lament flax
chrome bay
#

You check the length of time on when the client "End"s pressing, and checks it's near to the time you expect them to hold the button for plus some small tolerance for error

#

The point is that in the real world, those RPC's will not arrive with a perfect 2 second delay

lament flax
#

i see, ty

chrome bay
#

psuedo-code

void Started()
{
    LastStartTime = GetWorld()->TimeSeconds();
}

void Stopped()
{
    float TimePressed = GetWorld->TimeSeconds() - LastStartTime;
    if (TimePressed.IsNearlyEqual(2.f, 0.5f)
    {
        DoThing();
    }
}```
lament flax
#

also, i found that that you can use replication conditions
for the elapsed time float var, i should do this in owner only right ?
because other clients doesnt care about "how far he his"

chrome bay
#

Client should just track it locally

#

Replication will be way too latent to be of any use

#

Plus it's wasteful

#

You should test this with packet emulation to see how quickly it falls apart under real world conditions.

lament flax
chrome bay
#

Just run one client side too

#

Doesn't have to do anything

#

Your 'ElapsedTime' property will not update regularly enough to be of any use

heady copper
#

hello goodmorning guys ..please i am trying to make a static mesh movement replicate form client to server

chrome bay
#

It will in editor, but not IRL

heady copper
#

it works from server to client

#

but not the othe way round

chrome bay
#

Replication is always Server->Client

#

If you want the client to move it, you have to tell the server to move it via RPC

heady copper
#

i wonder why...i have implemented rpc

#

for client to server but doesnt work

chrome bay
#

What does the log say. You need to be the Network Owner of the actor to call a Server RPC

#

Clients are not allowed (for obvious reasons) to just move any actor they please

lament flax
chrome bay
#

The Server should just validate things for gameplay, that doesn't mean for UI for instance you need to replicate that back to the client

heady copper
chrome bay
lament flax
#

to small

#

to read

heady copper
#

ahh

#

let me make it better sorry

chrome bay
#

Well that's definitely not going to work

#

You're getting the Mouse Location from a Multicast, that's going to give you the mouse location on the local machine

lament flax
chrome bay
#

The Client calling the RPC needs to send the location to the Server with the RPC. The Server should then set the ball to that location, and the ball should have "Replicated Movement" enabled so that other client see it. You don't need or want a multicast here

chrome bay
lament flax
#

ill do that, thanks for discussing this with me

heady copper
#

sorry not rili used to bp thanks for the clarity...

torpid storm
#

I have a question for anyone familiar with the C++ side of UE multiplayer.
Here's my timeline:

  1. Start a game in PiE, 1 client
  2. Map includes one 'NetStartup' actor with a replicated property (in this case a material color)
  3. I change that color during play, see it change onscreen
  4. I connect a second client (via the experimental 'Allow Late Joining' option)
  5. Second client gets the RepNotify for the NetStartup actor's changed material
  6. Second client gets BeginPlay called on the NetStartup actor, as a side-effect of the GameState RepNotify
  7. Play starts on second client with all actors in correct states

This is all good, but here's my question - where in the code does it guarantee - if it guarantees it at all - that the net startup actor will get fully replicated to a joining client before the game state? Is there any guarantee that the in-world actor states are all replicated to a new client before they get BeginGame called on them?

lament flax
torpid storm
#

If you're asking about "for inputs where i want some hold before doing X", just count it on the client then send the RPC. On the server, do extra validation

lament flax
#

thats what i am trying to do

#

the thing is that the client cant call the event on server because he is not the owned actor

torpid storm
#

You can always do validation on the server. You can use a different actor if you need

obsidian halo
#

Does destroy session only works for host(listen server)? and if i wanna leave a session as a client i should just open a new map?? instead of using destroy session??

lament flax
#

this will be dropped

hoary spear
torpid storm
#

Well, I don't know anything about what that is, what it's called on, or why you rely on it.

lament flax
#

wdym

hoary spear
#

Through a client owned actor

lusty sky
# lament flax wdym

basically have the rpc on a player owned actor like a player controller or character and call it there

hoary spear
#

But yeah clients cant destroy sessions

obsidian halo
lament flax
#

let me give some context

  • (player character, client) input event
  • (acbp on player, client) call interface on item (actor)
  • (item actor, client) call event on acbp
  • (acbp on item, client) run timer
  • (acbp on item, client) when conditions meet callback to server <- where i am stuck
lusty sky
#

or no one?

lament flax
#

the item is spawned by client, and is replicated
so the client is the owner

torpid storm
#

It still exists on the server. You can still call RPCs on it

lusty sky
lament flax
#

only thing that isnt owned by client is the actor component attached to the item actor
but its weird since the owner of the item actor is the client

torpid storm
#

Just sounds like you need a [Server] RPC

obsidian halo
hoary spear
obsidian halo
#

im calling but its not working

hoary spear
#

do you have a valid session?

obsidian halo
#

yes

obsidian halo
lament flax
#

1- (item actor) on client
2- (item acbp) on client
3- (item acbp) on client, not calling on server

hoary spear
#

are you testing this in-editor ?

hoary spear
lament flax
#

that what i am doing

hoary spear
#

this doesnt look like that

lament flax
#

doing the cooldown on client, and call the result on server

#

his is client side

obsidian halo
lusty sky
#

do you get any warnings when the rpc is called?

obsidian halo
#

and with play as standalone checked

hoary spear
# obsidian halo yes

I wouldnt trust the result in-editor , as they can differ from actual clients by a fair amount

lament flax
lusty sky
# lament flax

that means the item is not owned by the client who called the rpc

lament flax
#

so the tiem actor isnt owned by client

hoary spear
lament flax
#

weird that on breakpoint it shows "client"

obsidian halo
obsidian halo
hoary spear
lament flax
#

wdym

hoary spear
#

the start use

#

is it explicitly called on server, or on client aswell?

#

i suspsect client calls it

lament flax
#

i just resume to breakpoint to breakpoint

hoary spear
#

so, it runs oin clinet

lament flax
hoary spear
#

the interface event yes

torpid storm
#

The "no owning connection" thing looks like a massive red flag to me. That implies something is wrong with how that object is being created, or that it's not designed to be replicated at all

lament flax
#

full call stack

#

from player character to item

hoary spear
#

which would be strange, imo

lament flax
#

the actor is spawned from server

hoary spear
#

and you forgot to set owner

#

so client cant rpc server

lament flax
#

it isnt automatic ?

hoary spear
#

and server dont know which client to rpc to (as it has no client owner)

#

ownership is explicit, always

lament flax
#

im to used for solo games

#

works now

#

ty guys

lusty sky
#

Now you have to change the owner eveytime a different player tries to do that xD

lament flax
#

wdym

#

item is spawned each time the selected slot in hotbar is changed

hoary spear
#

We dont really know if this is an item spawned from an inventory, ment to only be used by a single player

#

right

lament flax
#

it will always be the correct client owner

hoary spear
#

so single owner is fine

lusty sky
#

if the item is going to be used by different players

lusty sky
#

oh all good then

lament flax
#

and so destroeyd when unselected

hoary spear
#

Its only used by one player, as it is their hotbar item ^^

lament flax
#

ty for wondering

hoary spear
obsidian halo
#

its working

hoary spear
#

There's also a function in GI (not BP exposed) that safely returns you to main menu

#

Ah cool ,alright

obsidian halo
#

thanks

ember jasper
#

@thin stratus
Hi ! ๐Ÿ™‚
Found that old post and was wondering if - with all the experience you gathered - you would come up with a cleaner solution ^^
https://forums.unrealengine.com/t/rpc-client-server-not-working-owner-problem/32590/12

Epic Developer Community Forums

Hey guys and girls, i already solved this with the PlayerController as a bridge (as most of you mentioned). Thanks for your time! This thread is already solved for me. If you have any questions that build up on mine, feel free to ask them.

hoary spear
#

There's not much choise beyond routing it through a client owned actor

hoary spear
#

That or edit the engine

warm willow
#

"If your team consistently implements the extra steps for creating multiplayer, the process of building gameplay will not consume much more time compared to a single-player game". Ive recently finished my first (multi) unreal game. And this line from unreal manual makes me feel like an idiot. Because ive struggled hard to get things working compared to single player. Do you with year(s) of exp agree with unreal devs?

hoary spear
#

If you at both starting points would have the knowledge to use the framework as intended, i would kinda agree (altho I dont have years of MP experience myself)

#

I feel like MP forces you to work with the framework, while singleplayer gives you tons of leeway to almost do as you like

#

(Which doesnt speak to the quality or 'correctness' of the code, but if it works per your frame budgets and target performance, it can be considered acceptable)

warm lintel
hoary spear
#

Biggest caveat being related to prediction / lag and compensation of it

warm willow
#

i've added multi when game was like 50% finished, thinking that checking 'replicate' will make multiplayer. And result was like someone hit my face with a brick

warm lintel
hoary spear
#

Its often rewriting tons of code to even get the events in the correct sequence etc

warm willow
#

Yes thats what I did... Can you recommend any unreal sample to learn multi? Although Ive finished the game I feel 50% of stuff I coded badly. I did everhing in blueprints, is it big no-no when doing multi?

hoary spear
#

It certainly constrain you heavily compared to the fine-grained control you get in c++ when it comes to replicating properties and whatnot

#

Dont really have much learning material beyond stuff pinned in this channel already

warm willow
#

thanks

#

heres screenshot to make your day better

#

love pasta

hoary spear
#

Ugh

#

Yours?

#

Functions functions functions

warm willow
#

yeah

#

oh this particular graph have 60 functions hehe

hoary spear
#

Not enough apparently ๐Ÿ˜…

warm willow
#

fix on fix on fix on fix

hoary spear
#

AI?

warm willow
#

pseudo AI

#

with mimicking user clicking on ui

hoary spear
#

Damn

#

This reminds me of an old game i used to play

warm willow
#

jones in the fast lane

hoary spear
#

Yepp!

#

Damn, 25 years ago or smth ๐Ÿคฃ

warm willow
#

good times playing on single pc with friends

tardy fossil
#

can GetActorEyesViewPoint be used on a client?

torpid storm
#

Of course

indigo brook
#

I need private multiplayer tutoring. I'm not fully grasping things and I need just one hour of someone's time to help answer any questions I have. Any takers?

dark parcel
#

paid?

indigo brook
#

I mean, do you know your stuff? @dark parcel

#

If it's paid, I expect you to have some proof you know your stuff haha

dark parcel
hoary spear
indigo brook
modest crater
#

I know you cant replicate a tmap in a traditional sense but is it fine to serialize and send a version of a map over rpc inside of a struct payload

chrome bay
#

you can do it yeah

storm wind
#

I'm having an issue, when 2 player connecting to the same dedicated server using open level + ipAddress of AWS ec2 instance, the one of the player controller sometimes stucked

#

The issue is when 2 player connect in the same moment

#

It happens in aws, also happen in my dedicatec server in my local laptop using PIE 2 player

deft plinth
#

Check out your Game mode. PostLogin is called after a player joins. Maybe you overriden something there already and broke it for anyone other than the first player
If you can't figure it out, try it out with an empty level or different game mode.

#

Game Mode is responsible for handling the player connecting to the server. E.g. how to spawn their pawn/character and such

fluid lichen
#

Hello, I started to learn multiplayer programming in UE using these articles:

https://docs.unrealengine.com/5.3/en-US/multiplayer-programming-quick-start-for-unreal-engine/
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/HowTo/RespawnPlayer/

and I'm trying to make RespawnPlayer replicated, so I added:

    UPROPERTY(ReplicatedUsing = OnRep_bIsDead)
    bool bIsDead;
    UFUNCTION()
    void OnRep_bIsDead();
    void OnDeath();

void AMultiplayer3PTestCharacter::OnRep_bIsDead()
{
    OnDeath();
}

void AMultiplayer3PTestCharacter::OnDeath()
{
    CallRestartPlayer();
}

void AMultiplayer3PTestCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);
    DOREPLIFETIME(AMultiplayer3PTestCharacter, CurrentHealth);
}

to the Character class

Also modified the SetCurrentHealth to call OnDeath

    if (GetLocalRole() == ROLE_Authority)
    {
        CurrentHealth = FMath::Clamp(HealthValue, 0.0f, MaxHealth);
        OnHealthUpdate();
        if (CurrentHealth <= 0)
        {
            bIsDead = true;
            OnDeath();
        }
    }

but I never added bIsDead to the GetLifetimeReplicatedProps

And it still works as I expect:

  1. server calls OnDeath() then it calls CallRestartPlayer() which calls Destroy()and then it calls gamemode's RestartPlayer for specified controller

My question is how the clients know that the character is dead if GetLifetimeReplicatedProps doesn't have bIsDead variable?

solid wave
#

Hi, I migrated lyra's locomotion for our project and I only use it with the AI character's. Currently it works but only on server, on the client everything is wrong. I did assume that we don't need to replicate stuff for the AI as all the calculation's are done on the animation blueprint, which happens on both server and client. Any idea if I also need to replicate something like they did on Lyra's movement component, even though we use it only for AI? Thanks for any help

jolly nymph
#

greetins i have a problem with my project, i used the online subsystem for to connect my Oculus quest 2 device to my PC, my device as client and the PC as a serve, before works! but now idk why it doesnยดt work. may some body can help me

maiden flame
#

@jolly nymph Are you testing with localhost? Does FindSessions trigger OnSuccess or OnFailure?

pallid mesa
#

Also! The client shouldnt call "RestartPlayer", only the server, as its a server authorative action.

wary marsh
#

Noob Question again. I'm getting stuck trying to get a property from player state and replicating it properly. Made a video showing the issue if someone could help point me down the right path that would be much appreciated!!

sinful tree
# wary marsh Noob Question again. I'm getting stuck trying to get a property from player stat...

Text Renders don't replicate, so yea, you don't need to mark it as replicated.
Part of the problem is that you're using the player controller to replicate the name you want to use. PlayerControllers only exist on the server or the owning client, so the server would have both the local player controller and the client's player controller, but the client would only have the client's player controler - this means they wouldn't receive the new name value for the other player.

wary marsh
dark edge
#

It should be as simple as:
WhateverTheServersideOnPossessIs -> shove the right playerstate's name variable into the pawns text render

#

I think OnPossess is serverside

#

er wait a sec

#

yeah you want a clientside onpossess, sec

#

or on possession changed

wary marsh
#

so perhaps better to run this logic on the gamemode?

dark edge
#

no

#

the pawn has enough info

#

That's your getter

#

now you just need a WHEN

#

Test, use a timer or delay loop on beginplay, just in the pawn:
GetPlayerState -> cast to YourPlayerStateClass -> pipe the name into the text render

#

make sure that works

#

then solve the WHEN problem

wary marsh
#

okeey okeey i'll give that a go.

dark edge
#

The way to approach these problems is to sort of start from the fundamentals.
At any given time, does a pawn on any machine have enough info to know what name to put in its TextRender?
Since pawn can get the corrosponding PlayerState, and those are replicated, and name is replicated within it, then pawn should already have enough info on any machine. No need for any additional networking. You just need to find the right trigger event.

wary marsh
#

I think that was sort of where i started but then probably started chasing a red herring when it didnt immediately work

#

okee I have it working now. Thanks a bunch!

storm wind
indigo brook
#

Question: How do you isolate your game instance and get information out of it to apply to a specific client?

#

In multiplayer this is crazy

sinful tree
indigo brook
#

@sinful tree Maaannnn I tell you, I tried this that and the other thing and for some reason when I try to load that info into my client, it just dosn't happen. I'll get screenshots. I've been stuck on this for a freaking week and pulling my hair out haha

#

L_Lobby_Multi
-Game mode casts to player controller to spawn third person character
-Player controller spawns third person character
-Server has his clothes
-Client does not
L_Persistent
-When I change clothes in the persistent level, it looks fine in game and replicates...but it does not save
-When I go back to main menu, it's the default save clothing choices

#

I fixed the save issue for the server, I missed the connection here

#

Easy mistake, yet, my client still arives naked haha

#

Net next step is to get the freaking clients charcter info loaded up, having trouble

#

Any tips based on what you seen in the bp's

placid flame
#

Hello, I was trying to search for someone that could achieve a p2p connection, what are you using exactly to manage p2p? are you truly using a solution without a server? are you keeping the way that networking works in unreal?

#

Well I'm trying to create a p2p solution, I thought there was no way in doing that while keeping the unreal's networking system.
A partner of mine create a web socket solution with a kind of json format to replicate basic stuff such as locations.

But is there a native implementation to create a connection without a server? I'm still not sure if EOS p2p is just to handle services like invitations and matchmaking.

fossil spoke
#

@placid flame There is no such thing as Peer 2 Peer in unreal in the context of what you want.

#

Unreal has a Server Authoritative architecture.

#

There is always a Server

#

Whether thats a headless (dedicated) or a Player operating as a Host (Listen)

placid flame
#

oh okay, then why is a lot of people talking about p2p? I saw that someone explained that it is a misunderstand

fossil spoke
#

Because people throw terms around without understanding their meaning or provide context to what they are actually talking about

placid flame
#

yeah thank you, that was what I was trying to clarify

fossil spoke
#

EOS does use P2P messaging, but it has nothing to do with the overall server architecture of Unreal

placid flame
#

okay, well we could achieve a p2p solution, but is pretty much recreating the server's code with web sockets, I'd love to see if someone else has any improvements, but I only find people confusing terms

fossil spoke
#

Honestly in my opinion, unless you have specialist engineers and a lot of money, its not worth even trying to introduce P2P as you understand it, into Unreal.

#

Its gameplay framework is just not designed for it.

placid flame
dark edge
#

Seriously though, your best bet for something that simple will be to just get some sort of communications endpoint in the game and run as standalone on all machines

#

the game process doesn't know it's "networked", just theres data coming in from somewhere which affects game state. None of the Unreal networking is in play.

placid flame
dark edge
#

Yup that shouldn't be too hard, depending on what you're actually doing.

placid flame
#

I love it cuz it avoids server and client crashes

dark edge
#

You doing something liek Dark Souls soapstones or what?

placid flame
#

but well I'm the master in unreal, not in web sockets and backend, I wanted to get some help in order to do it by myself

dark edge
#

they are little messages you can leave on the ground and other people can see them

#

and vote on them

placid flame
#

I hope so

dark edge
#

"Fort
night"

"Is this a dog?"

"Try finger
but hole"

etc

boreal bison
#

If I want to handle assigning teams, for example, allowing players to select their team in a lobby, where is the best place to actually represent what team the players are on? Right now I'm basically using boolean values that I track within the game instance so that it's maintained when the players move from the lobby to the game level, and then in the game level gamemode blueprint I use the boolean to determine what team the players should be on

#

but something about that seems extremely flimsy and not the way I should be doing it, even if it technically works

dark edge
#

I'd put it on PlayerState

boreal bison
#

but is there a best way to actually represent the teams themselves other than booleans?

#

I have no idea what best practice is

boreal bison
#

Enum sounds pretty good

shy gust
#

hey all, with these nodes , do either of them account for players that are still server traveling? or are they just counting the loaded the players?

trying to check for all players to be loaded before starting play.

obsidian halo
#
Only Local Player Controllers can be assigned to widgets. BP_PC_C_1 is not a Local Player Controller.

Im getting this error everytime im doing this

#

can anyone help me whats wrong

#

but when i do this the error gets resolved, i just randomly did this but i wanna understand how it got solved

obsidian halo
dark parcel
#

@obsidian halo the begin play will run on every single actor and every single machine

#

So if u have 5 of your player character instance in your world, you do be running it 5 times on each machine

obsidian halo
#

yes and it will get called on both server and client

dark parcel
#

So u r adding the widget as many times as there are number of instance in the world

obsidian halo
#

yea

dark parcel
#

So what u have to do here is

obsidian halo
#

i did this

dark parcel
#

Only create widget on the actor that is controlled by the local player

#

Exactly

#

That will do the trick

obsidian halo
#

yea thanks for the explanation!

dark parcel
#

By doing that, if the character is not owned by the local player, it will just go to the false node, so the widget only created once this way

obsidian halo
#

yes

bright summit
#

Ok I have a problem and have no idea what's wrong. When my bool is changing OnRep function is not being called. I know that it is called when it is changed on the server but I checked it and var is changed in server and client so it should be called but it's not.

.h:

UPROPERTY(ReplicatedUsing = OnRep_IsFullySubmerged, BlueprintReadOnly, Category = "Base Player|Movement|Swim")
    bool bIsFullySubmerged = false;```

.cpp:

```cpp
        if (fWaterLevel >= fFullySubmergedLevel)
        {
            if (GetLocalRole() == ROLE_Authority)
            {
                UE_LOG(LogTemp, Warning, TEXT("Server"));
            }
            else
            {
                UE_LOG(LogTemp, Warning, TEXT("Client"));
            }

            bIsFullySubmerged = true;
        }```

OnRep:

```cpp
void ABasePlayer::OnRep_IsFullySubmerged()
{
    GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Purple, TEXT("Submerged state changed"));

    if (!bIsFullySubmerged)
    {
        // Here will be it fired once?
        GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Purple, TEXT("Player is no longer submerged, we can play particles effects!"));
        OnEmergesFromWater(GetVelocity(), GetActorLocation());
    }
    else
        OnFullySubmerged(GetVelocity(), GetActorLocation());
}

Edit: I have bReplicates = true; and GetLifetimeReplicatedProps implemented

bright summit
#

Ok, had to change this value via Server RPC

#

should I every variable change via serverrpc if I want to be replicated or only when I want to use OnRep function?

last storm
#

Hey, I have issues with replication:
I defined a value like this:

FWeaponData WeaponData;```

and set GetLifetimeReplicatedProps:
```void AAriseRangedWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    DOREPLIFETIME(AAriseRangedWeapon, WeaponData);
}```

But the value of my structure is always equal to its default value on the client, any idea ?
chrome bay
#

AAriseRangedWeapon also needs to be replicated

#

Also, what does the FWeaponData definition look like?

rapid pike
#

Can someone help me with this. Why is this setting greyed-out?? I really want to open a client viewport much bigger than these settings.

#

Now I need to rescale with every play

crisp shard
#

i realize this process will be much more complex than the answer i receive (possibly) but how can i make it so that in a muliplayer open world like game, quests take them to a different instance of that world, so that they are no longer inside the same game world as other players? so that they can complete quests that might trigger thing in world that i don't need/want other players to experience

chrome bay
#

You'd need to send them to a completely different server

#

Not really much different to a "Hub" style server system where the hub server spools up another game server on your backend, then sends all/required players to it when it's ready.

crisp shard
coarse aspen
#

Hi All! Some help needed with dedicated server. All works just fine, but after some time if no one is playing he game, server hibernates. Players can't connect, unless I press 'Space' button within the server console. Any ideas how to keep server running?

plush shoal
#

Hey just a general question regarding voice chat, is there a specific way you're meant to do it, since the documentation for it is horrible and the tutorials are basically non-existent and don't work

chrome bay
crisp shard
#

or maybe have them have like a transparent mask around them when they are in a quest and an enemy ai that pertains to it isn't interactable by the other clients

#

or maybe even having places that are only access when on the quest. i suppose there are other methods to solve the problem

brazen anvil
#

Can putting certain information on the player state open your game up for cheating? Like for example if you had your inventory on your player state and now that all clients have a copy of your player state they can "see" in your inventory?

chrome bay
#

Assume that any data you send to a client can be read by that client somehow, even if you don't put a mechanism in game for them to see it.

#

Inventory on a Player State seems like an odd choice to me but obviously depends on the game

unkempt tiger
brazen anvil
unkempt tiger
#

i personally find the idea of putting an inventory on the player state appealing, because that way the inventory naturally persists across deaths as pawns come and go, giving you control over what to do with the inventory should a player respawn. there is also the 'outfit' part of the inventory (which arguably should be a part of the inventory) which other players should be able to see (if your game has outfits), so the pawn can be an external observer and react to changes in the owner's player state

chrome bay
#

yeah very much depends on the game really

brazen anvil
#

I want to aim for a game that kind of combines EFT with Day Z

#

So I think having that inventory state during the entire game session would make the player state a good candidate?

lament flax
#

how does multiplayer works with anim graph

#

some states arent the same between client and other clients

chrome bay
#

anim graph has no networking

lament flax
#

mh

#

when printing in the event graph i got weird results

lament flax
chrome bay
#

not supported, nothing in an animation is network relevant

lament flax
#

because you can see the player running and stuff, and its replicated

dark parcel
#

Anim graph just read values

lament flax
#

so states are replicated

chrome bay
#

They are driven from data that comes from other systems

dark parcel
#

from the character or w/e

#

the character can have replicated values

#

liek onCrouch

lament flax
#

so each client gets from server the data ?

dark parcel
#

the graph just read w/e the value from the owner

dark parcel
lament flax
#

client or server

chrome bay
#

Both, independently

dark parcel
#

i think there's a bit of misconception when you say that

chrome bay
#

server has no idea about clients animation, client has no idea about servers' animation. They are completely independent

dark parcel
#

it just care about it's owner in it's machine

lament flax
#

because on debug, the animgraph exist on server and client

chrome bay
#

That's because there are two of them, one on the server machine, the other on the client machine

dark parcel
#

everyone have their own version in their own world

chrome bay
#

Assuming you had one player ofc

lament flax
#

okay

#

the only thing that isnt sync between clients is this aim offset

#

and i cant find out why

dark parcel
#

U don't just expect things to be in sync

#

that's your responsibility to check what should be in sync and how to sync them

#

if you need something to be sync, then it can be a replicated variable (Not the variable inside the anim graph ofc, but the value from the anim graph owner , eg your player character)

lament flax
dark parcel
#

if you need something to be sync, well then sync it

#

by reading a replicated variable for example

lament flax
#

isnt the character the same on clients ?

lament flax
dark parcel
#

not sure what logic and what you mean by that

#

could be doing something wrong but I can't tell

#

for something like aim offset, pretty sure there's a replicated value that you can use from the player controller

lament flax
#

doing some math

dark parcel
#

but don't ask me, I don't do FPS

lament flax
#

from other client, you are the default aim center pose

dark parcel
#

debug

#

find out why the client's pitch and yaw is not updated

#

you probably didn't tell the server to update the var

dark parcel
#

but again, for something like aim offset, im pretty sure there is an existing variable you can use

lament flax
dark parcel
#

๐Ÿคทโ€โ™‚๏ธ , ask someone that knows. iirc there is something like that

lament flax
#

these are the only default made vars

dark parcel
#

Unreal is kinda made for FPS game

#

i mean the engine it self

#

it would have somehting like that handled

lament flax
#

prob

#

i am doing a TPS tho

dark parcel
#

same deal then

lament flax
#

idk if UE was used for something else before

dark parcel
#

it's used for all types sort of game

#

but the CMC it self is made for competetive shooter is my guess

#

cathered to it

maiden flame
#

They have a default node for yaw or pitch (can't remember which is responsible for looking up and down), which is automatically replicated. However, for sideways aiming, you would have to replicate your own logic from the pawn or similar.

lament flax
# dark parcel it's used for all types sort of game

i mean, when you are a studio and are building games, you either make you own engine or use another one

epic games made their own, and before fortnite i think UT is the real entry point (because it had a level editor really similar to UE4)

#

maybe it wasnt "epic games", prob another group name, but you see the point

#

is this a bit to much ?

#

should i replace this by "get world delta seconds" ?

shadow aurora
#

Anyone know if there's an event on the client that gets triggered when they're disconnected from a server that's crashed? Want to add a timeout message and then boot players back to lobby in that case...

unkempt galleon
quasi tide
#

(Of course Epic's games as well)

lament flax
#

what games epic made that required to start making their own engine

#

before it became a public engine like nowdays

quasi tide
#

UE was made for UT, yes. Beforehand though, Tim made things like ZZT and Jill of the Jungle

hexed star
#

Hi there..

I'm currently struggling with a Problem targeting a SceneCapture2D in my PlayerCharacters.
The Screenshot shows the BeginPlay Setup of the Capturing..

The Select choses one of two RenderTarget textures, depending on the Playr Index of the Session (2-Player Coop.. so 0 or 1).

The Problem is...:
I can't get it to work to have both Players have their own Animated, rendered Texture in their Inventory.. Only Player 1 has it fully working.. bot not the joined Client...

Can one pass me a Hint?

#

Player 2 simply has a white RTT...

dark parcel
#

@hexed star check if the controller is valid?

hexed star
#

It indeed is..
Calling that from Event Possessed

dark parcel
#

u want to check if everything is set in the client machine

lament flax
lament flax
#

Ty

brazen anvil
#

looks like windows 11

hexed star
hexed star
lament flax
#

Yeah i guessed that

#

Didnt knew that node graph assistant had an option to change style

drowsy blade
#

Noob question, if I replicate a variable with OnRep and also handle the server side update of the variable. Can I assume that the value in the details view should be correct for clients and server?

lament flax
#

To update a var on server and make it replicated to clients. You have to set it on server side

hexed star
#

OnRep will always be called, when the variable changes on server side, only.
And it will call the moment, the variable got updated on the client.

drowsy blade
#

Yes. So I should expect e.g. count to represent the correct value for each client when inspecting that value in the editor details section.

#

Why in asking is because i see different outcomes from the UI of a client compared with the value in the details view for that client

dark parcel
#

try to print the value as well in the rep notify function

#

see if the client actually gets an update

drowsy blade
#

Yeah, if I press a button I can get the value to decrement correctly in the UI for both client and server, I must have done something else wrong

#

Thanks โค๏ธ

lament flax
lament flax
#

also, when setting a var replication to "owner only", does it propagate to actor components ?

dark parcel
lament flax
dark parcel
#

event tick -> Get delta seconds

lament flax
#

okay

dark parcel
#

afaik get world delta seconds give an almost same number

lament flax
#

ill make it owner only

dark parcel
#

down to the small decimals

lament flax
#

okay ty

primal trellis
#

Hi guys!
my animations on the client are jittery. Only for the client character, doesn't happen with the host character. Both the client and the server can see the same thing, I will send two example videos (in the last seconds of the first video you can see it well). Does anyone know possible elements that I can check or study to try to find a solution?

More info:

  • I'm connecting via Steam
  • I'm only using blueprints
  • Both PCs and internet connections are good (the problem happens always with the client)
  • I used a default thirdperson character controller as a base, but I changed the
    mesh and SK, and created my own ABP
  • Using an animation blend for movement
  • It only causes problems in the build, the same doesn't happen in the editor

https://www.youtube.com/watch?v=cy43agEjFNE

fluid lichen
#

@pallid mesa Thanks, really helpful "VS watch", I also had to change the configuration from "Development Editor" to "DebugGame Editor" because debugger was ignoring a few breakpoints when I used the "Development Editor" configuration

Server executes:

Character#OnDeath()
  Character#CallRestartPlayer()
    Character#Destroy()
      Character#Destroyed()
        GameMode->GetOnPlayerDied().Broadcast(this);
          AController* CharacterController = Character->GetController(); // returns NULL in the GameMode for some reason
    GameMode->RestartPlayer(ControllerRef); // calls Super::RestartPlayer(NewPlayer); // NewPlayer is not NULL

Client1 executes:

Character#Destroyed()

Client2 executes:

Character#Destroyed()

Now I see that technically the clients don't see that the character is dead they just react on the server's Destroy()/Destroyed() call ( automatically replicated by the UE's code I think ). Also I'm not sure if it's bad that GameMode's RestartPlayer() runs on the server before each client runs Destroyed() function. Looks like the GamMode's RestartPlayer() is also automatically replicated, because I run the dedicated server with 2 clients and on the both clients I see new Character spawned.

Will check GetController()'s implementation to see why it returns NULL for the character's reference in the GameMode's function

maiden flame
#

@primal trellis It doesn't look like a latency issue, but rather a discrepancy between what the client is trying to do, and what the server is telling it to do.
That's probably why it does not affect the host. Essentially, the client is in disagreement with the server, and the server is constantly trying to correct it.

A typical case for this type of jitter is setting walk speed on the server, but not on the client, or rotation rate on the server, but not the client.
To remove jitter, you have to set whatever you intend to replicate (e.g. walk speed float) on the server and locally to make them synchronize.

primal trellis
#

Thanks for answering!
I just didn't quite understand the ending: "to remove jitter, you have to set whatever you intend to replicate (e.g. walk speed float) on the server and locally to make them synchronize."

What I understood is that the server should take care of everything and then replicate the information to the clients

But in your example, so I have to make everyone, e.g. take care of their own speed and then I make them synchronize it?

What would be an example of how I could set this walk speed correctly?

(sorry for the possible doubts beginners, it's my first multiplayer)

maiden flame
#

Basically, if walk speed is not synchronized, you can fix that by setting the walk speed on the client, and on the server.

#

The server has authority of course, and should handle all gameplay events, but we can help it by settings things locally. As long as the server agrees with what we set, there should be no discrepancies.

shadow aurora
#

If I've got an actor that's out of relevance, and teleport in to relevance, is there a way to not play an audio component attached to it from the start, and instead pick it up where it would be for folks who were in-range the entire time?

primal trellis
halcyon mural
#

Can someone summarize multiplayer for me? Like the different aspects of it and how it works on a technical level? Just so I have a better understanding of multiplayer as a whole and how it functions in a game

maiden flame
#

Hmm @shadow aurora. I don't have experience with that, but what about saving a timestamp of when the audio started playing, and once it comes into relevance, we check how long ago it played?

wanton bear
#

hey everyone, how do you deal with primary data assets in multiplayer

#

i have a player who selects a building which sets a data asset variable to the one theyve selected, then i want to replicate which one is selected on another client. should i just replicate the variable or the asset id or something else

lament flax
#

hello

lament flax
wanton bear
#

that seems incredibly wasteful if its static data no?

lament flax
#

example

wanton bear
#

i was considering just sending one key bit of info so i can search through all the assets to find the right one

lament flax
urban moth
lament flax
lament flax
#

that only actors and actors component have

urban moth
lament flax
wanton bear
#

would replicating primary asset id work?

lament flax
#

idk, test

lament flax
#

as i said earlier, you can make it replicated

#

there is even plugins to do that automatically

vagrant grail
#

I have a variable in the GameState set to array replicated, and when trying to print its content by the host of the game it has the right content, however when I try to print its content by the client it doesn't have the same content, why is that ? I print that in the Player Controller like this

lament flax
#

i just stayed with struct to be more clean

lament flax
wanton bear
lament flax
#

my inventories are small so i can allow this

wanton bear
#

but you dont need to replicate data assets? everyone has the same data assets on their systems

lament flax
urban moth
lament flax
wanton bear
#

no, replicate which data asset the first client is pointing to

hollow eagle
#

Anything with a "stable" name (so... any asset on disk) can be replicated this way.

lament flax
#

the ref is still null if i remeber correctly

wanton bear
#

so i can just replicate it and itll work? i assumed itd have to be loaded or something

lament flax
#

thats the issue i had

wanton bear
#

im new using data assets so

hollow eagle
#

In general, replicating a pointer to something isn't replicating the data inside that pointer. It's replicating a reference to that object (which would need to exist on both sides already). This is super important for assets.

urban moth
wanton bear
#

interesting, thanks for the info siliex

wanton bear
vagrant grail
wanton bear
#

i may be wrong, but i think arrays only replicate when you set them rather than add items

wanton bear
#

i believe this is something i ran into before a couple of times

#

i ended up doing a rep notify with single variables and then on the notify i added it to the array

urban moth
#

so if you have a bigger array(or array which tends to be bigger in the future), you could think about FastArraySerializer(c++ only)

vagrant grail
lusty sky
vagrant grail
urban moth
lusty sky
vagrant grail
urban moth
vagrant grail
#

And here (still in the lobby) I disabled all the roles for examples except 2 then start the game

#

On the left side it still printing all of them because I'm still getting the GameInstance values which is not where I save when I enable / disable roles as I save that in the game state (in the next level being where people would play)

urban moth
#

man I mean NETWORK Role ๐Ÿ˜„

vagrant grail
#

Now I'm in the next level (so no the lobby anymore) and press P and it prints only the 2 enabled roles, so that's all good on the host side

#

However on client side it's still printing all the roles

vagrant grail
urban moth
vagrant grail
vagrant grail
#

And as I'm printing that in the Player Controller, it's owned by the owning client if I'm not mistaking

#

Ok then doing this fixes the issue

urban moth
#

that's correct(sort of.. PC is autonomous proxy, but for a sake of a simplification yes, client "owns" controller).. Server owns gamestate which is replicated to all clients.. but only server should do changes in there.. means when you want to replicate something to all clients, so you have to check HasAuthority() and make changes only when you really has an authority otherwise there is a solid chance that server replicates your variables correctly but you erase them by local version

urban moth
vagrant grail
vagrant grail
#

Another question : How would you test something like in my game where I need to distribute all the roles in the game (there are 16 roles so 1 per person) without having to open 16 clients window ? ๐Ÿ˜„

lament flax
#

from server print ?

i would rather open a couple of time the 16 windows to be sure each clients know what they are

urban moth
vagrant grail
urban moth
#

so it means your game always need to be played by 16 players right

vagrant grail
#

you can play with how many players you want (I need to set up a minimum still) and the max is 16 players. So depending on the amount of players and the amount of enabled roles, the game will distribute those roles so everyone has role and if there aren't enough roles to give to everyone because the amount of enabled roles are lower than the number of players in game I will either fill that by giving simple roles like Simple Villager and Simple Werewolves or I will give certain roles multiple times.

I will create a setting for that to let the host choose which one he prefers.

urban moth
#

so you answered your question by yourself or?

vagrant grail
#

I will give you an example : There will be a role that will make the name of someone being killed being displayed to only certain roles and other roles will see that name being blurred / censored. So I have to make sure that every role I wanted to see the name being able to see that name while others must not see the name, so that's a reason why I need to test it with alot of players to see all the roles and if my programming skill succeed doing that.

dark edge
#

if you just open the game and not the editor you can have quite a few no problem

urban moth
# vagrant grail I will give you an example : There will be a role that will make the name of som...

I could say you something about
https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/GameFramework/AActor/IsNetRelevantFor/
or implementing a rule in your ReplicationGraph(filter certain connections)
but I think that for your own sanity just replicate kills on all clients through GameState and filter it on client's UI.. I know it could be hacked, but you can tweak this later

Checks to see if this actor is relevant for a specific network connection

#

e.g you will replicate to each client that player with role A gets killed.. and on all clients you will do some check if (KilledRole == MyLocalPlayerRole) do this.. else do nothing..

vagrant grail
urban moth
#

why you need to test it in a game.. it is not a network related problem. it is a design

vagrant grail
urban moth
#

sorry, dont get it.. well good luck man ๐Ÿ˜‰

vagrant grail
maiden flame
#

Just test with the minimum amount of players needed, and test combinations for all roles. If it works with four clients, it should be scalable and work with more.
If you need to test with a lot of players, test with LAN using multiple packaged instances to reduce performance load, maybe with two computers.

#

Make friends help you.

vagrant grail
vagrant grail
maiden flame
#

I have heard you can make them ๐Ÿ˜‰

vagrant grail
hoary spear
#

Cant you spawn a bunch of pawns and test your logic on those in a non replicated scene ?

#

If you're worried your distribution of roles is incorrect. Test it in a minimal environement.

#

No replication, just a bunch of Actors

#

Can test 10 roles , 15 pawns and vise versa (dont need no real friends for that. Can use fake friends. Fake friends are nice)

#

@vagrant grail

west cairn
#

Noob in need of some help with replication and ownership in the context of simple tutorial task.

The task is to make a simple button press animation and have it be replicated to all clients(ultra small demo task, not worried about net cull or any distance gate, consider all of that well past my current level of understanding and demo requirements)

I have so far: Made the button press BP, added static mesh, collider box, added logic for collider component overlap, added simple timeline and anim logic for button as well as getting player input and allowing the button to be pressed by "E".. all of this is contained in my BP_Button - How should i go about sending an RPC to the server that the button press has taken place? I have tried creating a variable bool and passing this to server and an OnRep function without success(probably incorrecly mind you)

#

This all takes place on BP_Button - I tried to add in server logic and RPC here but failed. It feels like maybe I have not understood the problem well enough or making a basic mistake i think

#

I really wanted to have the client just toggle a bool and then have the server replicate the animation entirely too all clients

twin juniper
#

Did you try a rep notify using that bool variable?

#

It helps with visual things that are changed by the server but the clients need to see

#

Instead of just replicated you do rep notify and handle the animation in the function that it creates

dark edge
#

If it's a pawn and a button actor, it'd have to be like this:
Pawn:
Input -> RPC
RPC -> get button -> toggle bool

Button:
OnRep_bool -> call event OnBoolChanged
OnBoolChange -> branch on bool -> enter timeline

#

you can't directly have a timeline inside an onrep, that's why you need event OnBoolChanged

west cairn
#

I am too embarassed to post the photo of my blueprint

#

๐Ÿฅฒ

#

So lets try this like a computer might, line by line.. Kaziie, I will attempt now to create a rep notify using the bool Is A

dark edge
#

Start with the bool in the button.
Set up your button so that
Begin play -> branch on authority -> bool = !bool -> 3s delay -> loop back

#

put a print string on the onrep for the bool. print it, make sure everyone agrees its flip flopping

#

then just directly set relative location in the onrep

#

then add an event so you can use the timeline instead of instantly snapping

west cairn
#

I appreciate this super detailed and fast reply Adriel!!

#

I think i got to about here before I cannot follow

#

So far i am clear on lets try to make Is_A a var, then set this variable to a RepNotify replication type. However further steps are unclear

dark edge
#

ignore input for now

#

remove all inputs from the button

#

you need ownership to call RPCs through an actor so putting inputs on the button isn't a great idea.

dark edge
#

you should set it to be NOT(IsA)

#

and also loop that delay back into the set

#

so it keeps flip flopping

west cairn
#

I dont know how to do the test loop youve specified but the OnRep print string is working

dark edge
dark edge
west cairn
#

Hmm? im not sure i follow

#

Why dont we just remove the test loop and focus on the onrep?

dark edge
#

get the test loop going

#

i literally just handed you it

west cairn
#

Hah! im sorry i am quite dense

#

I dont get it ๐Ÿ™‚

dark edge
#

Do this

west cairn
#

OnRep appears to be working

dark edge
#

ok show what you got right now

west cairn
#

Looks like more functionality on the same test. ButtonPressed or "True" or "False"

#

i dont really get the difference

dark edge
#

false means Button unpressed

west cairn
#

the main issue i think is i dont understand how u mean to loop back over that delay

dark edge
#

just drag the execution so it loops forever, flipping the IsA from true to false to true to false to true to false forever

west cairn
#

Yes false would mean state of the button is depressed((like me working to learn netcode))

dark edge
#

false is button NOT pressed

#

I wouldn't call it Is A though, call it ButtonIsPressed or whatever

#

IsA doesn't mean anything

#

Once you understand this, change the onrep to move the button to a different spot DEPENDING ON THE BOOL

west cairn
#

I see what you mean on the looping delay! ugly as sin but works like this right? :

dark edge
#

Onrep -> if bool -> true -> button position should be down
-> false -> button positon should be up

#

yeah it's just a quick and dirty loop, you could use a timer but this will work

west cairn
dark edge
#

Better than the branch is to use select though

#

yup that's perfect

#

dirty but gets the job done

#

so now you got a flipflopping bool, now make it do something visible rather than print a string

west cairn
#

Man why is visual scripting so obtuse ๐Ÿฅฒ !! I want to write the word "for" so badly it hurts right now

dark edge
#

there is a for loop but that wouldn't help you here lol

west cairn
#

This bool is also server side i can see from PIE

#

which is good news!!

dark edge
#

yes it's server side, and gets replicated to clients

#

and the onrep fires when it changes

west cairn
#

Understanding this flow has been so tricky w/ docs alone - i will attempt to use custom events to call the button animation now with onrep?

dark edge
#

Now just snap it to position

#

do animation later

#

onrep -> set local position (select position based on bool)

#

select node is what you want. it'll pick one of the vector inputs based on the bool

#

you can also select on enums too, it's templated for all sorts of stuff

west cairn
#

In my image above for the loop - we are setting Is_A = False, i have yet to get that flip flopping like you had wanted to achieve

#

hmm

dark edge
#

isA -> NOT -> Set isA

west cairn
#

I dont follow this last instruction

dark edge
west cairn
#

How do you access the logic gate functionality?

#

I am not seeing any NOT or logic gates familie to select from

dark edge
#

Do you see how this works?

west cairn
#

OK! Makes sense line for line in pseudo style : Get Is_A, Invert its state with the NOT, then use that state to Set (With OnRep)

#

The Pick_A var into the select vector is something new may take a few minutes - set rel location i see you've chosen to simplify inplace of the timeline , for testing i assume?

dark edge
#

yes, crawl before running

#

since timelines can't run in a function then you'll need a new event and also need to handle trickier situations like what to do when you release button before timeline is done etc

dark edge
# dark edge

After, this, the final timeline version will probably look like this:

#

and that'll be it

#

button done

#

now you need to handle the path between the clients input and the bool being changed

#

but get button done first

west cairn
#

For this you mention the client input, at that point we may be adding to our character BP?
Heh but first let me get caught up a bit more! so far we've got the server's rep notify loop working and this is being replicated correctly to all clients connected

#

(In case any other new people wish to follow along)

#

AHHH so even better yet i see you've used the Is_A var to select a home , or displaced vector in the Select Vect function! very clever wow . i kept asking myself why cant we just use timeline in our OnRep Functions!

dark edge
#

Yeah the best way to think about multiplayer is "What is the least amount of state or events that need to replicate to make the end result the same?"

#

In this case, it's just a single bool

west cairn
#

After using the Select Vector test to confirm the behavior is replicating, i see you have extended out to a custom event driven from this bool to get that timeline node back

lament flax
#

Hello

Some context about my issue :
when i equip a weapon i change in the anim BP the pose (this pose is replicated to all clients)
i am shooting a line trace from server, the linetrace start is using the world location of a actor (that is attached to a player mesh socket)

when i debug the linetrace, i looks like that for the server, my actor is next to between my player legs (instead of his arms)
how can I debug this to find the issue ?

#

the pose is replicated between clients, so my server should have it to
the actor is spawned and attached for all clients, so the server should know it to

wintry forge
#

Hello everyone, I have a system for turning the brake lights on and off. If the client connects to the game later and the brake light is on at this time, the client does not see it. I used RepNotify for this and it works. When the client connects late to the game, it sees the Brake lamp without any problems, but I don't understand what should I choose in the Replication Condition, can someone please inform me?

sinful tree
wintry forge
#

I understand, thank you very much.

west cairn
#

Old docs but maybe helpful for giving you an idea of the this function in older engine ver

sinful tree
wintry forge
wintry forge
west cairn
#

As predicted there is no way for the client to access the bool but this is where I was able to get the button task Adriel! Thank you very much for the kind explanation

dark edge
dark edge
#

now all you need to do is change the button on the server at behest of a client

#

Simplified, it'd be like this

In Pawn:

Input -> run on server event //call it Interact or whatever
Interact -> determine what button to talk to (line trace, get actor of class, sphere trace, whatever) -> change its bool

Done

#

The simplest setup would be this. This is literally ALL you'd need.

in pawn:
Input -> run on server event
run on server event -> get actor of class Button -> swap its bool

Do that for now.

west cairn
#

I have been stuck there a bit >.<

#

Even just your delay loop is a great bit of logic that gives me a lot of cool ideas

#

you could animate a wind mill, use net cull to keep the distance player relevant and voila , really cool server side animation replicated to all clients

#

Any mechanical structure could be effectively done i think this way

#

for level design etc, its more than a test loop ๐Ÿ™‚

young spoke
#

in PIE with "Play as Client" selected, i notice that calling ServerTravel() from my GameModeBase doesn't bring the connected client with it?

fossil spoke
young spoke
fossil spoke
young spoke
crimson ore
#

How do you replicate an array of plain UObject in C++ ?

formal solar
#

I thought it was the opposite, that seamless travel didn't work in PIE?

sinful tree
crimson ore
#

I'm talking about replicating plain UObjects by overriding IsSupportedForNetworking

maiden flame
# lament flax Hello Some context about my issue : when i equip a weapon i change in the anim ...
hoary spear
#

That ones a bugger ;p

lament flax
#

Its nice that people are willing to help others

hoary spear
#

Wish i had more time to sink into it lol. Kids change everything , atleast the first decade

lament flax
#

Make them learn UE bigbrain

hoary spear
#

To smol yet

formal solar
#

So weird - if I use the default 'player start' actor in my game I get 'ghost' units spawning on the server corresponding to player starts that players don't use - if I change to use a customplayerstart actor that I created the problem goes away

maiden flame
#

Sweet

obtuse field
#

Is using PendingData num for Buffer size safe?

lament flax
#

i am creating a dynamic material instance and saving it in a replicated var on server
then later on, on server side i am trying to access this var to update a vector param
i get no errors, but the material didnt change on client

did i do something wrong, or materials cant be replicated on server ?

maiden flame
#

Is the variable/parameter being updated on the clients?

lament flax
#

is this true ?

lament flax
#

i think dynamic material instance are unique per client (and cant be shared ?)

#

1 - on server
2 - on server
3- to all clients
4- clients

on 4, the var is null (on server its not null)

maiden flame
#

I don't think it is an issue with material instances, but obviously your client needs to get the data from the server somehow, so all clients can set their material locally and match it to the server state.

lament flax
maiden flame
#

Sorry I'm too lazy to try to solve the specifics of it xD

lament flax
#

no pb

maiden flame
#

You're saying the index returns 0 on clients?

lament flax
#

the material dynamic instance is null on clients when setting it on server

maiden flame
#

Oh. So when you set MaterialDynamicInstance with RepNotify on the server, clients get a null reference?

lament flax
#

on rep of the material var its called once on server

#

not clients

#

thats why its null

maiden flame
#

Got it, just confirming. That's kinda interesting though.

lament flax
#

thats weird

#

idk if its a net issue or the MDI cant be replicated

maiden flame
#

How about... instead of setting the MaterialInstance with a notify, just use a boolean notify, which triggers an event on the client outside the notify?

#

And that sets the material instance locally.

#

We only care about getting the index from the server afterwards.

lament flax
#

found this in a forum of 2022

maiden flame
#

Good to know!

lament flax
#

or i can do a mutlitcast

maiden flame
#

Indeed. I'm sure it could be optimized more, maybe you can call the client side event using the Status RepNotify variable. Of course, you will need some logic in order to select the correct material.

lament flax
#

since its a temp gameplay thing

#

this works perfectly

maiden flame
# lament flax or i can do a mutlitcast

Hmm, possibly. I think it might be safer to stick with a notify, as materials are a state related thing usually.
But if it works, it works. Just make sure clients who come into relevance, or join later are updated.

lament flax
#

true

#

updated to using a repotify bool, works better

maiden flame
#

What about this? Cleanest solution I can think of. Not sure if it would work, but worth a try I suppose.

lament flax
#

thanks for helping

maiden flame
#

Np!

lament flax
#

i did this :

maiden flame
lament flax
#

yes

but i am chaning this var when i shoot

so with your setup i will create a new DMI at each shoot
with mine i create a new DMI at begin shoot, and use it until the end

maiden flame
#

Ah, then it makes more sense.

vagrant grail
#

Is there a way to know when all players were teleported from the lobby to the main level ? I need to be sure that everyone is there before giving roles as I need to know the amount of players in the game

hoary spear
#

Cant you just hand out along the way?

#

Doesnt make much difference

#

Can players join after the round starts?

vagrant grail
# hoary spear Doesnt make much difference

Right now yes, but maybe later it will if I need to give a certain amount of roles left depending on the amount of players in the game (like the distribution between the amount of werewolves compared to simple villager roles)

vagrant grail
hoary spear
#

So no

#

Logically you do the same wether you know or font know the amount of players

#

If roles remain, give role

#

Else handle according to server rules

vagrant grail
#

it's so stupid if Epic didn't put like an event "OnEveryoneJoined" or something like that

hoary spear
#

Who is everybody

lament flax
vagrant grail
lament flax
#

well in your case you just have to get the nb of ppl conneced to lobby

vagrant grail
lament flax
#

using game state (or instance i dont remenber which persist between levels)

#

well its depends of other stuff aswell

#

for eg if you have a matchmaking

vagrant grail
#

right now I don't have matchmaking, it will be people inviting their friends to play with only

shrewd ginkgo
#

I want to make prophunt mechanics but I couldn't find how to replicate the set skeletal mesh. because my English is not very good and because I'm a beginner on unreal engine, I would appreciate it if you explain step by step and in detail as if you were explaining it to an idiot.

vagrant grail
shrewd ginkgo
#

I assigned set skeletal mesh to be triggered with beginplay event but replication is not working

shrewd ginkgo
vagrant grail
shrewd ginkgo
#

I don't care much about making mistakes, after all, I am developing a project for learning purposes rather than a commercial business.

#

So, can you help me with the above problem? ๐Ÿ™‚

vagrant grail
visual mountain
#

Been trying to setup a listen server and just wanted to make sure I understand correctly. If the host is on the server does this mean they replicate independantly without needing further replication? By and large do I need 2 separate lines of code for host and client?

#

do you mean like islocalcontroller?

gloomy tiger
shrewd ginkgo
stoic lake
#

How do i check if the owning player is the server on a widget?

hoary spear
#

Any server check should return true

#

"IsServer"

formal solar
#

Wasted 10 hours because I didn't know 'sets and maps cannot be replicated'
Questioning my understanding of the basics thinking I was missing something incredibly obvious

#

Will the order of player states in the default 'playerarray' in gamestate be consistent, no matter what client i access the gamestate from?

#

I'm hoping so

hoary spear
#

I dont think so

#

Its locally maintained iirc

#

The playerstates are replicated, but the playerarray in gamestate is not

#

@formal solar

formal solar
#

ok ty

hoary spear
#

You can assign id's to the playerstate itself tho, so you can find the correct order if you wanted to

formal solar
#

Cheers for tip, stressed myself out today but at least I figured out what the problem was, going to restart tomorrow

lament flax
#

for some reason, the var seems not replicated

the route is :

1 - set the var on server
1 - call event on owning client
2 - call another event on owning client
3 - get back the var (buts its null ?)

i am in the player state

hoary spear
#

Var is not replicated yet.

#

Use onrep for tjis

lament flax
#

okay

#

is the player state created before or after the pawn ?

half iris
#

Can someone confirm an assumption I am running with in regards to using print strings when debugging multiplayer? I assume we want to add a print string for every set of functionality that has some effect on the other clients/server right?

This way when looking at things like crash logs, we would have more oversight on the different steps a client has/has not gone through

tardy fossil
#

whoa setting the CMC's tick rate low, the character mesh absolute and then lerping between position updates seems to work fine network wise... i wonder if theres any hidden consequences

formal solar
#

well lower tick rate is usually choppier movement

#

and less accurate velocity/physics calculations and stuff

thin stratus
quasi tide
#

If I recall correctly, the PC creates it in like PostInitComponents or something like that

#

Indeed

vagrant grail
#

How does Among Us create games with a code that people can share to their friends to play with ?

obtuse field
#

You mean mods?

vagrant grail
vagrant grail
obtuse field
vagrant grail
obtuse field
#

Does among us make it like warframe? So one player become a host, and rest can join for the game?

obtuse field
#

There is a plugin to make it even better called Advanced sessions

#

Its free

vagrant grail
obtuse field
#

That would be without steam sessions. With steam sessions, idk, never worked with it. Maybe it has some built in api

hoary spear
#

^

#

Sounds reasonable

vagrant grail
#

I guess the Node.js and Websockets parts are done through C++ ?

obtuse field
#

You can actually use any Websocket server

#

C++, Rust(my favorite), Javascript etc.

#

Node.JS is just the easiest one imo

#

Websocket is a network protocol

#

But, Unreal has a built in web socket client api

#

So its shouldn't be very hard to do

vagrant grail
# obtuse field No

No like I'm talking in Unreal, can I do the link between that central server using Blueprint or must it be done in C++ ?

obtuse field
#

I've done this several times

obtuse field
obtuse field
#

But I'm more of a C++ guy

obtuse field
#

Before you start

vagrant grail
obtuse field
obtuse field
obtuse field
vagrant grail
hoary spear
#

HiveMind just makes me think of some alien swarm

obtuse field
gloomy dune
#

Hi, has anyone encountered a similar problem?
In ABP I set the AimRotation value depending on whether the player is locally controlled or not. Then in the CalculateSpineYaw function I take the player's transform and invert the Yaw. The problem is that on the client the Yaw value is set correctly, but on the server and simulated proxy it is equal to zero. As I understand it, the problem is that on the server and on the simulated proxy I get a zero transform. Does anyone know what the problem is and how it can be fixed?

nimble snow
#

how would I use repnotify to play an animation?

fossil spoke
#

@obtuse field Did Sockets end up helping you reach a better solution to your chunk streaming?

lost inlet
#

no need for WS at all for that

#

and Node.js never dies huh

obtuse field
#

Needed to make some research on serialization etc.
Sending data trough TCP is working, not just to do things with the data

obtuse field
#

Can I somehow promise unreal, that << will be valid, or make it to check by template provided type at compile time?

#

Something like that

template <typename  T> void SendBytes(T& Data, APlayerController* Destination)
    {
        TArray<uint8> Bytes;
        FMemoryWriter MemoryWriter(Bytes);
        
        uint32 NumBytes = 16;
        MemoryWriter << NumBytes;
        MemoryWriter << Data; //problem

        MemoryWriter.Seek(0);

        NumBytes = Bytes.Num();

        MemoryWriter << NumBytes;

        int32 BytesSend = 0;
        if(!Connections[Destination].Socket->Send(Bytes.GetData(), MemoryWriter.TotalSize(), BytesSend))
        {
            UKismetSystemLibrary::PrintString(GetWorld(), "SEND ERROR");

        }
    }
obtuse field
#

Ok, so I tested it a little further, and its possible

#

Idk why it didn't work earlier

short arrow
vagrant grail
short arrow
#

It really shouldn't be a problem unless you're game gets massive unexpectedly

#

But I did say from the start It's not the best method, but a quick one

mild lynx
#

In Blueprint, I have a Rep Notify on Begin play to get the Steam ID of players based on the Player State. I send a RPC to the Server and have the server Call Rep Notify. In my case, it's working for players who are already connected, as they can see the names of people who join, but for people just connecting, it doesn't set any of the names of people who are already there.

Get Unique Net ID from Player State is Retuning Invalid. What should I do to fix this?

mild lynx
#

I think I got it working. I just had the Server do a Validity Timer check on the Player State Unique Net ID until it was Valid, then had the Server update the Rep Notify with the Name Result.

dark edge
mild lynx
#

I have a Controller validity check if local, then after that, it calls the Server, which checks the Player State ID, and if that's valid, it sets the String Variable which is rep notify.

That seems to work

sonic obsidian
#

Has anyone had a crash because of this i keep getting crashes (AWorldSettings* ULevel::GetWorldSettings(bool bChecked) const { if (bChecked) { checkf( WorldSettings != nullptr, TEXT("%s"), *GetPathName() ); } return WorldSettings; }) Call stack was showing stuff about HLOD's and LOD's im only getting this problem after setting up world partition.

static lava
#

"While we can predict GameplayEffect application, we cannot predict GameplayEffect removal. One way that we can work around this limitation is to predict the inverse effect when we want to remove a GameplayEffect. Say we predict a movement speed slow of 40%. We can predictively remove it by applying a movement speed buff of 40%. Then remove both GameplayEffects at the same time. This is not appropriate for every scenario and support for predicting GameplayEffect removal is still needed. Dave Ratti from Epic has expressed desire to add it to a future iteration of GAS."

#

Is this still true?

#

I'm trying to create a slow GE, and it is predicted correctly one apply GE_Slow

#

but when It is removed the character rubberbands back

#

or as Dave Ratti has left epic i'm out of luck?

steady musk
#

Hi Matt. Have you found a good way to do this?

Seems like I can go with smth like
FCustomStruct.NetSerialize(Ar, Map, bOutSuccessLocal) + forLoop iterating array
But maybe you found a better way of doing it?

fossil spoke