#multiplayer

1 messages · Page 545 of 1

quasi wyvern
#

basically what i want to do is to call some functions on the logged in player controller

#

but i am having trouble calling him from the postlogin...

if i do it hard coded with a widget, it works fine

snow imp
#

Cast the output controller to your own controller. If succesful, do fun stuff

#

Or am I missing something here?

winged badger
#

also, use HandleStartingNewPlayer override

#

it works in all cases, not just after a hard travel

quasi wyvern
#

thats how i tried to set up. but the function does not get called

#

@winged badger thx, just tried but same result

winged badger
#

not reliable to call RPCs that early

#

the PC itself is likely to replicate later then a reliable RPC sent at the time of its construction

quasi wyvern
#

ha! i added a delay, now it works

crimson fiber
#

Server targets are not currently supported from this engine distribution.
do you really have to use source version to build a dedicated server for Linux?

quasi wyvern
#

oh i think i forgot to check reliable on the server event - no it works without the delay

chrome bay
#

ha! i added a delay, no it works
@quasi wyvern please god no

#

@crimson fiber yeah you do, not just for Linux, any platform.

quasi wyvern
#

how can i detect/remove a client which did leave the game without logging off?

#

(like crash, or forced quit on client end)

#

tried net networkfailure in the servers game instalce, but so far it does not fire

chrome bay
#

They will timeout

quasi wyvern
#

hmmm

the client detects the network error if i kill the server but they will remain on the server if i kill them...

chrome bay
#

if a client or server crashes or force-quits, the other end won't know about it - so it'll just wait for the heartbeat to timeout before throwing the network error

#

The key is to make sure they don't crash 😄

quasi wyvern
#

good point :)
but the clients will be oculus quest HMDs and espcially on oculus people tend just kill the app...

quasi wyvern
#

ok looks like the server network error event doest not fire when using PIE... standalone works

halcyon totem
#

can someone help? I am trying to replicate a cloaking system in unreal

violet isle
#

hmm i wouldn't recommend having the mat be a rep notify

#

material instances shouldnt need to be replicated

#

u should just have a repped bool for weather they're cloaked or not

#

and then have the local material instance respond to that int he onrep

chrome bay
#

You can't replicate a dynamic material instance

#

That's the problem

#

DMI's are created locally

#

As said just use a bool then handle the material/visual changes locally based on that bool.

halcyon totem
violet isle
#

yeah, you probably want to do the sound in the repnotify function too

#

cosmetics that need to be repped should be done in that function

bronze arch
#

these inputs isn't working on local client?

#

when pressing one does it sends to server too ?

halcyon totem
#

thats the rep notify for the bool is that where it goes?

violet isle
#

yeah

#

also repnotifies need to be called on server

#

if you call it on the client, it wont replicate out to the server or other clients

halcyon totem
#

how do I call it on the server?

violet isle
#

RPC

#

u wanna do an RPC server call on client input

#

RPC's are the only way clients can talk back to the server really

halcyon totem
#

ok cool let me look into this, this is my first time doing something on multiplayer

#

thats for alll the help im learning

#

I found a pretty good video im watching on RPC, ill post it here for reference just incase anyone elses needs to learn https://www.youtube.com/watch?v=raLW5wg1PJA

In this video we look at the barebones (mostly just multicast) of function replication as the last major piece of theory in Unreal Engine 4 replication. Throw out suggestions for small things to add to the project setup for networking and the next videos may contain it!

We no...

▶ Play video
unkempt tiger
#

Quick question, can I use polymorphism in RPC calls?

jolly siren
#

yes

unkempt tiger
#

Sweet

#

Thanks

jolly siren
#

np you override the _Implementation

unkempt tiger
#

oh wdym?

#

do I not just cast<to some child class> of whatever it is I'm getting as an argument in the _Implementation?

#

Oh well yes, through overriding :V

jolly siren
#

I assume you meant can you override rpc functions?

#

"use polymorphism in rpc calls" is fairly generic

unkempt tiger
#

True I'll rephrase:

jolly siren
#

Example of how to override an rpc

virtual void ClientAdjustPosition_Implementation(float TimeStamp, FVector NewLoc, FVector NewVel, UPrimitiveComponent* NewBase, FName NewBaseBoneName, bool bHasBase, bool bBaseRelativePosition, uint8 ServerMovementMode) override;
unkempt tiger
#

Can I pass a Parent class reference, and then in the implementation, cast it to my child class (which extends the Parent class)

#

And expect it to work normally, etc

#

Of course my hunch says yes, I just want to make sure before I get coding

jolly siren
#

Yes you can with actors. Replication of ustruct polymorphism doesn't work though; without also replicating the class

unkempt tiger
#

OOF

#

That's not good for me

#

Hmmm wait a second

jolly siren
#

You can look at how FDamageEvent handles it if you need it with ustructs

unkempt tiger
#

In my design I am passing a ChildActor (derives from some ParentActor : AActor) which as a member holds a struct (which derives from UStruct)

#

I can't use polymorphism on UStructs, but I can on actors you say

#

That means I can just write another 'getter' function on my actor - that retrieves the correct type of UStruct

jolly siren
#

Does the ustruct have a hierarchy? Or just a plain ustruct that doesn't inherit from anything or have any children?

unkempt tiger
#

I plan on sending Snapshot as my RPC argument, which derives directly from UStruct

#

Oh, and.. in it, it holds this struct

#

Which holds the actual actor reference in squestion

#

And these actors need to derive from any ISnapshotInterpolatable : AActor

#

Or rather implement

#

God I probably explained it in the dumbest way that made no sense to you

#

Basically in my RPC_Implementation(Snapshot Snapshot) I want to do this:

#
void RPC_Implementation(Snapshot Snapshot)
{
   for (InstanceData : Snapshot.InstancesData)
   {
      ISnapshotINterpolatable* SnapshottedActor = InstanceData.ActorReference
      SomeClassThatDerivesFromISnapshotInterpolatable* AsSomeClass = cast<SomeClassThatDervicesFromISnapshotInterpolatable>SnapshottedActor;
      AsSomeClass->CallSomeLogic();
   }
}
#

@jolly siren

#

Will the casting work? Will I be able to call SomeLogic()?

jolly siren
#

As long as you aren't casting the ustruct itself it will work fine without doing anything

unkempt tiger
#

thank god, thanks

#

sorry for taking so long to properly form my question lmao

jolly siren
#

no problem at all

eternal anchor
#

if you want to replicate polymprhic ustruct

#

I suggest looking at FGameplayEffectContext

#

it's really easy

#

but requires some boilplate code to write

#

and have some limitations

unkempt tiger
#

perfect, thank you for this

#

I will surely need it at some point, so gonna pin that somewhere

twin juniper
#

Could someone explain how i replicate the Z axis on a multiplayer FPS template ?

dawn summit
#

I'm getting Null while requesting

Controller->IsLocalController()

on server character. It does work on clients however. I thought server has controllers too.

kindred widget
#

@dawn summit Listenserver setup?

dawn summit
#

yep -_-

kindred widget
#

The blueprint version returns fine, running it inside the character blueprint. Server prints true.

steady briar
#

any reason a newly spawned actor would be immediately pending kill?

dawn summit
#

@kindred widget well, i'm using c++ ;_;

kindred widget
#

They should be the same functions.

dawn summit
#

yeah, but i don't get why it's null

kindred widget
#

Did you check the controller reference?

dawn summit
#

wdym?

#

i can control the character, just in case

#

so it's obviously has one

kindred widget
#

It is odd that it would work on clients but not the listenserver, if you're calling it on the listenserver's character.

meager spade
#

you sure you have not got Dedicated Server ticked?

#

IsLocalController() returns true for me

#

in listen server as host

#

then again, not sure where you are calling that

#

you might be calling that on a the servers controller of a client

#

which will return false, as it should

#

you need to check LocalRole and RemoteRole

#

and make sure it is what you think it is

violet isle
#

are you trying to get the controller of a pawn other than the local one

#

the controllers for non-local players are not spawned

steady briar
#

ok i figured some of my problem. im trying to have an AI spawn another AI and attach it to itself. apparently its not wanting to stay attached, it falls through the world and gets destroyed. it was working before but obviously i broke something (or it shouldnt have been working before either). what is the proper way to attach an actor to a component on a listen server? doing this part in bp

warped stream
#

Why does it sometimes happen, that replicated objects on load don't update

#

They only update once my character (client) triggers them by moving them (e.g. stepping into them)

ivory marsh
#

