#multiplayer

1 messages · Page 469 of 1

winged badger
#

@hasty orbit it seems to have french spalling there, is that your custom class?

#

as for child actors, i am not sure how they fit into all this

#

you can reference the ChildActorComponent that holds them

hasty orbit
#

i don't no @winged badger

winged badger
#

well, that class either doesn't inherit from UObject and it should, or its missing an include in the header that lets the compiler know that it does

#

i never attempted to source build 4.21 so can't be more help then that

#

@opaque flicker both your server and client do know how to get to the door locally

hasty orbit
#

so I have to add Uobject

winged badger
#

so if that logic were to be in a WallActor, instead of the DoorActor

#

it will work just fine

#

@hasty orbit if you are not a programmer, then good luck 😄

hasty orbit
#

I use unreal engine for a 1/2 years

#

it's the first time I'm doing a dedicated server

#

but visual studio almost never use

opaque flicker
#

@winged badger thank you man for the reply, but the weird thing this problem doesnt happen while running the game in editor (With dedicated server up), but this only happens in the game dedicated server build

winged badger
#

that kind of thing happens often enough that it is no longer weird 😦

hasty orbit
#

yes

winged badger
#

it compiled @hasty orbit ?

hasty orbit
#

yes

winged badger
#

😃

hasty orbit
#

it displays ready

#

nn not the build

#

😩

#

bottom right of the screen it reads ready

#

what is the difference between building and rebuilding

#

@winged badger

winged badger
#

building only compiles the difference

#

rebuild builds everything

hasty orbit
#

I want to try to rebuild but I'm afraid to make mistakes

ember needle
#

Something I don't get. I want to MUTE a player (W4lly63), instead what happens is:

  • They get muted.
  • They get unmuted.
  • I can hear them in game.

This is the code I'm using:

#

Printed on screen I see MUTED: _SCAR -now muted: true.

I'm seeing this in the logs:

[2019.06.09-11.44.02:968][893]LogOnlineVoice: OSS: Muting remote talker (W4lly63 [0x2A57C100])
[2019.06.09-11.44.02:968][893]LogBlueprintUserMessages: [None] MUTED: W4lly63 -now muted: true
[2019.06.09-11.44.03:037][904]LogOnlineVoice: OSS: Unmuting remote talker (W4lly63 [0x2A578AA0])

What am I doing wrong?

Can someone point me in the right direction, I've been at it for months now...

keen thorn
#

Hi, anyone got some guidelines on how to bitpack my data so when sending data across network with RPC or replicated? I know C++ have bitfield but not sure if it is directly supported in ue4 or do I have to declare usigned ints and write to it using bit operators. All help is appreciated 😄

winged badger
#

if you're doing it so that the payload is a struct, just implement a custom NetSerialize

#

recommend taking a look at EngineTypes / FHitResult::NetSerialize for an example

#

if you want to send a uint8 or some such instead, then its just a matter of using some bitwise calculations

#

it doesn't have anything to do with UE supporting it or not, as you send a unit8 packing up to 8 flags and its your own logic that packs and unpacks them

keen thorn
#

thanks for your tip, do you recommend manually packing or using the NetSerialize?

winged badger
#

unless you're using it for other stuff and not just the RPC

#

i'd go for struct with custom NEtSerialize

#

i have a variable for example, uin8, that is holding flags for every way my character can get incapacitated

#

and then its already there, so its easy to just send it if i have to

keen thorn
#

this clears things up a bit, thanks alot man 😄

#

i hope doing this with delta compression and using a sane relevancy logic will save some bandwidth

small compass
#

Hello everyone,
Currently i am having issues with server events that need to be called by the client.
When the server calls it, all the clients get repnotified but the client cannot seem to call that same event. (run on server event)

#

i'm bad at explaining, if i could screenshare my situation with anyone for a minute, i would be eternally grateful!

hoary sandal
ember needle
#

this it?

hoary sandal
twin juniper
#

When I run my dedicated server, My log spam this

hoary sandal
small compass
#

when the server calls it, the traffic light turns on. when the client calls it. nothing happens

#

the int = int is to pair the switch with the traffic light

winged badger
#

because client doesn't own a switch

#

you can only use server and client RPCs inside of actors that are owned by the PlayerController

#

and their Components

small compass
#

nvm i get what you mean

winged badger
#

and the output log prints "no owning connection for..." in yellow

#

also, don't get all actors of class then iterate over all of them, use a SphereOverlap

#

and the RPCs can have inputs, so you can send a reference to the trafficlight, or its ID through the RPC instead of looking for it again, with allactorsofclass, on the server

#

but the RPC itself needs to be in PC, Pawn, PS, or something that is owned by any of those

small compass
#

thanks! ill look into it. its quite confusing but i'll probably manage

kindred jungle
#

I have a weird issue:
Multiplayer, third person, on the client the character mesh (standard character class) jitters as if its movement wasn't replicating properly.
This doesn't happen on server or for the client mesh on server or for the server mesh on client.
Movement of the actor itself is smooth. Only the mesh jitters.
Also, the jitter only happens when the fps of the client is high. If I limit it to 30 for example it works ok.
I tried adjusting replication settings of the actor and optimization settings of the mesh, but it didn't help.
Any suggestions?

winged badger
#

turn off replicated for all scene components that are part of the class defaults and have no replicated variables/RPCs in them

#

they do not need to be replicated, but can cause problems when they are

#

(as in, there is no benefit whatsoever in replicating them, they get created client side just fine, and they can be referenced over network even when not replicated)

kindred jungle
#

I will try that. I vaguely remember having to enable that for some reason 😃

winged badger
#

also, even for those that should stay replicated, turn off replicate movement unless they need to move independently of the character and its skeletalmesh/animation

kindred jungle
#

@winged badger thx. that fixed it. Honestly I don't even know what I was replicating it. Seems obvious not to do that.

bitter oriole
#

Quick question : on a remote player, what's the owner of another player's pawn ?

#

Owner is replicated, but the player controller isn't - would it be nullptr ?

meager spade
#

controller will always be null on other clients

#

server and owning client have access to the controller

bitter oriole
#

Yeah I'm aware

meager spade
#

so yeah would be nullptr on other clients

bitter oriole
#

So GetOwner() would return nullptr on a remote player

meager spade
#

if the owner is a player controller yes

bitter oriole
#

Thanks !

real yacht
#

does anyone have experience with aws lambda and ue4

#

?

lucid vault
#

How can I replicate a player's inventory component (custom component I built) only to that specific player client? If I replicate it as a normal variable, that could allow potential hackers to see other players inventories correct? To combat this I want to only replicate inventories to the owning player

copper mango
#

@lucid vault you can use conditional replication

lucid vault
#

@copper mango Thanks for the info. That would definitely work for only sending the data to the player. However, after doing some more thinking, I realized that there are times in which the player inventory should replicate to others; such as when the player is killed and someone attempts to loot them. The system that I am thinking of is essentially have "authorized" players for each inventory system. These authorized players are the players that the inventory will replicate to. For instance, a chest with an inventory system component will not replicate it's inventory to any actor that i s not authorized to view it's contents. In order to authorize yourself to view it's contents, you must 'interact' with it first.

#

This is the system that I am laying out for creation

#

Now here is my question: how can I replicate only to owners of specific player controllers that I specify (and can change at run time of course).

#

I didn't see an option for that in the link that you sent

copper mango
#

You can use a custom condition

#

I think?

#

If it’s an Actor there’s also an IsNetRelevantFor function you can override

#

Which gets a player controller who you’re checking against

lucid vault
#

I'l take a look at those options

#

Somebody said quote "By default, the COND_CUSTOM is not per connection. It just allow you to send or not the replicated data based on custom algorythim but not to choose the connection on which the data will be replicated."

#

So it seems that won't work for specifying clients

copper mango
#

Well

lucid vault
#

I'l look at IsNetRelevantFor

copper mango
#

It’s just the condition can’t change per client

#

So for example if your condition is “owner is in this tarray”

#

That’s fine

lucid vault
#

Oh

#

That's confusing. When he says "not choose the connection on which the data will be sent" I assumed that meant that it will be replicated to everybody

copper mango
#

No, it’ll only replicate to whoever passes your custom condition

#

They just mean you can’t do different conditions based on whether the remote is autonomous or not

#

It has to be a simple Boolean expression basically

#

I think

#

If you want to do something more complicated then IsNetRelevantFor would be the way to go

lucid vault
#

I will probably just test if the player is in a tarray of authorized players

copper mango
#

As far as I know, that should be possible

#

In a custom condition

granite peak
#

Hi all, I'm trying to get player meshes to appear for other players in my FPS, so I put in the third person mannequin mesh into my character bp and checked the Owner No See bool. That works fine, players can see each other walk around and whatnot, but how would shooting work?

