#multiplayer

1 messages · Page 669 of 1

quartz smelt
#

I'm not sure what's happening

sinful tree
#

You're not doing an RPC or anything asking to kill on both server and client, right?

quartz smelt
#

Nope, nothing like that

#

Omg wait I got it

short arrow
#

Hey so I'm working on a little replicated combat system to advance my knowledge. Anytime the player attacks an enemy I want them to automatically slide closer to the target they're attacking.

My take on this is to use a Vinterp to smoothly suck the player closer to his target, however since this is multiplayer I'd need the server to do this. I don't really want the server setting the actors location every world delta seconds unless that is the preferable method (I don't think it is). Does anyone have any ideas worth trying? I'm not sure if UE has some sort of method in place for what I'm looking for

tepid pawn
#

Hey peeps. Need to know the details for Port Forwarding. Can't find it online. Spent about 5 hours looking so far

hollow eagle
#
  1. look up the manual for your router
  2. find port forwarding instructions
  3. ???
  4. profit
nova wasp
#

don't explain this to your parents it will freak them out

tepid pawn
#

I need to know what "service type" means and what I should set it too.

#

It has Pop3 and Http and DNS etc as choices

hollow eagle
#

the answer is custom

#

ie none of the above

tepid pawn
#

Oh so type the word "Custom"?

hollow eagle
#

no

#

I don't know what you type

#

or what you're looking at

#

that's why I said to look up the manual for your router

#

there is no standard here, it depends on your router.

#

some manufacturers put some common services in there so you don't need to know the ports yourself, but you're not using those.

#

you're ostensibly using some custom port

tepid pawn
#

I see So UE doesn't have a type?

hollow eagle
#

I don't know what "service type" means because again, that's something specific to your router.

#

The only "standardized" parts of this are port numbers and the ip address to route to.

tepid pawn
#

Yeah it seems to be the type of server

#

Like FTP server or Mail server

#

Or DNS server

#

I can't find what a Listen Server is anywhere

#

It shouldn't matter right? If it's a Pop3 mail server, the port should open and an external service should be able to connect

sinful tree
#

If you're able to set the port and that it's UDP, then it probably doesn't matter what you select for the service.

fair lantern
#

does anyone know how I can replicate an animnotify event differently amongst clients?

#

im trying to do this in an actor component, is this correct?

#

I have a feeling that im doing something wrong here, it works but i dont think it is the ideal solution

quartz smelt
tepid pawn
fair lantern
#

Im not doing anything insane

#

just simple replication nodes

tepid pawn
fair lantern
#

u dont know how to open a port?

tepid pawn
#

Tried pretty much every combination

fair lantern
#

u found the settings in router?

#

if not then afaik its not possible if ur router doesnt support it

tepid pawn
#

Yep. It's Nat Server

fair lantern
#

firewall?

#

make sure firewall not blocking

tepid pawn
#

Nat Forwarding Virtual Server

#

I thought I did

fair lantern
#

I remember port forwarding when I was like 10 for a minecraft server, it can't be that hard

#

theres probably something simple ur leaving out

#

idk tho its been quite a while

tepid pawn
#

I just shut down all the firewalls. I'll check again

fair lantern
#

I actually don't know how to make a dedicated server for ue4 btw

#

im quite new myself

tepid pawn
#

Okay then. Firewall it is

#

Thank you

fair lantern
#

hahaha

#

was that it?

tepid pawn
#

Now to make an exception

#

Somehow

fair lantern
#

haha damn im a genius

#

asif that worked lol

tepid pawn
#

LOL

fair lantern
#

firewall check works like 1% of the time

#

haha

#

lucky bugger

tepid pawn
#

Yeah first person in 6 hours to lead to a break through

fair lantern
#

as I said, port forwarding isnt meant to be hard

#

had to be something simple

#

back to basics 😛

tepid pawn
#

Yeah just thought I added an exception already

#

I did but it was the wrong exception

#

Wrong UE4 editor

#

LOL

#

Well now I can get back to work! THANK YOU!!!!

fair lantern
#

kekekekek ❤️

short arrow
fringe galleon
#

ReplicatedUsing runs on server or client?

chrome bay
#

Clients only. Since you can only replicated values from Server->Client

lost dune
#

Have someone the time to help me? , My Move To nodes constantly fails

#

my mob have to move to my player character , both mob and player character have sphere collision around them but i setted it to can't affect navigation

#

the navmeshbounds is correct when i press P

#

the move to is executed server side

#

but always fail

round star
#

Whats a good place to store player inventory. Listen server. What about making an actor component with the inventory struct and attach to each character or no>?

kindred widget
#

This depends on your game style and the inventory in question.

round star
#

I figured as much

kindred widget
#

Server type doesn't matter.

round star
#

Well the inventory saving doesnt matter

#

I mean whjiole playing ya

#

but if you reconnected to same host it is not persistent

#

I am woried to make some huge mistake while deep into it

#

lol

#

Ive done this so many times when doing something because I am naieve and dont ask enougfh for help

kindred widget
#

Generally speaking, I'd say to place it on the Playerstate if you're unsure. It has the least drawbacks. It's easily seen from all players for UI if you want a squad screen sort of thing. It can persist for a short time for disconnects.

round star
#

Hm okay

kindred widget
#

There are some arguments to put it on the character if you want deathboxes, but this only really works if you have a saved game state for d/c handling. For a persistant online style, you'd likely want it on the character. Easier deathbox creation in the end.

slate basin
#

That the variables always replicate in the order setup in GetLifetimeReplicatedProperties or can it be random if there is packet loss etc?

kindred widget
#

I generally would not trust the order. Just rely on state in your onreps. Your OnReps can be set up to check each other's state and handle the logic accordingly.

round star
#

Appreciate your help thank you

rocky topaz
#

anyone has any advice on how to implement sprinting, sliding and wall running as efficiently as possible?

#

for it to be smooth in multiplayer

#

I know of MOVE_Custom but when using it for sprinting it broke everything (even though max speed was high)

#

I assume I need to rewrite more than that to make it work

hard cipher
#

For Multiplayer AI what Should I use ?
BT with BB or Just AI Blueprint?

chrome quest
winged badger
#

multiplayer doesn't really matter when it comes to AI design

#

it all runs on server, controlers are not replicated, BTs don't run on clients

misty plover
#

Hey guys, I am having an issues changing my players Mesh material for clients. I am using a function that is ran through the server and calls SetMaterial() this updates the materials for the server but not the clients. Any ideas why

meager spade
#

You need to tell those clients via either multicast or rep notify property. You want the later one as its a state change.

misty plover
#

Thank you!

sinful tree
#

Not sure I follow.
When you're talking about Unreal Engine, there is only two options for types of servers: Listen Server or Dedicated Server, and Listen Server is really only for when you have a player that wants to play and their computer can act as the server for the game. There would be no point in running a Listen Server on something like AWS or Google Cloud as there would be no player on the server end, so you would always deploy a dedicated server on something like AWS, or any other hardware where there wouldn't be a player playing on that hardware.

#

The only thing I can think of is maybe you're thinking "dedicated" means always on which you may not necessarily want?

rocky stag
#

How can i mix two conditions for replication of my property . for example COND_Initial && COND_OwnerOnly ?

rocky stag
#

Something like this :
DOREPLIFETIME_CONDITION( AMyPlayerController, PlayerActivePerks, COND_InitialOnly && COND_OwnerOnly );

#

Also checked PreReplication functuon to use DOREPLIFETIME_ACTIVE_OVERRIDE but i dont know how can i mix these conditions for condition parameter

lost inlet
#

it's actually better to use push model I guess, but I don't believe you can, it's not a bitfield by the quick google result I found

#

plus if it was a bitfield, then you wouldn't use it like that either

twilit radish
#

Hello, what would you guys recommend as project to practice multiplayer? Something that would definitely be doable and isn’t as complicated as say an MMORPG 🙂

native forge
#

i have a question but not sure where to post it

peak sentinel
#

Colors, chat system, and game state etc. very generic and easy to implement

#

While trying to solve the problems related with Among Us development its very likely you will ask what every developer should know about UE's replication system and this way you'll learn a lot

#

Like 'should I use an RPC or OnRep for color changes, how can I determine the winner of the game' etc.

peak sentinel
rocky stag
lost inlet
#

why not use push model then?

rocky stag
#

What is that ?

lost inlet
#

you can read what's in PushModel.h, but it allows you to explicitly invalidate variables as changed rather than comparisons being run every replication update

rocky stag
#

PushModels are so cool didnt know about that . thanks i think this helps.

rocky stag
#

Oh thats not cool 🤣 . Push models just support static arrays not TArrays .

meager spade
#

no

rocky stag
#

you mean i can use them in push models ?

meager spade
#

yes

rocky stag
#

what did i do wrong ?

#

Its a TArray of EnumType

meager spade
#

show the member

fossil spoke
#

Did you add the right #includes?

rocky stag
#

UnrealNetwork.h?

fossil spoke
#

#include "Net/Core/PushModel/PushModel.h"

#

You need that one as well

rocky stag
fossil spoke
#

You also need to add NetCore to your Build.cs

rocky stag
#

Thanks for helping me 🙏

fossil spoke
#

👍

lime vortex
#

im working on a server and for some reason the server stops here [2021.10.07-19.19.27:159][706]LogNet: AddClientConnection: Added client connection: [UNetConnection] RemoteAddr: 127.0.0.1:55649, Name: IpConnection_0, Driver: IpNetDriver_2 IpNetDriver_2, IsServer: YES, PC: NULL, Owner: NULL, UniqueId: INVALID

#

does anyone know

quartz smelt
#

Hey quick question, if I wanted to spawn an actor based on someones save, am I able to use the game instance or should I call the save?

misty plover
#

if you want to save a players location when they sign out or something along those lines you would want to use a USaveGame then you can get the location from that players save game slot when they sign back in

silent valley
#

On client, is there any way of knowing inside ::EndPlay() if an actor has been Destroyed by server vs Destroyed thru relevancy?
I want to play a deathfx on client but it's also triggering when the actor is no longer relevant...

#

is there some other pattern that is useful in this case? e.g. I want to do something on client when an actor is killed. RPC is no good because the server has destroyed the actor. I suppose I could delay an arbitrary amount then destroy on server but seems a bit hacky.
Could also send RPC via the player controller or pawn, but then there's potentially a mismatch of the RPC comes at a different time to the actor being destroyed...

chrome bay
#

You can send a reliable multicast RPC. Probably one of the few cases where it actually makes sense.

#

The RPC will come through before the actor is destroyed, that's guaranteed (so long as you call it before destroy ofc)

#

But otherwise there's no way to know whether it was destroyed via relevancy or gameplay on the client.

meager spade
#

should it actually matter tho?

#

i have projectiles that do stuff via EndPlay, BUT i have a replicated property which lets me know if its been detonated on the server (think RPG rocket)

#

i can check this bool for stuff like that. Most of the time though, your End Play logic should not care if its relevancy or it being removed from the world by DestroyActor.

elder sage
#

simple question, but what should I do to make things like PlayerController's Input Pitch Scale persistent between levels?

#

or if I use a game instance for this, what event should I use to trigger my Player Controller grabbing those values?

empty axle
#

it might be that you are not

elder sage
#

I am, so

#

event tick runs in both levels, but the value is reset

empty axle
#

how are you setting it?

elder sage
#

through an event in the ui

#

that doesn't seem to be the problem, as it prints the value I set it to, until the new level loads

silent valley
# meager spade should it actually matter tho?

I don't know, ideally it would not matter, but if it's playing a loud sound effect it might!
I did think about a replicated bool, but is there any guarantee a replicated var will be sent before the actor is destroyed?

chrome bay
#

There's not

#

Usually you hide the actor then give it a lifetime so that it has time to replicate

#

But it's a "lossy" method so to speak, i.e. not garaunteed

empty axle
thin stratus
silent valley
#

yeah I was looking at that but it's a bit tricky for this usecase. In my tests the replicated bool approach seems to be pretty reliable, especially given I'm also introducing a delay, and if some of the fx don't spawn sometimes then I don't think it's a big deal.

thin stratus
#

Right, yeah you can just do a 10s delay and destroy then and deactivate everything in an OnRep in the meantime (e.g. Collision and Visuals)

#

There are lots of ways I gues

viscid lantern
#

Hi guys. Does anyone have some good tutorial links to unreal multiplayer for mobile? Thanks

hybrid zodiac
#

Hi everyone. I'm messing around with networking profiling and just wanted to check what I'm looking at. I thought I'd try some stress-testing (such as replicating an array of 2000 constantly-changing FVectors) to see what kind of numbers I get. I tried running a standalone game with separate server and ran stat net on the client, and saw this:

https://gyazo.com/0d30c7d4bbd8004849bef69fdb84c185

Does the "in rate" refer to how many bytes the client is having to download from the server per second? i.e. the client is having to download just under 100kb/s of data?

I also ran the net profiler for a simple PIE session with 3 clients and a listen server. The generated file notes around 362kb/s bandwidth:

https://gyazo.com/5fc1d4dc6f004dcabe43af9e42353a3e

Is this only from the server's perspective (i.e. the server is having to push 362kb/s of data across all 3 clients), or is this including data inbound to each client as well? Just want to make sure I understand these numbers correctly

woeful ferry
#

Is it possible to change replication conditions in runtime?

hybrid zodiac
#

@woeful ferry As in when a variable should be replicated? You can do this with a DOREPLIFETIME_CONDITION macro with COND_Custom. In simpler cases you can also do it with DOREPLIFETIME_ACTIVE_OVERRIDE where you can toggle replication of a variable on and off with a boolean

#

If you mean change the logic for replicating a variable completely, I don't think so. You would have to define one set of logic to cover it

woeful ferry
#

Yes, I meant from like having no replication condition to only replicating to the owner for example

hybrid zodiac
#

I noticed there is a function called ResetReplicatedLifetimeProperty

#

In C++

#

There's no documentation on it though so I don't know if it works in the way you're looking for

woeful ferry
#

Ah, it's just a minor thing I was thinking of 😛 I was just curious rather than needing it

#

I changed our health component to use owner only on its health, which is logical for our player character, but not for other stuff that uses the same component

#

that's why I was curious

vague fractal
#

Is there a way to see the "reliable buffer" ?
Like that you can see how filled the buffer is

chrome bay
#

Might be able to pull the information from the actors' actorchannel

#

IIRC max number of unacked reliable packets is 256

quasi tide
#

Apparently the internet is divided on this - if you have an array of structs, does the entire struct get replicated when a value in the struct changes or just that value?

chrome bay
#

Should be just that value, unless the struct has a custom NetSerialize implementation

#

Arrays do their best attempt at delta serialization IIRC

quasi tide
#

I'm pretty sure just the value of the array gets replicated, at least that's what I've found on the interwebs. But when it came to structs, there were a bunch of mixed responses. Some saying the entire array gets replicated, the entire struct gets replicated, or just the changed value.

chrome bay
#

Taking an educated guess at this point but IIRC, so long as the property can be identified by index + property offset it'll be just that property that gets sent, but the header that identifies the property gets longer and longer ofc as you get deeper and deeper recursion

#

Might test that theory tbh..

young tide
#

Hi. I have a replicated object that is showing a widget when player is looking at it. How do show this widget only to player that is pointing at it?

chrome bay
#

@quasi tide Actually, I might be wrong - it may indeed be the full item

#

Want to know myself now so going to dig through

chrome bay
#

If you're using FFastArraySerializer, it's definitely the full item, I know that much

meager spade
#

FastArray sends the entire array?

#

i thought it just sent that element

#

(that was marked dirty)

chrome bay
#

Yeah just the changed element I mean

#

But it's always the full element

gray orchid
#

is there a way to make a fortnite random matchmaking for an fps game?

chrome bay
#

Digging through source.. it looks like with regular TArray it actually might send the individual property of the struct. Quite hard to work it out. It seems to be recursively looking at property handles

#

FRepLayout::SendProperties_r() that is

eternal canyon
chrome bay
#

I seem to remember a golden rule was that:

  • If you are adding/removing items a lot but the items themselves don't change, use FFastArraySerializer.
  • If you are not changing array count often, but the items themselves are changing often, use regular TArray
gray orchid
#

well im looking for any help I can get any methods or blueprints

eternal canyon
chrome bay
#

I did discover a nasty bug recently which is that FFastArraySerializer's wrapped with a regular USTRUCT do not use delta serialization when they are actor properties, even though they should.

#

static or at least infrequently changing count

#

Because it's wasteful to use FFastArraySerializer if the item count is static, and each item changes slightly

#

Because you're always going to be sending the full item which might have many members

#

So it's a trade-off

eternal canyon
#

Good to know!

chrome bay
#

This was the bug I was talking about

Actor
{
    Struct StructMember;
}

struct
{
    uint8 SomeByte;
    FFastArraySerializer SomeArray; // <- Doesn't use delta serialization :(
}```
#

It looks like when the engine "unwraps" the struct member properties, it doesn't preserve the network traits for them

#

Seems like an oversight

#

There's also another annoying bug with FFastArraySerializer which is that PostReplicateChange() doesn't get called on the array when GUID's are resolved

#

Had to implement an annoying workaround for that

#

Then you just do this instead:

{
    return HT_NetSerializationUtils::FastArrayDeltaSerialize_WithRemapCallback<FHT_DivisionMember, FHT_DivisionMemberList>(Members, DeltaParms, *this);
}```
eternal canyon
#

They should make a save message thing for individuals

#

Like pins but for anyone

#

And only u see it

chrome bay
#

Yeah.. need bookmarks

meager spade
#

i thought fast array runs postchanged when the GUID is resolved

#

i am sure i experienced that..

#

but that is interesting to note

chrome bay
#

It does on the individual element, but not on the array

#

Wierdly...

#

Rep notifies will fire ofc

meager spade
#

i mean i only use the per item Post/Pre

chrome bay
#

ahh kk

meager spade
#

not the entire array post/pre

#

so maybe that is why i have never ran into an issue

thin jacinth
#

Does steam have its own multiplayer platform, where u can have multiplayer in your game using steam?\

#

hmm intresting.

stoic rover
#

@chrome bay Are you familiar, with multiplayer and steam at all? If so i just had a question, and sorry if im disturbing you.

sinful tree
#

Ask your question here anyway... Someone may be able to help you.

stoic rover
#

So i have multiplayer set up, it works in engine, and it works after packaging, but after its uploaded to steam, it dosnt work. Its something with steam and im not sure what it is.

dawn delta
#

When testing MP on a single computer, all the network clients still return true to "Is Locally Controlled". Makes sense since they are all technically "local" on the same computer. Anyone know a way to differentiate them from being pure clients vs. clients on the same PC as the listen server? This is PIE testing. Works normally w/ multiple Standalone instances.

kindred widget
#

@dawn deltaIsLocallyControlled will return true for any actor that is controlled by the local controller.

#

This is regardless of testing type, or server type.

dawn delta
#

ya. I guess when PIE testing multiple clients those "PIE clients" don't really behave as seperate clients because of this behavior of IsLocallyControlled

#

since the "server" plus 2 "PIE clients" are all the same local controller

chrome bay
#

IsLocallyControlled is correctly true on network clients

dawn delta
#

yep

chrome bay
#

They all have their own controllers though, it's not the same controller.

#

Calling IsLocalController() on the Server, on a Clients' player controller, would return false.

dawn delta
#

ok, that's a way I could handle this case for PIE testing. Persist the server's controller and treat the others as seperate

chrome bay
#

PIE and non-editor would be the same, even on different machines

#

"Local" means local to that instance of the game, not the actual hardware machine

dawn delta
#

right, but in PIE arent all the "clients" sharing the same instance?

chrome bay
#

Negative

#

They're all new "instances" of the game

dawn delta
#

ok, thank you. My error must be elsewhere then. The "server" is returning true for IsLocallyControlled for all clients controllers, which is what led me down this path.

chrome bay
#

Likely being called on the wrong controller

#

It would return true calling HasAuthority() on them, but not IsLocalController()

dawn delta
#

thank you

cosmic badge
#

anyone know if there is a way to get the current bound port [as unreal will just keep trying to find one beyond 7777] within blueprints?

#

nevermind i just did it in c

vivid seal
#

When working with Root Motion Sources, do i need to apply them on remote clients? Right now I'm predictively applying them on owning client, then applying them on the server, and it works correctly, and looks okay even with a lot of lag. If i also apply on other clients, i don't see a difference, so i was wondering if this even does anything

tepid pawn
#

Hey guys, Where can I find all the blueprint nodes listed along with what they do and how they work?

elder sage
smoky crag
#

Hey guys, I have a quick question, in order to interact with object in a game, which way to find object is better line trace from camera center or sphere collision detection?

bitter oriole
#

There isn't a better one, they're just different tools

#

One is a line of sight check, so colliding objects would interfere and you'd have to see the object

#

The other one is just a distance check

#

Could try both and see which one feels best

smoky crag
#

Got it thanks. Do you know compare to performance which one is better?

bitter oriole
#

It's irrelevant really

#

Depends on the game quite a lot, too, so hard to say

#

Get the game right, worry about performance later

smoky crag
#

Got it. Thx!

lost dune
#

Hello , i move characters AI to location , It works when running under one process but not with Separate server.

#

I'm stuck.

#

This is exactly the same script not working on separate server.

barren patrol
#

Has anyone successfully done the offline -> manual connect to server flow in the Play In Editor mode?

#

using Launch Separate Server = true with Standalone mode

#

I am trying to test my main menu -> get in game flow.

#

current issue is that the PIE server seems to be launching my main menu level also.

#

what is the magic incantation to make the PIE server start up with my game map?

barren patrol
#

In the Project Settings -> Maps and Modes I have the Server Default Map set to my game map, that didn't work

#

I also tried setting the PIE preferences -> Server -> Server Map Name Override to my map name but it doesn't seem to do anything either.

#
LogPlayLevel: PlayLevel: No blueprints needed recompiling
PIE: New page: PIE session: MenuEntry (Oct 18, 2021, 5:52:24 PM)
LogPlayLevel: Creating play world package: /Game/MOBATest/Maps/UEDPIE_0_MenuEntry```
#

The edit output log on the 4th line shows UEDPIE_0 (the server) being set up with my menu entry level even though I set all these things

rocky stag
#

what is diffrence between DOREPLIFETIME WITH PARAMS FAST and DOREPLIFETIME WITH PARAMS ?

chrome bay
#

Right Click -> Peek Definition

rocky stag
#

nothing here

#

DOREPLIFETIME is wrapper on DOREPLIFETIME WITH PARAMS . but what is the diffrence between reqular and the DOREPLIFETIME WITH PARAMS FAST ?

chrome bay
#

Well, you're looking at it. By the looks if it the _FAST version caches some static variables at startup time. Doubt it makes any real-world difference

dark edge
dark edge
#

New World interaction would be a sphere trace, Skyrim interaction would be a line trace.

meager fable
#

with advanced sessions plugin how can I join my steam friend's session?

winged badger
#

you need a list of sessions, not list of friends

#

to start with

meager fable
#

yeah but I want to join my specific friend's session

#

like create a list of session held by friends and let user choose which one to join

winged badger
#

don't know if advanced sessions knows how to do that

#

you normally do that by using steam client API

#

click on friend ingame, join game

#

then game needs to handle

#

FOnSessionUserInviteAcceptedDelegate

#

to actually join that session

meager fable
#

okay, will look into that

#

thanks

winged badger
#

which is basically

#

if (bSuccessful) { JoinGameSession(InviteResult); }

meager fable
#

is it c++ only or can I access it in BP?

winged badger
#

that depends on AdvancedSessions

#

and i don't know that plugin

meager fable
#

okay, I'll dig into that

#

thanks

twin juniper
#

hello guys iam using ue 4.27 source version so when i call bReplicates its saying "bReplicates is inaccessible"

#

so how to access that

bitter oriole
#

SetReplicatedByDefault

twin juniper
#

how?

#

i didnt get you

bitter oriole
#

Use SetReplicatedByDefault() instead

twin juniper
#

ok

#

its saying undefined

#

just give me line of code how to write

bitter oriole
#

SetIsReplicatedByDefault()

hybrid zodiac
#

Hi everyone. If I am replicating a TArray and I want to utilise RepNotify, is there an efficient way to only see the items that have changed, or do I need to iterate through the whole array to figure out which elements have been modified?

twin juniper
#

so @bitter oriole its working but now my health bar is not full and my health is 0 even i after i set my to 100

#

and damage is not applying to clients

#

its applying only to sever

hybrid zodiac
#

@twin juniper Is the parent actor also set to replicate?

twin juniper
#

@hybrid zodiac in line 23 i did but still my clients health is not updating

#

can check here right is sever and rest are clients

#

you can see print string in left that damage is happening in server only not in client

hybrid zodiac
#

@twin juniperWhere are you printing the health? If it's in the TakeDamage function then you're probably printing the number out before it's replicated to the client. Try printing the health in Tick instead

twin juniper
#

iam just printing current health and also iam using PainCausingVolume from unreal assets

#

when ever player steps on that he will take damage

rocky stag
chrome bay
#

Alternatively if you're using FFastArraySerializer, it has internal callbacks for items

hybrid zodiac
#

@rocky stag @chrome bay Thanks both! Not heard of a push model before. I'll take a look into both suggestions. The array will be a fixed length array of structs in which items will have values changed fairly frequently

chrome bay
#

May want to use a static array

#

Actually doing some tests right now regarding that 😄

hybrid zodiac
#

Ooh definitely keep me updated then. The array will be around 200 items in length max, so it wouldn't be too demanding to just loop through looking for changes

chrome bay
#

It seems that as far as actual size-of-packets is concerned, a static array has identical cost to a member

#

Which makes sense, as they can statically determine property offsets by just unfolding it

chrome bay
#

Hmm. I mean, my findings so far are showing TArray being considerably cheaper than FastArraySerializer :/

hybrid zodiac
#

If I wrap a Tarray into a struct, would it still efficiently replicate deltas? Thinking of having an "index" containing an array of bytes with values pointing to which indexes have changed in the array

chrome bay
#

Should do, so long as the struct is a member var. Will test that as well

hybrid zodiac
#

Cheers :-) will try as well when at my computer next

chrome bay
#

Results are pretty interesting to be honest. FFastArraySerializer uses nearly 4x the bandwidth doing the same operations

oblique inlet
#

So I'm trying to re-organize my code for firing weapons so that my Server functions are inside the gun object and not just being called inside a Server function inside my character. Would this work if my weapons were actors or would I need to make them components or something else?

chrome bay
#

They can and probably should be actors, just need to be be actors owned by the character they belong to

#

Components have additional RPC/Property handle overhead

oblique inlet
#

yeah it would also be easier to make it an actor for other purposes

chrome bay
#

It's the most common approach. See ShooterGame

#

So a few stats from my little test... testing a struct with two int32 properties

Property Change: 6 Bytes
C-Array Change: 6 Bytes

TArray Add: 13 Bytes
TArray Change: 8 Bytes
TArray Remove: 4 Bytes (Index 0) 3 Bytes (Other Index)

FastArray Add: 34 Bytes
FastArray Change: 29 Bytes
FastArray Remove: 23 Bytes```
#

BRB deleting all my FastArray's

#

Need to do more testing but right now starting to think FastArray is really only designed for large arrays of large structs, rather than many small items.

#

As otherwise, the built in TArray delta serialization is way cheaper.

oblique inlet
#

so now it works from the listen server but nothing happens when it is fired from the client

chrome bay
#

Make sure the character is the "owner" of the weapon when you spawn it

#

You can only call RPC's on actors you "own"

oblique inlet
#

I've set the owner in the spawn params. When I set it from the actor itself it throws an error

chrome bay
#

And there's an ownership chain which eventually leads back to the player controller

#

Also make sure you only set it server side, and spawn the weapon server side ofc

oblique inlet
#

oh that would be why

#

iirc beginplay bets called on both sides and I can just check which side I'm on right?

chrome bay
#

BeginPlay will fire on both yeah

#

Should only spawn the weapon if you're the authority

#

Then the weapon actor itself would be replicated

oblique inlet
#

if I do

    if (WeaponClass && HasAuthority())
    {
        FActorSpawnParameters spawnParams;
        spawnParams.bNoFail = true;
        spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
        spawnParams.Owner = this;

        FTransform weaponTransform;
        weaponTransform.SetLocation(FVector::ZeroVector);
        weaponTransform.SetRotation(FQuat(FRotator::ZeroRotator));

        Weapon = GetWorld()->SpawnActor<AWeaponBase>(WeaponClass, weaponTransform, spawnParams);
        Weapon->SetOwner(this);
    }```
#

it throws an error saying weapon is null only when I fire on the client

#

firing from the server works fine

#

and when I remove HasAuthority() nothing happens

eternal canyon
chrome bay
#

@oblique inlet both the Weapon property and the actor need to be replicated

#

And there's no guarantee the weapon will have replicated when you go to fire it, so you need to handle it being nullptr safely

oblique inlet
#

ah ok

#

what do I need to include for DOREPLIFETIME? I forgot and I can't find it anywhere

lost inlet
#

Net/UnrealNetwork.h probably

oblique inlet
#

that's it thanks

#

I'm getting this error

1>  C:\Program Files\Epic Games\UE_4.27\Engine\Source\Runtime\Engine\Classes\GameFramework/Actor.h(149): note: see previous definition of 'GetLifetimeReplicatedProps'
1>C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\TestFPSCharacter.cpp(91): error C2039: 'Weapon': is not a member of 'AWeaponBase'
1>  C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\WeaponBase.h(10): note: see declaration of 'AWeaponBase'
1>C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\TestFPSCharacter.cpp(91): error C2672: 'UE4Asserts_Private::GetMemberNameCheckedJunk': no matching overloaded function found
1>C:\Users\nicol\OneDrive\Documents\Unreal Projects\TestFPS\Source\TestFPS\TestFPSCharacter.cpp(91): error C2660: 'GetReplicatedProperty': function does not take 2 arguments
1>  C:\Program Files\Epic Games\UE_4.27\Engine\Source\Runtime\Engine\Public\Net/UnrealNetwork.h(185): note: see declaration of 'GetReplicatedProperty'```
lost inlet
#

show declaration and implementation of your GetLifetimeReplicatedProps

oblique inlet
#

I just forgot to declare it

#

I get the same errors though

#
void AActor::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
    DOREPLIFETIME(AWeaponBase, Weapon);
}```
#
protected:
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
#
    UPROPERTY(Replicated)
    class AWeaponBase* Weapon;```