Newbie question about GameMode lifecycle: I have an UE4 ThirdPersonCPP example running in Linux as a dedicated server with C++17 enabled. When i run the server, the GameMode subclass i have is created and it's StartPlay method is invoked. However, the Tick method is not. Is this because i don't have a client connected? If yes, is there a way to start ticking in the dedicated server without a client?

stoic acorn
#

here's a bit of a conundrum. I'm trying to determine how many unique actors of a certain class are dotted around my map using the AddUnique node, but it considers each and every actor (which are children of a master pickup class I created) to be unique. I would have expected a smaller number.

#

ah.. I would expect it to only have added 5 unique child classes, but I can see that it takes the full child name into account

#

hmm..

halcyon totem
#

can someone please help,? I made some code that changes my characters mesh material, and it works the clients can see the server change but the server cant see the client. why is this if I used the switch has authority

winged badger
#

and how would that allow a client to set the variable server side?

halcyon totem
#

i thought because when I press the button both have authority

#

so both should be able to see

winged badger
#

all input actions are local

#

server has no clue if you're holding a C key on your keyboard or not

#

for example

#

it has a vague idea where your camera is, that is it

#

so when you press whatever triggers the cloak

#

it executes only on the owning client

#

nowhere else

halcyon totem
#

so how do I make it do it on the server? I tried this but it didnt work

#

how can I make so the server sees the cloak also?

winged badger
#

those RPC calls need to be connected to input action

#

they won't get magically sent

#

and you should really call them ServerCloak and ServerUncloak

#

and start with word Cleint for RPCs that go Server->Client

halcyon totem
#

how can I connect the RPC to the input action there is no pins to connect to

winged badger
#

you call ServerCloak just like you would any other BP event

halcyon totem
#

oh cool it works!

#

im so happy this is my first time understanding

#

its a little like im learning unreal all over again

winged badger
#

now go to pinned messages, find exi's compendium and read that 5 or 6 times 😄

halcyon totem
#

yeah I was reading someones compendium and their graphs confused me

#

stuff like that confuses me

#

i understand better now

#

wait im still confused, now my server can but the clients cant see each other cloak

winged badger
#

first asggregate that

#

there is no point having IsCloaked and IsNotCloaked booleans

halcyon totem
#

but they are my repnotify I dont need them?

winged badger
#

also you can aggregate RPC to carry a boolean parameter

#

this is so you don't need 2 repnotifys

#

and they all ultimately execute the same 2 functions

#

Cloak/Uncloak

#

or Events

radiant jolt
#

You need to have a multicast function for cooking too

#

For server cloak you need to have a multicast cloak. Then connect server to multicast and make the multicast actually call the cloak

#

Do the same for uncloak

#

Also how’d u do the actual cloak it looks really good

halcyon totem
#

@radiant jolt I set them both to multicast but the client still cant see the other clients cloak

radiant jolt
#

No you still need the server

#

So make a new custom event under server cloak

#

Call it multicast cloak

#

Then make server cloak call multicast cloak

#

And make multicast cloak call the cloaking function

#

Do the same for uncloak

halcyon totem
#

yeah it works!

#

thanks so much I learned alot

#

this is my first thing I got working in multiplayer

radiant jolt
#

You can delete stealth and unstealth after the server event

#

But yeah ofc multiplayer can be so tricky

halcyon totem
#

ok cool

#

yeah its still weird but at least I have a reference now

radiant jolt
#

Why is it weird

mystic hull
#

(i know i have been asking alot in the past few days, i am sorry about that)

#

this is my current bluerprint which is setting Aim offset

#

the problem is , when setting this value (pitch and yaw) i check the role first

#

if it's server then set the value, (and both the 2 values are replicated)

#

if not server, it will fire up the event, which is then called by server that will set the 2 values

#

again both the 2 values are replicated

#

the error is:
the client can rotate correctly in its own view and at the server's screen , it's correct

#

but the server is rotation correctly in its screen, but in the client's it is not.

#

The event just calls the same fn , that's called by the server

#

and the role i am branching on , is the role of the local player

#

if anyone knows i will be grateful

valid imp
#

I have a Procedural Mesh Component that is an obstacle for players/ennemies/projectiles/whatever, does it mean that the server should have the mesh data too or is the position just sent as-is to the server by clients?

stoic acorn
#

Shouldn't it always be that the server has the data and sends to the client? I thought that's how Unreal MP works

cyan current
#

There is no need to replicate look rotation if that's what you're doing. It is already replicated by default. You would only need something like this: @mystic hull

mystic hull
#

@cyan current this is my issue

cyan current
#

The screenshot I posted above fixes that problem @mystic hull

#

I'll be home in about 20-30 min and then I'll show you a quick example

meager spade
#

i never replciated pitch

mystic hull
#

I> i never replciated pitch
@meager spade if I don’t replicate it, it’s not updated in the client

meager spade
#

let me show you my bp

#

hold on

mystic hull
#

The screenshot I posted above fixes that problem @mystic hull
@cyan current i will add them right away, but I don’t really get why what i did didn’t work

cyan current
#

Disable the replication from your aimpitch and aimyaw, it's not needed

meager spade
#

and NEVER

#

replicate inside the animbp

#

ever.

mystic hull
#

Should i make it in c++ class and set it there replicated then expose it?

meager spade
#

no

#

you dont need to replicate anything

#

for pitch and yaw

#

my editor is loading gimme asec

mystic hull
#

Thank you

meager spade
#

you have c++ base for your character?

mystic hull
#

Yes