My assumption is players still shoot out of the FPS gun but wouldn't the FPS gun and the gun on the third person model be in different locations?

lucid vault
#

@copper mango I'm having trouble finding an example of COND_Custom. It's says SetCustomIsActiveOverride is used for the on/off (replicate/not replicate I assume), but where does this function come from?

#

Maybe I feed in a custom function as a parameter in the DOREPLIFETIME

meager spade
#

@granite peak check out Shooter Game

#

it does exactly what you would need

#

FPS shooter networked

granite peak
#

is that in the market place?

meager spade
#

yes

#

its free

#

its a epic official example project

#

it is C++ tho :/

granite peak
#

aye thanks for pointing me to it tho i appreciate it

#

i understand C++, but i'm farrrr more used to blueprints lmao

#

at least ue4 c++ is scary to me

meager spade
#

but in a nutshell, the player fires from the FPS gun

#

the thirdperson gun is attached to the thirdperson mesh, and just plays visuals to other clients

#

so its like a dummy weapon

granite peak
#

noice that's what i assumed ty man

copper mango
#

@lucid vault I believe the way you do it is once you've marked the condition custom, then in your Actor PreReplication function you use DOREPLIFETIME_ACTIVE_OVERRIDE( ActorType, VariableName, Condition)

#

oh wait, I read it some more and maybe you can't use it for what you want

#

so you might need to use IsNetRelevantFor then

twin juniper
#

Hello everyone I am having trouble telling the server to do something from a player controller. Any help is appreciated I can give more details as needed.

winged badger
#

@twin juniper you didn't give any of those... details i mean

twin juniper
#

Basically what I have is a few functions that control the terrain generation in a procedural world inside my player controller. One updates which "chunk" the player is in the other two add the chunnk the player is in and removes it when the player is not in it to save performance. The problem is in multiplayer the clients do not tell the server to add the chunk despite me using the execute on server for replication. Not sure what to do as I have been trying to fix this for a while. @winged badger

winged badger
#

you're pushing a reference to the chunk thru the RPC?

twin juniper
#

I can send screenshots through dm if it would help

winged badger
#

can just do it here, its not busy

twin juniper
#

k

#

One second

winged badger
#

you do know that Tick runs on Server and Client?

twin juniper
#

I forgot to remove the server one

#

That wasn't there before

#

That was from testing earlier

winged badger
#

also nothing that is RPCed on Tick should ever be reliable

twin juniper
#

It was only for testing for the moment

#

Gonna be moved to a seperate function

winged badger
#

i suspect you are trying to jury rig streaming levels by hand there

twin juniper
#

This is a screenshot of in game Server left client right. The client should tell the server to add a chunk where he is but doesn't

winged badger
#

both server and client know where the client is

#

so there is no need to send any network requests

twin juniper
#

I know but the server isn't adding the chunk which is the problem

winged badger
#

yet the client doesn't seem to be falling

twin juniper
#

Hes on a platform that isn't part of the world

winged badger
#

how do you add/remove chunks?

twin juniper
#

Spawning an actor that I have created

winged badger
#

is that Actor replicated?

twin juniper
#

Yes

winged badger
#

and Destroy for removing it?

twin juniper
#

Yes

#

even if I remove the remove chunk function it still does not add the chunk in the first place to the server

winged badger
#

well, your logic should be simplified by

#

client doesn't need to tell the server where it is

#

server knows that at all times

#

so server can spawn chunks on its own just fine

twin juniper
#

How would I get all of the different client positions and use them to spawn the chunks>

#

chunks?*

winged badger
#

you should test with something simpler, as i have no idea what replicates and what doesn't inside that voxel chunk

twin juniper
#

Ok thanks

winged badger
#

that should pinpoint if the problem is the spawning logic

#

or the voxel actor

twin minnow
#

are rpc's synchronous?

winged badger
#

they have network latency involved

#

but they do get sent right away when called

twin minnow
#

for example if i have

void test(){
    serverRPC();
    // rest of the code
}
#

will the test method wait for the rpc method to finish?

#

before going on to the "rest of the code"

winged badger
#

no, and it will never get the information that it did finish

twin minnow
#

alright, thank you

winged badger
#

for that you'd need to send a server RPC, which does its thing, and sends a client RPC acknowledgement

#

then implement a callback to that

twin minnow
#

that's what im currently trying to do, but i want to pass an a pointer to an actor to the server rpc

#

but for some reason the pointer ends up being null by the time it reaches the server rpc

winged badger
#

its a normal pointer, its not a TScriptInterface or some other wrapper that can silently fail?

twin minnow
#

yes

winged badger
#

is the actor pre-placed on map, or replicated and spawned by the server?

twin minnow
#

spawned on the client side, and then i pass it to a server rpc

winged badger
#

then it doesn't exist on the server

twin minnow
#

yea that makes sense

winged badger
#

and NetGUID will never be assigned to it

twin minnow
#

im trying to spawn something client side to make up for the latency

#

so that when it does spawn server side, i can destroy the actor spawned on the one client

winged badger
#

server doesn't need a pointer to that Actor

#

just needs a UClass* and a Transform

twin minnow
#

i see

winged badger
#

client still needs to detect when the server-spawned Actor appeared to get rid of the simulated copy

twin minnow
#

then im not sure how to destroy the actor on the client side, since a lot of these actors can be spawned fairly quickly

#

i guess i can call a client rpc from the server rpc

#

but then it's gonna be annoying to figure out which actor to destroy in the client rpc

winged badger
#

i would never engage in a simulation of that particular kind

#

but

#

you could have a replicated int32 or some such in it, ID

#

and have the client send it thru the RPC, server sets that ID after spawning an Actor, and it will be available by the time BeginPlay is called on a replicated Actor client side

twin minnow
#

would u happen to know if fortnite does any client side prediction for their building?

winged badger
#

better solution is to have them pre-spawned by the server and pooled somewhere

twin minnow
#

hmmm that's probs better

winged badger
#

spawn actor is problematic because its expensive

#

and you're currently doing it 2x on client

twin minnow
#

alright, i appreciate the insight, thank you so much for your help!

real yacht
#

im having strange problem, apply damage doesn't work when i'm running 2 instances on dedicated server

#

any damage is not recived

#

how is this possible?

bitter oriole
#

Well, key presses happen on clients

chrome bay
#

How are you pressing 'Z' on a dedicated server?

bitter oriole
#

Damage happens on server

chrome bay
#

ninja'd

bitter oriole
#

😛

real yacht
#

im pressing z on client

#

apply damage is on server right?

bitter oriole
#

Yes

real yacht
#

this will work, but is this correct way

#

to apply damage?

bitter oriole
#

It's one way

real yacht
#

what is the other way?

bitter oriole
#

You can also use functions

#

if I'm not mistaken

#

(Never used Blueprint for multiplayer)

real yacht
#

okay, thnx

chrome bay
#

Events only unfortunately

bitter oriole
#

That's weird, thanks for the info

#

Thought BP would work the same

real yacht
#

functions are not replicated in bp, only events

bitter oriole
#

Okay, didn't know about that. In C++ you replicate functions

winged badger
#

almost nothing works exactly the same in BP @bitter oriole

#

OnReps are called locally, for one

bitter oriole
#

Yeah I knew about that one

winged badger
#

even if the client sets a variable locally, it fires

rose egret
#

I have a NetMuticast function in GS. which send the information of teams.
I call it when the last player joins . (In GameMode::PostLogin )
but all the clients receive that function except the last one . why?

graceful cave
#

if you call it on post login the client might not have the game state yet but i could be wrong

#

the best way to handle something like that is with an OnRep

#

that way anyone connected after its set will still receive the data and run the function

#

multicasts should generally only be used for things that should run right now are irrelevant if ran later

#

like the effects of a gun firing

#

or a chat message

chrome bay
#

yep. Use variable replication for states

#

You can't guarantee when an actor will be relevant or even exist on a given connection

rose egret
#

spectator paw is spawned on local client only ?

glass plaza
#

Is there an event called when a player disconnect from a server with a reason? Similar to QuitGame()

ember needle
#

Does anyone know why animations may be stuttering on listening server? You can see here the other person's animation is not fluent. BTW the other player sees me with no issues at all, and if the other player hosts - no issues for anyone.

fleet raven
#

the listen server only ticks the character pose when it receives a move from the client

ember needle
#

ah!

#

am I supposed to change that in settings or is this desired behavior?

fleet raven
#

it's desired behavior from an engine point of view, but not necessarily for players

#

I don't think there are any settings for it

ember needle
#

double-ah! apparently i recall badly i remember an option for ticking animations on the character

#

i will search for it

#

thanks

fleet raven
#