lost inlet
#

huh?

#

why is AActor there?

#

why doesn't it call the base?

oblique inlet
#

that was an old error message I updated the message above

lost inlet
#

why

oblique inlet
#

copypasted the wrong code

#

it's actually cpp void ATestFPSCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const { DOREPLIFETIME(AWeaponBase, Weapon); } in the file

#

sorry for the confusion

lost inlet
#

then you're not going to have AWeaponBase there either

#

and call the Super

oblique inlet
#

🤦‍♂️ will do

#

it works! Thank you

peak sentinel
#

Anyone ever tried to implement FRootMotionSource to their custom movement component? I made a replicated pawn movement component a couple months ago and now I want to implement root motion replication, guess there isn't any guide unless source code?

#

This time unlike many other class/struct, header file looks well commented though

quasi tide
#

Working on creating a container, like a chest pretty much. I am currently doing all of my interactions on the server. How can I tell the client to display the UI for the container? Because everything runs on the server, it will activate the UI on the server. I've tried setting the owner to the interacting actor and then running a Run on Owning Client event, but that does not work.

sinful tree
# quasi tide Working on creating a container, like a chest pretty much. I am currently doing ...

Your flow should probably be:
From Player Controller or Character > Interact Key Press > Check Target Actor is in range / can currently be interacted with > Run On Server, passing reference actor the player wants to interact with > Server validates distance / interaction state and if valid > Triggers required interaction event on the required actor OR if it's to display something to the player do a "Run on Owning Client" event to display the appropirate UI.