meager spade
#
{
    float ClampedPitch = (RemoteViewPitch * 360.f / 255.f);
    ClampedPitch = ClampedPitch > 90.f ? ClampedPitch - 360.f : ClampedPitch;
    return FMath::Clamp<float>(ClampedPitch, -89.f, 89.f);
}```
mystic hull
#

And i i will make this blueprintcallable and use it for the pitch, correct?

meager spade
#

yea

mystic hull
#

I will try that right away , i just woke up😂

#

It’s frustrating tho why the bp above doesn’t work, I really tried everything

#

Okay last q, why isn’t it a good practice to rep in animBP

meager spade
#

cause its not for replicating

#

no rpc's, no replicated props

#

animbp should really be a one way street, take data in, process it

chrome bay
#

I really wish Epic would block you from creating replicated properties or RPC functions in non-replicated classes.

#

Would save a lot of this confusion.

unkempt tiger
#

Can I change who (server or individual clients) has the authority over my actors dynamically?

bitter oriole
#

Depends what you mean by authority

#

RPC ownership, sure

#

Using SetOwner on the server

meager spade
#

seems a bit stranghe

#

if you want clients to have authority, just set them as not replicated

#

client can never replicate stuff

mystic hull
#

the servers moves now are replicated correctly to the client

#

and when the client rotates, it moves correctly in the server

#

but it doesn't do the animation in the client

#

it's weird, in dedicated servers , each client can see the animation of the other but not itself

meager spade
#

hmm

#

it should work

#

let me test

mystic hull
#

i added this to the character blueprint

#

and in the animation blueprint, i would cast to that character and set the AimPitch to that value

#

it works, but it's all jitter-y when the server plays the client's animation

#

but the client can see the server all smooth

chrome bay
#

You don't need to do any of that

#

the engines Character Movement system already handles the aim pitch

#

Just use GetBaseAimRotation() from the pawn class.

#

It'll give you the control rotation if you are the pawns owner, or the remote view pitch if you aren't.

mystic hull
#

call that in the animation blueprint?

chrome bay
#

GetBaseAimRotation() is part of APawn

#

So you can access it via the animation blueprints "owning pawn"

unkempt tiger
#

@bitter oriole thanks for replying, I meant - when I spawn custom actors by default, it seems that HasAuthority() is only true for the server, not the client

#

I was wondering if there was a way to set it so it returns false for the server, and true for the client

chrome bay
#

Yeah that's correct

#

HasAuthority() won't be true on a client unless the actor was spawned locally by that client.

unkempt tiger
#

Oh, in which case said instance isnt created on the server

#

Oof

chrome bay
#

Replicated Actor Spawned By Server:
Server: HasAuthority() == true;
Client: HasAuthority() == false;

mystic hull
#

okayyyyyyy thankfully this replicates well and the animation works, but it just kinds snaps to some value

chrome bay
#

Authority is not the same as being able to call RPC's though.

mystic hull
#

i will try and clamp it

unkempt tiger
#

Aye, thanks @chrome bay

mystic hull
#

holy shit

#

i love you

#

😂 i just hate how you don't know why something doesn't work but oh well

chrome bay
#

Basically the Character Movement system already sends the players control rotation as part of the network movement (it has to for prediction etc.)

#

So it's already doing it all efficiently for you

mystic hull
#

thank you so so much

dawn summit
#

Greetings!

#

Question.
I have a function that is replicated, prefixed with Server_
Does this function being called locally as well?

mystic hull
#

Server funcutions are called in the server as i understand, so if the server does edit a variable or something, and that variable is replicated, the effect of that replication will be shown locally

#

Server_ChangeNumTo3
or something like that, means that the variable "num" will be equal to 3, on both the server and the client, IF, num is set to replicated

void mantle
#

Hi all anyone able to help point me in the right direction when it comes to networking. Trying to learn how to implement tcp/udp system for a client to server with a sql database for stats and inventory storage. I know its bad to let clients have direct access to the sql database but what about the server. I am alittle confused on this. Doesnt the client connect to the game server directly and then the server send the info to the database?

bitter oriole
#

Client connects to the game server, game server connects to database server that authenticates the game server as one of your own dedicated servers, database server does transactions with the database

#

You can have clients connect to the database server, too, as long as you allow no changes

void mantle
#

So clients would just recive the info from the database while be locked from directly sending to it

#

Would it be ok to directly incorporate the database into the dedicated server rather then lets say sending info to it from the server using varest? This being that the game server and the database are on the same system.

bitter oriole
#

It would make sense if you know your game will never have more than one dedicated server

#

Or it the database doesn't need to be saved after a game

#

(but why would you use a database then ?)

void mantle
#

Persistent world storage so players can come and go.

bitter oriole
#

That's probably not a great idea because players would be locked to a single server after they start playing, and if other players on the server stop playing, they'd be alone forever

void mantle
#

Why would the database be locked to one dedicated server? Couldnt you implement it to be used the same way for others all on the same physical system?

#

Like each dedicated server spins up a level

bitter oriole
#

Would it be ok to directly incorporate the database into the dedicated server
Why would the database be locked to one dedicated server

#

So which one is it

void mantle
#

Maybe i am wording it wrong bear with me. I believe there is a sql plugin for the ue4 engine so the database being sql would be correct no matter the level. The players inventory and stats would carry over while transferring to the new map/server

bitter oriole
#

Here's the deal basically :

  • either the database should be shared between dedicated servers (player inventory could be transfered between servers, this is basically what most games do)
  • or, the database should be unique to each dedicated server (all progress lost if you change server, if the server is full you can't play)
#

If you're doing the second version, yes, get a simple database plugin for UE4 and it'll work fine

#

You don't even need a database for that really, a simple json save would do

void mantle
#

Ah ok yeah in the end i need a shared db i was thinking if you attached each game server to the same one that would be it. Ok so then that probably wont work correct?

bitter oriole
#

Then you need an autonomous database server software that owns the database and talks to the game servers

#

It can run on the same physical server if you don't have multiple physical servers

void mantle
#

Yeah right now this is all for me to learn how it works. I have 1 pc and one over kill server to play with.

#

I am getting aheqd of myself with multiple dedicated servers when i just need to learn how to make the one talk to the database and client. I have seen an example of the varest plugin sending json to a php file that writes and reads from the data base. I wanted to see if i could do the same using tcp/udp sockets for better performance. (Got side tracked in thinking that i could bypass the middle man and incorporate the database directly with the server provided the client doesnt have direct access to the database.

bitter oriole
#

Save yourself some pain and send the JSON over HTTPS

#

Both built-in into UE4 and extremely trivial to use in php

void mantle
#

Whats the limitation on sending the data that way?

bitter oriole
#

Why would it have limitation ?

void mantle
#

Hmm is there any examples or documentation about this i would like to learn more

#

And thanks again for helping answer some of my questions 😊

stoic acorn
#

Is multiplayer, in general, quite broken in 4.25.0?

#

I'm not seeing anything in the debug Filter for my BP_PlayerCharacter1. Also it says (Server). This isn't right, or is it

#

If I've selected BP_PlayerBase (Server) and I press E to trigger this What's in my Vault function I see this

#

If I've selected BP_PlayerBase1 (Server) It doesn't seem to trigger. meaning.. I can't see the glowing lines that indicate the flow

violet cave
#

I'm having issues out of nowhere with RPCs

#

I've created a "lobby" gamemode and in the player controller (pawn currently because I got frustrated) I have the following

#

Inside the PC is the same thing, except the event is being called from a UI

#

For some reason when attempting to call ReceivePawnReady or ReceivePawnLockin in the case, it doesn't call the serverside function

#

ReceivePawnXXXXX gets called properly, including when it was just functions on the controller

#

But ServersideXXXX never works (when called from the client)

violet cave
#

When called from a listen server host, all is fine

#

I'm actually frustrated what I've done wrong

meager spade
#

where are those RPC's?

#

PlayerCharacter? PlayerController?

#

@violet cave

kindred widget
#

Looks like a Pawn.

meager spade
#

where do you see that?

violet cave
#

Currently it's a pawn

meager spade
#

ah nvm

#

i see now

violet cave
#

But I had the same events on a PC minutes ago

meager spade
#

so it should work

#

in controller or pawn

violet cave
#

It doesn't

meager spade
#

as long as the pawn is possessed by a controller

violet cave
meager spade
#

well, where are you calling them

violet cave
#

Currently, the UI calls an "owning client" event on the PC, the PC calls the client event in the pawn

meager spade
#

why is UI doing Owning client?

violet cave
#

I didn't have the pawn previously, it was just a last ditch effort for me to tryr it

meager spade
#

UI is LOCAL only

#

no need for it to call a Client RPC

#

its already local

violet cave
#

I was mostly safeguarding it with that

meager spade
#

from what?

#

its redundant

violet cave
#

I dunno, just habits I guess

meager spade
#

well you need to break point your flow

#

and see where its failing

violet cave
#

I've opened in debug, it attempts to call the event

#

And then nothing happens

meager spade
#

and in the log

#

when it does

violet cave
#

I'll try to screw around more and see if something gets fixed

meager spade
#

any warnings/errors?

violet cave
#

Nope

meager spade
#

if a RPC fails, it prints to the output log

dawn summit
#

Noob question. How to request destroy actor on server?

#

Now i'm getting warning it does not have related network connection

dark edge
#

Just call destroy actor server side. What are you doing now?

dawn summit
#

i'm calling an RPC, that calls a Destroy actor...but...it doesn do do anything

violet cave
#

It seems like I managed to fix it but I'm still confused NotLikeThis

meager spade
#

you have to call the RPC on a controller

#

or pawn

#

you cant Server RPC from an actor not owned by anyone

#

hence the warnings, No owning connection @dawn summit (i am assuming that is what you are getting)

dawn summit
#

@meager spade that is correct

meager spade
#

so Server/Client RPCs only work on actors that are owned by a owning connection

#

ie, they must be owned by something which eventually goes back to PlayerController

#

Multicasts can work in any actor

#

cause they don't care for a owning connection

#

but has to be called on the Authority

dawn summit
#

thank you

graceful cave
#

what protocol is the best for sending files to a client before they connect to a server? ftp? http? tcp?

#

is it possible to have the http server only be available to certain clients?

#

to prevent anyone from opening it up in their browser and spamming downloads

#

cool thanks

#

ill check it out

hearty atlas
#

unreal has cURL built into it somewhere, which should do HTTP well.

autumn mountain
plush wave
#

Sessions are not matches, right?

unkempt tiger
#

Is there any need to serialize stuff before sending it as an argument to an RPC? Obviously there’s already serialization going on in the engine under the hood

#

Can it perhaps provide better compression control?

meager spade
#

well

#

if its a lot of stuff

#

i normally wrap it in a struct

#

with a custom NetSerialize

#

or if im sending Rotation/Vectors i use Quantize version of FVector

#

(even for rotation, if i don't care for the extra precision)

unkempt tiger
#

OH

#

Wait wait

#

So if I got it right

#

Using a UStruct will have the engine automatically take care of everything having to do with serialization?

#

And serializing only becomes a requirement when working with a normal cpp struct?

#

@meager spade Do you mind sharing an example of how you went about serializing one of your structs if you're not too busy? There ARE examples on Google but every additional example is blessed ohfukyes

meager spade
#

well it depends on what data im sending

#

USTRUCT's can have custom serialize

#

i would look at some engine examples

#

that is what i did

#

to have a feel for how it works

unkempt tiger
#

And are these custom serializations called automatically by the engine?

meager spade
#

check FHitResult

#

in the engine

unkempt tiger
#

Oh! Will do, thanks

meager spade
#

it has custom serialization

unkempt tiger
#

I suppose that requires writing a deserialization as well?

meager spade
#

its in the same function

#

you check Ar.IsSaving() bool

#

for Saving/Reading

#

Ar.IsLoading() is also another one

#

it goes through the same function

#

but honestly FHitResult one has some nice examples

unkempt tiger
#

Thanks a ton, gonna look there

#

I guess when you implement NetSerialize on UOBjects (Is FHitResult a UObject?) then the engine recognizes and calls it automatically?

#

And that's just really for compression?

floral crow
#

Hi Everyone! I'm new to the server. Glad to see so many people helping each other here 😍 I have the following question about something I've been struggling with quite a lot:

What is a proper way to create a replicated Actor on the server that has to initialize itself dynamically and make sure replicas spawn on clients with that data already initialized (same data as the server copy). I don't want this dynamic initialization to rely on replicated properties/RPCs as they may reach the client either too late (replicated property) or too soon (RPC).

winged badger
#

in blueprints, its ExposeOnSpawn, in c++ its SpawnActorDeferred or SpawnActor with bDeferrContruction = true in FActorSpawnParameters @floral crow

#

in every case, all replicated variables set in the Tick the Actor is spawned server-side are sent in the same bunch as the instructions to spawn the actor

#

and will be set, and replication callbacks called before client calls BeginPlay

#

the ExposeOnSpawn/ Deferred Spawn lets you use the same BeginPlay logic on client and server, as those two methods will set the variables before beginplay

#

which i highly recommend, its easy to lose yourself when you have to branch and do completely different BeginPlay logic based on authority

floral crow
#

I'm looking into SpawnActorDeferred, looks like it is exactly what I needed. Thanks @winged badger !

grizzled stirrup
#

If you have many spawn point blueprints placed in the world that are used by the server to spawn stuff but don't really serve any purpose on the client, should they be destroyed on the client at beigin play for the client only or is there no real drawback to having lots of hidden actors that aren't ticking on the client?

floral crow
#

I see a bunch of potential problems with that approach @grizzled stirrup :

  1. Clients get to know about things they maybe shouldn't (potential for cheating?)
  2. Network bandwith consumption if these have any replicated property. You'd be sending unnecessary packets to the clients. If there's too many of those you can end up causing lag for no reason, or even worse if it's a mobile game as they might be consuming their internet quota for no reason.
  3. Susceptible to bugs... unnecessary work to make sure you destroy them right away which you can forget or get wrong.
grizzled stirrup
#

Thanks for the answer @floral crow

  1. Cheating is not a concern here (co-op)
  2. They don't have replicated properties and are just blueprints placed in the world to indicate spawn locations
  3. This counters the first two points since if they weren't destroyed then they'd exist in the world on the client and thus potentially be causing the mentioned problems
#

I wonder if it's possible to just have a blueprint be server only even though it's placed by hand in the world

#

Without manual destroying because I agree it is a messy solution to keep track of what should be destroyed manually

#

The hand placement is important as it defines where things will be in the game and can't be done through code on the server at runtime

#

But by placing blueprints by hand, they then exist in the world for both server and clients

floral crow
grizzled stirrup
#

Oh that's exactly what I was looking for

#

Thank you so much for the help!

floral crow
#

Hey @winged badger I have an issue with DeferredSpawning as I need the actor to initialize some members itself. I'm looking into lifecycle methods (PostActorCreated and similar). If there any lifecycle methods where if I set a replicated property the client replica will get that value before its BeginPlay fires?

I'm not sure if I understood correctly from what you said: The network message that tells clients to spawn a replica is sent at the end of the frame (hence sending each replicated property's current value within it)?

meager spade
#

yes Deffered spawning

#

everything you set will be replicated to clients

#

before beginplay

#

as long as it is a replciated property

winged badger
#

and its 100% reliable, as its the same bunch

#

no adverse network conditions will screw that up

floral crow
#

Problem with deferred is that I would have to expose private members so the external class requesting the spawn can set them

meager spade
#

use setters

winged badger
#

then expose a set or initialize function

floral crow
#

I want the spawned actor to initialize some private properties itself

#

Yeah, I was trying to avoid that

meager spade
#

or make a function

#

in the actor

#

that does it

#

you cant

#

there is no other way round

floral crow
#

no adverse network conditions will screw that up
@winged badger This is actually great to know. Thanks

meager spade
#

either make the props public or make a public function

winged badger
#

once you call spawn actor, if its not deferred

#

you can't do anything before it calls BeginPlay

#

with exception being that BeginPlay hasn't been dispatched on the world yet

#

sure, some of its functions are virtual, and get called before BeginPlay

#

but that doesn't help a lot when the initialize information is not something that Actor should know

#

@floral crow note that while a pointer to replicated UObject will replicate before the Actors BeginPlay

#

that doesn't guarantee that the object itself did already replicate, especially on the start of the game when you spawn alot of stuff

floral crow
#

I was about to ask you about pointer replicated properties

winged badger
#

the actors you are 100% sure are on level by the time non-delayed BeginPlay is called are GameState and actors loaded from the package

floral crow
#

That makes sense..... phew, this multiplayer game initialization part is killing me

#

What do you mean by loaded from the package

winged badger
#

as long as you are not using GameState base, DispatchBeginPlay on the World is called from OnRep_MatchState in GameState

#

so no actor will start play before that replicates over

floral crow
#

We are using GameStateBase

winged badger
#

i suggest switching to GameState, much more manageable

#

loaded from the package = pre-placed on the world

#

they come with an interesting perk

#

all of them, as well as any default subobject on them are net addressable, even if they are not replicated

#

so a pointer to them can be resolved over network

floral crow
#

That's good to know, though in this case these are all actors spawned at runtime (entities in an RTS game)

winged badger
#

we procedurally generate the entire level, and lie to the engine to convince it actors are loaded from the package

#

with 35k actors spawned into the level, only 800 or so are replicated atm

floral crow
#

Wow, how do you that? Have you tweaked the source engine? (for faking the load from package)

winged badger
#

leveraging concept of net addressing without replication is probably the best way to save on bandwidth and actor consideration times

#

we did not

floral crow
#

leveraging concept of net addressing without replication is probably the best way to save on bandwidth and actor consideration times
Could you suggest me places to learn about this?

meager spade
#

lying is a understatement

#

we actually lie to the engine about our player pawns aswell 😄

winged badger
#

for trickier networking, having chats about it here is the best place imo

#

there are very few resources for it

meager spade
#

normal replication is easier to manage tho

#

also adds cost to the players

#

the server sorry*

winged badger
#

definitely recommend reading NetSerialization.h header

#

half of it is comments

meager spade
#

net dormancy is also another headache

winged badger
#

my problem with dormancy is that it does a shit job combined with relevancy when you turn it on mid game

floral crow
#

haha ok, I really appreciate your help @winged badger @meager spade . I'm gonna look into NetSerialization.h

winged badger
#

can't turn dormancy on per connection

floral crow
#

I'll need help once I move into relevancy as well. I'm planning to hide actors inside Fog of War by cutting their replication for a particular client and I'm not entirely sure how to achieve that

winged badger
#

you need a buffer

#

anything not loaded from package that enters net relevancy is spawned anew

#

on clients

next fable
#

Hey guys ... trying to update spawned players with properties stored in their PlayerState.
All I'm doing is EventPlay->CastToMyChar->UpdateStuff

My conundrim is that .. I can only get it to work if I insert some delay. I sure wish I could find the right entry point/event to not use a delay.

winged badger
#

PlayerStates come with default NetPriority of 1 while Pawns and Controllers have 3

#

so, barring any packet loss, PlayerState actors will replicate after Pawns and Controllers

real cedar
#

Is it not possible to test in a Dedicated Server environment from the editor anymore in 4.25?

winged badger
#

BP solution to your problem is putting a RepNotify variable of your PAwn's type in your PlayerState

#

and do from inside the OnRep

#

server would have to set the variable at the time of spawning the Pawn, i recommend a HandleStartingNewPlayer override in the GameMOde

#

(do not forget to call Parent function, unless you have a very good reason not to for that one)

#

@real cedar if the checkbox is gone from play dropdown, check Advanced Play Options

next fable
#

I actually do have a rep-notify of my Team in Player State. It works fine when the player choses the new color.
The problem I'm having is when a new player joins, the existing players are not updated.

real cedar
#

@winged badger I have gone in there and the only option I could think that would be close to dedicated server would be "Launch Separate Server". I think I'm wrong but I am not sure what else it could be.

next fable
#

but I will checkout HandleStartingNewPlayer in GameMode... that's a new one.

winged badger
#

you do need to call it after both PawnPrivate and TeamColor have replicated

#

this would give you OnRep for the Pawn

next fable
#

would OnPostLogin be the place for that?

winged badger
#

there is an OnRep for it, but its c++ only

next fable
#

I am using C++

#

for the most part

winged badger
#

HandleStartingNewPlayer is called immediately after PostLogin

#

but its also called after SeamlessTravel

#

so works in both cases

#

the HandleStartingNewPlayer_Implementation is where the engine calls Restart() which actually spawns the Pawn

#

so if you're not using custom spawning logic you need to assemble your object graph after Super/Parent call, or there will be no Pawn around yet on server

#

Pawn has OnRep_PlayerState and PlayerState has OnRep for Pawn, in c++

#

so you can use either to get your timing right

next fable
#

Ok thanks... I will try to digest this

winged badger
#

delay is never required to get the construction to work

#

we procedurally spawn networked level with 35k actors without a single delay

#

and everything connects just fine

next fable
#

Sure I know it's not right

wicked brook
#

I posted in VR channel but its relevant here also. So i have a VR character that gets spawned into a server map. If i run in editor, he spawns correctly. Live on server, he gets spawned under the map. Any ideas anyone?

winged badger
#

you'll have to be a lot more specific then that

#

how do you spawn it?

next fable
#

@winged badger I set this up and it works.. but only for the Listen Server instance

winged badger
#

ah, i was thinking you set a replicated variable on the Pawn or PS from there so you can get OnRep

#

while i was still under the impression its BP only

#

as after parent call

next fable
#

I have C++ backend.. I just wanted to get it working in BP

winged badger
#

PC, PS and Pawn are all there and valid

next fable
wicked brook
#

Nevermind i found out why. LOL my spawn logic on server map bp got deleted

floral crow
#

@meager spade @winged badger I overrode PostActorCreated on the spawned Actor and did the initialization there. PostActorCreated runs before the call to FinishSpawning so any replicated property is guaranteed to have the right values as soon as the client replica is created. This way I avoided exposing private members or having a public Init method!

meager spade
#

Yeah I forgot about that

#

Well least ya got it done

exotic axle
#

Is there a way to statically place an Actor on a map, but only on the server instance?
I'm trying to put a spawner on the map, but if I do it statically in the editor, it'll run on every client.

foggy hinge
#

@exotic axle Make the Actor not replicate and turn off net load on client

exotic axle
#

Doesn't seem to work

#

This is my code on the spawner. It somehow spawns different sets of characters. Also for some reason when I try to put a breakpoint on it, it only ever runs once

#

Oh I figured it out. I unchecked Auto Connect to server so my two instances were each running on their own servers ugh that makes sense. Thanks for your help!

worthy knot
#

Does UE4 provide an anti cheat?

bitter oriole
#

No

worthy knot
#

But i keep seeing this thing called Easy Anti Cheat in UE4

#

In some folder

bitter oriole
worthy knot
#

Thanks

odd iron
#

Hello Guys if i want to make Dedicated Server for my game ..
i've downloaded SpatialOS UE4
but can i use the same Project repository or do i need to use another repository for dedicated server ?

bitter oriole
#

Same project... By the way, you don't need SpatialOS

odd iron
#

Are there easy way ?

#

I wanted to host it so the host will be other pc so i can test the replication since im still newbie learning

#

not very experience

bitter oriole
#

There is nothing easy about dedicated servers, but dedicated servers are an UE4 feature

#

If you're a beginner I would suggest to use listen servers instead

odd iron
#

But how can i host it to another or virtual machine

#

so i can keep it running just restarting when updating

bitter oriole
#

If you want that, then you do need dedicated servers, but I have to insist that for a beginner, it's quite a lot of hard work

#

You'd rent a virtual machine and put your server there

odd iron
#

Yes im not 100% beginner 6852_whistling

#

i have like 20-30% knowledge xD
but if you don't try the hard you will never learn it right ?

bitter oriole
#

You can learn about airplanes without building a 747 first

odd iron
#

i thought SpatialOS doing the host and deployment stuff

bitter oriole
#

No, it does more than that, and at a larger cost

odd iron
#

oh larger cost

#

Stranger Can the VPS solve this ?

bitter oriole
#

Solve what ?

#

If you want to host your dedicated server, yes, you should rent a VPS on put it there

odd iron
#

ok cool

bitter oriole
#

Well I don't know about cool, you'll need to produce Linux builds of your dedicated server, find a way to deploy them to the VPS etc

odd iron
#

i will try my best 😄

#

thanks mate ❤️

unkempt tiger
#

Does it make sense using Fast TArray Replication using NetDeltaSerialize for an array sent via an RPC, or is it mainly for properties?

winged badger
#

the benefits of a fastarray are its able to send an item at a time, when required, and execute client side callbacks

#

none of those do any good as a payload in an RPC

lunar root
winged badger
#

persisting works fine, altho if your destination map doesn't have the same GameMode class, a new one gets instantiated

#

whatever that guy was doing was pointless

#

GameMode->GetNumPlayers-> For (Index = 0 to NumPlayers-1)-> GetPlayerController[Index]

#

works just fine, and is a safe use of GetPlayerController[Index]

lunar root
#

My Target map didn't have any GameMode set

#

So when I set the same GM class the instance persists?

winged badger
#

there is a TravelMap as well

#

the one unreal loads while it unloads the map you travelled from

#

you also need to have the seamless checkbox checked on the departing GameMode

lunar root
#

TransitionMap u mean, I didn't make one yet since the documentation states that when none is set it creates a temporary one

#

Although I don't trust the documentation anymore after this xd

winged badger
#

i always find it better to be explicit

lunar root
#

So when I set the same GM on TransitionMap & Target Map it should persist?

winged badger
#

yeah

#

if you ticked seamless on

lunar root
#

Hm.. means for every GM I need a new TransitionMap map ?

winged badger
#

there is only one transition map, and honestly, im not sure it will reinstantiate the gamemode if its different

lunar root
#

Well I did bUseSeamlessTravel = true in the constructor , should work

winged badger
#

i have a gamemode for lobby and combat levels, its never the same GM at origin/destination

#

i did have to teach the travel level to persist my MIssionSetup actor, though

lunar root
#

Well I want a GM for Character Selection and then pass the selected Characters to the new GM but I didn't know how to

#

So I thought using the same GM for both is the way

winged badger
#

as it did not do that by default

#

your best bet is CopyProperties in the PS

lunar root
#

Wdym exactly?

winged badger
#

when your players select their character in your lobby

#

that gets RPCed to the server

lunar root
#

Correct

winged badger
#

well, you have to RPC it

#

if you want your other players to know about them

lunar root
#

And then I need to pass the selected Characters to the next GM somehow

winged badger
#

that information needs to be replicated either in the PlayerState, or the PAwn

#

if you choose PlayerState

#

even if you swap out the GameMode/PC/PS classes between levels

lunar root
#

Let's assume I want to make 2 different GM, 1 for Character Selection which basically just handles that and stores the selection in a TMap

winged badger
#

each time a new PS is instantiated, it calls CopyProperties to transfer the values you want to keep from the old instance (which may be of different class)

lunar root
#

And the BattleGameMode which has to spawn the characters from the TMap, how would I pass the TMap to the new GM

winged badger
#

when travel starts, server has all the information in all the PlayerStates

#

as it transitions, new PlayerState is created, and its PlayerData gets copied over via CopyProperties function

#

you load the next level via seamless

#

controllers call NotifyLoadedWorld, then ServerNotifyLoadedWorld, which is a Server RPC

lunar root
#

This also works when the PS are of different classes?

winged badger
#

after that GameMode calls HandleSeamlessTravelPlayer

#

which will reinstantiate the PC/PS for that player if its of different class

#

and also call CopyProperties

#

on the PS

#

after that GM calls HandleStartingNewPlayer

#

its default implementation just calls RestartPlayer() which spawns default pawns

#

but when that function is called, you have a valid PC & PS of the new class, with PS holding data copied over from the previous level

#

if you call Super/Parent at this point, you also get a Pawn

#

or you can custom spawn one, doesn't matter

#

after that it should be fairly simple

#

the CopyProperties will work only ServerSide, the client side PlayerStates would need to rely on replication to get that Data

lunar root
#

Hmm. The problem is I don't store the selected Character in the PlayerState atm because I don't want the enemy to receive the selected Character until the game starts. So I made an custom actor and only allow replicating when the game starts

#

Is there a way to make this actor persistent?

winged badger
#

you can just go around it by LobbyPlayerState replicating that data to OwnerOnly, and BattlePlayerState to everyone

lunar root
#

Yeah, but the teammates also need to see what you picked to gray out the button

winged badger
#

it can be done with or without persisting the actors to specifically hold the info

lunar root
#

I think I could override the IsNetRelevantFor for PS to not send the PS to the enemy

winged badger
#

that might be weird

#

because you'd affect the engine PS functionality that way

lunar root
#

If I could just "hide" a single field

winged badger
#

you can make a small TeamSetupActor

#

thats relevant only to the team with same ID

#

and persist it

lunar root
#

yeah that's pretty much what I have

winged badger
#

as GameMode will do a poor job replicating stuff to clients

#

well, put a breakpoint in GetSeamlessTravelActorList

#

in GM

#

see what happens when you step through

#

it won't take you long to figure out what adjustments you need to make

lunar root
#

But this would mean that the GM itself also has to persist right?

winged badger
#

you would do that by attaching a debugger to uncooked standalone launch, would be the simplest way

#

no

#

i persist my MIssionSetupActors even with my GameModes being different between levels

lunar root
#

So the Method gets called even tho the GM does not persist?

#

Okay imma give it a shit

#

Shot***

#

xD

winged badger
#

its just the Lobby GM needs to persist it to travel level, and Travel GM (can be same) to desitnation level

lunar root
#

Ahhhh I got you

#

Okay I'm gonna try it, thank you btw :)

unkempt tiger
#

the benefits of a fastarray are its able to send an item at a time, when required, and execute client side callbacks, none of those do any good as a payload in an RPC
@winged badger Thanks for replying, though I do not understand why it won't be good for a RPC, could you explain?
What if I have a permanent array that I keep on changing over the course of a game, and I continuously send it through RPCs to clients? Would it not make sense then to use FastTArrayReplication?

river hazel
#

i think the FastTArrayReplication is for a replicated variable not an RPC, if im understanding it correctly

unkempt tiger
#

I definitely imagine it being designed primarily for replicated variables, however I'm not exactly sure what limits its usage just to replicated variables

winged badger
#

if you send fastarray through the RPC

#

you send the entire fast array

#

there is no delta then

unkempt tiger
#

Where does the delta originate from?

#

Is it through ACKs in the TCP protocol?

winged badger
#

i recommend you give NetSerialization.h a read

unkempt tiger
#

(For replicated variables that is)

winged badger
#

as half of it is basically docs in comments

unkempt tiger
#

I'll do that, thank you!

unkempt tiger
#

@winged badger Just read it all, but I am still confused about where RPCs fit in the picture! And I'm currently working with them alone, so I really wana get this straight. Is it true that seemingly all these topics discussed in NetSerialization.h...:

 *    NetSerialize & NetDeltaSerialize
 *    Base States and dynamic properties replication.
 *    Generic Delta Replication
 *    Custom Net Delta Serialiation
 *    Fast TArray Replication

... have to do with replicated properties, and less with RPCs? And if so, what parts if any have to do with how RPC data is serialized?

#

If I implement my own NetSerialize() function for my UStruct, will that still be called when passing the struct through an RPC?

#

It's just, the word 'RPC' wasn't mentioned even once in NetSerialization.h

lunar root
#

@winged badger my traveling seems to work now and my TeamActor persists, thanks you :).

Just a little side question, you got a good way to test such things?
Because PIE doesnt support ServerTravel so I have to use Standalone Game to test, but this doesn't give me an outliner like the editor does.
So i had to make an debug print which prints how many actors are in the world which is quite annoying

dark forge
#

Why do people use blueprints?

bitter oriole
#

Well it is one of the main selling points of the engine

#

Fast iteration, designer-friendly language, can access all of the engine API

#

It's pretty much the main way to tie content to features, too

winged badger
#

@lunar root i attach a debugger to standalone, put in breakpoints and see whats going on

#

debug UI is also an option

#

takes 10 minutes to make a widget that would display your team actor's data and wire it into the HUD

#

won't be pretty, but it will serve its purpose

dark forge
#

@bitter oriole I don't like to think professional devs use drag and drop blueprints

bitter oriole
#

Professional developers use Blueprint externsively, why wouldn't they ?

#

Hell, much of Fortnite uses it

#

If you're scripting a unique weapon or adding animation to a character, using C++ for that would be a huge loss of time

#

Not to mention needing a costly programmer that you don't have enough on the team already

dark forge
#

Oh, okay.

#

So it's all just 100% blueprints?

#

lol

bitter oriole
#

Of course not

#

Depending on the game, it can be 90% C++, or 90% Blueprint

#

For example the weapon class can be C++ to deal with the multiplayer accuracy, anticheat etc, and have Blueprint override the GetDamage function to plug a curve asset in it

#

Typically that sort of thing goes 10x faster in Blueprint

unkempt tiger
#

best distribution is C++ does the backend stuff, blueprint is reserved for content setups and more 'front end' game scripting

winged badger
#

some things are very impractical to do from c++, like using a Timeline

rose egret
#

why I get this warning:
LogProperty: Warning: Native NetSerialize StructProperty /Script/Desolation.DezHitPackSimulated:TraceNormal (ScriptStruct /Script/Engine.Vector_NetQuantizeNormal) failed.

``
USTRUCT()
struct FDezHitPackSimulated
{
GENERATED_BODY()

UPROPERTY()
FVector_NetQuantizeNormal TraceNormal;
UPROPERTY()
bool bChanged;

};
``

#

UPROPERTY(EditDefaultsOnly, ReplicatedUsing=OnRep_FirstHitPack) FDezHitPackSimulated FirstHitPack;

#

oh my GOD FVector_NetQuantizeNormal ctor does nothing

dark forge
#

Can I make a single shard mmo in unreal engine

#

and can any recommend any c++ and unreal engine tutorials?

cyan current
#

Youtube and Google is your friend

bitter oriole
#

@dark forge No, you can't build a traditional MMO in UE4.

dark forge
#

What's this supposed to be then?

rose egret
#

I have a replicated property. I change it every 3 seconds on server. but clients don't get it most of the time. nearly 30% loss. thats so weird.
I am testing in PIE and the ping is too low and there is no congestion or heavy task.
I checked all the settings like (Relavancy, NetUpdateFrequency,...) all are ok.

``

USTRUCT()
struct FDezHitPackSimulated
{
GENERATED_BODY()

UPROPERTY()
FVector_NetQuantizeNormal TraceNormal;
UPROPERTY()
uint8 Counter;

};

class ADezWeapGun : public ADezWeapBase
{

//property in ADezWeapGun
UPROPERTY(EditDefaultsOnly, ReplicatedUsing=OnRep_FirstHitPack)
FDezHitPackSimulated FirstHitPack;

void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);
    
    DOREPLIFETIME_CONDITION_NOTIFY(ADezWeapGun, FirstHitPack, COND_SkipOwner, REPNOTIFY_Always);
}
void CahngeData(const FDezHitPack& hitPack)
{
    FirstHitPack.TraceNormal = hitPack.TraceNormal;
    FirstHitPack.Counter++;
}
UFUNCTION()
void OnRep_FirstHitPack()
{
    //this is not call properly as expected.
}

}

``

lost inlet
#

what's with the meme that everyone's first project in UE4 is an MMO

#

you should really think smaller if you're unfamiliar with the engine

bitter oriole
#

You really should think smaller regardless

rose egret
shy kelp
#

@dark forge its not designed for mmo but its possible, however, with limited knowledge its kinda foolish to start making one. I would recommend you make atleast a few games and understand the scope of ue4 b4 trying to make a mmo

grizzled stirrup
#

if bAlwaysRelevant = true does that mean NetCullDistanceSquared is ignored?

shy kelp
#

@grizzled stirrup ye

grizzled stirrup
#

ty

lunar root
#

i got more and more the feeling that PIE is not suited for multiplayer...

#

Right now my code is working in Standalone but not in Editor

grizzled stirrup
#

What exactly isn't working?

lunar root
#

Well for Example in the PlayerState I have an list of Team members, PIE says the value is null

#

while Standalone runs without any issues

#

And I'm pretty sure it the value cannot be null

#

since i wait for the player state to replicate via ReplicatedUsing + 5s delay before i access the variable

grizzled stirrup
#

Should work fine in PIE

#

If something isn't working in PIE but is elsewhere it is possible it's an editor limitation but also possible it's a bug that you will have to look out for in your game

#

For example recently I had an issue where projectiles weren't dealing damage in PIE dedicated server but were in packaged builds so I thought it was just broken

#

But it turned out to be related to net relevancy and was completely my fault

lunar root
#

Well right now i reached a level where one instance has the required information while the other doesnt

#

still working in standalone

icy nacelle
#

If you pass a really big array through a run on server event, the event will not execute, right?

#

I think that's the issue what I'm seeing here.

wise atlas
#

can anyone help me with replication?

winged badger
#

really big is 40kB

foggy idol
#

Is it possible to use repnotify to spawn actors

thin stratus
#

Needs more info that question.

#

Otherwise this is like asking "Can I turn on my room light with an orange?" Sure you can.

foggy idol
#

I'm using shooter games method of replicating effects

#

By using the repnotify to spawn the effects in different locations based on if the pawn is locally controlled

#

It works fine

#

But when it comes to spectating it looks weird

thin stratus
#

What kind of effects?

foggy idol
#

Like muzzle smoke , bullet tracer

thin stratus
#

You have to divide these into two different types of effects.

#

Instant
and
Ongoing

#

E.g. Your Muzzle Flash or Hit on a wall doesn't need RepNotify.

#

While maybe an ongoing looping sound of your weapon firing needs it

#

When a person hot joines or gets into relevancy range, they don't need to suddenly see your weapons muzzle flash

#

So these should be RPCs

#

Effects that happen and don't affect the "future", don't really need to be RepNotify

foggy idol
#

I understand that but the problem right now is the spectator issue

#

I'm working on a first person shooter

#

Regular gameplay replication works fine

#

But once you spectate a player you can still see that the effects are spawning from the third person guns muzzle and not the first person

thin stratus
#

You are using OwnerOnlySee and OwnerNoSee

foggy idol
#

I've tried to play around with owner no see but it doesn't work well on spawned emmiters

thin stratus
#

I assume a Spectator doesn't count as Owner

#

So they use the ThirdPerson meshes

foggy idol
#

Regularly I don't use it

#

It's not the meshes that are the problem it's the effects

#

Like let's say person A shoots

thin stratus
#

If your filteri s "IsLocallyControlled" that iwll still fail for a First Person spectator

foggy idol
#

Yup

thin stratus
#

So maybe do if(IsLocallyControlled() || CurrentViewers.Contains(GetLocalFirstPlayerController()))

#

Something like that at least

#

keep track of who is spectating a player

#

And decide based on that if they should see FP or TP effects

foggy idol
#

What about if it's a replay ?

thin stratus
#

Can't answer that. Never touched replays

foggy idol
#

Ok

#

Is there anyway to set the owner of a spawned emmiter

thin stratus
#

Don't think so

#

Do ParticleComponents have the OwnerOnlySee booleans?

foggy idol
#

Yup

thin stratus
#

Can pack the particle into an actor that is owned

foggy idol
#

But they don't have set owner functions

thin stratus
#

Yeah their owner is usually the actor they sit in

foggy idol
#

Ohhh

#

Can I like spawn an actor on all clients except the one that instigated the spawn

#

Like if I shoot for example

#

The bullet would be spawned for everyone except myself

thin stratus
#

Not sure if that's, at least replicated, possible in BPs

#

Despite Multicasting and spawning a non-replicated actor where you check if locally controlled before spawning

#

In C++ you could probably override the IsNetRelevantFor function to make the actor not relevant for the local player who instigated the spawn

#

But not sure if that's the right way to go

#

Might wanna ask how other peeps handle replays

foggy idol
#

Hmmnnn ok

#

Thank you

#

I just need to find someone who has done replays in a fps

buoyant wedge
#

hello guys. i really don't understud how comunicate with the widget on multiplayer. im trying to make a select team, waiting for other player and MATCH start . I have try to semplify the process for help me to understud how all widget work in multiplayer.
I have make this example to pass after a posses a command to the player controller and make a WG... but work only on the host

shrewd tinsel
#

how would i handle playing different gamemodes on a same level in multiplayer?

#
and then open the level with the additional flag game=[Alias]```
dawn summit
#