basically if you didn't do this you would only have 2 options:

  • the animation runs ahead of what the server knows about the inputs from this player, like a prediction, very complicated
  • the animation runs behind of what the server knows about the inputs, like interpolation, very bad as it will delay actions of the player on the server
ember needle
#

but why does the other player see everything ok

#

when looking at me

#

isn’t that the same issue?

#

also when he hosts everything is fine

#

i’m not talking about location btw

#

really about fluidity (so yeah, animation tick)

fleet raven
#

because he's just viewing an interpolated copy of your player

#

whether everything is correctly in sync doesn't matter on remote clients

ember needle
#

this attempts to fix it but i ahve no clue on potential consequences...

fleet raven
#

if you are not using root motion, and no gameplay features depend on the character animation (such as notifies, or maybe weapons attached to a socket) it will be fine

ember needle
#

yes i have notifies

#

that do change gameplay (bombs being thrown on animnotify)

#

and weapons attached to sockets.. wth

#

🤪

hexed wasp
#

Hello community! How realistic is it to attempt to do a client/dedicated server multiplayer project in UE4 currently with the expectation of not writing C++ code? Are the majority of the networking functions exposed to blueprints, or not yet? @golden stirrup

glass plaza
#

You have a lot of accesses in BP but I'm not sure if you have access to everything.

#

I think the less available part in BP is all the lobby name/etc.

winged badger
#

@hexed wasp not even close

#

I find networking done in BP to be extremely awkward

#

It is possible tho, but you wont have access toany low level optimizations

west rapids
#

Eerm, guys, doesn't the PlayerState get replicated to every client?

#

Like PlayerState A will be available for access to players B C and D + server yes?

#

I'm asking because I'm having trouble accessing player score on other clients. I'm getting it from inside the HUD class, but it stays as None.

chrome bay
#

Player States are replicated to all clients yeah.

#

You will have to access them from the Player Array in the Game State.

west rapids
#

oic, can't go direct from player controller id ye?

chrome bay
#

@hexed wasp To even ship a dedicated Server build you need to use a source engine build, so technically speaking it's not possible.

#

No

#

Because the player controllers don't exist on other clients

west rapids
#

omg ur right lol 😄

chrome bay
#

So GetPlayerController 1, 2, 3 etc. won't return anything

west rapids
#

ye ye

chrome bay
#

Same for GetPlayerPawn 1,2,3 and so on

west rapids
#

crap i can't believe i missed it

#

thanks man

chrome bay
#

np's

west rapids
#

one thing tho

#

why would you store score in playerstate

#

if u gotta go thru gamestate anyway

chrome bay
#

So that all players can access it

west rapids
#

could say the same bout game state

chrome bay
#

You could, but it's probably not a great design to do it that way. PlayerState is as the name suggests, information about a "players" state

west rapids
#

i see, i was thinkin the same thing

#

but always thought that was more for things like health etc

chrome bay
#

Well IMO health should belong to a pawn

west rapids
#

stuff like kdr

chrome bay
#

Player State is more for persistent player stats. Kills, Deaths, Score, Team etc.

west rapids
#

aight what about inventory then

chrome bay
#

Depends on the game

west rapids
#

persistent inventory lets say

#

gamestate or playestate

chrome bay
#

Persistent inventory I would say player state too, or player controller if other players never need to know anything about it (probably still best in the state though)

#

For an inventory that belongs to a specific character, having that in the pawn seems best to me

west rapids
#

interesting, was always split on where to put inv

#

Zlo told me of a very neat way of transfering inventory data without gameinstance

#

but thats a good place to store it post transfer

#

thanks 😃

chrome bay
#

It really depends to be honest on what kind of game it is

#

and the rules etc.

west rapids
#

well i was just asking for a general opinion

#

obviously for single player only game it don't matter much 😛

chrome bay
#

That's what I mean. My example, I have a game with Characters and Vehicles which have their own weapons - so weapons / inventory is stored on the character/vehicle. If they respawn in a new vehicle, I don't want them getting the old weapons, and if they leave a vehicle and hop into a new one, I don't want them taking the vehicles inventory with them.

#

If I was making an RPG and I wanted to keep exactly the same inventory when my pawn/avatar dies, I'd keep it in the player state.

west rapids
#

do u have loadouts that u gotta feed from each player or is it all preset depending on vehicle/char

#

cuz a loadout preset would technically count as a 3rd separate inventory

chrome bay
#

Vehicles/Character classes specify their default weapons

#

But that's just a class, new weapons are spawned with the object from that list when the vehicle/char is spawned

west rapids
#

i see

#

neat setup

chrome bay
#

ez stuff, but yeah depends on the game really so it's hard to say a one-size-fits-all solution

west rapids
#

eh i was just curious if there was an established "right way" 😃

#

at any rate, thanks for the tip, I can't believe I forgot bout the PC situation lol

chrome bay
#

np's

hexed wasp
#

@winged badger , @hollow nexus thank you for your answers, that proves my assumptions. I felt so too since the early phases of experimentation.

ember needle
#

@hexed wasp i’m not done yet but my whole mp project uses 99.9% bp.

#

i think what @chrome bay is saying is that to build a dedicated server you will need to do a little c++, however your project can be bp.

hexed wasp
#

Sure, the dedicated server build is not a problem to compile using Visual Studio. That is trivial.

#

@ember needle you mean you have developed a client/dedicated server project will full UE4 networking done in blueprints?

ember needle
#

i’ve done a full mp game in bp, however no dedicated server compiled (yet), so i partially answer your question.

hexed wasp
#

Interesting. That seems to reverse my assumptions then 😃

ember needle
#

well i don’t know. everyone says to not do bp multiplayer, so i’ll tell you if i hit a wall

#

hopefully, not 🙃

hexed wasp
#

@ember needle sent a friend request, maybe we can keep in touch on the subject.

ember needle
#

sure thing

hexed wasp
#

Much appreciated and godspeed in everyday work 😉

ember needle
#

thanks 😃

#

you too

west rapids
#

Can somebody explain to me why an object with Authority can't get a GameMode, whereas an RPC on the server can?

#

I mean the execution path switches to the server side, I don't understand why you can't run server owned functions that way and instead have to rpc

lucid vault
#

@copper mango bool AActor::IsNetRelevantFor(const AActor* RealViewer, const AActor* ViewTarget, const FVector& SrcLocation). RealViewer is the player correct? Which means I need to return true if RealViewer is within the array of authorized users and false if not?

ember needle
#

@west rapids not sure i understand your question, but if i do, clients do not have GameMode instances

west rapids
#

@ember needle yeah I know, i was asking why Switch Has Authority, when using Authority pin, returns None when accessing the GameMode, whereas calling an rpc on the server, returns it

#

nevermind, it works on both, I'm just blind, sorry

copper mango
#

@lucid vault yeah RealViewer should be the player controller that you're checking relevancy for

lucid vault
#

@copper mango So here is an issue. When the player interacts with a pickup, it get's added to the inventory on the server. Then, a function is called from the server to the client that updates the inventory widget. The problem is that when the function is called on the client, the inventory hasn't yet replicated down

#

So the inventory doesn't get the updated item

#

I guess I will have to set up some kind of listener onchange for the inventory replicated variable

#

Instead of calling a func

copper mango
#

you could do a ReplicatedUsing function which will then get called on the local player when the variable is updated via replication

lucid vault
#

How does that differ from rep notify?

#

Oh, is repnotify the blueprint equivalent?

grizzled stirrup
#

Will the get player controller node set to index 0 always return the local playing client?

#

Looking to do some clientside event that's based on an overlap event and have to verify it has been triggered only by the local owning client (be it the listen server host or a regular client)

wary path
#

generelly, yes, but be careful not to use this on the dedicated server

#

@grizzled stirrup ^

grizzled stirrup
#

Using a listen server approach so should be fine

#

Thanks a lot!

copper mango
#

I'd suggest using IsLocallyControlled to figure that out

grizzled stirrup
#

That actually returns true for AI on the listen server which can mess things up unfortunately

copper mango
#

could use IsLocalPlayerController on the controller, then

grizzled stirrup
#

good idea! thanks

meager spade
#

IsLocallyControlled returns true for AI?

#

i have never seen that :/

#

can't say i really use that tbh 😄

plush wave
#

does max player count include spectators?

elfin creek
#

i have a lobby level that players goes into when they join a session, the second they go inside they should get widget to select a character so they will be spawned inside the lobby i created a custom event inside the game instance and i try to call it from the level blue print in the begin play event and i run it on dedicated server, my problem is :
when the host creates the session and gets into the lobby he gets the character select widget and every thing goes fine , but when some one joins the session they get the widget for less than what second then it goes off without selecting anyone and leaving the player spectating and i don't know why