quasi tide
#

Yeah - that IS my flow

#

But when the client interacts with the chest, I can't get it to tell the client to show the chest UI

sinful tree
#

But you said you're doing it from the chest right? My flow suggests running it only on the Character/Controller.

quasi tide
#

The chest is what has the interaction event

#

This is on the player character

sinful tree
#

Ok, so then you should be able to pass back to the "interacting player"

quasi tide
#

Then, w/e object has the interface implemented, will handle the reaction.

#

Okay - so have a Run on Owning Client on the player, and in the chest, call that event?

sinful tree
#

Yep

#

You can use interfaces back to the player too if you want, then have that interface call the event, however you wanna do it.

quasi tide
#

Alright - sweet. Thanks. Now to work on the transferring logic.

#

Just missed that last step. Was off with the Run on Owning Client

barren patrol
#

Asking 1 more time here, has anyone successfully used the PIE play mode with Play Standalone and Launch Separate Server to simulate a main menu -> connect to dedicated server flow locally?

#

I launch the client from my main menu entry level and my server is launching the menu level. I can't seem to get the server to start up on the game level instead. I tried Server Map Name Override in the play settings and also changing the Default Server Map in the Project Settings, but the Launch Separate Server in PIE does not appear to respect them.

vivid seal
vivid seal
#