Are character movement component modes replicated? (SetMovementMode)

meager spade
#

no

rose egret
#

yes but through ACharacter AFAIK

meager spade
#

show me where?

#

the actual mode is not replicated but i can be passed through the unrealiable RPC's

#

but its not the actual mode that is replicated

jolly siren
#

@twin juniper Jobs posts go in #looking-for-talent, please read the pinned message in that channel for instructions on how to post.

elfin tartan
odd iron
#

Hi Guys Do i need to use 2 Seperate Repositories for Dedicated Server and Client version ?

#

Because its need different settings than client

elfin tartan
#

No, typically not. You just need to build the server and get the .exe from your Binaries\Win64 folder

#

And then if you want to run that, run it from a shortcut with -log and any other custom parameters you might have in the target line

odd iron
#

But what about the Entry map and server cycle

#

like when the game end server need to restart the mods and set everything again

meager spade
#

that is down to you

tropic fjord
#

Does anyone know how bad (or not) performance is impacted if your characters all have like 9 skeletal mesh components for exchangeable clothing/armor? Cuz I imagine they all tick independently :/ Or should I do this in a different way?

meager spade
#

as long as you merge them into a single poseable mesh

#

well the majority of them

tropic fjord
#

Is that possible during runtime?

#

Ah. Is that the MasterPoseComponent stuff? I see stuff about Ticking of "Slaves"