copper mango
#

the level begin play is likely to get called on the server before the player's even joined, so you can't rely on that

elfin creek
#

then what can i use ? player controller ?

copper mango
#

the game mode has a PostLogin function that's the first point where the server knows about the player controller

elfin creek
#

i am new to the networking thing

copper mango
#

well, where it's valid for you to call an RPC on the PlayerController

#

so you could make a Client RPC on the PlayerController that creates/shows whatever UI you want, and then in the game mode you make it so the player doesn't actually start until they make their selection (so you could set it so when they first join they're forced in spectator mode)

#

and then once they make their selection and tell the server, it can restart the player with their selections

#

if you're doing stuff in Blueprint, there's an OnPostLogin event you can use in the GameMode blueprint

elfin creek
#

so the RPC i should use it would be inside the playercontroller and i would be calling it from inside the gamemode on the OnPostLogin right ?

copper mango
#

right

#

so when the player joins you tell them to show the UI, and the server can also setup whatever options or whatever through that RPC potentially

#

the other thing might be if your server is just immediately starting the game before any players are ready

#

because by default the game mode will start the match once the first player connects

#

or joins rather

#

but you can override that also

#

to be honest, I don't know how much you can do via blueprints

winged badger
#

@elfin creek dedicated servers do not mix well with either use of GI, and especially LevelBP

#

you picked up 2 objects that you can't even hack to support network, out of total of 2

elfin creek
#

yeah i thought as much when i saw the casting failing every time 😂

#

how much is the blueprint far from the coding ?

real yacht
#

does anyone have experience with aws lambda and ue4?

copper mango
#

I honestly don't recommend trying to make a networked game in Unreal if you can only do Blueprints, but I guess it's possible

winged badger
#

skill wise or implementation wise?

#

it is possible, its just... awkward

#

trying to play basketball without using your dominant hand would be a good analaogy for it

elfin creek
#

i can code it but i find that blue print is a bit easier on me so i wanted to know the difference ,beside unreal coding is quite different from what i used to do normally with c++

winged badger
#

in BP, everything is verbose, difficult to track or read

#

and some of its implementations are just plain awkward, like OnRep being called even if client sets the variable locally

#

plus you don't have any access to any of the low level networking

#

if you want to see what changed in replicated array in BP, you'd need to store backup, then compare the arrays and/or elements with the backup

elfin creek
#

aha i see , maybe because i don't understand networking right that makes things a bit blurry to me , ia m building my game to learn more or less

#

so in a multiplayer game it's not good to use the game instance and level blueprint because they cause problems

winged badger
#

they can't ever support network

#

generally, i think using level BP for other then showing MainMenu widget from ManuMenuLevel BeginPlay is also a mistake

elfin creek
#

then what is game instance used for exactly ?

winged badger
#

its an object with a lifetime from start to end of application's runtime

#

it holds an array of local players

#

which hold the viewport

#

it doesn't get changed when you load a new level

#

i mostly use it to handle the menus, which don't really fit well in a HUD

elfin creek
#

okay , i tried the way @copper mango said , the Widget is being displayed now for both players but it's not functioning for the player who joins , only the host picks up and spawned but with the joining ones nothing happens when the buttons are pressed

winged badger
#

you can't send RPCs thru widgets

elfin creek
#

now this is confusing

#

i know this looks sucks , but it was the only idea i had 😂

fleet raven
#

would be nice if the engine told you when an rpc you made makes no sense

#

made an rpc on the game mode? nope
made a multicast on the player controller? nope

winged badger
#

it gets worse @fleet raven , some wrappers for pointers replicate just fine, like TWeakObjectPtr, while others silently fail, like TScriptInterface

fleet raven
winged badger
#

@elfin creek make a panel, OnConstruct for 0...7 create and add a custom Widget that has a button and ExposedOnSpawn integer Index variable, feeding the current element index into button index

#

in the ButtonWidget, add an EventDispatcher with Integer payload, and when its clicked call that dispatcher plugging the index into its integer parameter

#

when you create and add the button widgets, also BindEventToYourCustomButtonWidgetClicked

#

result: you end up with a single event in outer widget BP that fires when one of its child ButtonWidgets its clicked and its aware of the button's Index

#

then forward that to your PlayerController, which you can get as long as you connected Owner pins when creating widgets, with GetOwningPlayer

#

and have it send the RPC

fleet raven
#

replicated struct properties always arrive in a consistent state, right?

#

so if I change one of its properties, it replicates, I change another property, it replicates again, it will send a delta with both of those changes since the client hasn't yet acked the first one and it's possible it never gets it?

ember needle
#

Does anyone know what NetworkSimulatedSmoothLocationTime exactly does ("How long to take to smoothly interpolate from the old pawn position on the client to the corrected one sent by the server")? If I want to "smooth" animations should I increase it or decrease it?

unkempt mortar
#

on unreal http request, windows, android support multi thread. but FApplePlatformHttp not support threaded request. do anybody know why?

elfin creek
#

@winged badger i guess i am way too novice to understand most of those things you said forgive me, what i understood so far was i have to create another widget that contains a button and an integer variable which has the ExposedOnSpawn property and then in the all characters widget i add button from that widget i made with the same number of characters i have giving each button of them an integer value that corresponds to a character , is that right so far ?

winged badger
#

basically instead of adding buttons directly, you add a panel, then in a for loop (or a foreach loop - for each of your possible character selections) you add those custom buttons into that panel

#

buttons have to be aware what index (and possibly, classname, or charactername - for display) they correspond with

#

when clicked they call their event dispatcher, which the parent widget binds an event to at the time it creates the buttons and adds them to the panel

#

so yes, that was good so far

elfin creek
#

my only problem is i don't really know eventDispatchers and how they work , the event i bind to the event dispatcher what should it do exactly ?

winged badger
#

its basically an object that maintains a list of functions it should invoke when called

#

you add an event dispatcher below your variables

#

you name it

#

you select it and add it integer input in the details panel, just like you would for an event/functionj

#

afterwards, anything with a reference to an object containing the event dispatcher can get BindTo<YoutDispatcherName> from the reference context

#

that creates a node with the red square bottom left

#

and when you drag from the red square, and type in "Custom event"

#

it will create an event matching the dispatcher signature connected to it

#

its most commonly used (not in no way exclusively) for situations like A has reference to B, A needs to react to something happening in B, but you do not want to reference A from B

#

then B uses an event dispatcher, A binds to it, and when A needs to react, B just calls the dispatcher

#

(at least most commonly used in UI that way)

#

so when you connect this, in a widget holding the panel with buttons that event fires whenever any of the buttons are pressed, and it has an integer parameter telling you which button

#

@elfin creek

hasty orbit
thin stratus
#

Can I have a UFUNCTION(Client, Reliable) that I can override in BPs? 🤔

winged badger
#

in theory

#

if you slap blueprintnativeevent to it as well

#

it just might override the _Implementation

#

or crash

#

i'd say 20/80 for those 2 options

meager spade
#

seems like it should work but 🤷 never tried

thin stratus
#

Yeah I would assume one of the two doesn't like the others _Implementation

#

I will try it later

meager spade
#

i mean the safe way would be the client rpc implementation calls a BPNativeEvent

#

which would work, just means a extra funciton and extra bit of code

thin stratus
#

BPImplementable is enough

#

The extra function is what annoys me

hoary sandal
#

hey guys the cable component is replicating but not in the right spot also the object does not replicate when dragged by the cable

#

I figure out that if I want to replicate the position of the object I just need to enable "static mesh replicate movement"

winged badger
#

or replicate the stuff you need to simulate the cable component

#

and do it that way

thin stratus
#

Hm, where exactly does one apply impulse to another pawn when hitting them?
I thought using the HandleImpact function from the MovementComponent might work out, but that seems to 1. call more than once per frame (cause of substepping I guess) and 2. for simulated proxies :x

#

I would assume I want this to call for the local player and the server

#

And only really once per frame or, if multiple times per frame, not adding impulse onto impulse

#

I guess I can always filter via GetOwnerRole, just not sure about it calling more than once per frame.
CMC doesn't seem to filter it

hoary sandal
drifting plank
#

Hey anyone has already needed to replicate a FMatrix ?
It seems that in some case the matrix is not replicated correctly.

It's the rotation of my character to his current ground (all the logic of wall switching is proceed on the server side)
Base case : (Matrix zero)

#

Wall case (with correct replication) - The server and the client have the same matrix

#

And the case which doesn't replicate correctly is this one (a wall which is rotate by 30° for instance)

chrome bay
#

FTransform has replication support, FMatrix doesn't

drifting plank
#

Oh

#

Ok I will try this ^^

chrome bay
#