speaking of which, what would you guys recommend doing for something like a knockback. no prediction, just server-authority applying a push to players in an area, or a player hit by something. Using Launch Character on the server with latency causes clients to "jump" on their screens. Would a root motion source also be the answer here, and just replicate it down? or is there some way to have the client launch not jump

fierce grove
#

hello guys do you think that you could "replicate" locations with Firebase for Micro instanciation on 2D game Or simple 3D topdown ?

meager fable
#

how to handle joining a steam friend's session? Currently I can click on join game when my friend plays it but nothing happens

#

is there some delegate that fires or sth?

fierce grove
#

using advanced steam sessions?

meager fable
#

and how would I go about that?

bitter oriole
#

Look at advanced sessions (no need for anything steam specific)

#

Shootergame might support it too so you have two examples with code

#

Only works outside editor, two Steam accounts on different machines required

meager fable
#

thanks, will look into it

peak sentinel
#

When exactly an COND_InitialOnly variables become not replicated?

#

first PostReplication()?

meager spade
#

after first replication of the actor

#

so initial only, those properties get sent in that initial actor bunch

peak sentinel
#

It should be available to change in PostInitializeComponents() then

meager spade
#

yes

peak sentinel
#

Thanks

winged badger
#

ummm, no

#

PostInitComponent comes first

#

it will be available in PostNetInit / BeginPlay

meager spade
#

he means modify before the first bunch is replicated to client

#

i assume

winged badger
#

as long as its synchronous after spawning the actor

#

it will be in initial replication

meager spade
#

right, you have a window

#

actor replication is not instant

winged badger
#

net driver doesn't replicate actors as soon as they are spawned

#

net broadcast tick is on the end of the tick

meager spade
#

anything in the same frame as (Finish Spawning is called), is safe.

winged badger
#

deferred construction comes in handy, as the replicated variable then gets set on both server and clients before beingplay ius called

#

which allows you to not branch the beginplay logic based on authority

peak sentinel
#

Yeah, I was surprised when deferred spawning actually syncs the changes

#

Thanks for the informations

winged badger
#

as soon as you spawn actor, server calls BeginPlay

#

if you assign stuff after, its after BeginPlay, except for deferred spawn and stuff assigned prior to FinishSpawning call

#

on clients, initial replication comes in same packet as instructions to spawn the Actor

peak sentinel
#

I thought its being determined by clients

winged badger
#

and client runs all OnReps, then PostNetInit, then BeginPlay

peak sentinel
#

I see

winged badger
#

in that order

#

there are few more discrepancies, because its unreal

#

like server won't call construction script before it finishes spawning

#

while clients won't wait for replication to call it 😄

hallow acorn
#

hey guys.. I'm trying to force the movement of a Player character while using the navigation system, so I thought of using UAIBlueprintHelperLibrary::SimpleMoveToLocation and InEditor seems to work great but when using game builds, sometimes the Player character moves mega slow.. no obstacles or anything in the way.. any ideas? thanks 💙

sage isle
#

I made a full menu system for changing characters and stuff so the player can change between the different characters I made only I realized after testing in multiplayer that the game no longer possesses the newly spawned characters. I was using the possess node in the menu widget which I now know doesnt work but I am struggling to fix it. I tried moving the logic around so possessing the character was in the player controller but that wont work either, everything works except actually taking over the character. So what am I missing, the possess node is for the server only but can anyone explain more cause it does not want to cooperate with me.

chrome bay
#

Widgets are local/client-only. If the call to possess is in the widget then it's not happening on the Server.

sage isle
#

yeah so I tried moving it to the player controller and it still wont do anything, I am trying to get it to work on in the game mode currently but I cant get it to possess no matter what I do

winged badger
#

@hallow acorn best way to move it imo, is with MoveToActor node, with GoalTracking enabled, spawn a MoveTargetActor, and have the player just chase it around all the time

#

you need to move somewhere, you teleport MoveTarget, you need to follow, you attach your MoveTarget to whatever you're following, you need to stop, you teleport it to yourself

calm sundial
#

No stupid questions time. If I'm a listen server, can I still send an RPC to me as a Client?

#

Or rather, will ClientMyRPC still be called on Listen Server?

peak sentinel
#

Afaik if you're the owner of that actor, yes

#

But I'm not sure

calm sundial
#

I would expect it to work

peak sentinel
#

Client RPC gets the owner actor and sends the packet to it, so it should work i assume

hallow acorn
winged badger
#

PC doesn't have a PathFollowingComponent

#

you either need to make it work with PC in c+

#

or put a replicated AIController between PC and Pawn

#

and getting predicted movement to work is another bag of nails

#

epic kinda hardcoded some stuff with CMC to work only when directly possessed by PC

peak sentinel
#

Kaos had some messages .. somewhere around 2 or 3 years ago explaining how he did predicted movement for this situation

hallow acorn
#

that's why I used SimpleMoveToLocation haha, cuz it received any Controller.. but true, I'll have to check on that, thanks a lot! 💙

winged badger
#

it ran okay without prediction

#

but was short of production level

#

it took us one afternoon to switch to predicted model in the end, but we both had a good idea what we were doing

meager spade
#

yeah, using server to move, was a pain

#

the lag was unreal, and not good for players

hallow acorn
meager spade
#

well i work with Zlo

#

SimpleMoveTo will actually give the PC a PFC

#

so not sure why you are having issues

hallow acorn
#

right? it's weird cuz Editor tests goes great and on builds for some reason the speed goes to hell.. the worst part, not always happens