#

Yeah, that works. Alright. Thanks for confirming that ❤️

grizzled stirrup
#

Is it possible for an OnRep variable to not go through due to packet loss?

#

Having an issue where in normal network conditions and in 99% of cases all of my enemies get unpooled correctly with an OnRep bool but when I set the network emulation to "Bad" where there's 5% packet loss, some enemies never become unpooled and visible on the client even though on the server they are shooting projectiles

#

So it appears as though I'm being shot from an invisible enemy on the client

#

It is essential for the client to know about this bool changing so maybe a reliable Multicast RPC is the only way for this to happen across all network scenarios? I know there was a previous discussion here that said that OnRep properties will eventually get through

#

But they never seem to in this case

digital tide
#

@grizzled stirrup I'm a bit new to networking in ue4, but think the answer lies in the event used to change that variable. If the event is set to replicate, and you want confirmation that it was replicated, I believe that's what the "reliable" boolean (in custom event details) is for.

grizzled stirrup
#

The variable only changes on the server so the client should always recieve the replicated property automatically, which is does in most cases

#

But with heavy packet loss, a small % of cases don't seem to make it through

#

I was just trying to avoid RPCs but I think in this case it's an actual good usecase to use a Multicast RPC over an OnRep property

#

Since it is essential to gameplay