Still a bulky struct for replicating the relative orientation though. Just a rotation and location is probably enough

drifting plank
#

That's true !

#

Oh I used the matrix to get easily all the axes forward, up and right

#

I will try the transform first

#

That's works ! Thanks you !
As it's a student project which don't need to be used online, I don't care about bandwidth optimization at this point. But I will check that later if needed.

humble comet
#

Guys what type of lag compensation techniques for rpc you use in your games?

meager spade
#

what you mean?

humble comet
#

to delay rpc by half of the rtt in order to call it simultaneously

#

both on client and server

west rapids
#

@thin stratus I've tried several different methods of applying physics to a Pawn with a movement component, and as far as I can tell, it's incompatible with the physics system if you want to maintain control.
You'll have to simulate custom physics on that, at least that's what I had to do. You can use the regular input function to create a fake "impulse". Use ConsumeInputVector to prevent "impulse" stacking. My approach anyway.

#

@humble comet check the character cpp, there's some pretty neat tricks when it comes to prediction there.

eternal anchor
#

did anyone used EOS sample app ?

#

how the heck do you login in it ?

thin stratus
#

@west rapids Na, no custom physics. It's just an impulse added to the velocity of the movement comp

#

I would never touch multiplayer and actual physics haha

west rapids
#

I can understand that

#

I'm suffering through that right now 😄

#

was just an idea anyway

#

Like the same setup works for prints, yet not even a breakpoint is triggered on this

thin stratus
#

If "BeachBall" isn't owned by the client executing the rpc, then yeah, there is a reason

west rapids
#

@thin stratus Receive Input doesn't count as ownership then?

thin stratus
#

No

west rapids
#

i see

#

just wanted to have a quick test

#

but i aint about to possess and unposess 😛 thanx

wary willow
#

you don't need to possess the beach ball to own it though

west rapids
#

is there some other way to transfer ownership? (excluding spawning and children) @wary willow

thin stratus
#

calling "SetOwner" on an actor, but that has to happen on the Server

tropic fjord
#

Is there anyone here who's got a good idea of building something that keeps track of who has vision of what?

#

When a unit is in vision of someone, the entire team is informed about that unit and their details (health, location, items, etc.) through minimap and info tab

#

I have been struggling to come up with a good way to keep track of this across the entire team

#

It's simple enough when it's just one player that tracks its own units

#

But when you get interaction between a whole group....

#

I tried doing something with the PCIterator to inform the different players, but that didn't work well

west rapids
#

@thin stratus omg, thanks man

#

@tropic fjord wouldn't a box trace work?

#

store the info in player state and then get it on other cleints

#

or better yet have an enum and just send a byte to the clients and they read stats locally

#

unless they aint preset

tropic fjord
#

I'm doing a trace to get an array of all the visible enemies, so that works fine

#

The thing is... For instance

#

A unit gets into my vision

#

it gets added to this array

#

I inform the others that I can see it

#

now my teammate does the same

west rapids
#

oic

tropic fjord
#

what happens?

west rapids
#

this seems pretty heavyy

tropic fjord
#

His overrides mine?

#

His doesn't do anything?

#

Can't do either

#

Cuz if one of us walks away and the other stays

#

still needs to give vision to entire team

#

🙀

west rapids
#

well, what you can do is keep track of every player in the game state

#

and then just use a bool to trigger visibility on minimap

#

for other players

#

dunno how heavy that would be tho

tropic fjord
#

Well, I don't have just players

#

I also have around 100 AI on the map at any point in time

#

😓

#

But you mean that I should do it in reserve @west rapids ?

west rapids
#

for Ai

#

in 4.20

#

you can now assign a playerstate

tropic fjord
#

Keep track of the vision on the unit that is getting seen

#

instead of keeping track on the units that see

#

if that makes sens

west rapids
#

in aicontroller tick "wants playerstate"

#

yeah i think in reverse is gonna be better

thin stratus
#

You don't really want every single AI to have a PlayerState

west rapids
#

cuz ull be tracking only once

thin stratus
#

That's more for actual Players

#

e.g. a Bot in UT

fiery geyser
#

Hi everyone,

I have the following issue: I am trying to setup a Weapon class for a FPS game with a 1st Person mesh (which has Only Owner See flag) and a 3rd Person mesh (which has Owner No See flag). My problem is that the other clients don't see the 3rd Person Weapon Mesh, any thoughts on that?

tropic fjord
#

eXi, you got an idea about my issue? It's pretty much an MMO/MOBA minimap system.

thin stratus
#

Just keep one Array of visible units for either player or whatever sort of "group" you want

#

If a unit sees something, add it unique to it

#

And maybe increase the viewcount on it

#

So that you know how many units see it

tropic fjord
#

Where would you store that array

thin stratus
#

Depends on how should know about it

tropic fjord
#

I mean, teammate AI can give vision

#

teammate players can

#

yourself can

#

teammate AI can turn into enemies

#

the other way around

#

etc

#

So I'm pretty sure everyone should know

thin stratus
#

Make your own custom TeamState?

#

Set it up similar to how the PlayerState works

#

Spawn it in the GameMode

#

Keep an Array of teams in the GameState

#

Save the units in their

#

Assign a teamstate to each PlayerState

#

tada everyone has access to their team

tropic fjord
#

I'm not seeing it yet.

west rapids
#

Wouldn't that be a bit heavy thho?

#

what he means is Inherit from the actor class

tropic fjord
#

How are we going to keep track of the count of each unit we see, though?

west rapids
#

set up ur teams in GS then distribute across

tropic fjord
#

I'm actually going to take out pen 'n paper cuz my brain can't do this

west rapids
#

a lazy way would be just to track position in GS and reveal based on bool from ur trace, update every second or two.

lucid vault
#

@copper mango I'm using ReplicatedUsing and there is an issue that I'm trying to understand. Basically, each player has his own inventory widget and when the inventory of that player get's changed, ReplicatedUsing will call a function to update the player's inventory widget. The problem is that this seems to be calling on all clients because each client has a reference to each player, therefore overlapping huds on top of each other.

west rapids
#

depending on ur visibility logic (fog of war or not) then ud pretty much get away with a toggle

tropic fjord
#

It's a bit more complex than that

west rapids
#

well if u can swap gear at run time

#

then yeah

#

but even then you can just update ur actor stats when they update their inventory and sync in slowly

tropic fjord
#

Not quite figured it out yet, but thanks for the help 'n the ideas

west rapids
#

look

#

get it working dirty first, you can refactor and make it pretty later

#

try the custom state, probably a better idea, i dunno

wheat eagle
#

Hello poeple I want to set the relative location of a component from an character that the player is controlling. It works good for the player possesing that character , but it doesn't for others. How does replication for set relative location work and how can I fix it? (for background: I'm trying to make a custom crouch and set the player's mesh up as he is crouching , otherwise it will go underneath the level)

west rapids
#

@wheat eagle set ur location serverside

thick sand
#

Has anyone here had any success getting Oculus sessions working?

wheat eagle
#

I've tried that , it doesn't work

west rapids
#

does it work on a listen server?

#

for the server?

#

im not sure if u have to multicast it

#

or use a bool with repnotify, that would probably be cleaner

fiery geyser
#

Hi everyone,

I have the following issue: I am trying to setup a Weapon class for a FPS game with a 1st Person mesh (which has Only Owner See flag) and a 3rd Person mesh (which has Owner No See flag). My problem is that the other clients don't see the 3rd Person Weapon Mesh, any thoughts on that?

wheat eagle
#

I've tried with both only server and with multicast. Tested on listen server and still it only works for the client possesing the character.

#

let me try with the bool with repnotify

west rapids
#

@fiery geyser so they see the 1st person then? or nothing at all?

fiery geyser
#

Well, they would see the 1st Person if I would untick (Only Owner See flag)

thin stratus
#

Are you setting the Owner properly when spawning the Weapon?

west rapids
#

oh so they dont see a thing then

fiery geyser
#

Yes, eXi, I do that when I equip it, I set the new owner.

west rapids
#

ur 3rd person mesh is a child of 1st person

#

if u cant see 1st person then u proly wont see 3rd too

tropic fjord
#

I really think I should go for the reverse mechanic. Thoughts on this? @thin stratus @west rapids?

  1. By default, keep track of everyone, but have stuff "Hidden".
  2. Every xx, do a check of who can see "this unit"
  3. Keep track of those people in an array. This doesn't involve any networking yet.
  4. Do a check of those unit's teams. Have 3 booleans (3 teams). VisionByRed, VisionByBlue, VisionByWhite. These booleans are replicated.
  5. When boolean is set to true or false, hide/unhide UI (minimap, tab info) for all players on those teams.
west rapids
#

so I assume u gonna keep track in game mode or some server only thing then?

#