sharp pagoda
#

Do both 'Run on Server' and 'Run on Client' work on singleplayer (Play Standalone)?

#

I'm trying to integrate a network replicated plugin and I was thinking if I might as well use what it currently have than modifying it

chrome bay
#

They do yeah

sharp pagoda
#

Thanks, Jambax!

cosmic trail
#

Is there no already quantized FVector2D?

harsh lintel
#

can a server RPC called from a client fail due do packet loss?

median crypt
#

Does anyone know a good resource to learn a bit more about controlling multiple characters, specifically I need to learn about multiple gamepads inputs

#

Like say you have a few player controllers each controlling a different character

#

I'm not quite sure how I assign or how the engine automatically assigns a gamepad to a player controller

lost inlet
misty stump
#

Anyone know why I might not be able to find Steam lobbies? I'm using my own steam game ID, steam enabled in ini, I have bUselobbiesifAvailable set to true, i have Search for lobbies set in the query. bshouldadvertise, busepresence, ballowinvites,ballowjoininprogress, are all true, public connections set to 5; map opens with ?listen. In the dev logs it prints that a steam lobby is created with a unique lobby ID with lobby type 2 on host and Steam P2P IP/Port. But search always returns successfully nearly instantly with 0 lobbies found. I myself am signed in on steam and so are my friends who are separate PC's and steam accounts. It shows the correct game title in the steam overlay. Any idea what might be going wrong? If I enable LAN the search returns 0 lobbies as well when on the same network.

misty stump
#
{
    //Set Session Settings
    FOnlineSessionSettings SessionSettings;
    SessionSettings.bIsLANMatch = bIsLAN;
    SessionSettings.NumPublicConnections = 5;
    SessionSettings.bShouldAdvertise = true;
    SessionSettings.bUsesPresence = true;
    SessionSettings.bUseLobbiesIfAvailable = true;
    SessionSettings.bAllowJoinInProgress = true;
    SessionSettings.bAllowJoinViaPresence = true;
    SessionSettings.bAllowInvites = true;

    Sessions->CreateSession(0, SESSION_NAME, SessionSettings);
} 

void UGameInstance::Search()
{
    if (!Sessions.IsValid())
    {
        UE_LOG(LogTemp, Warning, TEXT("Invalid Session Interface on Search Attempt"));
        return;
    }

    SessionSearch = MakeShareable(new FOnlineSessionSearch);
    if (SessionSearch.IsValid())
    {
        //Set Query Params
        SessionSearch->MaxSearchResults = 20; //update val
        SessionSearch->bIsLanQuery = bIsLAN;
        SessionSearch->QuerySettings.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);

        UE_LOG(LogTemp, Warning, TEXT("Starting Search for Online Games..."));
        Sessions->FindSessions(0, SessionSearch.ToSharedRef());
    }
}

harsh lintel
#

if I have some logic that only runs client side on Tick(), and I need to call server RPCs from this client Tick() logic, would it be bad for a multiplayer game?

peak sentinel
#

depends™️ but it needs to be unreliable in any case

twin juniper
#

hello, is it here that i post this? im trying to make a photocamera in a vr game. so u can actually take pics and it saves like phasmo. how do you capture a picture like that? is it witha 2d scene capture?\

hallow fiber
#

Can UObjects replicate variables? Because I noticed it has the GetLifetimeReplicatedProps

clever plinth
#

Is there any meaningful difference between the reliability of a UFUNCTION(Client, Reliable) RPC from Server -> Client vs a replicated property? In this context, ignoring:

  • The fact that some replicated property values might not arrive (ie. if the value changes quickly on the server and the intermediate value is not sent or is lost in transit). For the the purpose of this question, I am interested in only the final value.
  • The fact that properties will replicate to new clients who join late, while RPCs only apply to a currently connected client.

In other words, ignoring those two things, are there advantages of one over the other for communicating a piece of information that needs eventual synchronization on the client? (Hope that makes sense)

fossil spoke
#

An RPC will have a higher network overhead than a single replicated variable, assuming of course they are the same type.

clever plinth
dull lance
#

at the same time Reliable RPCs are guaranteed to get sent in the next buffer

#

whereas Rep Variables will just Eventually get there

clever plinth
fossil spoke
#

Yes, though the Actor itself will be throttled by its relevancy and frequency.

#

Which subsequently causes replicated variables to change when they are sent.

sinful tree
fossil spoke
#

RPCs will always be sent as soon as possible, they will only trigger if the Actor that owns them is net relevant to the receiver.

dull lance
#

also let's not forget that RPCs that don't exec on a given machine (relevancy or that the client joins later) will end up in desynchronized states

lost inlet
#

which is where push model is the way to go if you're on 4.26+

clever plinth
#

I guess this might be a bit specific and I'll just have to experiment with it, but I have something like:
(1) Player tries to pick up world object
(2) Player RPCs to server to request object
(3) Server checks, and RPCs reliably back to client to indicate success/failure
(4) World object item has OwningCharacter set to the relevant player character (so other clients can see that ownership has transferred)

I don't like this pattern though, because it involves the same information being sent twice in the case of pick-up success (namely the RPC to client and OwningCharacter). I want to change it so that the OnRep_OwningCharacter just acts as the successful indicator. In my testing this seems fine so far, but was wondering about the trade-offs for the client who is doing the picking-up (ie. are they getting the result less responsively).

dull lance
#

(3) should probably be a ReplicatedUsing variable

#

also, (4) doesn't need to happen depending on how you handle the owning character.

clever plinth
dull lance
#

Not at all. Making a given Machine the owner of your interacting object is not mandatory

#

it's an architectural choice

#

that allows you to code stuff in a given way

#

but for instance, for pickup/interaction, it could be your Character that RPCs, and that currentHeld is a rep variable

#

in that model, the item never needs to have its ownership transferred

maiden ermine
#

Anyone know of mechanisms for server to server communication in the engine?

meager fable
#

How can I disable joining my session? Sth like

UGameInstance::OnLobbyLeave()
{
GetGameSession()->SetJoinable(false)
}
elder sage
#

in order to make a display name for the player, should I actually do something to set the player controller's name, or should I just have a string variable for that?

thin stratus
#

PlayerState has the PlayerName already

thin stratus
meager fable
#

@thin stratus thanks, will look into it

midnight crag
#

Hi There, I also came across similar did you solve it?

hollow halo
sharp hound
#

Hi everyone, I have a multiplayer project. Every player has a playerstate with the playername. When I collide with another player I'm trying to get other actor playerstate but it always returns my playerstate instead of the other one..I'm using blueprints. Thanks!

winged badger
#

DisplayName is a little problematic there

#

there is no guarantee whatsoever that those are named the same between server and clients

#

usually aren't

#

that is not a PlayerName

sharp hound
#

@winged badger It works, I used the console command SetName to set the Playerstate's Playername

#

Thanks for the suggestion

winged badger
#

if you get 2 players selecting the same name

#

that will crash

empty dove
#

This is a photo from UE4 Networking Compendium. It is depicted that GameState and PlayerState are shared across all the players. Does this mean that If I change a variable in PlayerState class on Server, it will be replicated to all other clients?

chrome bay
#

It does

winged badger
#

provided the variable itself is replicated

#

also

chrome bay
#

^ and is not marked with any conditionals stopping it being sent to players other than the owner

#

🥷

winged badger
#

not on PlayerState class but on PlayerState instance

empty dove
#

Thanks

oblique inlet
#

So I've added a replicated variable using

    UPROPERTY(Replicated, Transient)
    bool bIsSliding;```
I've put it in
```cpp
void AShooterCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    DOREPLIFETIME(AShooterCharacter, bIsSliding);
}```
but  Server slide never prints
```cpp
    if (HasAuthority() && bIsSliding)
        GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Server slide!"));
    else if (!HasAuthority() && bIsSliding)
        GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("Client slide!"));```
and I'm setting it on the client
empty axle
oblique inlet
#

so what should I do?

#

just send an RPC changing it?

empty axle
#

yes

oblique inlet
#

ok

knotty veldt
#

if bIsSliding is going to affect your character movement you'll want to handle the replication in the character movement component instead of an RPC for better move prediction / less corrections

eternal canyon
#

But it does some other stuff beside the rpc

hallow fiber
#

What's the difference between regular DOREPLIFETIME and DOREPLIFETIME_FAST? Is it just faster?

eternal canyon
#

but i might be wrong

hallow fiber
#

Yeah, I am seeing that in params

#

What is that

#

GAS source code uses DOREPLIFETIME_WITH_PARAMS_FAST exclusively it seems

#

And I can't find any documentation on it

fossil spoke
hallow fiber
fossil spoke
#

Yeah

hallow fiber
#

Okay, I am going to just use the standard DOREPLIFETIME cuz it's giving me red squigglies despite it working and I don't like that

fossil spoke
#

Its just saving the CPU some time i guess by trusting the programmer got their shit right.

hallow fiber
#

Yeah, I thought fast would just somehow actually make it replicate faster and that would've been awesome but too good to be true

fossil spoke
#

DOREPLIFETIME is just a wrapper for the non FAST version

#

So basically its a default DOREPLIFETIME_WITH_PARAMS

meager spade
#

ignore the squiggles 😛

#

i do, don't bother me in the slightest

hallow fiber
#

I do not like red squigglies

#

Means code doesn't work obviously

fossil spoke
#

Red Squiggles is 99% of the time Intellisense not knowing whats going on.

#

Causing a false positive.

hallow fiber
#

It compiles fine, just red squiggles remain...

dull lance
#

get R#/Vax/Rider

fossil spoke
#

Exactly what i just explained above

hallow fiber
#

I know

#

I am using Rider

fossil spoke
#

Rider for Unreal?

#

Or just regular Rider?

meager spade
dull lance
#

does regular Rider even compile Unreal?

fossil spoke
#

🤷‍♂️

#

Id just assume Rider for Unreal would not produce red squiggles

meager spade
#

it does

dull lance
#

it does for some things

#

but it's kinda rare

meager spade
#

there is a fix for it planned

#

mainly on the push model stuff, and the DOREP_Fast

fossil spoke
#

I use VS and VAX so I dont have to deal with any of that shit.

#

lol

meager spade
#

you just deal with it tho 😛

dull lance
#

for instance, this inside PreReplication makes a red squiggle, but it compiles ```cpp

