#multiplayer

1 messages · Page 603 of 1

winged badger
#

it can get a little bit dodgy, as the weapon reference in the character would replicate immediately, but the weapon actor itself likely would not

shy osprey
#

I'm updating the weapon values on the weapon BP inside of a function, and that function is called by a gameplay ability.

The values do get updated, but for the client this update takes several seconds

winged badger
#

once they sync up, they stay synced?

shy osprey
#

yep

winged badger
#

what im guessing happens

#

your PC and Character have a NetPriority 3 by default

#

which means when the Actors start replicating to clients, they will be at the front of the list

#

your weapon is derived from AActor, which gives it NetPriority of 1, unless you tweaked it

#

it has to wait its turn

#

so you spawn the weapon on server, you set the reference and all is good

#

Character replicates, it has good weapon NetGUID, but it can't resolve it yet, as the WeaponActor itself still doesn't exist on clients, waiting for its turn to replicate

#

i have no idea how you bound your UI to the weapon, so thats the best guess from the symptoms

shy osprey
#

When I pick up the weapon, I just pass the reference to the HUD Widget via event and it stores the reference.

winged badger
#

we are talking HUD widget or HUD actor?

shy osprey
#

HUD Widget

#

I only use the HUD Actor for drawing the crosshairs

winged badger
#

its very convenient place to manage all your widgfets

shy osprey
#

Well the HUD does manage the widget

winged badger
#

HUD has 1:1 relationship with the PC and is local only

#

which... simplifies things alot

#

anyhow, how do you pass the reference to the widget?

shy osprey
winged badger
#

you mentioning its a pick up a weapon scenario, means its not the start of the game scenario i speculated about earlier

#

trigger for that action is what im interested in

shy osprey
#

It's on the map, but I don't get to pick it up as the client until I'm fully synced and can walk around

winged badger
#

what calls it

#

not how you put the widget on screen

shy osprey
#

Call what?

winged badger
#

the part left of that branch

shy osprey
#

That's an OnRep function for the CurrentWeapon

winged badger
#

that should work better then you describe....

#

if you pick up one weapon, wait for sync, then pick up another, does your widget show the old weapon values or just zero?

shy osprey
#

Each weapon has its own Ammo counter

#

So when I switch weapons, the widget switches with it

winged badger
#

different widget classes?

shy osprey
#

yes

#

And they do get called to update every time I fire on the client. The value just doesn't update

winged badger
#

your widget itself is bound to OnAmmoChanged event dispatcher in the weapon?

shy osprey
#

I actually only have this issue with weapons that use energy too. The weapons with rounds replicate fine.

I'm working with a plasma weapon that uses a timer to dissipate heat, but that heat value inconsistently updates.

The HUD widget does bind an event to the weaponFire dispatcher, but the client never gets that bound event to fire.

winged badger
#

EventConstruct?

#

do all your ammo counter widgets have a common base?

shy osprey
#

I did find that lowering the timer period to simulate 30fps instead of 60fps made the Heat Variable update sometimes rather than never, so I think maybe it's just a case of dropped packets? I'm using a timer instead of tick because I get huge drops in FrameTime when using Tick.

And no, this is the binding events in the HUD Widget:

winged badger
#

whats to the left of those binds?

shy osprey
winged badger
#

i'd try this first

#

make a widget class, WeaponWidgetBase or some such

#

delete its entire UMG hierarchy, its the only way BP will allow for UMG blueprint inheritance

#

add a variable of whatever your CurrentWeapon type is in it

#

and mark it as instance editable, and exposed on spawn

#

then reparent all your weapon widgets to that

#

change the variable type of AmmoCounter in your weapon to be a class reference of that base weapon widget

#

effect is that this create widget node will get a pin of your weapon's type on it

#

so you can connect your current weapon to it

summer tide
#

This is not working for me. I have this in my main menu player controller. v

winged badger
#

and the current weapon will be valid and available to the weapon widgets by the time construct is called

summer tide
#

So I tried this from 2 diff pc. I have a host who sent invite to the client. The client accepts the invitation then that node should get triggered. But not happening. Am I doing it wrong?

half jewel
#

is it alright for server to call serverRPC functions on its own?

hybrid zodiac
#

@half jewel yes, a server RPC called from the server just executes as a normal function

half jewel
#

no hidden side effects anywhere ?

exotic jay
#

I have a small multiplayer setup with fairly slow guns (think bolt action rifle rate of fire) with projectiles. So very few and infrequent bullets, but ideally very accurate to what the shooting client expects. I am planning to do:

  • Client presses shoot and bullet is spawned on client that does cosmetic hit effects
  • RPC tells server to span bullet that replicates and actually causes non-cosmetic hit effects

Does this make sense? And, perhaps a dumber question, how do I avoid the server's version of the bullet appearing on the original client that already has a bullet instantiated?

meager spade
#

every bullet in my game is a server RPC

#

even fast firing assault rifles 😄

#

if you never want the client to see the server bullet, you can only do that in C++ and override IsNetRelevantFor

#

and to return false if Owner == Viewer

eternal briar
#

As the replication of maps and sets is not allowed, can you put the map in a blueprint struct and replicate that struct? (I can definitely set that struct to "Replicated" in the blueprint, but will it work properly?)

thin stratus
#

No

#

The Property will still not replicated

eternal briar
#

👍🏾 thank you

exotic jay
#

@meager spade I feel like when I spawn my bullets on the server, they've hit something and have disappeared before first being rendered on clients. Are you spawning a bullet on the server and replicating it? Or multicasting to spawn the bullet on each client?

eternal briar
meager spade
#

i don't actually spawn a bullet (even for snipers), only time a projectile gets spawned is things like rocket launchers

#

snipers i do a distance and math based time to hit and drop, etc

#

but if your spawning projectile, you def want to spawn one client side, issue is, if the shot is super close (closer than one sub step of projectile movement), kinda pointless spawning a projectile, but that being said client spawning it and server, is the only way to fix it

#

and i don't use multicasts for projectiles, cause a replicated actor is on clients and server

exotic jay
#

what are your bullets then? Just particles for cosmetics?

meager spade
#

hit scan and trails/tracers

#

those i do multicast the trails

#

but that is not a projectile, which is handled differently

exotic jay
#

got a link to anything for what you mean by trail/tracers? I get it conceptually but not sure what it means in the engine itself.

#

is it like a ribbon on a particle effect?

lost inlet
#

substepped line traces for us

#

for tracers, we just spawn a PSC and update it to where the bullet's position is, though we do a bit of a pre-sim so there's a bit of an initial lerp

#

we do drop, bullet penetration and ricochet

exotic jay
#

PSC stands for?

lost inlet
#

particle system component

meager spade
#

i wonder if in Fortnite they shoot from the Pawns center rather than the camera

#

they did that in H1Z1

exotic jay
#

ah ok. makes sense.

#

Ok, I'll give it another shot with this all in mind. Thanks for all the help

uncut atlas
#

Hi! When I spawn my projectile on the server I set the instigator and its supposed to be replicated to clients but every once in a while the clients copy of the projectile says the instigator controller is invalid. I need to access the instigator controller on BeginPlay. Does anyone have an idea for why the instigator controller isn't consistently being replicated?

chrome bay
#

Most likely because the instigator isn't relevant to that client when the projectile replicates

#

Bear in mind, Instigator "Controller" will never be replicated

#

Apart from their own local controller, controllers never exist on clients

uncut atlas
#

If I set the instigator on the server, shouldn't the instigator controller be valid for the client who triggered the spawn? because the instigator on the server is connected to a player controller and the player controller is replicated to its owning client

chrome bay
#

Yeah the owning client should be fine, but only them

#

In theory if you spawn the projectile and set the instigator in the same frame, it should replicate immediately as part of the spawn packet

#

And therefore be valid at BeginPlay time

uncut atlas
#

That's my problem. Your theory is how I implemented it, but every once in a while one of the projectiles does not successfully replicate and the instigator controller becomes invalid. I'll check again.

chrome bay
#

Oh you mean it doesn't replicate at all?

#

I thought you meant just the instigator property isn't set

uncut atlas
#

Yeah sorry. Everything replicates but the instigator property

chrome bay
#

yeah kk, that's a bit stranger

#

I don't know if it's 100% guaranteed that you'll get those set properties in the first bunch. It might be due to network stress, you could try spamming it and see what happens.

#

Individual actor properties will replicate non-atomically I'm fairly sure

uncut atlas
#

I think your right. It might be a network problem. I'm testing it on one laptop using the command prompt, so having 2 standalone games open along with the editor might be causing problems. Thanks @chrome bay for answering my question.

chrome bay
#

Oh sorry, I'm wrong - actor properties do replicate atomically

#

When an actor is replicated all of its changed values will be sent as an atomic update. This means that we guarantee if you receive the update, you will receive all the properties that have actually changed in that update. This includes subobject properties as well.

uncut atlas
#

ok

echo snow
#

I've got a wall run system where the client tells the server to launch the character. I want to run this function on a high frequency, around 50 times a second. I've limited my game to have 4 players at most.