cuz I'm not sure if u tracking these things in GS that it won't eat up bandwidth like pacman

#

unless u setup rules for replication

#

like only replicate if visible

#

At any rate, I gotta go soon, but I think its a good approach cuz u can scale that to more teams quite easily, can't tell you about how optimal it would be even if you make it sqeaky clean

#
  • you can do all sorts of fancy things with a map tracker that always has the info available
tropic fjord
#

Yeah, dunno either, but I don't know if my brain can come up with that perfect solution :/

#

As you said, it it functions how it should, then I'm alrdy pretty happy

west rapids
#

well another option would be event dispatchers

tropic fjord
#

cuz previously it wasn't correctly updating when I was doing it from the side of those who " see'

west rapids
#

like an "enemy spotted" event

#

and then request replication for others from the array

copper mango
#

@lucid vault well one way might be to set the replication condition of the variable to COND_OwnerOnly, then it'll only replicate to the owning player

west rapids
#

dunno

tropic fjord
#

I did something like enemy spotted first, but it got really messy

west rapids
#

i think repnotify would be your best bet for a clean sync

lucid vault
#

@copper mango True, but this inventory system will also apply to chests, which means it will need to replicate to more than just the owner

#

@copper mango I want to replicate to everybody in an array

copper mango
#

and you're using IsNetRelevantFor?

west rapids
#

anyway i g2g, good luck

tropic fjord
#

Thanks, Ken

lucid vault
#

Yeah I think that will work, right now my question is more of how to prevent widgets from other players from showing on your screen (since the other player instances are also in your game)

#

There is probably a function for it that I can't think of

copper mango
#

wherever you create the widget, only make it if it's a locally controlled player controller

#

IsLocalPlayerController

lucid vault
#

Hmm. So maybe my issue is also that I have been using the player character for all of my logic as opposed to the controller

copper mango
#

well you could still get the controller from the player character and test it there

#

but one advantage of using player controller is that the non-local players do not have a PC on your client

#

so like if you have two clients, each with one PC, they don't have access to each other's PC

lucid vault
#

Oh. So that means if I created the widget in the PC I wouldn't even need condition checking?

copper mango
#

yeah, so for example could make a Client function in the PlayerController and then the server tells the player when to create their Inventory

#

or for example when the player opens the chest, the server could send a Client RPC to the PlayerController telling them to show the chest view or whatever

#

depends what you're trying to do, but I guess you shouldn't make your widget in the Player Character

lucid vault
#

I see, that makes sense

copper mango
#

so basically for PlayerControllers, only the Server and the owner of the PlayerController has access to it

#

PlayerState is replicated to all, though

glass plaza
#

@fiery geyser Check the NetRelevant status of your meshes.

#

Make sure your class has the Replication section properly checked and that your component is set to replicate

fiery geyser
#

@glass plaza everything is properly checked. Still got no idea yet what could cause it.

winged badger
#

@fiery geyser why is your 3P mesh in hierarchy under the 1P mesh?

west rapids
#

Use scene component

#

as parent

#

if ur 1p is hidden so will ur 3p

winged badger
#

and weapon mesh components don't need to replicate, they are default subobjects of a replicated actor

west rapids
#

@winged badger in theory, if a game works in multiplayer, it should run with only 1 player as well yes? (aside from missing controllers)

winged badger
#

there are no missing controllers

#

one needs to exist, and one does

west rapids
#

no i mean if there is a multiplayer game designed for 10 people, and you launch it in editor with only 1 player, no dedi servo, it should still run the same, right?

winged badger
#

if its made for dedicated servers it might break in listen server mode

west rapids
#

no no

#

no server mode

#

just single player

#

as in, no need for rpc or replicaiton

winged badger
#

yeah, they usually do

west rapids
#

rpcs wll function like regular calls right?

winged badger
#

yes

west rapids
#

aight that narrows down my problem by a large margin 😄 thanks

winged badger
#

they do that in network as well, calling a server RPC from server is just a normal function

west rapids
#

i wonder

#

this would technically be heavier then right?

#

i mean ud be calling an extra function for every time ud need 1

winged badger
#

if any of your game critical code depends on it actually being run on dedicated server

#

it will still break

west rapids
#

i see

#

i was always curious about that

#

thats why im askin 😄

#

since WoW

#

launched lol 😄

#

always wondered why i couldnt play by mahself locally

#

i know they had their own engine and all, but architecture was prolly the same

winged badger
#

you could play it standalone in editor

#

packaged, it would probably break

west rapids
#

oh so if i had WoW as a project on my pc it would run huh

#

good to know 😃

#

thanks man, resolved a decade old curiosity here 😄

winged badger
#

there used to be pirate wow servers when it first came out

lucid vault
#

@copper mango Any way to use IsNetRelevantFor on a UActorComponent?

winged badger
#

its a AActor function

#

and components don't replicate or get relevant on their own

lucid vault
#

Components have bReplicates as a variable though

#

So, is there no way to decide which clients a component will replicate to?

#

I am trying to replicate an inventory component's ItemData TArray to specific clients

copper mango
#

the bReplicates for the component just means that should the component replicate if its owning actor replicates

#

but the relevancy of a component is based on its owning actor's relevancy

winged badger
#

you can choose which players

#

sortof

#

mostly owner, not owner, or everyone

copper mango
#

well, you could set a replication condition for the component pointer in the DoRepLifetime etc

#

but it won't let him do what he wants, since custom conditions can't be connection-specific

lucid vault
#

Basically I only want the player's inventory replicating to other players if they have first gained access to it (such as if the player ha died and they interacted on their body). This would prevent cheaters from viewing inventories that they shouldn't be able to view

#

But as of right now the inventory component replicates to everybody

#

As opposed to only those in the authorized array of players

winged badger
#

so why don't you just spawn an actor, transfer the dead man's inventory into it

#

and replicate it to everyone

lucid vault
#

Well I am trying to make the system modular so it can be used elsewhere. In a chest, for instance

#

I want players to have to interact on the chest first before being able to view it's contents

#

So I am trying to make the system modular for inventories

#

The player should be able to gain access to any inventory, no matter if it is a player or chest inventory. Once they gain access and are added to the array of authorized users for that inventory component, it should replicate it's data to that user

winged badger
#

option 2

#

any inventory container when interacted with adds a replicated component onto an interacting pawn at runtime

#

and destroys it when interaction is stopped/completed

copper mango
#

you could probably add that component onto the PlayerController instead of the pawn, yeah?

winged badger
#

bonus: you can move the logic for picking up and stashing stuff into that component, and it can also handle the interaction UI

#

yeah, doesn't really matter

#

or the PlayerState, works too

copper mango
#

just thinking if you put it on the PC it's a bit easier since it wouldn't replicate to non-owning clients since they don't have access to the other player's PCs

lucid vault
#

So if a player accesses a chest, the chest would add a replicated component to the player controller?

#

Then this component added has access to the chests inventory

#

I'm trying to think of how to set that up modularly

copper mango
#

then you shouldn't need to maintain that list of authorized players

lucid vault
#

I'm trying to figure out how the newly added component should transfer the data to the player

#

Maybe it keeps a reference of the inventory that created it?

#

And then it uses that reference to view/add/remove items

#

And it replicates that reference's inventory

west rapids
#

@lucid vault you could use an event dispatcher

#

aka delegate

winged badger
#

if you're using c++, just have the inventory as structs

lucid vault
#

Yeah I'm using c++

winged badger
#

and copy the entire array into a component

lucid vault
#

Basically I have an inventory component that contains an array of struct data

#

For the items

winged badger
#

yeah, copy that

lucid vault
#

Oh I see

#

You mean make an exact copy of it?

winged badger
#

well, you'd still have to keep the inventory in sync somehow

lucid vault
#

