#multiplayer
1 messages · Page 545 of 1
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
Cast the output controller to your own controller. If succesful, do fun stuff
Or am I missing something here?
also, use HandleStartingNewPlayer override
it works in all cases, not just after a hard travel
thats how i tried to set up. but the function does not get called
when i call this via a widget, the function works as i want
@winged badger thx, just tried but same result
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
ha! i added a delay, now it works
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?
oh i think i forgot to check reliable on the server event - no it works without the delay
ha! i added a delay, no it works
@quasi wyvern please god no
@crimson fiber yeah you do, not just for Linux, any platform.
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
They will timeout
hmmm
the client detects the network error if i kill the server but they will remain on the server if i kill them...
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 😄
good point :)
but the clients will be oculus quest HMDs and espcially on oculus people tend just kill the app...
ok looks like the server network error event doest not fire when using PIE... standalone works
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
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.
ok so your saying add the bool and make it renotify like this
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
these inputs isn't working on local client?
when pressing one does it sends to server too ?
so I added my code in here
thats the rep notify for the bool is that where it goes?
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
how do I call it on the server?
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
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...
Quick question, can I use polymorphism in RPC calls?
yes
np you override the _Implementation
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
I assume you meant can you override rpc functions?
"use polymorphism in rpc calls" is fairly generic
True I'll rephrase:
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;
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
Yes you can with actors. Replication of ustruct polymorphism doesn't work though; without also replicating the class
You can look at how FDamageEvent handles it if you need it with ustructs
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
Does the ustruct have a hierarchy? Or just a plain ustruct that doesn't inherit from anything or have any children?
It has a hierarchy, it's basically like so:
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()?
As long as you aren't casting the ustruct itself it will work fine without doing anything
no problem at all
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
perfect, thank you for this
I will surely need it at some point, so gonna pin that somewhere
I'm getting Null while requesting
Controller->IsLocalController()
on server character. It does work on clients however. I thought server has controllers too.
@dawn summit Listenserver setup?
yep -_-
The blueprint version returns fine, running it inside the character blueprint. Server prints true.
any reason a newly spawned actor would be immediately pending kill?
@kindred widget well, i'm using c++ ;_;
They should be the same functions.
yeah, but i don't get why it's null
Did you check the controller reference?
It is odd that it would work on clients but not the listenserver, if you're calling it on the listenserver's character.
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
are you trying to get the controller of a pawn other than the local one
the controllers for non-local players are not spawned
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
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)
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?
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..
aha.. I needed to get class of each actor
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
the code in the stealth and repnotify bools looks like this
and how would that allow a client to set the variable server side?
i thought because when I press the button both have authority
so both should be able to see
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
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?
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
how can I connect the RPC to the input action there is no pins to connect to
you call ServerCloak just like you would any other BP event
oh cool it works!
im so happy this is my first time understanding
its a little like im learning unreal all over again
now go to pinned messages, find exi's compendium and read that 5 or 6 times 😄
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
this is the code i used
first asggregate that
there is no point having IsCloaked and IsNotCloaked booleans
but they are my repnotify I dont need them?
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
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
@radiant jolt I set them both to multicast but the client still cant see the other clients cloak
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
i think it works like this now
yeah it works!
thanks so much I learned alot
this is my first thing I got working in multiplayer
You can delete stealth and unstealth after the server event
But yeah ofc multiplayer can be so tricky
Why is it weird
(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
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?
Shouldn't it always be that the server has the data and sends to the client? I thought that's how Unreal MP works
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
Using an Aim Offset, a character aims a weapon in the direction of your mouse or controller.
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
i never replciated pitch
I> i never replciated pitch
@meager spade if I don’t replicate it, it’s not updated in the client
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
Disable the replication from your aimpitch and aimyaw, it's not needed
Should i make it in c++ class and set it there replicated then expose it?
no
you dont need to replicate anything
for pitch and yaw
my editor is loading gimme asec
Thank you
you have c++ base for your character?
Yes
{
float ClampedPitch = (RemoteViewPitch * 360.f / 255.f);
ClampedPitch = ClampedPitch > 90.f ? ClampedPitch - 360.f : ClampedPitch;
return FMath::Clamp<float>(ClampedPitch, -89.f, 89.f);
}```
And i i will make this blueprintcallable and use it for the pitch, correct?
yea
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
cause its not for replicating
no rpc's, no replicated props
animbp should really be a one way street, take data in, process it
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.
Can I change who (server or individual clients) has the authority over my actors dynamically?
Depends what you mean by authority
RPC ownership, sure
Using SetOwner on the server
seems a bit stranghe
if you want clients to have authority, just set them as not replicated
client can never replicate stuff
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
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
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.
call that in the animation blueprint?
GetBaseAimRotation() is part of APawn
So you can access it via the animation blueprints "owning pawn"
@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
Yeah that's correct
HasAuthority() won't be true on a client unless the actor was spawned locally by that client.
Replicated Actor Spawned By Server:
Server: HasAuthority() == true;
Client: HasAuthority() == false;
okayyyyyyy thankfully this replicates well and the animation works, but it just kinds snaps to some value
Authority is not the same as being able to call RPC's though.
i will try and clamp it
Aye, thanks @chrome bay
holy shit
i love you
😂 i just hate how you don't know why something doesn't work but oh well
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
thank you so so much
Greetings!
Question.
I have a function that is replicated, prefixed with Server_
Does this function being called locally as well?
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
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?
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
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.
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 ?)
Persistent world storage so players can come and go.
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
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
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
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
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
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?
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
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.
Save yourself some pain and send the JSON over HTTPS
Both built-in into UE4 and extremely trivial to use in php
Whats the limitation on sending the data that way?
Why would it have limitation ?
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 😊
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
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)
When called from a listen server host, all is fine
I'm actually frustrated what I've done wrong
Looks like a Pawn.
where do you see that?
Currently it's a pawn
But I had the same events on a PC minutes ago
It doesn't
as long as the pawn is possessed by a controller

well, where are you calling them
Currently, the UI calls an "owning client" event on the PC, the PC calls the client event in the pawn
why is UI doing Owning client?
I didn't have the pawn previously, it was just a last ditch effort for me to tryr it
I was mostly safeguarding it with that
I dunno, just habits I guess
I'll try to screw around more and see if something gets fixed
any warnings/errors?
Nope
if a RPC fails, it prints to the output log
Noob question. How to request destroy actor on server?
Now i'm getting warning it does not have related network connection
Just call destroy actor server side. What are you doing now?
i'm calling an RPC, that calls a Destroy actor...but...it doesn do do anything
It seems like I managed to fix it but I'm still confused 
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)
@meager spade that is correct
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
thank you
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
unreal has cURL built into it somewhere, which should do HTTP well.
Module for Http request implementations Use FHttpFactory to create a new Http request
Anyone available to help me figure out some skeletal mesh changes? https://www.youtube.com/watch?v=8kI5tUz8YVw&feature=youtu.be
Need help with skeletal mesh replication
Sessions are not matches, right?
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?
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)
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 
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
And are these custom serializations called automatically by the engine?
Oh! Will do, thanks
it has custom serialization
I suppose that requires writing a deserialization as well?
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
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?
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).
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
I'm looking into SpawnActorDeferred, looks like it is exactly what I needed. Thanks @winged badger !
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?
I see a bunch of potential problems with that approach @grizzled stirrup :
- Clients get to know about things they maybe shouldn't (potential for cheating?)
- 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.
- Susceptible to bugs... unnecessary work to make sure you destroy them right away which you can forget or get wrong.
Thanks for the answer @floral crow
- Cheating is not a concern here (co-op)
- They don't have replicated properties and are just blueprints placed in the world to indicate spawn locations
- 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
Use this instead
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)?
yes Deffered spawning
everything you set will be replicated to clients
before beginplay
as long as it is a replciated property
and its 100% reliable, as its the same bunch
no adverse network conditions will screw that up
Problem with deferred is that I would have to expose private members so the external class requesting the spawn can set them
use setters
then expose a set or initialize function
I want the spawned actor to initialize some private properties itself
Yeah, I was trying to avoid that
or make a function
in the actor
that does it
you cant
there is no other way round
no adverse network conditions will screw that up
@winged badger This is actually great to know. Thanks
either make the props public or make a public function
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
I was about to ask you about pointer replicated properties
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
That makes sense..... phew, this multiplayer game initialization part is killing me
What do you mean by loaded from the package
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
We are using GameStateBase
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
That's good to know, though in this case these are all actors spawned at runtime (entities in an RTS game)
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
Wow, how do you that? Have you tweaked the source engine? (for faking the load from package)
leveraging concept of net addressing without replication is probably the best way to save on bandwidth and actor consideration times
we did not
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?
lying is a understatement
we actually lie to the engine about our player pawns aswell 😄
for trickier networking, having chats about it here is the best place imo
there are very few resources for it
normal replication is easier to manage tho
also adds cost to the players
the server sorry*
net dormancy is also another headache
my problem with dormancy is that it does a shit job combined with relevancy when you turn it on mid game
haha ok, I really appreciate your help @winged badger @meager spade . I'm gonna look into NetSerialization.h
can't turn dormancy on per connection
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
you need a buffer
anything not loaded from package that enters net relevancy is spawned anew
on clients
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.
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
Is it not possible to test in a Dedicated Server environment from the editor anymore in 4.25?
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
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.
@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.
but I will checkout HandleStartingNewPlayer in GameMode... that's a new one.
you do need to call it after both PawnPrivate and TeamColor have replicated
this would give you OnRep for the Pawn
would OnPostLogin be the place for that?
there is an OnRep for it, but its c++ only
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
Ok thanks... I will try to digest this
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
Sure I know it's not right
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 I set this up and it works.. but only for the Listen Server instance
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
I have C++ backend.. I just wanted to get it working in BP
PC, PS and Pawn are all there and valid
Left is a listen server
Nevermind i found out why. LOL my spawn logic on server map bp got deleted
@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!
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.
@exotic axle Make the Actor not replicate and turn off net load on client
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!
Does UE4 provide an anti cheat?
No
Thanks
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 ?
Same project... By the way, you don't need SpatialOS
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
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
But how can i host it to another or virtual machine
so i can keep it running just restarting when updating
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
Yes im not 100% beginner 
i have like 20-30% knowledge xD
but if you don't try the hard you will never learn it right ?
You can learn about airplanes without building a 747 first
i thought SpatialOS doing the host and deployment stuff
No, it does more than that, and at a larger cost
Solve what ?
If you want to host your dedicated server, yes, you should rent a VPS on put it there
ok cool
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
Does it make sense using Fast TArray Replication using NetDeltaSerialize for an array sent via an RPC, or is it mainly for properties?
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
Hey, im Encountering a similar problem like this guy: https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/102335-gamemode-variable-empty-after-seamless-travel
Is there a fix for that?
(GameMode does not persist after ServerTravel even tho the documentation says it should persist)
Build powerful visual scripts without code.
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]
My Target map didn't have any GameMode set
So when I set the same GM class the instance persists?
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
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
i always find it better to be explicit
So when I set the same GM on TransitionMap & Target Map it should persist?
Hm.. means for every GM I need a new TransitionMap map ?
there is only one transition map, and honestly, im not sure it will reinstantiate the gamemode if its different
Well I did bUseSeamlessTravel = true in the constructor , should work
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
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
Wdym exactly?
when your players select their character in your lobby
that gets RPCed to the server
Correct
And then I need to pass the selected Characters to the next GM somehow
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
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
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)
And the BattleGameMode which has to spawn the characters from the TMap, how would I pass the TMap to the new GM
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
This also works when the PS are of different classes?
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
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?
you can just go around it by LobbyPlayerState replicating that data to OwnerOnly, and BattlePlayerState to everyone
Yeah, but the teammates also need to see what you picked to gray out the button
it can be done with or without persisting the actors to specifically hold the info
I think I could override the IsNetRelevantFor for PS to not send the PS to the enemy
If I could just "hide" a single field
you can make a small TeamSetupActor
thats relevant only to the team with same ID
and persist it
yeah that's pretty much what I have
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
But this would mean that the GM itself also has to persist right?
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
So the Method gets called even tho the GM does not persist?
Okay imma give it a shit
Shot***
xD
its just the Lobby GM needs to persist it to travel level, and Travel GM (can be same) to desitnation level
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?
i think the FastTArrayReplication is for a replicated variable not an RPC, if im understanding it correctly
I definitely imagine it being designed primarily for replicated variables, however I'm not exactly sure what limits its usage just to replicated variables
if you send fastarray through the RPC
you send the entire fast array
there is no delta then
i recommend you give NetSerialization.h a read
(For replicated variables that is)
as half of it is basically docs in comments
I'll do that, thank you!
@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
@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
Why do people use blueprints?
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
@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
@bitter oriole I don't like to think professional devs use drag and drop blueprints
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
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
best distribution is C++ does the backend stuff, blueprint is reserved for content setups and more 'front end' game scripting
some things are very impractical to do from c++, like using a Timeline
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
Can I make a single shard mmo in unreal engine
and can any recommend any c++ and unreal engine tutorials?
Youtube and Google is your friend
@dark forge No, you can't build a traditional MMO in UE4.
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.
}
}
``
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
You really should think smaller regardless
@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
if bAlwaysRelevant = true does that mean NetCullDistanceSquared is ignored?
@grizzled stirrup ye
ty
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
What exactly isn't working?
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
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
Well right now i reached a level where one instance has the required information while the other doesnt
still working in standalone
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.
can anyone help me with replication?
really big is 40kB
Is it possible to use repnotify to spawn actors
Needs more info that question.
Otherwise this is like asking "Can I turn on my room light with an orange?" Sure you can.
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
What kind of effects?
Like muzzle smoke , bullet tracer
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
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
You are using OwnerOnlySee and OwnerNoSee
I've tried to play around with owner no see but it doesn't work well on spawned emmiters
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
If your filteri s "IsLocallyControlled" that iwll still fail for a First Person spectator
Yup
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
What about if it's a replay ?
Can't answer that. Never touched replays
Yup
Can pack the particle into an actor that is owned
But they don't have set owner functions
Yeah their owner is usually the actor they sit in
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
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
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
how would i handle playing different gamemodes on a same level in multiplayer?
and then open the level with the additional flag game=[Alias]```
Are character movement component modes replicated? (SetMovementMode)
no
yes but through ACharacter AFAIK
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
@twin juniper Jobs posts go in #looking-for-talent, please read the pinned message in that channel for instructions on how to post.
[posted in Plugins as well]
Hello, I'm looking for assistance with a feature in Rama's 4.24 Victory Plugin.
I've posted here detailing the issue. A reply in the thread was helpful, but not exactly what I'm looking for.
https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/102757-dynamic-level-streaming-with-multiplayer-support?p=1730107#post1730107
Build powerful visual scripts without code.
Hi Guys Do i need to use 2 Seperate Repositories for Dedicated Server and Client version ?
Because its need different settings than client
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
But what about the Entry map and server cycle
like when the game end server need to restart the mods and set everything again
that is down to you
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?
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 ❤️
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
@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.
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
Sounds like a good decision to me.
Stepping into a realm of 10,000 concurrent players what service provider for servers would you use?
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.
Properties are 100 percent reliable @grizzled stirrup
they are guarenteed to be replicated
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
@copper grove my friend swears by RamNode. I haven't used them myself, but will be trying them out soon. https://ramnode.com/
problem is, if the actor has too low a priority
it might not be considered for some time (sometimes not at all)
@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?
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
unless the client version changes
server will always trey to replicate it
only time is if client and server values match
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
multicasts are for one of things like explosion effects etc
properties are for states
This is pooled / unpooled but all clients have to make sure they call the unpool code
Or else they can't shoot the enmeis
like if i multicast a chest is open, if a new player sees the chest, he will see the chest closed
But the enemies can kill them
So the unpool logic must run and must be very reliable
what is unpool?
why do clients need to call unpool?
And unpool them when needed
ai is server only
To unhide the mesh etc.
AI meshes
Characters
I deactivate everything when pooling
All components etc.
Sure it works the first time
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
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
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
Found a lead on the answer to my issue. For anyone else looking for HTML5 networking help, I found this on the #web channel: https://github.com/UnrealEngineHTML5/Documentation/blob/master/Platforms/HTML5/HowTo/README.2.advanced.UE4.HTML5.md
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 ?
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
@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();
HiddenInGame is replicated btw
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?
by the engine
I commented the first line out, does it also affect the mesh SetHiddenInGame ?
I did not know that
It happens with that commented out
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
SetActorHiddenInGame is quirky
with networking i have noticed
hence i just hide meshes
when hiding the monster
and no using SetActorHiddenInGame
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
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
i use replicated flags tho
How do you do that?
#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```
That's actually useful because you don't need to type out the code again
So that each define calls a function?
well these are just flags
It should function the same without using those right?
If the function gets called on the client
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);```
So when a flag changes you go through the if statements and unhide stuff as needed?
in the OnRep function?
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
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
i never trust montage for things like that
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
Multicasts are fine if used properly
and should be used for things like one off particles, one off sounds, etc
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
bExploded doesnt make sense
how about if a new player joins
he will all those explosions go off
how about if it isnt
Then you set bExploded back to false when pooling it
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
But projectiles typically have a short life
Right unless setting to 0
only the last value
Which I do to prevent that