#

And not unreliable or cosmetic

#

I have 0 multicast RPCs in my project so far but since every client needs to know about the unpool event and it can't get missed, I think it's a fine usecase for Multicast. If anyone disagrees please ping I'm always curious to know the best approach

digital tide
#

Sounds like a good decision to me.

copper grove
#

Stepping into a realm of 10,000 concurrent players what service provider for servers would you use?

digital tide
#

Anyway, I came here to check if anyone knows how to connect to a dedicated server from an HTML5 client? I realize HTML5 support technically ended on 4.24. But this is the one obstacle I seem to be stuck on. Connecting to the server works on Android and as an executable, but I can't seem to get HTML5 to work.

meager spade
#

Properties are 100 percent reliable @grizzled stirrup

#

they are guarenteed to be replicated

icy nacelle
#

really big is 40kB
@winged badger Thanks Zlo <3. I was thinking about passing data in strings instead, and split it into groups of 1000 characters in each chunk

digital tide
meager spade
#

problem is, if the actor has too low a priority

#

it might not be considered for some time (sometimes not at all)

grizzled stirrup
#

@meager spade So if an actor is set to bAlwaysRelevant = true and a bool gets set on the server, there is absolutely no way for it to be missed, on a NetUpdateFreq of say 10.0f?

meager spade
#