My question is how I go about replicating the data from point a (the chest's inventory) to point b (the newly created one on the player)

#

Yeah

winged badger
#

but replicating an array of structs from another actor isn't going to work

#

so as long as you have a reliable operator== on the inventory struct

#

you can just copy the array and when something is taken, you remove whatever == the item from the Actor that actually holds the inventory

lucid vault
#

So probably when the chest creates the inventory component for attachment to the player, I should pass in the reference of the chest so that the newly created component can retrieve the struct data

winged badger
#

its instance on the server also has to keep the chest in sync with player actions

#

so it has to have a reference to the chest

#

the reference doesn't have to be replicated

#

as i don't see why the player would send a ServerRPC referencing the chest directly

west rapids
#

wouldnt an interface be better?

#

cast to ILootable and off yago

winged badger
#

inside the scope of a Server function on that component, it has to have a valid reference to the chest

#

i am assuming an interface or a common base actually exists

#

already

#

not talking about interacting with another class, but the networking involved

west rapids
#

oic sry didnt read the whole thing

lucid vault
#

Yeah I already have an interaction interface

winged badger
#

the add a replicated component approach is a pretty much the only solution when you have lots of specific interactions without much in common

#

like say, a crafting bench, vendor, alchemy bench... etc

#

reducing that to common interface would be.... challenging to say the least

#

and putting all that networking logic inside one of your game framework classes would be a clutter clusterfuck

west rapids
#

i was under the impression this was needed for looting dead bodies and chests 😛

lucid vault
#

My idea of reducing it was to have any inventory be able to hold any item unless you specify item restrictions on specific slots (ie. slot one can only hold wood)

winged badger
#

well, for looting just needs a single component class to work for any inventory container

lucid vault
#

So you think that for every item (chest, vending machine, furnace) they each need their own custom component that will be spawned onto the player?

winged badger
#

if the Actor in questionj

#

has specific networking logic, requiring specific UI

#

yes

#

otherwise, no

lucid vault
#

True, I didn't think about the UI. I can use that component to display it to the player

west rapids
#

u got a loot table ye?

winged badger
#

and you can use the component to react to the UI and send the required RPCs

#

without any of that ending up in your PC or Pawn

lucid vault
#

True. I'm going to try and implement this in code and see how it goes. Thanks for all the help!

lucid vault
#

Okay, I have a component called ChestAccessor. When the user interacts with the chest, the chest adds a ChestAccessor to the player (passing in itself as a reference). The ChestAccessor then adds a widget to the player's screen and handles input. The ChestAccessor can RPC to the server and modify the chest using the chest reference.

#

How should the chest notify the ChestAccessor when it's inventory has changed?

#

If two players have the chest open, one may modify it's contents. In which case, the chest needs to notify the ChestAccessor to update the client's widget with the new data.

rotund sapphire
#

just replicate the array of inventory with a notify and on client side make the call to the accessor thing to update the ui

lucid vault
#

That won't work for what I'm trying to do

#

@winged badger I think I will send the event to all of the stored Accessors when an item is added/removed. Should work

winged badger
#

if that happens frequently with anything more then small arrays

#

you should consider FFastArraySerializer

#

its capable of per-item callback client side for add/remove/change

fluid prawn
#

Question for the player as a listen server is there a reason why 3+ players spawn properly and possess on each client but for 2 players It does not?

real yacht
#

anim montage is not player on other clients, only on my

#

what i'm missing?

#

i have tried with repNotify also

#

still, anim is not played

scenic raven
#

hey everyone!

#

I am getting an error Warning: CanServerTravel: Seamless travel currently NOT supported in single process PIE. but I explicitly deselected the use singleprocess in general settings. Any clue?

wary wyvern
#

Guys, Is there a setting to set network timeout? For example my server crashed or client has lost connection. I need to open up a screen to return to main menu.

thin stratus
#

@scenic raven You need to start the game as Standalone (e.g. Rightclick Uproject File -> Launch Game). Everything inside the Editor doesn't support SeamlessTravel.
@wary wyvern You mean a delay before it automatically kicks you back to the mainmenu?

wary wyvern
#

@thin stratus A delay before NetworkError inside GameInstance gets called

thin stratus
#

Don't think there is

#

That's a pretty direct call to it

#

UnrealEngine.cpp Line 11175
UnrealEngine.cpp Line 11047

#

You can follow that further up the chain if you are interested

real yacht
#

what is the other way to play montage

#

on other clients?

#

thnx

wary wyvern
thin stratus
#

Yeah but don't you kinda need to know when you timeout?

#

The value when just means that it waits longer for the Connection resume

winged badger
#

you can confiigure timeouts, somewhere

#

but actual errors, a deletage gets broadcast, and thats the end of it

wary wyvern
#

Well, for example my server crashes and i have this timeout before client decides what to do.

meager spade
#

@real yacht Multicast or a Replicated property witha struct

thin stratus
#

What happens with an RPC that has a UObject* parameter, where the actual instance in that variable is an AActor (replicated)?

#

Does that just work?

chrome bay
#

yeah should do!

winged badger
#

if its replicated, or stably named

#

otherwise it won't work

chrome bay
#

I have a few places I think where I have replicated UObject ptrs which point to actors sometimes, components other times etc.

winged badger
#

not even that, by default it has to be loaded from a package to be referenced over network

#

and unreal will give you no warnings

#

replicating UObject* is fine, as a variable

#

for a RPC payload its loaded from package, replicated, or after making sure it has exact same name on all machines, making it net addressable

chrome bay
#

Oh yeah, I assumed we are talking about stuff which can knowingly be referenced on the network already

#

As opposed to just arbitrary objects etc.

winged badger
#

usually the simpler way it to send a pointer to its Outer

#

example, you don't do

#
UFUNCTION(Server, Reliable, WithValidation) void ServerPlayAnimMontage(UAnimInstance* InAnimInstance, UMontageAsset* InMontage):
#

instead you can do

#
UFUNCTION(Server, Reliable, WithValidation) void ServerPlayAnimMontage(USkeletalMesh* InSkeletalMesh, UMontageAsset* InMoontage);
#

then in its body grab InSkeletalMesh->GetAnimInstance()

#

option #1 here will just silently fail, or crash, depending on how rigirous your null checks are

meager spade
#

learnt that first hand :D

#

AnimInstance is not net name stable

#

well not network addressable

rose egret
#

dose multicast or client RPC use Actor Relevancy like replication?

winged badger
#

multicast does

#

client does not

rose egret
#

@winged badger are u sure ?
both reliable and unreliable ?

winged badger
#

client is directed at one specific instance on one machine

#

there is no sense to get relevancy involved in that

#

and if it can receive client RPC, it would return true for relevancy anywyas

#

since it will look into owners relevancy as well

#

for reliable multicasts, not 100%, they are handled quite differently then unreliable ones

rose egret
#

I want to send a int to all clients. since there are lots of clients. I needed to make sure muticast uses relevancy.

winged badger
#

is it for a replicated actor?

rose egret
#

yea

winged badger
#

just set the int on it server side

#

have it replicated

#

(set it in the same frame its spawned)

#

and clients will have the int ready on beginplay

rose egret
#

the problem is my variable is adjusted multiple time with the same value.

winged badger
#

not quite sure what you mean by that

rose egret
#

I mean my variable is changed to a different value every frame.
on the client side I want to get the same number of OnRep_

chrome bay
#

You can't

#

You're never garaunteed to receive all the changes to a variable

#

Only it's latest state

rose egret
#

so thats why I switched to NetMuticast

#

🤔

chrome bay
#

Not to be ThatGuy but this sounds like bad design

#

what are you trying to achieve exactly?

rose egret
#

I want send some kind of event to tell the clients that a player is immune for a period of time.

chrome bay
#

Surely all you need then is a bIsImmune flag or something similar?

bitter oriole
#

A replicated "is immune" bool looks like it would be fine

rose egret
#

🤔
I am gonna go try it.

chrome bay
#

technically, it already exists. bCanBeDamaged in AActor is replicated by default.

#

if bCanBeDamaged is false, they're immune. If it's true, they aren't.

rose egret
#

🤔

quasi scroll
#

hi guys, i have an issue with replication : if i create a blank c++ actor and make it replicates with bReplicates = true, and then spawn this actor with a blueprint node "spawn actor from class" on server side, it won't spawn

#

but if i create a blueprint class child of my c++ class, and then spawn this blueprint on the server, it spawns for other peers

#

am i missing something ?

chrome bay
#

What components does the C++ actor have?

#

Make sure it has a root component at least

quasi scroll
#

it is empty

#

it may be why it does not replicates

chrome bay
#

That'll be why then - you need a root component or the server won't be able to determine network relevancy

#

blueprint will create 'DefaultSceneComponent' if one doesn't exist, but C++ won't

quasi scroll
#

oook

#

i'm trying this

#

it's working, thanks a lot !

chrome bay
#

np's

quasi scroll
chrome bay
#

In my experience it will just crash usually, as without a root component you're actor technically has no location

#

Usually your actor has a component so it's probably not worth mentioning

quasi scroll
#

yeah it's right

hoary sandal
chrome bay
#

that's pitch

#

For characters, it's normally replicated already via character movement.

#

you will need to make changes to the FPP template to show the pitch in third person.

graceful cave
#

if i call TearOff() or disable replication for an actor immediately after sending a reliable RPC, and the packet is dropped, will it still be resent even after disabling replication?

west rapids
#

Has anyone ever played around with high velocity physics replication?

#

for example launching something like a spear with a massive impulse

#

or a golf ball

#

basically any physx object that travels at high speeds

pallid mesa
#

Hi @thin stratus I know this is an old topic, but were you able to fix your PS persistence issue?

thin stratus
#

Ehhhm

#

Not 100% sure anymore what that was about

#

@pallid mesa

pallid mesa
#

copying properties around

#

just because I ended up having the same issue because I did fail to override "OverrideWith"

#

in case you didn't try that yet

#

worked for me 👌

thin stratus
#

I had issues with additional actors surviving cause they were referenced in GM and GS while these are reset after the SeamlessTravel

#

And yeah I fixed that by just getting all actors of class at the start to catch the actors

pallid mesa
#

ahhh, aight, I thought it was exclusively an issue with your PS :)