I want to ask if this will have bad networking performance or not

hollow eagle
#

You're going to have all kinds of bad times with that.
Why have the client tell the server to launch the character every time? Instead, just have the client say when they want to start and stop wallrunning.

echo snow
#

Is that for security reasons?

mighty zinc
#

No

#

Becos ur client is calling the functions again and again

#

On the server

echo snow
#

Ah so I'm going to call wall run once and the server will do all the work from there

mighty zinc
#

Yes

#

And also to prevent people with highend fast machine

hollow eagle
#

Lots of reasons...
Latency will screw over some RPCs, so you'll get weird timings for launching.
Server would need to validate that the client isn't calling things too often.
Network throttling may prevent RPCs from actually going out 50 times per second and instead batch some calls, which will also screw over timings.

mighty zinc
#

To not have a different functionality

hollow eagle
#

Also... your client should probably simulate the launches in addition to telling the server (clientside prediction)... but you're going to have to implement some way to reconcile differences between client/server + lag compensation or else you're going to have all kinds of jittery movement the moment any latency is introduced.

#

CMC does this for basic movement. It's non-trival and not well documented but you can add new features to it to deal with the above.

echo snow
#

I'll take a look, thanks!

hollow eagle
sly violet
#

This is driving me nuts. I have a dedicated server, running a simple experience. Main Menu (offline) -> Lobby Map (online) -> Game Map.

The first time I build a local dedicated server, the flow works, my loading screens fade correctly and the game works.

If I close the server, spin up another local dedicated, and play again, I get stuck on the Loading Screen. 100% of the time after the first time./

#

Is there anything that is saved locally or on the "local dedicated" server that could case inconsistency between runs of the local dedicated?

rich ridge
#

@sly violet how are you joining your server, via session or ip:port?

sly violet
#

IP

rich ridge
#

it should work then, are you getting any output in console of server?

sly violet
#

I actually have a ton of Prints within my server output that shows they are seemly identical.

rich ridge
#

server outputs the handshake logs, if client tries to join you should be able to see it

sly violet
#

Oh, I should clarify. The game loads into the level, all clients are connected and possessing a pawn, but the loading screen will not disappear.

rich ridge
#

you made that loading screen so at what point you are dismissing it

#

in the game settings you can specify the transition map, are you using that?

sly violet
#

OnPostSeamlessTravel

#

Yeah, Transition map is loading and unloading correctly.

rich ridge
#

OnPostSeamlessTravel -> this function is part of which class?

#

is it inside GameMode?

sly violet
#

Yes.

rich ridge
#

gamemode is server only

#

it won't run on client

#

thats why your loading screen is not dismissing

#

GameMode instance only exists on server.

sly violet
#

It casts to state and multi casts to clients.

The hard thing to comunícate is that this works the first time I run a new build of the dedicated server, and then never again on further iterations of the same server build. If I build it again from the Project Launcher, it works one time again.

rich ridge
#

hmm interesting.

#

so what I do usually do, lets say I have MainGameplayMap.umap which is loaded after server travel, once its loaded at client side, I have BeginPlay inside LevelBp, and I clear the loading screen widget there.

sly violet
#

Hmm, interesting. The level BP casts to say Game State to clear it in your example?

#

It feels like a race condition so I added a bunch of arbitrary frame delays, but the issue still occurs the same way.

Is it possible that the widget is somehow being kept between sessions without an owner?

rich ridge
#

every map has a blueprint class.

#

and inside that blueprint create begin play event

#

give your loading bp class here.

shy flicker
#

Hi everyone. I'm having a weird bug. This function is called from a timer by the server. After "x" seconds the Character called sets its location and rotation to the clients. The location is set correctly but by some reason the rotation does not change it sticks with the one it had before. Any help? Thanks

steel fox
#

HI, I'm using add yaw input and add pitch input functions in player controller to update my player rotation, replication works fine on server, but it won't replicate on the other clients, why? If Server has the correct values shouldn't all the clients have them too?

kindred widget
#

@steel fox Character class? Yaw should update in the form of the capsule rotating. Pitch usually needs to be shown with an AimOffset. How are you testing these values?

steel fox
#

So you suggest to use an aim offset?

#

Thank you

kindred widget
#

On the yaw angle?

#

Like left right turning?

steel fox
#

No

#

Like lookup

#

Turning works fine

kindred widget
#

For Pitch, yeah. Generally you'd use an AimOffet in your animation blueprint.

#

GetBaseAimRotation to get the pitch. GetControlRotation doesn't work well for that I find.

steel fox
#

Oh, then I've lost a lot of time for nothing😂, thank you @kindred widget

kindred widget
#

Haha, I know that feeling well.

#

@steel fox I should double check, you do mean like aiming arms up or whatever. Not turning an entire mesh upwards like a starship or something, right?

fading smelt
#

UGameInstanceSubsystem class have a replication or not?

steel fox
#

Right, I'm trying to do my multiplayer fps, so I'm already having an aim offset on tp mesh and I've thougt that fp should rotate automatically following camera, spring arm or whatever

kindred widget
#

@fading smelt AFAIK no subsystems replicate. But that's second hand hearsay from me from random conversations I've seen.

steel fox
#

Now I have another question, if I attach an actor, can I use a scoket for the owning client while using another socket(maybe from another mesh) on the other non owning players?

kindred widget
#

@steel fox Usually the camera is just attached straight to the base capsule, and the arms are attached to it. But yeah, for the third person mesh you'd use like a 1D AimOffset in the animation blueprint to show where it's aiming.

#

I assume you mean for something like weapon attachment?

fading smelt
#

Game State?

kindred widget
#

@steel fox There's a couple of different ways to manage it. I've grown to like the shooter game's method. Basically they do the same thing with a weapon as characters do with meshes. Two weapon meshes in one actor, and on every client each gets attached to their corresponding mesh. So 1P weapon gets attached to arms, 3P weapon gets attached to the 3rd person character mesh. Their visibility is affected accordingly to the owning client and the player, etc. This also allows for easy LOD effects from third to first person on the meshes.

#

@fading smelt Depends on what you need. Can use Gamestate directly, or through an actor component on it. Or you can even spawn a whole new replicated actor for it.

hidden thorn
#

Just wondering if anyone has done it enough times to remember, how can I run another VS Instance of the same project to be able to test locally, right now simply starting using 2 players (Server & Client) doesn't work as they are both the same player.

#

I found an article on how to do it before for multiplayer but I can't remember what I searched for and I can't find it anymore.

atomic vale
#

So I am getting now into Steam lobby stuff now. I am having trouble retrieving list of sessions. I am using SessionInterface->FindSessions, but I am getting a bunch of Unable to parse search result for lobby... I googled that this is kind of known issue, but I don't know how to get around that. Any experience?

steel fox
fading smelt
kindred widget
#

@steel fox Hard to say. In multiplayer I doubt I would. I'd probably just use the Projectile Movement Component. It'll be much easier to get working than simulating physics.

#

@fading smelt ActorComponents can replicate as well, but they use their actors to do so. So if you add a component to an actor that replicates, and then set the component to replicate, the component can do it's own networking. I don't know the difference of network integrity or performance of component vs new actor. Jambax, Kaos, or Zlo might be people you'd catch around to ask about that sometime.

meager spade
#

@fading smelt yes

#

we have an actor in the level, that holds a few replicated componnts

#

this is our Level Manager actor

#

and inside that, those components are also small managers

#

(SpawnManager, LootManager, etc)

grizzled stirrup
#

Does the client have ROLE_Authority over an actor that is placed in the world in the outliner that is not replicated?

#

As in if you call GetLocalRole() == ROLE_Authority on that actor it would succeed on clients?

#

It would appear so. Is there a way to make it so I don't have to replicate this actor but still be able to check if the local player is the server or not?

#

Will clients return their own player controller when calling GetWorld()->GetFirstPlayerController ?

chrome bay
#

You could use IsNetMode(NM_Client)

grizzled stirrup
#

Thanks that is easier!

#

Has anyone ran into issues when spawning static mesh components at runtime? When playing as a client that has spawned these meshes locally (not replicated), I notice this printing in the logs while I play FNetGUIDCache::SupportsObject: StaticMeshComponent AssetPath NOT Supported.

#

To clarify both server and client spawn the same thing at runtime based on a seed, but there shouldn't need to be any replication going on, so I'm not sure why it's warning me

chrome bay
#

It's probably something like character movement trying to walk on it

#

It won't work because the movement base object has to be network addressable

grizzled stirrup
#

Ah ok it does appear to work fine with clients but just that warning

#

So would the solution be to replicate the entire map?

#

Seems very heavy for a procedural level which I had though I only needed to replicate an int32

chrome bay
#

@winged badger has done some work on this, but you have to fool the engine into thinking those objects are part of the map

#

But essentially yeah there's a lot more to it than that

grizzled stirrup
#

I wonder if it's actually affecting anything or just printing to the logs

#

Movement on both client / server seems great and perf is fine so maybe it'll be fine in shipping build?

chrome bay
#