in saturation

#

frequency and priority are the key here

grizzled stirrup
#

I'll try bumping up the net update freq and priority a bit

#

Because I have noticed on rep seemingly never coming through when on low freq before

#

They probably would eventually

meager spade
#

unless the client version changes

#

server will always trey to replicate it

#

only time is if client and server values match

grizzled stirrup
#

Ok great thanks! I'm also very curious if you would choose a Mutlicast RPC here instead

#

As it is gameplay critical

#

And must happen

#

If the freq and priority changes don't fix it

meager spade
#

multicasts are for one of things like explosion effects etc

#

properties are for states

grizzled stirrup
#

This is pooled / unpooled but all clients have to make sure they call the unpool code

#

Or else they can't shoot the enmeis

meager spade
#

like if i multicast a chest is open, if a new player sees the chest, he will see the chest closed

grizzled stirrup
#

But the enemies can kill them

#

So the unpool logic must run and must be very reliable

meager spade
#

what is unpool?

grizzled stirrup
#

I have a basic pooling system

#

So instead of spawning enemies

#

I pool them

meager spade
#

why do clients need to call unpool?

grizzled stirrup
#

And unpool them when needed

meager spade
#

ai is server only

grizzled stirrup
#

To unhide the mesh etc.

#

AI meshes

#