harsh lintel
#

since client rpcs can't have an authority check (well they do but they're remote) , they should only be used for non game-breaking stuff or are they safe because they are called on the server but executed on the client, im puzzled : D

jade gazelle
#

The logic in a client RPC is kind of non game breaking by nature since it would only happen on that one client and not affect the state of the game as far as the server is concerned

harsh lintel
#

hmm what's the advantage of client over non-replicated if the server isn't messed up with

jade gazelle
#

Not sure what you mean. Server to client RPCs are used to get data from the server to the client for the client to use somehow, maybe it’s info thats needed for a widget to display properly or something, whatever

#

The server is still the one that has the “correct” version of the world, and a server to client RPC doesn’t affect the world at all so there’s no need for validation

#

Validation on a client -> server RPC is needed to prevent the client from giving the server bad/false data. There’s no point in validating a server -> client RPC since the servers data is assumed to be correct

west rapids
#

If ur looking for advantage, running on client allows you to do things that the server doesn't care about

#

like if ur throwing a smoke grenade, the server only cares where its located at, particle can be handled client side

thin stratus
#

RPC = Remote Procedure Call. Basically like your TV Remote telling your TV to Turn off/on.
It's a way to tell something else what to do.
That exists as Server, Client and Multicast.
ServerRPC (if the Actor is owned by the calling client) ask the Server to do something (Server = TV, Client = TV-Remote)
ClientRPC (if the Actor has a Client/ListenServer as owner) asks the Client to do something (Client = TV, Server = TV-Remote)
MulticastRPC tells everyone to do something (Everyone = TV, Server = TV-Remote)

#

Something like that

#

What they fiddle with is totally up to you

#

A ClientRPC always targets one client (the owner of the Actor), so you can't really destroy anything by that

harsh lintel
#

so a clientrpc would execute on the single client with the data of the server?

west rapids
#

whatever u feed it

#

cant use it for game mode related stuff tho

jade gazelle
#

It just tells logic to run on the owning client. You can pass data in as input parameters but it’s not required.

#

It’s a good way to get data to the client that has yet to be replicated, if you need that data immediately

thin stratus
#

Order etc is still not given

#

So you could also just utilize an OnRep

#

Not much difference I guess (if only targeting one client)

jade gazelle
#

OnRep would still not fire until the replication occurs though right? I’ve found that sometimes I need to get data from server to client faster than the replication occurs and I’ve been able to work around it by passing that data through an RPC.

#

Maybe not best practice though

west rapids
#

actually

#

now that I think about it, why can't u grab stuff from GM and send it through client rpc?

#

i mean ur refing it from the server, so it should return u something.

#

but ive tried this before, and it don't work

thin stratus
#

Cause the GameMode doesn't exist on clients

jade gazelle
#

Because the game mode doesn’t exist at all on the client

thin stratus
#

There is literally nothing to execute the RPC on

#

You can picture replicated actors like copies that are linked by an ID.

jade gazelle
#

You would have to run the RPC on something like the player controller and pass in data from the game mode

#

Before you send it

west rapids
#

my point is

#

Function A calls on server Funciont B calls things on owning client and sends through some float stored in game mode

#

like if I'm calling from the server side onto a client, I don't understand why i cant access GM from the server and dump info onto the client with the rpc

jade gazelle
#

It depends what class you are calling the RPC from. If the RPC is in the game mode it is always going to fail because there is no game mode on the client to receive the RPC

west rapids
#

on other actor ofc

jade gazelle
#

Like I said you would have to, on the server, send an RPC through a replicated class like the player controller. Then you would be able to grab a float value from the GM and pass it in as an input parameter

thin stratus
#

You can totally do:

Inside PlayerController -> CallServerRPC -> GetGameMode->GetFloat -> CallClientRPC(Float)

Where both RPCs are in the PC.

#

However that's rarely ever needed

#

You should already replicate everything the client needs through the GameState/PlayerState/etc.

#

It's also highly recommended by me, if you do something more complex in Multiplayer, to use C++.

#

UE4 has tons of stuff not exposed to BPs

jade gazelle
#

^ I realized that very quickly when I started doing multiplayer

thin stratus
#

Starts with something simple like the "InitGameState" function in the GameMode:

void AHLGameMode::InitGameState()
{
    Super::InitGameState();

    HLGameState = Cast<AHLGameState>(GameState);
    if (HLGameState != NULL)
    {
        HLGameState->SetMatchTime(MatchTime);
        HLGameState->SetMatchStartTime(MatchStartTime);
        HLGameState->SetRespawnWaitTime(RespawnWaitTime);
        HLGameState->SetForceRespawnTime(ForceRespawnTime);
        HLGameState->SetTeamBased(bTeamBased);
        HLGameState->SetRequireFull(bRequireFull);
        HLGameState->SetAllowSwitchingTeams(bAllowSwitchingTeams);
        HLGameState->SetAllowSwitchToSpectator(bAllowSwitchToSpectator);
        HLGameState->SetTeamStates(TeamStates);
        HLGameState->SetForceRespawn(bForceRespawn);
        HLGameState->SetWaitBeforeRespawn(bWaitBeforeRespawn);
        HLGameState->SetCanRespawnByHand(bCanRespawnByHand);
        HLGameState->SetWarmupForced(bForceWarmup);
        HLGameState->SetTeamDamageEnabled(bTeamDamageEnabled);
        HLGameState->SetReplicatedMapInfoClass(ReplicatedMapInfoClass);
        HLGameState->SetGameModeName(GameModeName);
        HLGameState->SetBotDifficultyLevel(BotDifficultyLevel);
    }
}
#

Allowing you to pass all your settings that players need access to to the GameState

#

Where they can get replicated

#

Just one of many useful functions that don't exist in BPs (whyever)

harsh lintel
#

I think I get it, im testing a client rpc with launch character and it can't break the server state of the character, and a non-replicated actor variable changes only locally, still kind of bothers me that I get the same result with a not-replicated rpc 🤔 I'm still a noob so I can't use my imagination, as mentioned before, I guess the function could have inputs and since the server is the one that calls it, the inputs would be the server's version of the data

west rapids
#

oh yeah c++ if u wana do serious stuff, but bp is fun to play around with

#

Here's what I mean

#

the Multicast works fine

#

sends the string to all

#

run on client always fails

#

why? Isn't run on client the same as a multicast but for only 1 client?

thin stratus
#

BeginPlay calls on everyone

#

So you would already go ahead and filter that properly

#

Cause currently a lot more than the owning client try to call that rpc

#

Despite that, it should work I guess

west rapids
#

yeah but the output of printstring tells you what's printing, client n or server

#

was just ez to setup quick

#

needed somethin to fire

#

but yeah, the client rpc doesn't work

jade gazelle
#

That’s probably an ownership problem

#

The multicast will fire for everybody regardless of ownership

west rapids
#

tha pawn is just in an empty lvl

thin stratus
#

Yeah then it's def an ownership problem

west rapids
#

like if iposess it would it run

#

sec

jade gazelle
#

Yeah if it’s just a pawn in a level it isn’t going to work

west rapids
#

always forget bout ownership

jade gazelle
#

Because the client doesn’t own it

west rapids
#

apf yea it does run

thin stratus
#

Your BeginPlay, as already said, is tricking you

#

It calls on the Server and all Clients

west rapids
#

well then I was wrong, it is possible to send GM info into a client

thin stratus
#

So the ServerRPC is dropped on all clients

#

And the Server executes it as a normal event

#

You'd have noticed if you properly limited it to the owning client

west rapids
#

yeah withh 5 clients I get 6 calls but still

thin stratus
#

I just noticed that if Client and Server set a boolean to true

west rapids
#

but anyway, thats one more thing cleared up for meh lol

thin stratus
#

And the boolean has an OnRep

#

The OnRep doesn't f*cking fire for the client

west rapids
#

you mean if they do it at the same time it doesn't notify?

thin stratus
#

Yeah the Client does it earlier of course

#

And then the Server does it and the OnRep doesn't call

#

Cause the Replication of a boolean

#

If it's the same state

#

doesn't do shit

#

Maaaaan

west rapids
#

that's supposed to be a good thing lol 😄