Well it means none of those objects you are spawning can be used over the network at all

grizzled stirrup
#

That's fine as they are just static meshes for terrain and such

chrome bay
#

Well it's not fine if you're using characters, as characters will try to use it as the movement base primitive which won't be net addressable

#

so it will cause issues

grizzled stirrup
#

The only case I saw that was strange which I've now fixed was clients spawning a mesh that doesn't exist on the server and walking on it

#

Which caused the client to go to the origin on the server until it stepped off it

chrome bay
#

Yeah that's the kind of thing you'll see

grizzled stirrup
#

But for all the other terrain that the server had also spawned, the client was walking perfectly on it

chrome bay
#

Essentially if it works, it shouldn't

#

But I'll be surprised if that's allowed to pass in shipping

grizzled stirrup
#

It did in my tests last night

#

No warnings of any kind

#

I noticed the origin bug when testing on 3 machines

chrome bay
#

I mean it might just work by fluke, but it shouldn't be relied on

grizzled stirrup
#

I'm sure games spawn clientside actors all the time though even for cosmetic things like little physics objects

#

Would they not be of concern as they wouldn't affect movement?

#

Or is this tricking the engine thing for every mesh you spawn clientside?

#

Interested to see what Zlo says

chrome bay
#

yeah, they wouldn't affect collision or gameplay - so that's fine

#

But something that impacts gameplay or collision should really be replicated, or deterministically generated

#

It can be done, but there's some trickery to it

grizzled stirrup
#

It is deterministically generated currently

#

Just with this warning

chrome bay
#

It is, but the engine doesn't know that

grizzled stirrup
#

Right so the trick part needs to be done

chrome bay
#

yeah

grizzled stirrup
#

I've been looking around online but can't find info there, hopefully Zlo can shed light on it

chrome bay
#

AFAIK the parts you need to overrule are bIsNetStartupActor, which fools the engine into thinking the object was loaded from the map and can therefore be addressed through it, and also ensuring that all of those objects are generated with identical FNames

#

But I've not done it, so there may be more to it

grizzled stirrup
#

Ah great, thanks I'll try it now

chrome bay
#

But Zlo has it working

grizzled stirrup
#

Since client / server are generating the same assets in the same order at the same time it should be named the same

#

Will give it a shot

#

Thanks!

#

If not it'll be a hefty initial replication!

#

Thousands of individual meshes

#

Though I use a lot of HISMs which should be only 4 bytes each right? Though if needing to replicate all the instance transforms... not happening

#

How do you avoid the FNetGUIDCache::SupportsObject: StaticMeshComponent AssetPath NOT Supported error that shows in logs when playing as a client?

meager spade
#

You can't replicate them

grizzled stirrup
#

Im not

#

Only generating on client

#

Only replicating the seed

meager spade
#

Something is

#

Something is saying its replicated

grizzled stirrup
#

UStaticMeshComponent* SpawnedTerrain = NewObject<UStaticMeshComponent>(this);

#

This is being run completely clientside

#

The actor that it is being run on is not replicated, nor is this component

#

It works fine

#

I'm just wondering about these logs

#

Jambax said it's due to the server and client having the same mesh but not linked for collision so the CMC might be warning?

meager spade
#

Well whatever assetpath is trying to be or attempting to be replicated we have no such warnings

grizzled stirrup
#

Interesting, I'll have to figure out what exactly is happening

#

It fires off whenever and enemy gets spawned

#

So maybe the server is referencing a mesh that doesn't exist on the client or something

meager spade
#

Strange none of our world meshes are replicated

#

But they do have the same name server and client

grizzled stirrup
#

It works flawlessly like I said

#

Never notice any issues

meager spade
#

One thing you must ensure

#

Names must match

grizzled stirrup
#

Shoudl be the same here they are all generated in the same order and same stream / seed

#

I'll log names and check

#

Thanks

#

Will UE automatically know they are linked if they have the same name?

#

Even though I'm just spawning a component clientside?

meager spade
#

we dont spawn just components

#

we spawn the entire actor client side

#

we haven't done HISM based yet

#

its penned for next year

grizzled stirrup
#

I just have a local actor that sits in the outliner that spawns EVERYTHING, Actors, Components, HISMs etc.

meager spade
#

we have the same

#

but components exist inside the actor

grizzled stirrup
#

I think my components exist in the actor too

#

Using NewObject

meager spade
#

but we haven't done ISM/HISM yet, but you do need to ensure same name across client server

#

even components

grizzled stirrup
#

Thanks I'm trying logging now to see if there could be a discrepancy

meager spade
#

(if you want it to act like it was part of the package)

grizzled stirrup
#

HISM setup is super fun and easy- ALL meshes other than the terrain meshes are HISMs for me currently

#

Just have to pass in an array of transforms and boom instances

grizzled stirrup
#

Seeing as it all works fine in playtests I wonder if it's just a log and nothing more bad will happen

#

But I'd like to do it the right way if possible

meager spade
#

well any warning is not good really lol

#

im still tracking down a warning we get

tidal crown
#

Is there anything that a vanilla dedicated server using level streaming would write to disk/re-read on a second run of the process? I'm observing strange behavior that I can only correlate based on running my dedicated server binary more than once post compilation...that terrifies me.

#

I am completely lost on how to debug this

#

100% of the time the binary works fine on first run after compilation, second run it always hangs at a particular spot.

#

seems to be something related to levelstreaming/servertravel potentially.

#

I'm really concerned by the idea that multiple runs of my server process could interfere with unrelated sessions

shy osprey
#

I have an interesting problem, regarding crosshair positions.

I've got a set up in my HUD class that draws the crosshair, but can take a vertical offset for lowered crosshair positions.

I deproject this 2d vector to get the position in 3d space to trace to for firing my weapon.

The problem is the server can't access this position unless I send it to the server instance of the character via RPC. This is a lot of data to replicate frequently, as you can imagine.

I'd like to either find a way to recreate that variable without the HUD or to be able to access that variable via event (when firing) instead.

winged badger
#

there is a ServerUpdateCamera RPC firing under the hood constantly

#

so the server has a pretty good idea about each client's camera pos/dir at all times

#

GetPlayerViewPoint in the PC will pull it out (for some reason not exposed to blueprints)

#

but it takes minimal c++ chops to wrap the native fucntion into blueprint callable one

shy osprey
#

Right, if I just had a centered crosshair, this wouldn't be an issue. But it's important to be able to have lowered crosshairs, which means I can't simply trace from the camera, otherwise shots don't line up with where the player is aiming.

the only method I've found that consistently gets the correct world position under the crosshair is this:

#

Which only exists on the client, because it's the HUD.

I can't recreate this outside the HUD because I have no way of getting screensize on the server, or I'm not aware of another method to trace to the location under the crosshair

winged badger
#

that would leave you with a more significant c++ override (you can lie to the server where your camera is in ServerUpdateCamera, we do)

#

or calculating a shot on client

#

then RPCing the entire shot over to server

#

i personally don't like involving the UI in any gameplay stuff though

#

as replacing the HUD widget can break your entire game, never a good thing

warm leaf
#

Does anyone of you know how to replicate a map(variable)? because you cant do it in details pannel is there any workaround i dont think of?

winged badger
#

yeah, convert it into array of structs that have key, value members, replicate that and reassemble the map on the other side

twin juniper
#

Hiya, what is the appropriate way to create and display widgets in multiplayer? Also I am trying to learn how to use the HUD class.

winged badger
#