Characters

#

I deactivate everything when pooling

#

All components etc.

meager spade
#

yes but i send this in the initial bunch

#

when activating the AI

grizzled stirrup
#

Sure it works the first time

meager spade
#

never had invisible AI 🤷

#

client side

#

ever

grizzled stirrup
#

But the issue comes with when you kill the enemy, it pools and then needs to get unpooled

#

It happens fine 90% of the time

#

And 100% of the time with good network conditions

#

But with latency and packet loss 1 in say 20 is invisible

meager spade
#

well the issue is, if server doesnt see that client needs a change

#

then he wont rep

#

its possible client has that bool set to show meshes

#

but never fired the onrep cause he got it set locally

grizzled stirrup
#

Yeah so somehow the clients value is correct but I have been through the code a million times and can guarantee it only gets set on the server

#

Hmm thanks I'll test more and see if I can find the issue

#

Might try using an int32 instead of bool

#

Just to ensure the client cannot possibly have the same value

#

As it'll always increment

#

If it all fails I'll try the reliable multicast

#

As that would be guaranteed to run on all clients instantly

digital tide
odd iron
#

Dedicated Server works fine from first test but when client join it return him to main menu anyone know this thing ?

#

found the error was ..

[2020.05.31-17.48.55:309][ 85]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = OutdatedClient, ErrorString = The match you are trying to join is running an incompatible version of the game.  Please try upgrading your game version., Driver = PendingNetDriver IpNetDriver_0
[2020.05.31-17.48.55:310][ 85]LogNet: Warning: Network Failure: PendingNetDriver[OutdatedClient]: The match you are trying to join is running an incompatible version of the game.  Please try upgrading your game version.
#

Can i make it joining even with different version ?

unreal pine
#

How should I replicate a variable from GameState to PlayerState? When I try to fetch it from the PlayerState, tt doesn't see the GameState as valid

grizzled stirrup
#

@meager spade it's so strange, the client actually does call the OnRep event 100% of the time at the correct place AND runs the unpool function at the correct time which literally unhides stuff but somehow once in a while (probably when packet loss is high) while the function always runs, the mesh does not show

#
        SetActorHiddenInGame(false);
        GetMesh()->SetHiddenInGame(false);
        GetMesh()->RefreshBoneTransforms();

meager spade
#

HiddenInGame is replicated btw

grizzled stirrup
#

That is essentially the meat of the function and logging inside it shows that the client always calls it correctly. Might be some kind of bug related to meshse?

meager spade
#

by the engine

grizzled stirrup
#

I commented the first line out, does it also affect the mesh SetHiddenInGame ?

#

I did not know that

meager spade
#

ActorHiddenInGame

#

hides everything in the heirachy

grizzled stirrup
#

It happens with that commented out

meager spade
#

includeing the mesh

#

including

#

and its replicated by default

grizzled stirrup
#

So currently only the mesh component is being hidden and SetActorHiddenInGame() is no longer called but it seems to still happen

#

Good to know for other cases though

meager spade
#

SetActorHiddenInGame is quirky

#

with networking i have noticed

#

hence i just hide meshes

#

when hiding the monster

#

and no using SetActorHiddenInGame

grizzled stirrup
#

Yeah but it seems to happen without using SetActorHiddenInGame unfortunately 😦

#

Just using the 2nd line

#

Happens about once in every 20 eliminations

#

And I can produce on just one enemy

#

So it's not saturation or bandwidth related

#

Using the "bad" network preset in UE to test

meager spade
#

no clue then, but i don't have that issue

#

even with "bad"

grizzled stirrup
#

Ok thanks for the suggestions

#

I'm thinking there is some problem with the hiding code somewhere

#

Because it's working perfectly on paper

#

everything runs when it should

meager spade
#

i use replicated flags tho

grizzled stirrup
#

How do you do that?

meager spade
#
#define MRF_HIDDENMESH (1 << (1)) //Hide Monsters Mesh
#define MRF_COLLISIONS_DISABLED  (1 << (2)) //Disable Monsters Collisions
#define MRF_RENDER_PASS_DISABLED  (1 << (3)) //Monster render pass is disabled
#define MRF_IDLE_OPTIMIZED (1 << (4)) //Monster is idle optimized
#define MRF_TICKS_DISABLED (1 << (5)) //Monster has ticks disabled
#define MRF_SENSES_DISABLED (1 << (6)) //Monster has senses disabled```
grizzled stirrup
#

That's actually useful because you don't need to type out the code again

#

So that each define calls a function?

meager spade
#

well these are just flags

grizzled stirrup
#

It should function the same without using those right?

#

If the function gets called on the client

meager spade
#

so i have functions like this

#
    UFUNCTION(BlueprintPure)
    bool IsTicksDisabled() const { return AreAnyReplicatedFlagsSet(MRF_TICKS_DISABLED); }

    //Sets a replicated flag
    FORCEINLINE void SetReplicatedFlags(uint8 Flags) { ReplicatedFlags |= Flags; }

    //Clears a replicated flag
    FORCEINLINE void ClearReplicatedFlags(uint8 Flags) { ReplicatedFlags &= ~Flags; }

    //Sets/Clears a replicated flag
    FORCEINLINE void SetReplicatedFlag(uint8 Flags, bool bSet) { if (bSet) SetReplicatedFlags(Flags); else ClearReplicatedFlags(Flags); }

    //Does replicated flags contain a flag
    FORCEINLINE bool AreAnyReplicatedFlagsSet(uint8 Flags) const { return (ReplicatedFlags & Flags) != 0; }```
#
    UPROPERTY(ReplicatedUsing = OnRep_ReplicatedFlags)
    uint8 ReplicatedFlags;
    
    UFUNCTION()
    void OnRep_ReplicatedFlags(uint8 OldFlags);```
grizzled stirrup
#

So when a flag changes you go through the if statements and unhide stuff as needed?

#

in the OnRep function?

meager spade
#

yeah

#

allows me to just rep one property

#

to handle 6 states

grizzled stirrup
#

Got it! In my case I do everything in one bool so it should have the same result

#

If it reps to the client and the client acts on it

meager spade
#

instead of 6 bools

#

for the same

grizzled stirrup
#

Yeah if you needed fine control over each state

#

In my case it's either active or not

#

So I can do it with one

#

The only thing I can think of that could potentially be triggering my problem is that when unpooled there is an anim montage set to play immediately after activating all the components (but the mesh is still hidden)

#

And then the actual visual update where everything becomes unhidden happens after a short timer

#

The client calls both the pre and post functions just fine

#

But perhaps something with the montage is messing up

meager spade
#

i never trust montage for things like that

grizzled stirrup
#

I just hate that it works almost all the time

#

But not 100%

#

And it's not network related

#

Anyway thanks for the help I'll try disabling the montages and see

#

At least I don't have to use multicast RPCs or bump up the net freq

meager spade
#

Multicasts are fine if used properly

#

and should be used for things like one off particles, one off sounds, etc

grizzled stirrup
#

I've always heard the advice to use onrep where possible as it would be cheaper. For example using bExploded on a projectile or int32 CurrentShot on a rifle like in shootergame

meager spade
#

bExploded doesnt make sense

#

how about if a new player joins

#

he will all those explosions go off

grizzled stirrup
#

The projectile is destroyed

#

he will not know about it

meager spade
#

how about if it isnt

grizzled stirrup
#

Then you set bExploded back to false when pooling it

meager spade
#

nah explosions don't belong in a OnRep

#

Exploded state, yes

#

actual explosion, no

grizzled stirrup
#

I can see the downside on say a rifle

#

Where if you only incremented an int

#

It could play 365987 FX when a player gets in range

meager spade
#

yep

#

well

grizzled stirrup
#

But projectiles typically have a short life

meager spade
#

no

#

just 1

#

cause it will never onrep each value

grizzled stirrup
#

Right unless setting to 0

meager spade
#

only the last value

grizzled stirrup
#

Which I do to prevent that