DOREPLIFETIME_ACTIVE_OVERRIDE_FAST(AMyClass, CarryingPlayer, ItemState == ItemStates::Carried);```
hallow fiber
meager spade
#

then turn off Resharper, and just code without it 😛

dull lance
#

use VS Code kek

hallow fiber
#

I cannot do that

#

I am bad at coding

meager spade
#

then don't complain about a silly red squiggle. If the code compiles, its fine.

#

(normally)

knotty veldt
eternal canyon
#

Tho would prefer not to talk abt it too much here as that could be self promotion etc

vivid seal
#

still trying to figure out how abilitytasks for root motion work (so i can make my own, hopefully simpler, version since im not using GAS). do root motion tasks need to be replicated to all clients? Right now i'm running root motion predictively on the owning client, then on the server after confirmation, but not on remote clients. I haven't tried anything crazy but it looks alright. For something that's server-initiated (knockback), would I just run it on the server, or would i replicate it to everyone?

twin juniper
#

Guys, does anyone know how can i simply

GetOnlineSubsystem() // or something like that

Am i missing something in the API? I'm just trying to access the OnlineSubsystem in order to tell it to Destroy the session

hallow fiber
winged badger
#

IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();

vivid seal
#

the more i work on it, the more i start stealing ideas/functionality from GAS anyway, but its helpful to build it myself from a learning perspective. movement has really been the worst part though, dealing with CMC prediction and root motion sources and trying to tie that into the ability system i made

winged badger
#

you are using gameplay task component to run those, yes?

vivid seal
#

no, i'm basically creating something similar to ability tasks but not actually using the gameplaytask class, currently just a UObject that controls applying/removing the source after a certain amount of time. mostly trying to figure out if every machine needs this handler object or just the predicting client and the server

knotty veldt
twin juniper
#

I'm trying to access it from GameInstance, because i want to handle Network failures and stuff like that. Problem i have right now is that upon host leaving the game... all the clients are like "hey we are already in a session, therefore we can't join a new one or host"

twin juniper
winged badger
#

@vivid seal its not part of GAS

#

and it runs the root motion pretty much out of the box

vivid seal
dull lance
#

Actually Game Instance does have a function for Network Failures

twin juniper
dull lance
#

just go from there

vivid seal
# winged badger and it runs the root motion pretty much out of the box

I briefly looked at the source for this, but i'll check more in depth. Do you know off the top of your head if it runs root motion individually on every client? this seems more of a CMC concern (whether the server replicates root motion to remote clients smoothly or whether they need to run it themselves).

twin juniper
#

I'm trying to recreate warcraft 3 lan lobby 😄

winged badger
#

Kaos was doing that bit, so not off the top of my head

vivid seal
#

yeah he mentioned the other day he had root motion sources working without GAS, but i wasnt sure exactly how he structured it

winged badger
#

he had it working in 2 hours time

vivid seal
#

it seems like one of those things where if you know the answers to a few questions and you already have CMC extended its not too much work to implement, i just want to make sure im doing stuff correctly

twin juniper
# dull lance Actually Game Instance does have a function for Network Failures
    UFUNCTION()
        void HandleNetworkFailure(UWorld* World, UNetDriver* NetDriver, ENetworkFailure::Type FailureType, const FString& ErrorString);

I have borrowed the code from AnswerHub, and i have connected it with this in the constructor.

GetEngine()->OnNetworkFailure().AddUObject(this, &UWorldGameInstance::HandleNetworkFailure);
winged badger
#

just don't do what one of my juniors did

#

handled network error on server by exiting to main menu (with listen servers)

dull lance
#

Eh, isn't it just easier to just implement the BIE at the GameInstance Level ?

dull lance
#

and just based on the network fail type, handle it

winged badger
#

result: anyone disconnects, and server goes to main menu, then everyone disconnects

dull lance
#

Eh the way we do it is that we detect who disconnected, and then act based on that

twin juniper
#

Yeah, that is totally correct. When host disconnects, everyone goes back to mainmenu. And is unable to join new or host a new session because one already exists. So i'm just trying to destroy it

#

BUT

dull lance
#

And since we're using Steam, we can handle other people's connection that way

twin juniper
#

When you leave (as the client) your session gets destroyed

#

I just have the problem when host closes the game :/

winged badger
#

there is no harm in trying to destroy a session if you're not in one

#

i find it convenient to have DestroySession call on BeginPlay of MainMenu

dull lance
#

Also, there's no harm in destroying your local session if you're not the host

twin juniper
#

Thank you so much guys ❤️

#

Yup... this works like a charm, no more headache 😄

#

I also have one more question. How in the world would you transfer a save file? Just with RPC call ? Is there a limit for the save file size?

#

Or do i need to divide it in chunks?

winged badger
#

there is a limit, think default is 40kB for payload

#

but its configurable

#

and i would RPC it to server from the PlayerState after it finishes its PostNetInit (if it has a local controller a.k.a. GetOwner() from PS scope)

#

note that in case of lobby and game level not being the same level, that RPC would had happened in the lobby, and would just get transferred to game level via seamless travel / copyproperties

twin juniper
#

Interesting, so if i for example add 2 ints to my save file. Like "CurrentChunk", "TotalChunks" and make it the first payload that is recieved, i can chain them till i get to the end. Or if by any chance someone gets disconnected while transfering a bigger save file?

#

My idea was that once the save file is transfered, everyone would simply regenerate the world when the game starts

winged badger
#

for that you just need a seed for a random stream

#

ideally

#

unless players can modify the level and that gets saved as well

twin juniper
#

Oh yeah, seeds would be amazing for procedural. But since it's my first time doing a multiplayer project. I'm trying to make it simple with a static map.

Yet... i need to save stuff like items, talents, spells

winged badger
#

that is not part of the level though

#

part of the map*

#

you need a struct with which you can fully instantiate the player

twin juniper
#

Yeah, you are right, but since the default start map is always the same, with the characters and stuff... i wanted to regenerate the characters based on equiped items for example

#

Alright i got it, thank you again for your time 🙂

winged badger
#

it can be saved as json or binary

#

via engine functions

twin juniper
#

So i wont even hit that 40kb mark for a single payload, perfect

winged badger
#

and it makes the RPCs simpler

#

unlikely, my characters are rough equivalent of a MOBA

#

and the setups are 3kB when in .json format, and just a fraction of that when inside an actual struct

twin juniper
#

That is a huge relief

winged badger
#

for example, they have equipment, of sorts

#

i don't save the stats for the gear, just the Rowname of the DataTable row that holds the data for it

twin juniper
#

So all the things like inventory with item IDs... it should be simply nothing

winged badger
#

and where its equipped, Slot, Index

twin juniper
#

This is going to be so much fun, i love indie dev. This community ROCKS

steady iron
#

how to make p2p games using eos for mobile

bitter oriole
#

Unreal doesn't support P2P, it only does listen servers which aren't great for mobile

#

EOS is essentially a matchmaking service so it's irrelevant (doesn't handle multiplayer)

steady iron
bitter oriole
woeful ferry
#

Saving for characters for multiplayer, what are you guys using?

Currently we're using a object that creates once you save for all players, if a new player joins it checks if there's a save object for that pawn and assign all the saved info to that character.

#

But the issue is it's not that scalable I've figured out now

chrome bay
#

save it client-side to the users local prefs, send it to the server when they join

#

Assuming this is data the client can store anyway

#

If you're talking about global data that clients shouldn't modify, you're looking at a data server solution or something

winged badger
#

i find that RPC from PlayerStates PostNetInit (if the PS is that of local player) works best

woeful ferry
#

It's not an issue, it's a co-op experience. 😄

chrome bay
#

But if it's just stuff like "I have this hat equipped" then probs client is the best way

#

that's how we do our cosmetics for e.g.

#

server just validates their choices

woeful ferry
#

You have that in the cloud?

winged badger
#

which is a non issue if you have a lobby

chrome bay
#

noop

winged badger
#

as you can just RPC data while in a lobby and transfer it via seamless travel through PS

woeful ferry
#

So if you format your computer, you'll lose your cosmetics?

chrome bay
#

Well you lose your choices, not access to them

#

Whether you have access is either a DLC key on Steam or tied to your steam stats

#

Which obvs we don't have to worry about cus that's steam

woeful ferry
#

We have a survival experience, think Subnautica, Valheim et.c. So clients will lose their items and so on

#

Probably have to keep that in the steam cloud save

chrome bay
#

yeah that's fine

winged badger
#

i hate steam cloud

chrome bay
#

Cloud saves on Steam in UE4 is basically a check box

winged badger
#

consider the following scenario

#

player starts playing on friday and plays through the weekend

#

then slacker that he is, continues playing on his work computer from work the next day

#

only the work computer doesn't allow steam client to write into say, AppData

#

so it tries to fetch a cloud save, fails, and creates a new one

chrome bay
#

Oh yeah, in that instance it doesn't work 😄

winged badger
#

which is the main profile file

#

then he figures cloud doesn't work fine, continues from home

#

but now the new profile he made and that cloud was still able to read and pull

#

had the newer date then the one from weekend

chrome bay
#

The way I setup cloud in the past was just asked Steam to backup the contents of appdata/mygame/saved

#

So if you can't write to appdata, nothing gets saved

winged badger
#

so it overwrites his weekend profile

#

at home

woeful ferry
#

Makes sense, I can probably do something like you said

winged badger
#

then you get "OMG I LOST THE SAVES, WTF !?"

#

because the player is basically computer illiterate

chrome bay
#

😄

winged badger
#

i just added a backup that is not cloud synced

#

was still fairly annoyed

chrome bay
#

tbh my only real problem with steam cloud is that it seems to be totally impossible to actually delete the cloud data

#

Trying to test a packaged game that already had a cloud save for my account as if it was a fresh account was a pain

#

Just kept restoring the cloud data

winged badger
#

we have 2 game IDs, one strictly for itnernal use

woeful ferry
#

I'm gonna ask our publisher what they're doing with their own games too, but I'm pretty sure it's something along the lines of what you guys describe

chrome bay
#

I mean storing per-player save objects server side definitely isn't the solution

woeful ferry
#

No, I figured

#

😂

winged badger
#

for starters you need half a dozen servers

#

running till judgement day

chrome bay
#

You either want some kind of global data server that stores the user data, or you keep it local / confined to the user data of OSS you're usin

#

I do wonder how many games would be totally unplayable forever if Valve closed their doors tomorrow

#

I think a lot of us are dependant on that not happening 😄

winged badger
#

we'd need 2 days to fix the OSS

#

then it would be fine

chrome bay
#

I'd be job hunting 😄

woeful ferry
#

Hmmm, so when a player joins does it send each saved property to the server? It can be a quite heavy operation

winged badger
#

one struct

chrome bay
#

Depends what it is really too

winged badger
#

from which you can completely instantiate a player

woeful ferry
#

Yea, my save file is one struct

winged badger
#

its easy to (de)serialize as well

#

yeah, you put that struct as RPC parameter

chrome bay
#

unless it's megabytes a one-off packet is ok

winged badger
#

and off it goes

#

but generally, player setup fits into 300 bytes

woeful ferry
#

save file goes:

#

I get it now, I'll try it out

chrome bay
#

You can help yourself out too ofc. Like for our cosmetic choices, we don't send asset names or anything, it's just an FName that get's looked up in a data table that both server+client have

#

If it's static data you can key with something that helps

winged badger
#

we use tags that also happen to be matching the datatable rowname

chrome bay
#

dat sweet gameplay tag net serialization

woeful ferry
#

Yea, we just have inventory, character stats (health et.c), gear, stamina

winged badger
#

exactly

chrome bay
#

@winged badger how many tags are you up to now :D?

#

Would be nice if we could do a data table customisation that used tags for row keys tbh

winged badger
#

nearing 3000

chrome bay
#

oof

#

So by my logic that's..

#

12 bits for a tag

#

With enough headroom for another 1,000 or so before you need another bit 😄

winged badger
#

it shouldn't be too difficult to make

#

would just need to replace that one slate element

chrome bay
#

I'll settle for multi-row editing tbh

winged badger
#

i'd go custom DT for that tho

chrome bay
#

yeah

winged badger
#

and put an actual tag there

#

i had to increase the tag container max size to 128

chrome bay
#

Still can't believe that's a thing

#

Was also surprised to find that adding one tag sends the whole container.. which is just upsetting

#

You'd think they'd have implemented some bespoke delta serialization for tag containers

winged badger
#

but they did go and save that one bit on the tag container num

chrome bay
#

oof

winged badger
#

thats important

chrome bay
#

10/10 Epic

winged badger
#

find that odd to say the least

#

considering most games don't have a bandwidth problem, but are happily choking the server CPU

chrome bay
#

yeah, really bizarre

winged badger
#

to go and complicate stuff for 1 bit per tag container

chrome bay
#

I guess though they only really replicate FGameplayTagCountContainer in GAS, maybe they never planned for anything else

#

Might be wrong about that actually

winged badger
#

counter is way too complicated for simple use/replication

#

especially for stuff like COND_InitialOnly, which happens a far bit with tag containers

meager spade
#

when we switched from normal container to count in our custom system

#

we had issues where multiple tags got added, but the same amount was not removed

#

was.. fun 😛

#

player getting randomly frozen in place, etc urgh

kindred widget
#

Earlier conversation does remind me. I was messing around with some RPC testing once and noticed that RPCs are dropped near getting over 65,535 bytes. Is that hard coded, or is that a project setting?

#

I assume hard coded due to some networking hardware limitation. Just curious about it. Seemed odd that the limit of size matched a uint16 integer size in bytes.

golden nest
#

Hi, is there any way to use "OpenLevel" with servertravel?

#

What i'm trying to achieve is to have the "Completed" node within server travel

#

For loading screen porpouse

empty axle
#

They are deprecated in 4.26 though, not sure what they use right now

kindred widget
#

Huh. I think my testing was in 4.25. Didn't know about those then. 😄

bitter swift
#

I'm trying to join myself through 2 standalones. What am I doing wrong?🤔

I open the level first and then open my local ip address on the other client.

#

This is the output i got

shy copper
#

can someone direct me to the right way. I'm looking to replicate the Jump from the server to the other clients, What needs to be changed on the MovementComponent? I see the state it's being stored in the FSavedMove_Character but it's not sent to other players unlike the rest of the movement events.

kindred widget
#

I thought Jump was automatically replicated?

shy copper
#

Only client to server, but not other clients

#

thought it was my project, but I've just tried with the thirdperson example

#

only executed on the server

thin stratus
#

Jump is not replicated to Simulated clients

#

You will need to fire an RPC there

#

And filter server and owning client

shy copper
#

Yeah, i've checked this is quite annoying right now, because i was testing yesterday a build and it was working apparently? i even have a gif of the movement lol

thin stratus
#

Well you are jumping

#

But the simulated code has no concept of jumping

#

It just applies the velocity

#

So no callbacks are called

#

You don't even know if velocity is a jump or not as a simulated client

#

@shy copper

shy copper
#

I just checked the gif again and realized it was a buggy animation 😥

#

So is there a way to send a multicast event but ignore the owning client? 🤔

chrome bay
#

there is not

#

You can choose to ignore it client-side, but it'll always be sent

hexed pewter
#

I have a question regarding hit registration in multiplayer scenario, with 2 clients (client A, client B). Assume its a FPS game with guns firing projectiles slow enough that player may attempt to dodge them (think something like alt-fire shock rifle from unreal tournament), if the distance between clients is not too close.

My understanding so far is this:

  1. Client A calls SERVER_FIRE RPC locally to fire a projectile at client B;
    simulation projectile is being spawned locally;
    then Client A (locally) simulates all the necessary things like sound of gun firing, various animations;
    and finally projectile collision animation, either a blood splatter when it hit player or explosion when it missed;

  2. Server determines if the fire action is valid, and then if appropriate, proceeds to fire on the server;
    projectile is being spawned (it can either hit or miss, the outcome is not neccesarily bound to be the same on client and server)
    some ON_REP function tells other clients that they should play appropriate animations and effects;

  3. Client B first notices that a projectile is being spawned;
    ...

In this situation, will player B have more time to dodge, depending on how good his connection quality is?
The worse his connection, the later will he notice projectile being spawned?
Similarly how do games tackle following:
Client A has bad connection issues, fire a projectile and scores a hit locally;
but in fact misses miserably on the server (in the end no hit is being registered).

chrome bay
#

You need to implement lag compensation. Server will store a history of transforms for each player and timestamp them. Hit registration takes place client-side (shooters POV). When they think they shot something, they tell the Server, and the server validates the hit by checking whether the hit player was where the shooter says they were (rewinding by the RTT of the shooter)

#

Don't forget each client sees every other client back in time by a factor of their own ping, the server processing time + the victims ping.

#

All of these things can vary so you have to build in tolerances

#

Non-shooters may also want to fast-forward other players' projectiles by RTT / 2 so they are closer to the Servers' current position. However that also means they might think the projectile missed them when in fact it didn't, since on the Server, their pawn is actually behind by RTT / 2 + processing time.

bitter swift
hexed pewter
chrome bay
#

fast-forwarding by RTT / 2 would give you where it currently is on the server (roughly) - RTT would give you where it currently is in relation to you on the Server

#

So it's a trade off

#

perfect sync (sadly) isn't possible. Whichever choice you make also affects how you see projectiles hitting other players

#

I.e. projectile might fly past another player on your screen since they're all in different timesteps, but it might hit on theirs

#

But usually unless it's your own shot, player doesn't care or cry BS 😄

hexed pewter
chrome bay
#

nah it doesn't

#

ShooterGame just does client-side hit reg for hitscan weapons, and server-side for projectile weapons

#

UT does it to some extent, but UT's system is also really tightly integrated with the weapons and the character movement so I don't like it much

hexed pewter
#

Does that mean if I were to build a simple project, server side hit registration isn't necessarily that bad right?

chrome bay
#

Probably fine as a basic starting point but not for anything competitive or PVP

bronze jasper
#

Hi,

could someone help me with actor components (in a player character class)?
They contain replicated stuff like movement, peeking, flashlight etc. because I don't want a huge monolithic player character class.

I create them in the actor's BeginPlay with NewComponent.
I don't use CreateDefaultSubobject in the constructor because if I change them later it messes up child blueprints, at least this is my experience.

The problem is, whenever the client tries to use these actor components, it gets disconnected with this error:
Client attempted to create sub-object.

If I'm correct this means that the server doesn't have that component and this should never happen. So basically there is one component instance on the server and one on the client but the engine doesn't think they are the same. (?) Or the server just ignores NewObject and all of them are just null on the server?

All of these components marked as replicated and stored in a UPROPERTY. If I create them only on the server they are not present on the client.
I've read on some forum thread that I should create them in a multicast RPC and I thought it may solve my problem (but doesn't seem logical because I think it's basically the same as calling BeginPlay on every client).
I tried calling this multicast RPC on the server but the method only runs on the server but not on the owning client (I can't figure out why, the actor is replicated).

Basically all I want is to create actor components that have replicated functionality (properties and methods too). I want the same as if I were using an actor but with actor components.

I'm not a beginner so if you could give me some tips I'm sure I can figure this out.
I'm surely missing something basic, I would be really grateful for some tips or any documentation where I can learn about how actor component replication works.

chrome quest
#

First off, the corruption in the child blueprints.
Are you by any chance hotreloading? i.e Compiling in the editor or compiling in your IDE while the editor is still open.

#

Also, marking the components as replicated and creating them on the server should work fine. I think?

bronze jasper
#

Hot reloading doesn't matter in this scenario because I tried building and starting the editor afterwards, it was the same. With default objects some of my components weren't ticking for example and I tried everything. As soon as I started using NewObject they started to work as intended. I don't want to play this gamble so I really don't want to use CreateDefaultSubobject if I don't have to.

eternal canyon
#

I don’t think just building will do anything

bronze jasper
#

I haven't changed any code just created them with NewObject and they were suddenly working fine. I think this might be some blueprint cache or magic stuff which I'm not interested in, I don't want to learn the behind the scenes of UE. I don't want monolithic 10k rows classes because they are hard to manage and disgusting. Also I don't want to use actors for basic stuff. My question is how can I make an actor component that is present on both the server and the client and can call RPCs and have replicated properties? If it's even possible.

chrome quest
dark edge
#

Just back up to a version that worked. And if your answer is, you're not using version control, then consider this a lesson learned LOL

bronze jasper
#

I’m using git, as I said I’m not a beginner. The problem is it never worked. I shorten my question, maybe someone knows the answer: can I use actor components for replicated stuff and if I can, could you explain how actor component replication works? Not the properties but the component itself.

chrome quest
kindred widget
#

If you mark the component replicated, and it's created by a replicating actor, the component itself will replicate. Past that it's largely identical to Actor replication.

bronze jasper
#

Yup, I call SetReplicates(true) after I created them.

#

The client only disconnects when I call an RPC in these components, I try to dig deeper right now.

kindred widget
#

I don't think you need to do anything besides set SetIsReplicatedByDefault(true); in the component class constructor, then do NewObject, and RegisterComponent? Not as familiar with runtime component creation.

bronze jasper
#

Like this?

kindred widget
#

Dunno. My only known working example uses the class constructor on the component to set replication. But I assume that should work.

bronze jasper
#

SetIsReplicatedByDefault(true); in the component construct makes no difference 😦

kindred widget
#

What is This in this case?

#

And this code is running serverside?

bronze jasper
#

this = the owner actor, and this is currently in the actor's BeginPlay

#

if I use HasAuthority() the components are not created on the client, this is my problem. If I create them on the client too, it disconnects, if I create them only on the server, the client doesn't have them.

kindred widget
#

Odd.

chrome quest
bronze jasper
#

Yup, this is why I'm clueless.

kindred widget
#

Are you sure this might not be a test fail? How are you checking their validity on clients?

bronze jasper
#

It's pretty easy, you can't move if you don't have the movement ability. 🙂

chrome quest
#

Have you tried a simple is valid to check the validity on both client and server.

kindred widget
#

Personally, I'd just create a print in the Component's Tick. See if it ever prints on clients. If it does, you have an issue somewhere else.

bronze jasper
#

Only ticks on server. But this is weird:

#

BeginPlay runs 1x on server and 2x on client (?) WTF?

dusky yoke
#

Hey guys. I'm trying to add a directional combat system, and to do that I compare two floats from eachother and get the Up, Down, Right and Left direction that the mouse is inputting. I've set the input to be a replicated float variable representing the mouse input. Depending on what direction I drag the mouse to, I run an animation montage with a Multicast.

However, the animation does not replicate to other clients. If I remove the directional stuff the animation plays. Any takes? 🙂

bronze jasper
#

"BeginPlay runs 1x on server and 2x on client (?) WTF?" -> never mind, one is for the server character, one is for the client

bronze jasper
dusky yoke
bronze jasper
#

Oh I see. Do you call the multicast on the server?

#

If the client attacks, you have to tell the server first that the client wants to attack, and then call the multicast on the server.

dusky yoke
#

Yeah I call the Multicast on the server

#

Now the strange thing is that the animations run just fine if I skip the directional variable jumbowumbo and just run an animation. The variables are replicated, so not sure what else should be done in regard to that 🙂

bronze jasper
#

You have to send the values to the server

#

Just create an input for the server call and send the float with it

#

And store the float on the server so it can replicate it to the clients

dusky yoke
#

An input for the server call? Sorry, completely new to network-coding 🙂

bronze jasper
#

Your float is 0 on the server

#

So your function doesn’t do anything (the action based on movement thing)

#

I mean an input for that function, a float input

#

Like this.

dusky yoke
#

Not sure if I used your suggestion correctly here though, but I'm setting that variable here on the servercall https://gyazo.com/1a93808e02ca59213d1f6cea09f5309f but no effect. I guess I fail to understand how the Server is actually being fed that information 😅 Thanks for all your inputs so far, feel like that was enough to teach me some things already haha

bronze jasper
#

Do you see the prints on the screen? The "Down", "Up" etc.

dusky yoke
#

Yeah as the client calling it

bronze jasper
#

So they are there on the client but not on the server?

dusky yoke
#

Actually both clients see the print

eternal canyon
#

Inputs only run on the local machine

meager spade
#

how do i change the ALobbyBeaconState to my custom one?

gentle pagoda
#

LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = FailureReceived, ErrorString = Host closed the connection., Driver = GameNetDriver IpNetDriver_28

#

I am facing this issue. please help

#

I am new to unreal its my first multiplayer game.

thin stratus
gentle pagoda
#

Can anyone please help?

dusky yoke
dusky yoke
#

Im thinking maybe I shouldve done all of that variable stuff on the client, and then just set bools depending on which comøarefloat is correct, and then just check that bool as the server? 🤔

violet sentinel
dawn shore
#

Does anyone know how to let RepNotify for bool variable work on initialization?

#

Details: I have bool:bVREnabled, which is replicated and has a RepNotify function. If it is changed, RepNotify exists to do some stuff on clients, such as calling EnableHMD. A client can call ServerRPC to send a requent to change the value.
The problem is on the initialization. If I initialize it with false on BeginPlay, RepNotify wouldn't be called on clients because the default value is false.

kindred widget
#

Why not just call the function anyway on beginplay?

dawn shore
#

Oh I didn't notice that way.

#

I can call the RepNotify function on clients if the value is the same, but the time delay might be issues.

#

Does it take some time for clients to get notify from server, right?

kindred widget
#

Usually. Network travel time at least plus usual server tick time. Can sometimes be up to a full half second in bad situations.

dawn shore
#

Then that might make another issues because on RepNotify i do a lot of stuff.

#

Is there other solution for this?

kindred widget
#

It usually doesn't matter. Your replication state should take into consideration all of the other state that it relies on. For instance, if you have three different states, and these all do a ton of things, it should matter if it's called three times once per state. Specially if this is initial setup, you can hide it behind some camera work or a loading screen.

#

I'm curious though. If this is a client set value, why does it matter so much? If it's client authoritive, the client should set it and call necessary functions after sending it to server. The Replication should never come back to client since it should skip owner.

#

The only onreps that would need to happen would be on other machines than the owner, and if the state is set to true, then it can change them, if it's false, then that should be their default state on initial setup.

dawn shore
#

I quickly checked my codes, but maybe that doesn't matter.

#

so I will try that way until i find issues

#

thanks, man

#

By the way, I found something called ELifetimeRepNotifyCondition::REPNOTIFY_Always. Do you know if this is something useful for this situation? just curious.

kindred widget
#

Could work. Though on that note if you're running 4.26 or more, it might be worth considering a pushmodel system that you can just mark dirty.

#

More deliberate.

dawn shore
#

What is that system?

kindred widget
#

You can check it out in the native PlayerState.

#

Pretty easy system. You specify the variable the same way.

#

Call a slightly different macro in GetLifetimeReplicatedProps.

#

Then when you set it, you also mark it dirty.

#

I'm semi sure that marking it dirty will send it to a client regardless of the value changing.

#

Curious, will test.

dawn shore
#

Does it skip all of the replicated variables, or just specified ones?

kindred widget
#

Skip?

dawn shore
#

it skips changes, right?

#

on sync

#

I meants, skip all of the changes or changes of specified variables only

kindred widget
#

Normal currently replication just checks the variable on tick basically. Little more complicated, but still. Pushmodel only checks the ones specifically marked dirty. Saves a lot on server ticks in some cases.

#

You can use the two together as well, it's not one or the other as far as I'm aware.

dawn shore
#

I see. That sounds good. I will take a look at it.

dawn shore
#

If the value is not the same as default, doesn't matter. server changes it and rep notify is called on all clients

#

but if the same, all clients call RepNotify by themselves

#

but in the function, I have something I have to wait for at least one frame

#

I mean I use SetTimer in RepNotify to do some stuff after that

#

that might be an issue

#

Oh, it is not that the problem happens if the value is the same. it happens if the value is different.

#

clients which is not local call RepNotify and set timer, then a local client finds the value is different, and then call ServerRPC so server notify changes to other clients

kindred widget
#

Okay. Seems even with Pushmodel, the OnReps won't run without that condition set.

dawn shore
#

I will definitely learn that.

kindred widget
#

Hmm. Well that's.. odd. Even with that condition set to always it isn't running. :/

dawn shore
#

I didn't try REPNOTIFY_Always yet

#

just trying your initial answer, and noticed

#

I can still check value on the function which is passed to SetTimer, and if the value is different, then I can skip that.