use the HUD to instantiate all gameplay widgets (not menus, its lifetime isn't good for those)

#

and not loading screens

#

thats pretty much it, don't let any piece of code except the HUD actor subclass reference any of the UI

#

(notable exception are widgets on widgetcomponents, that often require the owner to inject a reference to itself)

#

and avoid using GetPlayerController/Character[0[]

twin juniper
#

my knowledge of multiplayer UI is very poor. This is what I have inside my HUD class but the widget I create is not displaying.

winged badger
#

HUD has a 1:1 relationship with the PC

#

and is always local only

#

you don't need any network checks, its always the local players HUD

warm leaf
#

instead of a map

twin juniper
#

oh I remove the network check and it worked. lol

winged badger
#

also, because the HUD is spawned by the PC on client

twin juniper
#

didnt expect

winged badger
#

client has the authority over the HUD Actor

meager spade
#

one of those situations that confuses people

#

they assume Authority means server

winged badger
#

it doesn't

meager spade
#

Authority is WHO has authority over that actor

#

client spawned actor, client has authority

#

if its replicated, the server has authority

winged badger
#

why would you replicate a datatable @warm leaf ?

#

its an asset, as long as its packaged on clients, clients have it

meager spade
#

DataTables can't be replicated, and DataTables are supposed to hold static information

#

not mutable at runtime

warm leaf
winged badger
#

you can replicate a pointer to the datatable

#

and you should never ever replicate static data

warm leaf
#

naaah

#

hate this replication shit XD

meager spade
#

well the data table exists on both clients and server

#

so you function should know where the data table is and get the value

warm leaf
#

Whats going wrong? (I think im brain AFK from this whole replication shit)

rose chasm
#

I have a weird problem when im leveling streaming(Loading) 2 clients to the same map it doesnt spawn the players characters. When i Level stream only using one client (Level Streaming) it works correctly. Does anyone know why this would happen?

rose chasm
#

Figured it out. Game mode was not Begin Playing when there are 2 or more people.

grizzled stirrup
#

@winged badger Any insight on the discussion from earlier? FNetGUIDCache::SupportsObject: StaticMeshComponent AssetPath NOT Supported being printed at runtime in the logs on client when generating an identical procedural level on client and server (the components causing the log to print are created as so UStaticMeshComponent* SpawnedTerrain = NewObject<UStaticMeshComponent>(this); ) Jambax mentioned you knew a workaround

#

Works fine but of course would like to fix whatever issue is causing the log

lost inlet
#

did you set the mesh to be replicated or something?

grizzled stirrup
#

Nope

#

Completely clientside

#

The actor that is spawning it is a non replicated actor that exists in the world outliner

#

The server just replicates down a seed and the client gets this actor and generates the same level based on the seed

#

Maybe need to call UActorComponent::SetNetAddressable or something since it's not created in the construction script? (which is one of the conditions for UActorComponent::IsNameStableForNetworking to return true)

#

Yep that seems to have stopped the logs!

#

Zlo if you know of a better / more correct workaround I'm all ears!

winged badger
#

set net addressable shouldn't work with that way of spawning it

#

even if the actor owner is net addressable, the component, not been given a unique name relative to its owner, isn't net addressable

#

and is likely to cause a client disconnect if a pointer to it is ever send over the network

grizzled stirrup
#

I'm setting net addressable on the spawned component

winged badger
#

yeah, i caught that

#

but the thing is, it just expects to be net addressable, but isn't

grizzled stirrup
#

In this case does it matter if I never will be using it as a pointer

#

Just has to have the same level on client and server

#

And no log warnings

winged badger
#

you should still give it a name unique for that actor scope that matches on client and server

grizzled stirrup
#

As if I hand placed the mesh in the outliner- never to be referenced again

winged badger
#

when you're spawning it

grizzled stirrup
#

Since there is exactly one level generator in this case and never will be more, and UE give a unique name to each spawned component, should be fine right?

winged badger
#

otherwise you're just leaving a landmine in your code

grizzled stirrup
#

Since it runs in exactly the same order on client / server and on only one actor

winged badger
#

no, the same name, on all machines

#

you can't let UE autopick it

grizzled stirrup
#

Yes the output should be the same, it's like StaticMeshComponent_0 etc.

#

I'll double check to verify

winged badger
#

NewObject

#

accepts a name parameter

grizzled stirrup
#

I know but the autogenerated name appears to match on client / server

winged badger
#

yeah, and when you start listen server + client game in pie

sinful tree
winged badger
#

they al have playercharacter0 and 1

#

they both typically have the 0 one for local tho, both

grizzled stirrup
#

So I should just give it a name like TEXT("MySpawnedComponent_%d") to make it unique and match on client / server?

#

To avoid any autogenerated mishaps?

winged badger
#

i would

grizzled stirrup
#

Great thanks, and should I do this for HISMs spawned too?

#

Basically any mesh that needs to match on client / server that has collision

winged badger
#

that would also actually make it net addressable

#

note: unique name is important only in the scope of the actor owner

grizzled stirrup
#

Oh I see, so by giving it a custom name I can remove the

               SpawnedTerrain->SetNetAddressable();

call?

winged badger
#

you can have 10 instances of actor A, each with instance of component B called "ComponentB"

grizzled stirrup
#

That's good to know

#

And you'd do it for HISMs too?

#

And anything with collision basically?

winged badger
#

HISMs do have an actor that holds the instances, yes?

grizzled stirrup
#

Yes it's the same actor

#

I do all my spawning there

winged badger
#

well, anything you know you need you can preplace

#

that solves all the problems out of the box

grizzled stirrup
#

But I need the seed from the server

#

Which is why construction script is out of the picture

#

Which would suppress the logs

winged badger
#

to what? add instances to HISM?

grizzled stirrup
#

Yes

#

The seed determines the density

#

I can't add the correct number of instances

#

Until I get it

winged badger
#

you don't need a seed to spawn the HISM itself

#

so you can preplace it

grizzled stirrup
#

Well in this case the seed also determines how many HISMs get spawned

#

Sometimes 1 sometimes 20

#

Depends on many factors, so has to wait on the seed

winged badger
#

fair enough

#

actor is preplaced tho?

grizzled stirrup
#

The spawner itself is

#

But that spawns multiple sub actors that spawn things

#

Depending on seed

winged badger
#

so its net addressable by default

#

components net addressing is resolved basically by resolving an actor owner + its unique name relative to that actor

#

if your Spawner has HISM_1 and HISM_2

#

and those HISMs are spawnet at runtime

#

the pointer to them can be resolved only if the
1 - have the exact same relative names on server and client
2 - have SetNetAddresable called on them

grizzled stirrup
#

Thank you so much for the breakdown

winged badger
#

or

#

the components themselves are replicated, on a replicated actor

grizzled stirrup
#

Or created in construction script right?

#

I saw in the check at least

winged badger
#

created in constructions cript

#

makes them part of the CDO

#

which guarantees the names match

grizzled stirrup
#

Ah I see

#

So is this proving that the autogenerated names DONT match

#

And SetNetAddressable just hides the problem?

#

Or they could match, and SetNetAddressable is allowing them to be linked on client / server?

winged badger
#

i would not trust the UE to make it work out of the box there

#

and would treat SetNetAddressable as a landmine

#

unless i explicitly set the component's names

meager spade
#

i would not trust UE to work at all trollface

grizzled stirrup
#

Got it, custom names it is

#

Thanks for the help

#

I'll try custom names and NOT calling SetNetAddressable

#

and see if the warnings go away

winged badger
#

they won't

grizzled stirrup
#

Oh so I still have to call SetNetAddressable?

winged badger
#

yes

#

but it will actually work

grizzled stirrup
#

But landmine? At least now it's a guaranteed working?

#

Ok good to know

meager spade
#

ofc that marks bNetAddressable so it can be accessed over the network, but i thought HISM components can not replicate?

grizzled stirrup
#

Talking about UStaticMeshComponents in this example, maybe HISMs don't cause this warning

#

Would have to test

winged badger
#

they would

meager spade
#

nor do static mesh components replicate

grizzled stirrup
#

Ok so I'll do it on all

winged badger
#

all components spawned on replicated actor at runtime that are not themselves replicated

#

will throw that warning

grizzled stirrup
#

In this case the actor isn't replicated either (the spawner)

winged badger
#

could be just net addressable actor then

#

which your spawned definitely is

meager spade
#

@winged badger don't you mean replicated component on a non replicated actor?

#

cause that warning does not appear for non rep components on a replicated actor

winged badger
#

no, its the FNetGUID Package : Component not supported for networking

grizzled stirrup
#

Spawner spawns sub spawners which are the things spawning ustaticmeshcomponents in my case but the sub spawners would still be net addressable right?

winged badger
#

warning

grizzled stirrup
#

Or should I call SetNetAddressable on those too?

meager spade
#

yes the actor is replicated (or marked as being replicated)

#

oh right

#

but that should not happen for non rep actors, nor should it try to ever create a netguid for it ?

winged badger
#

the net addressable ones have a valid static net guid

#

the CDO components on them as well

meager spade
#

but why is the component marked as net addressable?

winged badger
#

but ones spawned in do not

meager spade
#

if its only ever used locallyt?

winged badger
#

because the warning log annoys him

grizzled stirrup
#

In this case since the net addressable spawner spawns in another actor which does the actual spawning, is that actor NOT net addressable and should call SetNetAddressable On it too?

meager spade
#

we don't get that tho

winged badger
#

we used to

#

with all audio components spawned at runtime

meager spade
#

ah damn forgot about those

#

they happened even with weapons etc

winged badger
#

setting the spawned spawners as net addressable

#

gives you extra options that you might not need

grizzled stirrup
#

I just want spawned meshes to be linked and not warning in the logs, so I should just do nothing on the spawned spawners then?

winged badger
#

like ClientSpawnMeshes(AMyMeshSpawner* InMeshSpawner, int32 inSeed, int32 InMeshCount);

grizzled stirrup
#

Yeah in this case I don't need that at all, just need the seed and basically run this locally

for (PotentialSpawner : PotentialSpawners)
{
  if (RandRange > X)
  {
      PotentialSpawner->SpawnStuff();
  }
}

winged badger
#

but if you spawna apsawner dynamically, and then spawn component on it, as long as spawner itself is not replicated

#

there should be no warning

grizzled stirrup
#

There is in my case for some reason

#

Unless SetNetAddressable is called on spawned components

#

Strange!

#

One last design question, if you have some actors that need only be spawned on the server as they are replicated or server only like a spawn point and I want to keep the client and server using the FRandomStream in exactly the same way, should I create a separate serverside FRandomStream for any server only RandRange usages which should keep the client one in sync?

winged badger
#

yes

#

every random you pull out changes what the next one will be

#

so for seed to work in sync

#

the server and client need not only pull from a stream with the same seed, but also pull exactly the same number of randoms

grizzled stirrup
#

Perfect thanks yeah have been wondering about keeping it exactly the same

#

Two streams it is!

#

Thanks for your help

#

And just final thing: the only way the net addressable thing could ever bite me in the ass is if I'm using the pointers right?

#

So since I'm not touching them, the warnings go away due to SetNetAddressable and they are named correctly, there shouldn't be any repercussions?

#

As replicating an entire level down would be unfeasable

winged badger
#

they would, but you're leaving a landmine for just avoiding a couple of lines of extra code

#

not worth it

grizzled stirrup
#

Which is just adding a unique name

#

Right?

winged badger
#

yes

grizzled stirrup
#

Perfect thanks I'll do it just to be safe

#

Thanks Zlo

meager spade
#

@grizzled stirrup also order matters, so make sure your client/server order is the same

#

i do this by sorting the array on both client and server prior to randomizing

#

tho normally this is fine

#

just extra failsafe

grizzled stirrup
#

Yep in this case the server / client runs exactly the same code and has an array in the same exact order: for any server only actors in that array I'll now just use a second server only FRandomStream for any Random calculations

twin juniper
#

So I have a question. I have a HUD setup for each player which is able to translate a damage input into a visual widget output. My question: where should I handle damage input communication to HUD? Inside player state? Or player character better (as health is not persistent to player, only player character)?

kindred widget
#

@twin juniper When you say HUD, do you mean AHUD, or a widget that you've named HUD?

twin juniper
#

AHUD

kindred widget
#

Probably just where ever you're handling the damage variable then. You can set the new damage, and then call the local hud through the local player controller to update it.

rare cloud
#

Hello, is there a way to direct connect to a SessionId ? look like the FindSessionById is just an empty space in few OnlineSubsystem

ruby rock
#

I have a MP project that runs fine, replicates as expected. I have shared this project with a friend and when they run it the project starts, but they get very choppy replication - lots of movement desync, rubber banding etc. I have network profiles both and this is what I see (see link). The image on the left shows really patchy replication - the counts are several times higher on the right (working) than the left (not working).

I am wondering what on earth could interfere with replication in this manner? Feels like it's something PC related, but after scratching my head for a few hours on this, I'm not sure what that could be.
https://pasteboard.co/JGkJpEN.png

Simple and lightning fast image sharing. Upload clipboard images with Copy & Paste and image files with Drag & Drop

ember osprey
#

what does this warning mean? Warning: Fault: gap in received Debug buffer.

sly violet
#

Hello everyone. Another Replication mind-gap question.

I am trying to use the Player Character's ABP to rotate' the player character's head when the controller adjust stick deflection or moves their mouse. I have got it working locally, but I cant get any other client on my dedicated server (or local dedicated test server) to see the head rotation.

Here are my blueprints.

#

Seems pretty straight forward, it works on client, but not replicated on server characters.

peak star
#

I thought I knew how multiplayer worked but it appears that in my new UE4.25 project, player pawns that joined the host view the listen-server-controlled pawn as having no controller

#

When I GetController on them, it returns and ObjectName of "None"

#

(from the client side, but gives the expected controller name on the server side)

#

The trouble with that is, I want to execute an RPC for that pawn, but if it has no controller then the RPC doesn't seem to want to go through.

#

(Note: This is just a basic Pawn class, not a Character)

gleaming niche
#

controllers only exist on the server, and for the local client.

#

they are not replicated.

peak star
#

OK. So I just need to get the RPC to happen from the Pawn then I guess.

#

Wait I think I know - it needs to be the pawn that lives on the client making the RPC

#

I was trying to run it from the pawn owned by the server. Okay I'll try that.

#

Yep that was the problem! Makes sense.

vital heron
#

Hey guys, quick question about client side prediction. We need the inputs of the other players to actually predict the stuff, and if we are sending this input to only the server and the server has to give the input to the players, how can we actually predict other player's movement and stuff.

#

Also I'm still researching and learning about this stuff so I need all the help.

peak star
#

If you're not using CharacterMovement and creating your own prediction instead, then what I was taught was to store an array of velocities, transforms, and timestamps (in a struct) that gets updated on each pawn so you have a Server copy and a Client copy. Between server updates (when it replicates to the clients), then each tick you'll be using that array to interpolate. I guess that's more smoothing than prediction, but you can use hermite cubic spline along the multiple transforms based on the delta of their velocities. I went through a Udemy course about it. It works okay for car-like movement.

#

Also, @vital heron there is a plugin in the marketplace called SmoothSync which is open source so you can either use it or study their source code to figure out how they do it.

#

Not sure if their method is cheat-proof though.

vital heron
#

But that is a really good tip

#

the only thing I'm confused about client side predication is the other players

#

and how they send their inputs and all that stuff

vital heron
#

I really like using pawns because I get to learn more on how things work like this

#

With a character I literally wouldn't have 90 percent of my knowledge about ue4 especially when it comes to mp

fading smelt
winged badger
#

@fading smelt they can't, not without some ugly hacks and amount of work disproportionate to the benefits

fading smelt
winged badger
#

subssytems are derived from UObject - supports replication but doesn't do it out of the box

#

they don't have an Actor for an Outer, so they don't have an ActorChannel they can just replicate over

#

they can work in pair with a replicated Actor though

#

note that most subsystems have a class instance that doesn't normally replicate as Outer

#

GameEngine, GameInstance, LocalPlayer...

winged badger
#

TL;DR; whatever you would want the replicated subsystem for, there are easier ways to do it then replicating a subsystem

fading smelt
#

ok

rich ridge
#

@fading smelt may I know the reason why you thought that you should replicate s subsystem?

#

@winged badger I think its not that tough to implement a replicatable subsystem, similar to GameInstance Subsystem just implement PlayerState Subsystem or PlayerController-Subsystem.
If you see their source code actually GEngine or GameInstance stores map to Subsystems, do the same implementation inside PlayerState or PlayerController, and they are actors and they do replicate

winged badger
#

you can replicate GameInstance if you really want to

#

doesn't mean its a good idea

#

you could add subsystems to other actors, yes

#

but replicating default subsystem is.... not ideal imo

rich ridge
#

yes agreed on this that is not ideal to replicate

winged badger
#

and also, same can be accomplished by an ActorComponent

#

that just doesn't go on GI, or LocalPlayer, or World

rich ridge
winged badger
#

the latter

#

its really not a good idea to replicate that 😄

rich ridge
#

just for my knowledge i was asking

winged badger
#

btw, no idea how would a GameInstance react to having its Outer changed to an Actor in the World

#

but i don't imagine it would be any good

twin juniper
#

How expensive is AI character movement replication vs player character movement replication?

winged badger
#

it won't send any RPCs

twin juniper
#

Not 'character movement' as in 'character movement component' I mean in general

winged badger
#

as its all server side

#

for replicating to simulated proxies

#

exactly the same

rich ridge
winged badger
#

if you make it replicate

#

you'd get another GI on client

#

with the Actor that replicated it as the Outer

#

so, really bad idea 😄

rich ridge
#

Ohh I see.

#

And it disturbs the game design because GI is supposed to be singleton.

winged badger
#

don't think the game framework would recognize the replicated one as GI

rich ridge
#

So how would somebody access that replicated GI.

winged badger
#

as i said, really bad idea

rich ridge
#

Right right

fading smelt
#

Better place to Store Inventory Class and InventoryItem manager in multiplayer game? Game state?

kindred widget
#

I put ItemData in GameState, but I make each client populate it themselves locally from a datatable to avoid networking, and store the actual inventory on characters or storage actors in the level via a component that just holds simple slot information like count and an identifier ID. Players can interact with all other inventories from the component that's on their character.

fading smelt
#

ok

novel siren
#

Got a bit of a situation I can use help with.

Context: For those you have played DS like games, this is the save point. For those not familiar, when going up to a save point you have to activate it first. Then you can save there. The activation event is setting both on client and server, and the saving is working (client only).

Problem: During the activation event, which is being called, I turn a particle effect from hidden to active (a fire). The fire never appears on the client side. Again the event is being called, otherwise the save process would not work and I have also debugged to make sure that the event is being called. (doing this in BP). Is there anything unique about setting a component from hidden to not hidden that I need to be aware of in UE4?

sinful tree
#

Are you setting the visibility on the client or on the server?

novel siren
#

Both.

#

Server does the initial set up then when its done it calls a client version to run. When I turn dedicated server off, and test it with 2 users it only visually sets on server though

sinful tree
#

So your interaction feeds to a "Run on server" event in which it sets the visibility of the component to visible, then you do a "Run on client" event and do the same?

#

Or, multicast even?

novel siren
#

Initial set up is close to what you first asked. Though I have does on Run On Server calling a multi-cast as well.

#

(The ROS is so that the bool variable I am using is set properly, that is the primary reason for it to exist)

sinful tree
#

Do you have the component set to replicate?

novel siren
#

Tried both on and off with that, no difference

sinful tree
#

So here's what I have on my end, just using the mesh of an actor... I don't have the component set to replicate, but the visibility is updated on all clients.

#

Just using a get all actors of class to get an easy reference to the actor I'm unhiding.

novel siren
#

I gathered. Give me a moment to screen shot what is being called on my end

#

this is the function that is called (and it is going down the correct path):

#

Ignore the mess and the fact there are duplicated functions, I have been trying to resolve this for a bit. I have checked all three versions of the function (above) and they are all being called. (like I said I threw MC in as a test)

#

and the ROC and ROS for the activation events are correctly set in the parent

thin stratus
#

You don't want to change states with RPCs

#

Just as a note here

#

Also, what changes that boolean you use ?

novel siren
#

Where (and I guess how) then do I change states for the new hidden?

thin stratus
#

The RPC might come in before the boolean is replicated

#

Terrible setup

novel siren
#

The boolean works fine

#

I already stated that

thin stratus
#

You use OnRep variables for this

#

Not RPCs

novel siren
#

All tests go down the correct path.

#

Ah I will try OnRep then

thin stratus
#

The only RPC that's valid to use would be a ServerRPC to set the boolean in case on your on the owning client

#

But that's about it

#

Also is that code in the Bonfire?

novel siren
#

Yes, the parent class is just for the generic parts of all interactable actors (doors, levers, bonfire)

thin stratus
#
  1. Why is there a ServerRPC in the Authority code path?
#
  1. You can't call Server or Client RPCs in Actors that aren't owned by a specific Client.
#

If this is interaction based code, you need to RPC in your Character or Controller or similar already

#

The Multicast would be replaced by the OnRep boolean or enum

#

The Multicast RPC can stay for some one-time event that only needs to be seen by whoever is there at that time.

#

But everything that is state based, e.g. on/off, should be an OnRep variable of sorts

novel siren
#
  1. most likely cause I was trying multiple approaches to see if something was off.
  2. fair enough, plan was to make the actor owned by client 1.
    Trying to the OnRep approach and seeing how it goes.
thin stratus
#
  1. fair enough, plan was to make the actor owned by client 1.
    That still requires you to RPC before even touching the Actor, as you can't set the owner from clientside
#

So you win nothing by doing that unless the Client remains the owner for the rest of whatever determines it

novel siren
#

RepNotify had the same effect

#

everything works but the fire still does not appear

thin stratus
#

Even then, RPC setup was wrong

novel siren
#

Well it's working for everything before and after that point

thin stratus
#

So you marked the Active boolean as repnotify?

novel siren
#

Yes

#

and it's getting called

#

and it's going down the correct path, and continues onto the correct things afterwards

thin stratus
#

So you put a print string out and it calls on the Client?

#

Is "Fire" a particle?

novel siren
#

yes

thin stratus
#

I would try to not hide it, but to just activate and deactivate

#

Not only to check if that fixes it, but also be cause deactivate lets the particles die out

#

While hiding is quite ugly and instant

novel siren
#

switched with active instead of hidden, no joy still

thin stratus
#

Hm, strange

#

Just for sanity, check on tick if the boolean is true and force it to be visible/active

ember osprey
#

anyone know what this error/warning means?
LogNetworkSim: Warning: Fault: gap in received Debug buffer. PrevHead: 47. Received: 55-59. Reseting previous buffer contents

novel siren
#

already did, fire works then

#

just re-tried, the fire particle effect is still showing up if the bool is set to true at the start

#

repnotify run on a non dedicated server, still only see the activation (particle effect showing up) on server.

#

just added another print string to confirm that it is active. server is seeing as such.

sinful tree
#

Is your actor set to replicate?

novel siren
#

.... damn it....

#

I thought it was, I hit the check box above it by mistake...

#

son of....

#

Thanks

thin stratus
#

If that's true, how come the code for the fire calls on the client?

novel siren
#

no idea but now both sides of it are working (the particle) and practical (saving)

winged olive
#

wait how do i implement multiplayer into my game?

steel vault
#

Very carefully

winged olive
#

??

steel vault
#

That was just a very open ended question, so I gave you an open ended answer. My suggestion to you would be to first go online and go through some free youtube content/tutorials to get yourself started with the understanding. Even before that, go through cedric's compendium http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf and then if you are still having issues, consider very highly rated courses for the subject matter on udemy. Work through tutorials and when you have specific issues or problems then come back here and ask them. Everyone here is very knowledgeable, but you have to put in the leg work.

winged olive
#

ok thanks

winged olive
steel vault
winged olive
#

using AI

#

the problem is for the player controller

#

like locally

steel vault
#

I have no experience with the flying template player controller but it sounds to me like you have your input bindings mixed up. Is there an issue if you swap them so they behave correctly?

vital heron
#

Is there a way to check the milliseconds that the game updates or better, can I change them for testing?

peak sentinel
#

You mean latency or deltatime between client and server?

sinful tree
#

You can put this in player controller to get a ping display on screen.

vital heron
dark edge
limber mortar
#

Hi all, happy christmas eve!

#

I have had my level resetting each time damage is applied to the town, this has been working but stopped in the last day or two, and I can't figure out why. I didn't change the way the level resets, and I've confirmed with print string that it is making it to the server travel command. Anyone notice anything?

summer tide
#

I have placed EventOnSessionInviteAccept in my main menu Player Controller, after accepting steam invite that event doesn't get triggered. Any idea why not?

twin juniper
#

So I have a floating health bar above player character/ AI character heads that is visible to all players except the owner. The health bars are controlled by a variable on their corresponding characters. How would I go about replicating the health bar so that other clients can see when a player loses health? Currently only the owning player can see the bar change (when I disconnect a node to allow the owner of the health bar to see it). The health bar is a widget component in screen space.

thin stratus
#

By replicating the health variable

twin juniper
#

This is the setup I have, before I tried setting my 'percentage' value after the 'multi HP' node at the bottom

meager spade
#

why are you telling the widget directly the health changed, i would have a delegate the widget binds to for when the health changes

#

anyway you also have a replicated property inside the widget, which is not allowed, widgets are LOCAL only

#

and you need the server to modify the Health property never the client

#

so your logic there is also wrong

twin juniper
#

Hm I got it to work with this setup which I have used before

meager spade
#

also wrong

#

never multicast health change

#

its pointless

#

why is the client telling how much health the server should take away?

#

why are you using Set with notify on client?

#

clients can NEVER replicate properties

#

replication is one way, Server -> Client

peak sentinel
#

Are these all functions in CMC reliable? I dont see any UPROPERTY

meager spade
#

why would they have UPROPERTY() ?

peak sentinel
#

To set them as RPC

meager spade
#

still why would they be UPROPERTY?

#

you mean UFUNCTION

peak sentinel
#

yeah sorry lol

meager spade
#

also check ACharacter

peak sentinel
#

confused

meager spade
#

that is what calls them

#

so yes they are unreliable cause they are called pretty much every tick, and all RPC's called a lot should be unreliable unless it will impact gameplay

peak sentinel
#

Yep, I see now, all of them unreliable

#

The tutorial I am following (krazy karts) made it reliable on Tick

meager spade
#

yup that is wrong

#

never reliable RPC on tick

#

you will overflow the RPC buffer

#

(reliable buffer)

peak sentinel
#

👌 Noted, thanks

twin juniper
#

I used to use repnotify in single player a lot to fire logic whenever a variable changed. Is that wrong?

meager spade
#

why would you use rep notify in single player?

#

oh cause of the BP hack

twin juniper
#

Like I said, easy way to attach logic

meager spade
#

that rep notify fires using property changed event

#

well your logic above is wrong

#
  1. no replicated properties inside widgets, 2) Widgets are local only, 3) Replicated properties MUST be set on the server. 4) Never trust the client for things like health changes.
#

so your input (debug input) calls a server function called say Damage, this set the damage based on the hit points

#

the Health property being RepNotify, can set the widgets health

#

simple as that

lost inlet
#

at least it makes it easier if you do a coop mode later lol

#

it's pretty much a hack though rather than just having a setter function

twin juniper
#

I have 2 health display types. One is a widget connected to the HUD which is only for local client to see. The other is a floating widget for all other clients to see.

peak sentinel
#

iirc if health was a replicated variable i was just putting the health variable from GetOwner->CastTo CharacterBP->GetHealth to a binding in widget

#

And it was working for every connected client and server

#

is WasRecentlyRendered() local or if a client renders an actors it returns true for everyone?

heady python
#

How do I make smooth replicated movement in UE4? My client starts to stutter or my server sees clients stuttering every time i try to properly make movement. No answers I've gotten before have worked
NOTE: I'm testing this on steam and not in editor so ping is a factor

lost inlet
#

don't use widget bindings

#

that's one way to kill UI perf

summer tide
#

Why repnotify is not enough to replicate setting SK Meshes?

graceful pumice
lucid vault
#

Why doesn't multicast have the ability to exclude the owning client

#

For efficiency

native pagoda
#

Hey! Have you ever had a problem with RepNotify functions in C++? Mine is not getting called when i change a value

peak sentinel
#

iirc in c++ repnotify doesnt call to server

#

i remember people here talking about calling server rpc in repnotify to make it working also in server

native pagoda
#

Mine is not getting called at all. I change value on server (RPC), but its still not getting called

kindred widget
#

@native pagoda It's not getting called on the Client when the server changes a value?

steel fox
#

Is it true that blueprints are very limited compared to c++ for making multiplayer games?

kindred widget
#

For anything beyond basics, yes. You can get away with a lot, but it won't be nearly as good, and C++ has a lot of great tools like FastArrays, conditional replication, RepGraphs, etc.

#

Like. Coop to 6 player simple game. Blueprint will likely work just fine in a lot of cases depending on your scope.

rare cloud
#

there are some conditional replication in BP

#

I would like to know if I must use JoinSession to join a session or I can join using the IP directly if I already know it

kindred widget
#

@rare cloud I meant more whether it should currently replicate or not, more than how it should replicate. As far as I know, you can't set a property to not replicate for a small amount of time in blueprint, even if the server is changing it.

native pagoda
#

@kindred widget yes, its not getting called at all, both server and client

kindred widget
#

@native pagoda Well, as Idont mentioned, the server won't call it, you have to do that manually. But as for why the client isn't calling it.. that's odd. Can you put a quick print on like tick or something and change it? See if it changes on your client.

native pagoda
#

I used AddOnScreenDebugMessage in function that changes the value (gets printed) and in RepNotify (it doesn't )

#

@kindred widget

kindred widget
#

The function that changes it is on the server. You need to make sure that the value changes on the client.

native pagoda
#

So its not getting automatically changes on a client when I change it on the server?

kindred widget
#

I dunno, that's why I was suggesting the print string, to see if the value was actually getting changed, and the repnotify wasn't working. If the value changes, then replication is working and something with your notify isn't. If it doesn't change, your replication is broken and your notify wouldn't fire anyway.

twin juniper
#

So I have a health bar that I am replicating, problem is when a player gets too far away from the health bar it is destroyed (would like to stop this ideally), when it is redrawn the data does not persist for the health bar.

twin juniper
gloomy tiger
#

Hey y'all! Merry Christmas! 🎅

Question - I have an actor that was spawned on the Client only (intentionally), and I want to communicate something to the server through an RPC.

#

For obvious reasons, I can't do that through this same Actor. So I'm bridging the communication through an Actor that lives both in the Server and in the Client. But even so, my Run on Server RPC isn't called.

#

Ideas?

#

Just to better illustrate my scenario:

  • I have an Actor called Circle. This Actor was spawned in the client only.
  • I have this second actor called Square, which is a replicated Actor spawned from the server, and the client owns it. Both are aware of it.
  • Circle does its stuff, and in the end, it informs Square X occurred, and Square (the client version) attempts to communicate its server version about it. ---> this is the exact moment where things are failing.
#

Pretty much, the information doesn't arrive in the server. I'm suspicious this is occurring because the server doesn't know Circle, thus the communication between Circle and Square isn't possible (from the server perspective) b/c the origin of the communication is unknown to the server.

#

Sorry for the overwhelming information. But it is what it is. Let me know if I can help you better understand my problem.

#

And before you ask, I don't want to create Circle on the server b/c I don't care about cheating. In this specific scenario, latency is more important.

kindred widget
#

@gloomy tiger The Actor that you use for communication needs to be client owned. Like the client's player controller, or Pawn. In your case, Square might be replicated, but it's server owned, so the client can't use it for ServerRPCs.

gloomy tiger
#

One information I was omitting that I thought it might be irrelevant but... Square is a Component, owned by PlayerCharacter, owned by the Client.

#

That said, I believe Square is in fact owned by the client. (because its owner is, so...)

#

And Square has Component Replicates checked.

#

cc @kindred widget

kindred widget
#

Are you working in C++ or Blueprint?

gloomy tiger
#

Blueprint

kindred widget
#

Are you getting a hold of the component via GetPlayerCharacter(0), then GetSquareCompoenntThing, then calling the RPC via that pointer?

gloomy tiger
#

This is what's going on. Circle calls this function, TryToRevive from Square.

kindred widget
#

But this is on the client though, so wouldn't you want to use a Server RPC, not a Client one?

gloomy tiger
#

TryToRevive is happening on the Client, but it calls Answer Revive, which runs on Server.

#

That Hello Print String isn't being called when a Client attempts to execute these nodes.

gloomy tiger
kindred widget
#

I can't see why this wouldn't work, unless that component is invalid. Coming from GetActorRevivableComponent.

gloomy tiger
kindred widget
#

Here, try this really quick.

gloomy tiger
#

And it seems it's being created both on the server, and on the client.

kindred widget
#

Do, GetPlayerCharacter->CastToMyCharacterClassWithComponent->GetComponent->TryToRevive

gloomy tiger
#

Oh, good idea.

#

Let me try.

kindred widget
#

See if that works. That'd directly get the component. If that works, something is wrong with your function that's getting the component.

#

But yeah, as long as that component is on the client owned actor, called from that client, and the component is set to replicate, those functions should run fine.

gloomy tiger
#

I know, right? That's what's intriguing me.

gloomy tiger
#

OH, WAIT!

#

It didn't work, BUT

#

It made me realise our misfortune. Pretty much, my Client is calling TryToRevive from a Square component it doesn't own. 🤦‍♂️

#

I mean, the TryToRevive is residing inside the Square component of another PlayerCharacter. Thus, although my client is aware of it, it doesn't matter b/c it doesn't own it.

#

That puts me in a tight spot. Side question - can I call a server RPC from an Actor the server doesn't know it exists? lol.

#

An agnostic RPC of sorts.

kindred widget
#

Not really. Any RPC has to go through a replicated actor or component.

gloomy tiger
#

Fair enough. Well, many thanks for your help! It definitely not only clarified my problem, but also addressed it, ha!

#

Merry Christmas, @kindred widget! 🎅

twin juniper
#

hi

#

i click on button then i create widget, on create widget do i need to destroy the other widget or just make visibility hidden ?

#

i dont want extra cpu usage guess of an hidden widget?

kindred widget
#

@twin juniper Invisible will just hide it from view, Collapsed will stop it's tick and keep it from being used in the slate draw calls.

low sand
#

Is there any way to replicate a variable map container (dictionnary) in blueprint? By default, it isn't replicable, so I tried to make it update via a replicated server event, but the value returns as null.

kindred widget
#

@low sand I don't think that TMaps are networkable at all. Generally either use structs, or find a way to break them down, send them and reconstruct them on the other side.

twin juniper
#

5 seconds answer :

i finely login into my server.
what box i need to click to move in a deticated server ?

twin juniper
#

i dont know how to move replicated please help

rapid bronze
#

It's all very generic

twin juniper
#

how can i do a replicated jump ? :p

rapid bronze
#

I think it's already replicated?

meager spade
#

it is

twin juniper
#

thanks 😄

#

i heard it something to do about game mode

twin juniper
#

in the game mode i disabled all the UI and started the new one at the normal map, solved

low sand
#

I'm trying to pass a reference to an actor component via RPC, but it arrives null. Is it possible to do?

winged badger
#

as long as its net addressable, yes

#

i'll take it you spawned your component at runtime

low sand
#

How can I ensure that? It's a component that I use to manage the inventory, so I want it to be always accessible but I don't know where to start with that. (BP)

winged badger
#

any replicated component on a replicated actor is net addressable

low sand
#

It's part of the character's BP, and it spawns through the game player start

winged badger
#

and component on the CDO of a replicated actor is net addressable

low sand
#

Both the actor and the component are replicated

winged badger
#

any component on the CDO of an actor loaded from package is net addressable

#

any component on net addressable actor spawned at runtime, with exact same name on client and server (relative to actor) and that had SetNetAddressable called on it is net addressable

winged badger
low sand
#

Hmm.

winged badger
#

is it a component on the CDO?

low sand
#

What is the CDO?

winged badger
#

class default object

rare cloud
#

also make sure the component ref you put is valid

winged badger
#

if you can see it on component list in BP, the answer is yes

low sand
#

Yes it is

#

Jack: It works when I don't put the RPC on replicate on server.

winged badger
#

but when you do does it even execute?

low sand
#

Yep

#

That's how I found it returned null

winged badger
#

you'd better put some screenshots here

rare cloud
#

@winged badger since you are here, I would like to know if it's a bad pratice to connect to a session (using steam for example) with IP instead of the classic flow

low sand
#

I've noticed that I call a similar RPC function from the Pawn and it works, but it doesn't from the PlayerController.

winged badger
#

using steam yes

rare cloud
#

normal Crita

#

PlayerController exists for owning client and server

winged badger
#

its NAT punchthrough works via steam sockets

low sand
#

Jack: I'm not sending a ref of the PlayerController, the client's PlayerController is sending a ref of a component that exists on a player pawn.

winged badger
#

a picture is worth a thousand words

low sand
#

What do you want a picture of?

rare cloud
#

@winged badger thanks !

low sand
#

Nope. Basically, it's an inventory system. When the player drags an item and changes its position, the player controller sends the new container to the server so it can update.

#

So, it's not called before the ref can be created, it's called whenever you move an item.

rare cloud
#

imo Crita just move your RPC to character or playerstate

winged badger
#

actually

#

don't send the RPCs for that at all

#

just make a local translation map

#

server doesn't need to know which slot your items are in

low sand
#

Why?

winged badger
#

why would it?

#

its just a local UI thats affected

low sand
#

Not really.

#

Positions affect the gameplay with this type of inv

winged badger
#

equipping is different

#

but as for that box in there, is it at 0,0 or 7,4

#

makes no difference whatsoever

#

as long as client can still communicate gameplay interactions with the item properly

low sand
#

Multiple players can access the same inventories, so I feel like they should be synchronized

#

No?

winged badger
#

in that case, yes

#

so

#

whats the inventory component on?

low sand
#

The player pawn

winged badger
#

show me the RPC

low sand
winged badger
#

no way to tell if those slots are vaild at the time of sending here

low sand
#

They are

#

I've tested both in debug and print during run time

#

if I remove the RPC and run it locally, the function works as expected

#

if I run as RPC server, it triggers an error message saying the ref is null

winged badger
#

anything else in the log, warnings?

low sand
#

Not really no

winged badger
#

so there are 2 inventory components here

rare cloud
#

if the rpc is on playercontroller it will never succeed for a remote client

low sand
#

It's not for a remote client

winged badger
#

one is on playerpawn, the other?

low sand
#

PlayerController moves item on local GUI -> Sends intent to server -> Server applies inventory update -> Server rep notify new inventory

#

zlo: In this case, both are on the same player, just moving an item from one slot to the other. It's the same function wether you shuffle your items around or if you change from one container to the other

winged badger
#

which one comes as null on the other side?

low sand
#

"ToContainer"

winged badger
#

so one of them works, the other doesn't?

#

verify the target server side after the RPC

low sand
#

Yeah, seems like it. I'll double check

#

Oh no wait, yeah I get why it would do that. The function is located on the inventory container component, so it assumes that the "FromContainer" is the container executing the function

winged badger
#

if its executing in correct instance

#

target came through the RPC just fine

low sand
#

Yeah, target works fine, it's the ToContainer I'm confused about

winged badger
#

so whats different between the 2?

#

(way they are instantiated, or different replication settings)

low sand
#

Take item from ContainerA in X,Y and put it in ContainerB in X,Y
ContainerA is Target, ContainerB is ToContainer

#

(not sure what you mean, but same component and same replication settings)

#

but I think I know where it might come from

winged badger
#

LogNet will also log any NetGUIDs its unable to resolve

#

although, i don't remember on which verbosity level

low sand
#

Difference between on the client and server

#

one print is before the RPC, one is after

lucid vault
#

How do I compress an FRotator?

lavish cypress
#

I understand AActor has Role and RemoteRole for checking network execution context, but what about helper functions that wrap these checks for different use cases? So far I've found HasAuthority on AActor and IsLocallyControlled on Pawn. Are there others?

AActor
    HasAuthority (dedicated server or listen server)
    !HasAuthority (client)
    
Pawn
    IsLocallyControlled (listen server or client)
    !LocallyControlled (dedicated)
lucid vault
#

I think casting each value to a float should compress the rotator, if I'm not mistaken

winged badger
#

it won't

#

if you don't need a roll

#

you can just turn it into FVector_NetQuantizeNormal

lucid vault
#

It's the rotation of my actor, the roll is necessary

#

Then should I cast to int and remove the decmial?

winged badger
#

@lavish cypress that is not always correct

#

why would you compress it to start with? finished the game, profiled the network, its using too much bandwidth so now you're optimizing?

lucid vault
#

Basically

#

FVector_NetQuantize is half the bandwidth of a normal FVector, right?

#

I'm looking for the rotator equivalent

winged badger
#

@lavish cypress HasAuthority doesn't mean its server, it just means its a server spawned or loaded actor

#

client has Authority over all Actors it spawned locally

#

there is GetNetMode() as well

#

no, FVector_NetQuantizeNormal is half the size

#

but it can only do magnitudes of 0-1 per component

#

which is why its a popular choice to compress a rotator, with a caveat that you can't restore roll information from a vector

lucid vault
#

Wouldn't casting each value in an fvector to an integer work pretty well, assuming I don't need perfect accuracy?

winged badger
#

how would that work? int32 takes same amount of memory as float

lucid vault
#

Hmm, perhaps using an FFloat16 would each value would work

#

Half the bandwidth there I would assume

winged badger
#

still no point unless the game is at the beta stage

lucid vault
#

I'm moving into beta this month or the next

#

It's fully playable. Pretty much just time for optimizations and bug fixes

winged badger
#

well, read the NetSerialization.h bottom third of the header for inspiration

#
template<int32 MaxValue, int32 NumBits>
bool WriteFixedCompressedFloat(const float Value, FArchive& Ar)

template<int32 MaxValue, int32 NumBits>
bool ReadFixedCompressedFloat(float &Value, FArchive& Ar)```
#

noteably those 2 functions

low sand
#

(Thanks for the help guys! I managed to fix my issue!)

winged badger
#

the networking docs are not that bad, as far as replication flow and net addressing goes

#

you should re-read them occasionally until they fully sink in @low sand

low sand
#

I've been reading the wiki and the netcode compendium, but my issue was not really something that I've seen covered in those so far. I'm not even sure how to put it into words with my beginner level :p

winged badger
#

its not really fully digestible at the beginner level

#

thats why re-reading the more complicated sections every couple of weeks is a good idea

clever plinth
#

I've been using HasAuthority() based on Tom Looman's tutorial

winged badger
#

GetNetMode()

#
enum ENetMode
{
    /** Standalone: a game without networking, with one or more local players. Still considered a server because it has all server functionality. */
    NM_Standalone,

    /** Dedicated server: server with no local players. */
    NM_DedicatedServer,

    /** Listen server: a server that also has a local player who is hosting the game, available to other players on the network. */
    NM_ListenServer,

    /**
     * Network client: client connected to a remote server.
     * Note that every mode less than this value is a kind of server, so checking NetMode < NM_Client is always some variety of server.
     */
    NM_Client,

    NM_MAX,
};
clever plinth
#

:0

#

My ue4 career is a lie

#

Thanks man, that's probably why I've faced so many mp issues in the past

winged badger
#

you can pull it from Actor or World

lavish cypress
#

Do you use role or netmode more often? Or do you create helper functions to aggregate them

#

Sometimes I wonder if the presence of role or netmode checking throughout code is a code smell and I would be better off designing code to function properly through context hints rather than depending on global states

#

But it doesn't seem always possible to avoid checks

#

I want a better solution to writing some code and then getting undefined behavior on netmodes I didn't think about when I wrote it

winged badger
#

i often use Role because the IDE colors the ROLE_Authority and such differently

#

so makes it easier to skim the code

#

(i use role when either role or netmode would do)

lucid vault
#

Can I use FFloat16 as a function parameter?

#

I get an unrecognized type error

#

Even with the include

meager spade
#

no

drowsy bobcat
#

On a listens server how do you stop clients from spawning and just falling through the level? it seems the levels are only streamed on the client and not server so there no ground collision.

native pagoda
#

@kindred widget Just wanted to thank you for help. I don't know what exactly was the problem (engine/ bad include/ lack of GetLifeTimeReplicatedProps function or whatever - compiler didnt throw any error), but tried everything and finally got it working. Thank you man ^^

unkempt tiger
#

Is there any way to dynamically reduce the replication frequency of a single replicated UPROPERTY (without changing the NetFrequency of the entire actor)?

#

I guess I can 'exploit' the push model to just mark it dirty every X frames && per change rather than just per change but that seems indirect

rose egret
#

no

#

btw why u want to do that? how much your property is taking ?

unkempt tiger
#

I haven't net profiled it yet but it could be well over 25-30 floats worth of bandwidth for every player

#

when I reach my final classes

#

(at least, on the initial bunch)

#

and the thing is it's not all extremely needed - because my actors are already net synchronized through an input stream, the uproperty is only important for corrections, which are needed only like once every 10 seconds

twin juniper
#

so when I'm simulating multiplayer on my home screen, I am guessing my fps is affected by having n windows open at the same time (with n the number of players). Is there a way of simulating being a single player in a game of n players?

potent cradle
# winged badger GetNetMode()

Pardon, Zlo, this function/enum is really interesting. It's not available in Blueprint sadly, so I'm trying to wrap the function in a CPP function library.

Any idea how to get around the fact that the enum is not defined in EngineBaseTypes as a UENUM()?

meager spade
#

TEnumAsByte

#

is the only way

#

its the old style Enum

potent cradle
#

But perhaps I'm missing something