#multiplayer
1 messages · Page 603 of 1
I'm updating the weapon values on the weapon BP inside of a function, and that function is called by a gameplay ability.
The values do get updated, but for the client this update takes several seconds
once they sync up, they stay synced?
yep
what im guessing happens
your PC and Character have a NetPriority 3 by default
which means when the Actors start replicating to clients, they will be at the front of the list
your weapon is derived from AActor, which gives it NetPriority of 1, unless you tweaked it
it has to wait its turn
so you spawn the weapon on server, you set the reference and all is good
Character replicates, it has good weapon NetGUID, but it can't resolve it yet, as the WeaponActor itself still doesn't exist on clients, waiting for its turn to replicate
i have no idea how you bound your UI to the weapon, so thats the best guess from the symptoms
When I pick up the weapon, I just pass the reference to the HUD Widget via event and it stores the reference.
we are talking HUD widget or HUD actor?
its very convenient place to manage all your widgfets
Well the HUD does manage the widget
HUD has 1:1 relationship with the PC and is local only
which... simplifies things alot
anyhow, how do you pass the reference to the widget?
you mentioning its a pick up a weapon scenario, means its not the start of the game scenario i speculated about earlier
trigger for that action is what im interested in
It's on the map, but I don't get to pick it up as the client until I'm fully synced and can walk around
Call what?
the part left of that branch
That's an OnRep function for the CurrentWeapon
that should work better then you describe....
if you pick up one weapon, wait for sync, then pick up another, does your widget show the old weapon values or just zero?
Each weapon has its own Ammo counter
So when I switch weapons, the widget switches with it
different widget classes?
yes
And they do get called to update every time I fire on the client. The value just doesn't update
your widget itself is bound to OnAmmoChanged event dispatcher in the weapon?
I actually only have this issue with weapons that use energy too. The weapons with rounds replicate fine.
I'm working with a plasma weapon that uses a timer to dissipate heat, but that heat value inconsistently updates.
The HUD widget does bind an event to the weaponFire dispatcher, but the client never gets that bound event to fire.
I did find that lowering the timer period to simulate 30fps instead of 60fps made the Heat Variable update sometimes rather than never, so I think maybe it's just a case of dropped packets? I'm using a timer instead of tick because I get huge drops in FrameTime when using Tick.
And no, this is the binding events in the HUD Widget:
whats to the left of those binds?
i'd try this first
make a widget class, WeaponWidgetBase or some such
delete its entire UMG hierarchy, its the only way BP will allow for UMG blueprint inheritance
add a variable of whatever your CurrentWeapon type is in it
and mark it as instance editable, and exposed on spawn
then reparent all your weapon widgets to that
change the variable type of AmmoCounter in your weapon to be a class reference of that base weapon widget
effect is that this create widget node will get a pin of your weapon's type on it
so you can connect your current weapon to it
and the current weapon will be valid and available to the weapon widgets by the time construct is called
So I tried this from 2 diff pc. I have a host who sent invite to the client. The client accepts the invitation then that node should get triggered. But not happening. Am I doing it wrong?
is it alright for server to call serverRPC functions on its own?
@half jewel yes, a server RPC called from the server just executes as a normal function
no hidden side effects anywhere ?
I have a small multiplayer setup with fairly slow guns (think bolt action rifle rate of fire) with projectiles. So very few and infrequent bullets, but ideally very accurate to what the shooting client expects. I am planning to do:
- Client presses shoot and bullet is spawned on client that does cosmetic hit effects
- RPC tells server to span bullet that replicates and actually causes non-cosmetic hit effects
Does this make sense? And, perhaps a dumber question, how do I avoid the server's version of the bullet appearing on the original client that already has a bullet instantiated?
every bullet in my game is a server RPC
even fast firing assault rifles 😄
if you never want the client to see the server bullet, you can only do that in C++ and override IsNetRelevantFor
and to return false if Owner == Viewer
As the replication of maps and sets is not allowed, can you put the map in a blueprint struct and replicate that struct? (I can definitely set that struct to "Replicated" in the blueprint, but will it work properly?)
👍🏾 thank you
@meager spade I feel like when I spawn my bullets on the server, they've hit something and have disappeared before first being rendered on clients. Are you spawning a bullet on the server and replicating it? Or multicasting to spawn the bullet on each client?
Will sending the map using a multicast event (or any other rpc) work?
i don't actually spawn a bullet (even for snipers), only time a projectile gets spawned is things like rocket launchers
snipers i do a distance and math based time to hit and drop, etc
but if your spawning projectile, you def want to spawn one client side, issue is, if the shot is super close (closer than one sub step of projectile movement), kinda pointless spawning a projectile, but that being said client spawning it and server, is the only way to fix it
and i don't use multicasts for projectiles, cause a replicated actor is on clients and server
what are your bullets then? Just particles for cosmetics?
hit scan and trails/tracers
those i do multicast the trails
but that is not a projectile, which is handled differently
got a link to anything for what you mean by trail/tracers? I get it conceptually but not sure what it means in the engine itself.
is it like a ribbon on a particle effect?
substepped line traces for us
for tracers, we just spawn a PSC and update it to where the bullet's position is, though we do a bit of a pre-sim so there's a bit of an initial lerp
we do drop, bullet penetration and ricochet
PSC stands for?
particle system component
i wonder if in Fortnite they shoot from the Pawns center rather than the camera
they did that in H1Z1
ah ok. makes sense.
Ok, I'll give it another shot with this all in mind. Thanks for all the help
Hi! When I spawn my projectile on the server I set the instigator and its supposed to be replicated to clients but every once in a while the clients copy of the projectile says the instigator controller is invalid. I need to access the instigator controller on BeginPlay. Does anyone have an idea for why the instigator controller isn't consistently being replicated?
Most likely because the instigator isn't relevant to that client when the projectile replicates
Bear in mind, Instigator "Controller" will never be replicated
Apart from their own local controller, controllers never exist on clients
If I set the instigator on the server, shouldn't the instigator controller be valid for the client who triggered the spawn? because the instigator on the server is connected to a player controller and the player controller is replicated to its owning client
Yeah the owning client should be fine, but only them
In theory if you spawn the projectile and set the instigator in the same frame, it should replicate immediately as part of the spawn packet
And therefore be valid at BeginPlay time
That's my problem. Your theory is how I implemented it, but every once in a while one of the projectiles does not successfully replicate and the instigator controller becomes invalid. I'll check again.
Oh you mean it doesn't replicate at all?
I thought you meant just the instigator property isn't set
Yeah sorry. Everything replicates but the instigator property
yeah kk, that's a bit stranger
I don't know if it's 100% guaranteed that you'll get those set properties in the first bunch. It might be due to network stress, you could try spamming it and see what happens.
Individual actor properties will replicate non-atomically I'm fairly sure
I think your right. It might be a network problem. I'm testing it on one laptop using the command prompt, so having 2 standalone games open along with the editor might be causing problems. Thanks @chrome bay for answering my question.
Oh sorry, I'm wrong - actor properties do replicate atomically
When an actor is replicated all of its changed values will be sent as an atomic update. This means that we guarantee if you receive the update, you will receive all the properties that have actually changed in that update. This includes subobject properties as well.
ok
I've got a wall run system where the client tells the server to launch the character. I want to run this function on a high frequency, around 50 times a second. I've limited my game to have 4 players at most.
I want to ask if this will have bad networking performance or not
You're going to have all kinds of bad times with that.
Why have the client tell the server to launch the character every time? Instead, just have the client say when they want to start and stop wallrunning.
Is that for security reasons?
Ah so I'm going to call wall run once and the server will do all the work from there
Lots of reasons...
Latency will screw over some RPCs, so you'll get weird timings for launching.
Server would need to validate that the client isn't calling things too often.
Network throttling may prevent RPCs from actually going out 50 times per second and instead batch some calls, which will also screw over timings.
To not have a different functionality
Also... your client should probably simulate the launches in addition to telling the server (clientside prediction)... but you're going to have to implement some way to reconcile differences between client/server + lag compensation or else you're going to have all kinds of jittery movement the moment any latency is introduced.
CMC does this for basic movement. It's non-trival and not well documented but you can add new features to it to deal with the above.
I'll take a look, thanks!
There's some information on this page towards the bottom. https://docs.unrealengine.com/en-US/InteractiveExperiences/Networking/CharacterMovementComponent/index.html
Detailed explanation of Character Movement Component
This is driving me nuts. I have a dedicated server, running a simple experience. Main Menu (offline) -> Lobby Map (online) -> Game Map.
The first time I build a local dedicated server, the flow works, my loading screens fade correctly and the game works.
If I close the server, spin up another local dedicated, and play again, I get stuck on the Loading Screen. 100% of the time after the first time./
Is there anything that is saved locally or on the "local dedicated" server that could case inconsistency between runs of the local dedicated?
@sly violet how are you joining your server, via session or ip:port?
IP
it should work then, are you getting any output in console of server?
I actually have a ton of Prints within my server output that shows they are seemly identical.
server outputs the handshake logs, if client tries to join you should be able to see it
Oh, I should clarify. The game loads into the level, all clients are connected and possessing a pawn, but the loading screen will not disappear.
you made that loading screen so at what point you are dismissing it
in the game settings you can specify the transition map, are you using that?
Yes.
gamemode is server only
it won't run on client
thats why your loading screen is not dismissing
GameMode instance only exists on server.
It casts to state and multi casts to clients.
The hard thing to comunícate is that this works the first time I run a new build of the dedicated server, and then never again on further iterations of the same server build. If I build it again from the Project Launcher, it works one time again.
hmm interesting.
so what I do usually do, lets say I have MainGameplayMap.umap which is loaded after server travel, once its loaded at client side, I have BeginPlay inside LevelBp, and I clear the loading screen widget there.
Hmm, interesting. The level BP casts to say Game State to clear it in your example?
It feels like a race condition so I added a bunch of arbitrary frame delays, but the issue still occurs the same way.
Is it possible that the widget is somehow being kept between sessions without an owner?
every map has a blueprint class.
and inside that blueprint create begin play event
give your loading bp class here.
Hi everyone. I'm having a weird bug. This function is called from a timer by the server. After "x" seconds the Character called sets its location and rotation to the clients. The location is set correctly but by some reason the rotation does not change it sticks with the one it had before. Any help? Thanks
HI, I'm using add yaw input and add pitch input functions in player controller to update my player rotation, replication works fine on server, but it won't replicate on the other clients, why? If Server has the correct values shouldn't all the clients have them too?
@steel fox Character class? Yaw should update in the form of the capsule rotating. Pitch usually needs to be shown with an AimOffset. How are you testing these values?
Simply my mesh won't rotate on other clients
So you suggest to use an aim offset?
Thank you
For Pitch, yeah. Generally you'd use an AimOffet in your animation blueprint.
GetBaseAimRotation to get the pitch. GetControlRotation doesn't work well for that I find.
Oh, then I've lost a lot of time for nothing😂, thank you @kindred widget
Haha, I know that feeling well.
@steel fox I should double check, you do mean like aiming arms up or whatever. Not turning an entire mesh upwards like a starship or something, right?
UGameInstanceSubsystem class have a replication or not?
Right, I'm trying to do my multiplayer fps, so I'm already having an aim offset on tp mesh and I've thougt that fp should rotate automatically following camera, spring arm or whatever
@fading smelt AFAIK no subsystems replicate. But that's second hand hearsay from me from random conversations I've seen.
Now I have another question, if I attach an actor, can I use a scoket for the owning client while using another socket(maybe from another mesh) on the other non owning players?
@steel fox Usually the camera is just attached straight to the base capsule, and the arms are attached to it. But yeah, for the third person mesh you'd use like a 1D AimOffset in the animation blueprint to show where it's aiming.
I assume you mean for something like weapon attachment?
Exactly
Better place for "Manager" type class to put on?
Game State?
@steel fox There's a couple of different ways to manage it. I've grown to like the shooter game's method. Basically they do the same thing with a weapon as characters do with meshes. Two weapon meshes in one actor, and on every client each gets attached to their corresponding mesh. So 1P weapon gets attached to arms, 3P weapon gets attached to the 3rd person character mesh. Their visibility is affected accordingly to the owning client and the player, etc. This also allows for easy LOD effects from third to first person on the meshes.
@fading smelt Depends on what you need. Can use Gamestate directly, or through an actor component on it. Or you can even spawn a whole new replicated actor for it.
Just wondering if anyone has done it enough times to remember, how can I run another VS Instance of the same project to be able to test locally, right now simply starting using 2 players (Server & Client) doesn't work as they are both the same player.
I found an article on how to do it before for multiplayer but I can't remember what I searched for and I can't find it anymore.
So I am getting now into Steam lobby stuff now. I am having trouble retrieving list of sessions. I am using SessionInterface->FindSessions, but I am getting a bunch of Unable to parse search result for lobby... I googled that this is kind of known issue, but I don't know how to get around that. Any experience?
Let's say that you want to spawn a grenade with simulated physics from your weapon, how would you manage that?
So i Can create bunch of actor components as different "Manager" classes and add them to Game State/Player State/ GameMode and they will autonomously Replicates / live on server/ on client/ both ?
@steel fox Hard to say. In multiplayer I doubt I would. I'd probably just use the Projectile Movement Component. It'll be much easier to get working than simulating physics.
@fading smelt ActorComponents can replicate as well, but they use their actors to do so. So if you add a component to an actor that replicates, and then set the component to replicate, the component can do it's own networking. I don't know the difference of network integrity or performance of component vs new actor. Jambax, Kaos, or Zlo might be people you'd catch around to ask about that sometime.
ok
@fading smelt yes
we have an actor in the level, that holds a few replicated componnts
this is our Level Manager actor
and inside that, those components are also small managers
(SpawnManager, LootManager, etc)
Does the client have ROLE_Authority over an actor that is placed in the world in the outliner that is not replicated?
As in if you call GetLocalRole() == ROLE_Authority on that actor it would succeed on clients?
It would appear so. Is there a way to make it so I don't have to replicate this actor but still be able to check if the local player is the server or not?
Will clients return their own player controller when calling GetWorld()->GetFirstPlayerController ?
You could use IsNetMode(NM_Client)
Thanks that is easier!
Has anyone ran into issues when spawning static mesh components at runtime? When playing as a client that has spawned these meshes locally (not replicated), I notice this printing in the logs while I play FNetGUIDCache::SupportsObject: StaticMeshComponent AssetPath NOT Supported.
To clarify both server and client spawn the same thing at runtime based on a seed, but there shouldn't need to be any replication going on, so I'm not sure why it's warning me
It's probably something like character movement trying to walk on it
It won't work because the movement base object has to be network addressable
Ah ok it does appear to work fine with clients but just that warning
So would the solution be to replicate the entire map?
Seems very heavy for a procedural level which I had though I only needed to replicate an int32
@winged badger has done some work on this, but you have to fool the engine into thinking those objects are part of the map
But essentially yeah there's a lot more to it than that
I wonder if it's actually affecting anything or just printing to the logs
Movement on both client / server seems great and perf is fine so maybe it'll be fine in shipping build?
Well it means none of those objects you are spawning can be used over the network at all
That's fine as they are just static meshes for terrain and such
Well it's not fine if you're using characters, as characters will try to use it as the movement base primitive which won't be net addressable
so it will cause issues
The only case I saw that was strange which I've now fixed was clients spawning a mesh that doesn't exist on the server and walking on it
Which caused the client to go to the origin on the server until it stepped off it
Yeah that's the kind of thing you'll see
But for all the other terrain that the server had also spawned, the client was walking perfectly on it
Essentially if it works, it shouldn't
But I'll be surprised if that's allowed to pass in shipping
It did in my tests last night
No warnings of any kind
I noticed the origin bug when testing on 3 machines
I mean it might just work by fluke, but it shouldn't be relied on
I'm sure games spawn clientside actors all the time though even for cosmetic things like little physics objects
Would they not be of concern as they wouldn't affect movement?
Or is this tricking the engine thing for every mesh you spawn clientside?
Interested to see what Zlo says
yeah, they wouldn't affect collision or gameplay - so that's fine
But something that impacts gameplay or collision should really be replicated, or deterministically generated
It can be done, but there's some trickery to it
It is, but the engine doesn't know that
Right so the trick part needs to be done
yeah
I've been looking around online but can't find info there, hopefully Zlo can shed light on it
AFAIK the parts you need to overrule are bIsNetStartupActor, which fools the engine into thinking the object was loaded from the map and can therefore be addressed through it, and also ensuring that all of those objects are generated with identical FNames
But I've not done it, so there may be more to it
Ah great, thanks I'll try it now
But Zlo has it working
Since client / server are generating the same assets in the same order at the same time it should be named the same
Will give it a shot
Thanks!
If not it'll be a hefty initial replication!
Thousands of individual meshes
Though I use a lot of HISMs which should be only 4 bytes each right? Though if needing to replicate all the instance transforms... not happening
How do you avoid the FNetGUIDCache::SupportsObject: StaticMeshComponent AssetPath NOT Supported error that shows in logs when playing as a client?
You can't replicate them
UStaticMeshComponent* SpawnedTerrain = NewObject<UStaticMeshComponent>(this);
This is being run completely clientside
The actor that it is being run on is not replicated, nor is this component
It works fine
I'm just wondering about these logs
Jambax said it's due to the server and client having the same mesh but not linked for collision so the CMC might be warning?
Well whatever assetpath is trying to be or attempting to be replicated we have no such warnings
Interesting, I'll have to figure out what exactly is happening
It fires off whenever and enemy gets spawned
So maybe the server is referencing a mesh that doesn't exist on the client or something
Strange none of our world meshes are replicated
But they do have the same name server and client
Shoudl be the same here they are all generated in the same order and same stream / seed
I'll log names and check
Thanks
Will UE automatically know they are linked if they have the same name?
Even though I'm just spawning a component clientside?
we dont spawn just components
we spawn the entire actor client side
we haven't done HISM based yet
its penned for next year
I just have a local actor that sits in the outliner that spawns EVERYTHING, Actors, Components, HISMs etc.
but we haven't done ISM/HISM yet, but you do need to ensure same name across client server
even components
Thanks I'm trying logging now to see if there could be a discrepancy
(if you want it to act like it was part of the package)
HISM setup is super fun and easy- ALL meshes other than the terrain meshes are HISMs for me currently
Just have to pass in an array of transforms and boom instances
I just want the logs to go away and not worry about something breaking really
Seeing as it all works fine in playtests I wonder if it's just a log and nothing more bad will happen
But I'd like to do it the right way if possible
Is there anything that a vanilla dedicated server using level streaming would write to disk/re-read on a second run of the process? I'm observing strange behavior that I can only correlate based on running my dedicated server binary more than once post compilation...that terrifies me.
I am completely lost on how to debug this
100% of the time the binary works fine on first run after compilation, second run it always hangs at a particular spot.
seems to be something related to levelstreaming/servertravel potentially.
I'm really concerned by the idea that multiple runs of my server process could interfere with unrelated sessions
I have an interesting problem, regarding crosshair positions.
I've got a set up in my HUD class that draws the crosshair, but can take a vertical offset for lowered crosshair positions.
I deproject this 2d vector to get the position in 3d space to trace to for firing my weapon.
The problem is the server can't access this position unless I send it to the server instance of the character via RPC. This is a lot of data to replicate frequently, as you can imagine.
I'd like to either find a way to recreate that variable without the HUD or to be able to access that variable via event (when firing) instead.
there is a ServerUpdateCamera RPC firing under the hood constantly
so the server has a pretty good idea about each client's camera pos/dir at all times
GetPlayerViewPoint in the PC will pull it out (for some reason not exposed to blueprints)
but it takes minimal c++ chops to wrap the native fucntion into blueprint callable one
Right, if I just had a centered crosshair, this wouldn't be an issue. But it's important to be able to have lowered crosshairs, which means I can't simply trace from the camera, otherwise shots don't line up with where the player is aiming.
the only method I've found that consistently gets the correct world position under the crosshair is this:
Which only exists on the client, because it's the HUD.
I can't recreate this outside the HUD because I have no way of getting screensize on the server, or I'm not aware of another method to trace to the location under the crosshair
that would leave you with a more significant c++ override (you can lie to the server where your camera is in ServerUpdateCamera, we do)
or calculating a shot on client
then RPCing the entire shot over to server
i personally don't like involving the UI in any gameplay stuff though
as replacing the HUD widget can break your entire game, never a good thing
Does anyone of you know how to replicate a map(variable)? because you cant do it in details pannel is there any workaround i dont think of?
yeah, convert it into array of structs that have key, value members, replicate that and reassemble the map on the other side
Hiya, what is the appropriate way to create and display widgets in multiplayer? Also I am trying to learn how to use the HUD class.
Thx man
use the HUD to instantiate all gameplay widgets (not menus, its lifetime isn't good for those)
and not loading screens
thats pretty much it, don't let any piece of code except the HUD actor subclass reference any of the UI
(notable exception are widgets on widgetcomponents, that often require the owner to inject a reference to itself)
and avoid using GetPlayerController/Character[0[]
my knowledge of multiplayer UI is very poor. This is what I have inside my HUD class but the widget I create is not displaying.
HUD has a 1:1 relationship with the PC
and is always local only
you don't need any network checks, its always the local players HUD
Can I use a datatable to replicate it?
instead of a map
oh I remove the network check and it worked. lol
also, because the HUD is spawned by the PC on client
didnt expect
client has the authority over the HUD Actor
it doesn't
Authority is WHO has authority over that actor
client spawned actor, client has authority
if its replicated, the server has authority
why would you replicate a datatable @warm leaf ?
its an asset, as long as its packaged on clients, clients have it
DataTables can't be replicated, and DataTables are supposed to hold static information
not mutable at runtime
to get the values (intead of a map) replicated
you can replicate a pointer to the datatable
and you should never ever replicate static data
well the data table exists on both clients and server
so you function should know where the data table is and get the value
Whats going wrong? (I think im brain AFK from this whole replication shit)
I have a weird problem when im leveling streaming(Loading) 2 clients to the same map it doesnt spawn the players characters. When i Level stream only using one client (Level Streaming) it works correctly. Does anyone know why this would happen?
Figured it out. Game mode was not Begin Playing when there are 2 or more people.
@winged badger Any insight on the discussion from earlier? FNetGUIDCache::SupportsObject: StaticMeshComponent AssetPath NOT Supported being printed at runtime in the logs on client when generating an identical procedural level on client and server (the components causing the log to print are created as so UStaticMeshComponent* SpawnedTerrain = NewObject<UStaticMeshComponent>(this); ) Jambax mentioned you knew a workaround
Works fine but of course would like to fix whatever issue is causing the log
did you set the mesh to be replicated or something?
Nope
Completely clientside
The actor that is spawning it is a non replicated actor that exists in the world outliner
The server just replicates down a seed and the client gets this actor and generates the same level based on the seed
Maybe need to call UActorComponent::SetNetAddressable or something since it's not created in the construction script? (which is one of the conditions for UActorComponent::IsNameStableForNetworking to return true)
Yep that seems to have stopped the logs!
Zlo if you know of a better / more correct workaround I'm all ears!
set net addressable shouldn't work with that way of spawning it
even if the actor owner is net addressable, the component, not been given a unique name relative to its owner, isn't net addressable
and is likely to cause a client disconnect if a pointer to it is ever send over the network
I'm setting net addressable on the spawned component
yeah, i caught that
but the thing is, it just expects to be net addressable, but isn't
In this case does it matter if I never will be using it as a pointer
Just has to have the same level on client and server
And no log warnings
you should still give it a name unique for that actor scope that matches on client and server
As if I hand placed the mesh in the outliner- never to be referenced again
when you're spawning it
Since there is exactly one level generator in this case and never will be more, and UE give a unique name to each spawned component, should be fine right?
otherwise you're just leaving a landmine in your code
Since it runs in exactly the same order on client / server and on only one actor
Yes the output should be the same, it's like StaticMeshComponent_0 etc.
I'll double check to verify
I know but the autogenerated name appears to match on client / server
yeah, and when you start listen server + client game in pie
You appear to be setting a variable on a client when you've set that variable as replicated.
they al have playercharacter0 and 1
they both typically have the 0 one for local tho, both
So I should just give it a name like TEXT("MySpawnedComponent_%d") to make it unique and match on client / server?
To avoid any autogenerated mishaps?
i would
Great thanks, and should I do this for HISMs spawned too?
Basically any mesh that needs to match on client / server that has collision
that would also actually make it net addressable
note: unique name is important only in the scope of the actor owner
Oh I see, so by giving it a custom name I can remove the
SpawnedTerrain->SetNetAddressable();
call?
you can have 10 instances of actor A, each with instance of component B called "ComponentB"
That's good to know
And you'd do it for HISMs too?
And anything with collision basically?
HISMs do have an actor that holds the instances, yes?
well, anything you know you need you can preplace
that solves all the problems out of the box
But I need the seed from the server
Which is why construction script is out of the picture
Which would suppress the logs
to what? add instances to HISM?
Yes
The seed determines the density
I can't add the correct number of instances
Until I get it
Well in this case the seed also determines how many HISMs get spawned
Sometimes 1 sometimes 20
Depends on many factors, so has to wait on the seed
The spawner itself is
But that spawns multiple sub actors that spawn things
Depending on seed
so its net addressable by default
components net addressing is resolved basically by resolving an actor owner + its unique name relative to that actor
if your Spawner has HISM_1 and HISM_2
and those HISMs are spawnet at runtime
the pointer to them can be resolved only if the
1 - have the exact same relative names on server and client
2 - have SetNetAddresable called on them
Thank you so much for the breakdown
created in constructions cript
makes them part of the CDO
which guarantees the names match
Ah I see
So is this proving that the autogenerated names DONT match
And SetNetAddressable just hides the problem?
Or they could match, and SetNetAddressable is allowing them to be linked on client / server?
i would not trust the UE to make it work out of the box there
and would treat SetNetAddressable as a landmine
unless i explicitly set the component's names
i would not trust UE to work at all 
Got it, custom names it is
Thanks for the help
I'll try custom names and NOT calling SetNetAddressable
and see if the warnings go away
they won't
Oh so I still have to call SetNetAddressable?
ofc that marks bNetAddressable so it can be accessed over the network, but i thought HISM components can not replicate?
Talking about UStaticMeshComponents in this example, maybe HISMs don't cause this warning
Would have to test
they would
nor do static mesh components replicate
Ok so I'll do it on all
all components spawned on replicated actor at runtime that are not themselves replicated
will throw that warning
In this case the actor isn't replicated either (the spawner)
@winged badger don't you mean replicated component on a non replicated actor?
cause that warning does not appear for non rep components on a replicated actor
no, its the FNetGUID Package : Component not supported for networking
Spawner spawns sub spawners which are the things spawning ustaticmeshcomponents in my case but the sub spawners would still be net addressable right?
warning
Or should I call SetNetAddressable on those too?
yes the actor is replicated (or marked as being replicated)
oh right
but that should not happen for non rep actors, nor should it try to ever create a netguid for it ?
the net addressable ones have a valid static net guid
the CDO components on them as well
but why is the component marked as net addressable?
but ones spawned in do not
if its only ever used locallyt?
because the warning log annoys him
In this case since the net addressable spawner spawns in another actor which does the actual spawning, is that actor NOT net addressable and should call SetNetAddressable On it too?
we don't get that tho
setting the spawned spawners as net addressable
gives you extra options that you might not need
I just want spawned meshes to be linked and not warning in the logs, so I should just do nothing on the spawned spawners then?
like ClientSpawnMeshes(AMyMeshSpawner* InMeshSpawner, int32 inSeed, int32 InMeshCount);
Yeah in this case I don't need that at all, just need the seed and basically run this locally
for (PotentialSpawner : PotentialSpawners)
{
if (RandRange > X)
{
PotentialSpawner->SpawnStuff();
}
}
but if you spawna apsawner dynamically, and then spawn component on it, as long as spawner itself is not replicated
there should be no warning
There is in my case for some reason
Unless SetNetAddressable is called on spawned components
Strange!
One last design question, if you have some actors that need only be spawned on the server as they are replicated or server only like a spawn point and I want to keep the client and server using the FRandomStream in exactly the same way, should I create a separate serverside FRandomStream for any server only RandRange usages which should keep the client one in sync?
yes
every random you pull out changes what the next one will be
so for seed to work in sync
the server and client need not only pull from a stream with the same seed, but also pull exactly the same number of randoms
Perfect thanks yeah have been wondering about keeping it exactly the same
Two streams it is!
Thanks for your help
And just final thing: the only way the net addressable thing could ever bite me in the ass is if I'm using the pointers right?
So since I'm not touching them, the warnings go away due to SetNetAddressable and they are named correctly, there shouldn't be any repercussions?
As replicating an entire level down would be unfeasable
they would, but you're leaving a landmine for just avoiding a couple of lines of extra code
not worth it
yes
@grizzled stirrup also order matters, so make sure your client/server order is the same
i do this by sorting the array on both client and server prior to randomizing
tho normally this is fine
just extra failsafe
Yep in this case the server / client runs exactly the same code and has an array in the same exact order: for any server only actors in that array I'll now just use a second server only FRandomStream for any Random calculations
So I have a question. I have a HUD setup for each player which is able to translate a damage input into a visual widget output. My question: where should I handle damage input communication to HUD? Inside player state? Or player character better (as health is not persistent to player, only player character)?
@twin juniper When you say HUD, do you mean AHUD, or a widget that you've named HUD?
AHUD
Probably just where ever you're handling the damage variable then. You can set the new damage, and then call the local hud through the local player controller to update it.
Hello, is there a way to direct connect to a SessionId ? look like the FindSessionById is just an empty space in few OnlineSubsystem
I have a MP project that runs fine, replicates as expected. I have shared this project with a friend and when they run it the project starts, but they get very choppy replication - lots of movement desync, rubber banding etc. I have network profiles both and this is what I see (see link). The image on the left shows really patchy replication - the counts are several times higher on the right (working) than the left (not working).
I am wondering what on earth could interfere with replication in this manner? Feels like it's something PC related, but after scratching my head for a few hours on this, I'm not sure what that could be.
https://pasteboard.co/JGkJpEN.png
Simple and lightning fast image sharing. Upload clipboard images with Copy & Paste and image files with Drag & Drop
what does this warning mean? Warning: Fault: gap in received Debug buffer.
Hello everyone. Another Replication mind-gap question.
I am trying to use the Player Character's ABP to rotate' the player character's head when the controller adjust stick deflection or moves their mouse. I have got it working locally, but I cant get any other client on my dedicated server (or local dedicated test server) to see the head rotation.
Here are my blueprints.
Seems pretty straight forward, it works on client, but not replicated on server characters.
I thought I knew how multiplayer worked but it appears that in my new UE4.25 project, player pawns that joined the host view the listen-server-controlled pawn as having no controller
When I GetController on them, it returns and ObjectName of "None"
(from the client side, but gives the expected controller name on the server side)
The trouble with that is, I want to execute an RPC for that pawn, but if it has no controller then the RPC doesn't seem to want to go through.
(Note: This is just a basic Pawn class, not a Character)
controllers only exist on the server, and for the local client.
they are not replicated.
OK. So I just need to get the RPC to happen from the Pawn then I guess.
Wait I think I know - it needs to be the pawn that lives on the client making the RPC
I was trying to run it from the pawn owned by the server. Okay I'll try that.
Yep that was the problem! Makes sense.
Hey guys, quick question about client side prediction. We need the inputs of the other players to actually predict the stuff, and if we are sending this input to only the server and the server has to give the input to the players, how can we actually predict other player's movement and stuff.
Also I'm still researching and learning about this stuff so I need all the help.
If you're not using CharacterMovement and creating your own prediction instead, then what I was taught was to store an array of velocities, transforms, and timestamps (in a struct) that gets updated on each pawn so you have a Server copy and a Client copy. Between server updates (when it replicates to the clients), then each tick you'll be using that array to interpolate. I guess that's more smoothing than prediction, but you can use hermite cubic spline along the multiple transforms based on the delta of their velocities. I went through a Udemy course about it. It works okay for car-like movement.
Also, @vital heron there is a plugin in the marketplace called SmoothSync which is open source so you can either use it or study their source code to figure out how they do it.
Not sure if their method is cheat-proof though.
gotcha, I'm currently reading this article https://www.gabrielgambetta.com/entity-interpolation.html which is really helpful
But that is a really good tip
the only thing I'm confused about client side predication is the other players
and how they send their inputs and all that stuff
I'll look into that, I got an idea on what to do but it will be very helpful to look at examples and solidify the best way to do it
I really like using pawns because I get to learn more on how things work like this
With a character I literally wouldn't have 90 percent of my knowledge about ue4 especially when it comes to mp
Subsystems can be replicated?
@fading smelt they can't, not without some ugly hacks and amount of work disproportionate to the benefits
ok
So Subsystems it better use for local not replicated manager type classes and other stuff?
subssytems are derived from UObject - supports replication but doesn't do it out of the box
they don't have an Actor for an Outer, so they don't have an ActorChannel they can just replicate over
they can work in pair with a replicated Actor though
note that most subsystems have a class instance that doesn't normally replicate as Outer
GameEngine, GameInstance, LocalPlayer...
ok
TL;DR; whatever you would want the replicated subsystem for, there are easier ways to do it then replicating a subsystem
ok
@fading smelt may I know the reason why you thought that you should replicate s subsystem?
@winged badger I think its not that tough to implement a replicatable subsystem, similar to GameInstance Subsystem just implement PlayerState Subsystem or PlayerController-Subsystem.
If you see their source code actually GEngine or GameInstance stores map to Subsystems, do the same implementation inside PlayerState or PlayerController, and they are actors and they do replicate
you can replicate GameInstance if you really want to
doesn't mean its a good idea
you could add subsystems to other actors, yes
but replicating default subsystem is.... not ideal imo
yes agreed on this that is not ideal to replicate
and also, same can be accomplished by an ActorComponent
that just doesn't go on GI, or LocalPlayer, or World
by the way is there any flag to enable GI replication, or does it require to do same setup as that of UObject to make GI replicate.
just for my knowledge i was asking
btw, no idea how would a GameInstance react to having its Outer changed to an Actor in the World
but i don't imagine it would be any good
How expensive is AI character movement replication vs player character movement replication?
it won't send any RPCs
Not 'character movement' as in 'character movement component' I mean in general
As per my understanding GameInstance is the first UObject class created and then GameMode , and then other actors are created..
So if this hierarchy is followed , the super outer of all actors or UObject is actually GameInstance..
Is it really possible to make GameInstance 's outer point to this child??
if you make it replicate
you'd get another GI on client
with the Actor that replicated it as the Outer
so, really bad idea 😄
don't think the game framework would recognize the replicated one as GI
So how would somebody access that replicated GI.
as i said, really bad idea
Right right
Better place to Store Inventory Class and InventoryItem manager in multiplayer game? Game state?
I put ItemData in GameState, but I make each client populate it themselves locally from a datatable to avoid networking, and store the actual inventory on characters or storage actors in the level via a component that just holds simple slot information like count and an identifier ID. Players can interact with all other inventories from the component that's on their character.
ok
Got a bit of a situation I can use help with.
Context: For those you have played DS like games, this is the save point. For those not familiar, when going up to a save point you have to activate it first. Then you can save there. The activation event is setting both on client and server, and the saving is working (client only).
Problem: During the activation event, which is being called, I turn a particle effect from hidden to active (a fire). The fire never appears on the client side. Again the event is being called, otherwise the save process would not work and I have also debugged to make sure that the event is being called. (doing this in BP). Is there anything unique about setting a component from hidden to not hidden that I need to be aware of in UE4?
Are you setting the visibility on the client or on the server?
Both.
Server does the initial set up then when its done it calls a client version to run. When I turn dedicated server off, and test it with 2 users it only visually sets on server though
So your interaction feeds to a "Run on server" event in which it sets the visibility of the component to visible, then you do a "Run on client" event and do the same?
Or, multicast even?
Initial set up is close to what you first asked. Though I have does on Run On Server calling a multi-cast as well.
(The ROS is so that the bool variable I am using is set properly, that is the primary reason for it to exist)
Do you have the component set to replicate?
Tried both on and off with that, no difference
So here's what I have on my end, just using the mesh of an actor... I don't have the component set to replicate, but the visibility is updated on all clients.
Just using a get all actors of class to get an easy reference to the actor I'm unhiding.
I gathered. Give me a moment to screen shot what is being called on my end
this is the function that is called (and it is going down the correct path):
Ignore the mess and the fact there are duplicated functions, I have been trying to resolve this for a bit. I have checked all three versions of the function (above) and they are all being called. (like I said I threw MC in as a test)
and the ROC and ROS for the activation events are correctly set in the parent
You don't want to change states with RPCs
Just as a note here
Also, what changes that boolean you use ?
Where (and I guess how) then do I change states for the new hidden?
The only RPC that's valid to use would be a ServerRPC to set the boolean in case on your on the owning client
But that's about it
Also is that code in the Bonfire?
Yes, the parent class is just for the generic parts of all interactable actors (doors, levers, bonfire)
- Why is there a ServerRPC in the Authority code path?
- You can't call Server or Client RPCs in Actors that aren't owned by a specific Client.
If this is interaction based code, you need to RPC in your Character or Controller or similar already
The Multicast would be replaced by the OnRep boolean or enum
The Multicast RPC can stay for some one-time event that only needs to be seen by whoever is there at that time.
But everything that is state based, e.g. on/off, should be an OnRep variable of sorts
- most likely cause I was trying multiple approaches to see if something was off.
- fair enough, plan was to make the actor owned by client 1.
Trying to the OnRep approach and seeing how it goes.
- fair enough, plan was to make the actor owned by client 1.
That still requires you to RPC before even touching the Actor, as you can't set the owner from clientside
So you win nothing by doing that unless the Client remains the owner for the rest of whatever determines it
Even then, RPC setup was wrong
Well it's working for everything before and after that point
So you marked the Active boolean as repnotify?
Yes
and it's getting called
and it's going down the correct path, and continues onto the correct things afterwards
yes
I would try to not hide it, but to just activate and deactivate
Not only to check if that fixes it, but also be cause deactivate lets the particles die out
While hiding is quite ugly and instant
switched with active instead of hidden, no joy still
Hm, strange
Just for sanity, check on tick if the boolean is true and force it to be visible/active
anyone know what this error/warning means?
LogNetworkSim: Warning: Fault: gap in received Debug buffer. PrevHead: 47. Received: 55-59. Reseting previous buffer contents
already did, fire works then
just re-tried, the fire particle effect is still showing up if the bool is set to true at the start
repnotify run on a non dedicated server, still only see the activation (particle effect showing up) on server.
just added another print string to confirm that it is active. server is seeing as such.
Is your actor set to replicate?
.... damn it....
I thought it was, I hit the check box above it by mistake...
son of....
Thanks
If that's true, how come the code for the fire calls on the client?
no idea but now both sides of it are working (the particle) and practical (saving)
wait how do i implement multiplayer into my game?
Very carefully
??
That was just a very open ended question, so I gave you an open ended answer. My suggestion to you would be to first go online and go through some free youtube content/tutorials to get yourself started with the understanding. Even before that, go through cedric's compendium http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf and then if you are still having issues, consider very highly rated courses for the subject matter on udemy. Work through tutorials and when you have specific issues or problems then come back here and ask them. Everyone here is very knowledgeable, but you have to put in the leg work.
ok thanks
and yeah i have one more problem.the turning system doesn't work (flying template).:in my flight sim(the flying template)When i press my down arrow key should go up,but instead go's left,for up it goes right.and the right key leans to the right and the left leans to the left.can you help me?
Do you mean it does this over the network? Or just locally?
I have no experience with the flying template player controller but it sounds to me like you have your input bindings mixed up. Is there an issue if you swap them so they behave correctly?
Is there a way to check the milliseconds that the game updates or better, can I change them for testing?
You mean latency or deltatime between client and server?
You can put this in player controller to get a ping display on screen.
and if you want to set some latency
Oh that's what latency means. I've tried looking it up but it only comes up with the science or math definition
Thank you!
You can also test with lag by setting some launch game settings.
Hi all, happy christmas eve!
I have had my level resetting each time damage is applied to the town, this has been working but stopped in the last day or two, and I can't figure out why. I didn't change the way the level resets, and I've confirmed with print string that it is making it to the server travel command. Anyone notice anything?
I have placed EventOnSessionInviteAccept in my main menu Player Controller, after accepting steam invite that event doesn't get triggered. Any idea why not?
So I have a floating health bar above player character/ AI character heads that is visible to all players except the owner. The health bars are controlled by a variable on their corresponding characters. How would I go about replicating the health bar so that other clients can see when a player loses health? Currently only the owning player can see the bar change (when I disconnect a node to allow the owner of the health bar to see it). The health bar is a widget component in screen space.
Player 1 view
Player 2
By replicating the health variable
This is the setup I have, before I tried setting my 'percentage' value after the 'multi HP' node at the bottom
why are you telling the widget directly the health changed, i would have a delegate the widget binds to for when the health changes
anyway you also have a replicated property inside the widget, which is not allowed, widgets are LOCAL only
and you need the server to modify the Health property never the client
so your logic there is also wrong
also wrong
never multicast health change
its pointless
why is the client telling how much health the server should take away?
why are you using Set with notify on client?
clients can NEVER replicate properties
replication is one way, Server -> Client
Are these all functions in CMC reliable? I dont see any UPROPERTY
why would they have UPROPERTY() ?
To set them as RPC
yeah sorry lol
also check ACharacter
confused
that is what calls them
so yes they are unreliable cause they are called pretty much every tick, and all RPC's called a lot should be unreliable unless it will impact gameplay
Yep, I see now, all of them unreliable
The tutorial I am following (krazy karts) made it reliable on Tick
yup that is wrong
never reliable RPC on tick
you will overflow the RPC buffer
(reliable buffer)
👌 Noted, thanks
I used to use repnotify in single player a lot to fire logic whenever a variable changed. Is that wrong?
Like I said, easy way to attach logic
that rep notify fires using property changed event
well your logic above is wrong
- no replicated properties inside widgets, 2) Widgets are local only, 3) Replicated properties MUST be set on the server. 4) Never trust the client for things like health changes.
so your input (debug input) calls a server function called say Damage, this set the damage based on the hit points
the Health property being RepNotify, can set the widgets health
simple as that
at least it makes it easier if you do a coop mode later lol
it's pretty much a hack though rather than just having a setter function
I have 2 health display types. One is a widget connected to the HUD which is only for local client to see. The other is a floating widget for all other clients to see.
iirc if health was a replicated variable i was just putting the health variable from GetOwner->CastTo CharacterBP->GetHealth to a binding in widget
And it was working for every connected client and server
is WasRecentlyRendered() local or if a client renders an actors it returns true for everyone?
How do I make smooth replicated movement in UE4? My client starts to stutter or my server sees clients stuttering every time i try to properly make movement. No answers I've gotten before have worked
NOTE: I'm testing this on steam and not in editor so ping is a factor
Why repnotify is not enough to replicate setting SK Meshes?
The CMC handles replicated movement for you, which comes out pretty smooth by default. What are you doing, sprinting?
Hey! Have you ever had a problem with RepNotify functions in C++? Mine is not getting called when i change a value
iirc in c++ repnotify doesnt call to server
i remember people here talking about calling server rpc in repnotify to make it working also in server
Mine is not getting called at all. I change value on server (RPC), but its still not getting called
@native pagoda It's not getting called on the Client when the server changes a value?
Is it true that blueprints are very limited compared to c++ for making multiplayer games?
For anything beyond basics, yes. You can get away with a lot, but it won't be nearly as good, and C++ has a lot of great tools like FastArrays, conditional replication, RepGraphs, etc.
Like. Coop to 6 player simple game. Blueprint will likely work just fine in a lot of cases depending on your scope.
there are some conditional replication in BP
I would like to know if I must use JoinSession to join a session or I can join using the IP directly if I already know it
@rare cloud I meant more whether it should currently replicate or not, more than how it should replicate. As far as I know, you can't set a property to not replicate for a small amount of time in blueprint, even if the server is changing it.
@kindred widget yes, its not getting called at all, both server and client
@native pagoda Well, as Idont mentioned, the server won't call it, you have to do that manually. But as for why the client isn't calling it.. that's odd. Can you put a quick print on like tick or something and change it? See if it changes on your client.
I used AddOnScreenDebugMessage in function that changes the value (gets printed) and in RepNotify (it doesn't )
@kindred widget
The function that changes it is on the server. You need to make sure that the value changes on the client.
So its not getting automatically changes on a client when I change it on the server?
I dunno, that's why I was suggesting the print string, to see if the value was actually getting changed, and the repnotify wasn't working. If the value changes, then replication is working and something with your notify isn't. If it doesn't change, your replication is broken and your notify wouldn't fire anyway.
So I have a health bar that I am replicating, problem is when a player gets too far away from the health bar it is destroyed (would like to stop this ideally), when it is redrawn the data does not persist for the health bar.
Hey y'all! Merry Christmas! 🎅
Question - I have an actor that was spawned on the Client only (intentionally), and I want to communicate something to the server through an RPC.
For obvious reasons, I can't do that through this same Actor. So I'm bridging the communication through an Actor that lives both in the Server and in the Client. But even so, my Run on Server RPC isn't called.
Ideas?
Just to better illustrate my scenario:
- I have an Actor called
Circle. This Actor was spawned in the client only. - I have this second actor called
Square, which is a replicated Actor spawned from the server, and the client owns it. Both are aware of it. Circledoes its stuff, and in the end, it informsSquareX occurred, andSquare(the client version) attempts to communicate its server version about it. ---> this is the exact moment where things are failing.
Pretty much, the information doesn't arrive in the server. I'm suspicious this is occurring because the server doesn't know Circle, thus the communication between Circle and Square isn't possible (from the server perspective) b/c the origin of the communication is unknown to the server.
Sorry for the overwhelming information. But it is what it is. Let me know if I can help you better understand my problem.
And before you ask, I don't want to create Circle on the server b/c I don't care about cheating. In this specific scenario, latency is more important.
@gloomy tiger The Actor that you use for communication needs to be client owned. Like the client's player controller, or Pawn. In your case, Square might be replicated, but it's server owned, so the client can't use it for ServerRPCs.
One information I was omitting that I thought it might be irrelevant but... Square is a Component, owned by PlayerCharacter, owned by the Client.
That said, I believe Square is in fact owned by the client. (because its owner is, so...)
And Square has Component Replicates checked.
cc @kindred widget
Are you working in C++ or Blueprint?
Blueprint
Are you getting a hold of the component via GetPlayerCharacter(0), then GetSquareCompoenntThing, then calling the RPC via that pointer?
This is what's going on. Circle calls this function, TryToRevive from Square.
And inside Square, this is what I have.
But this is on the client though, so wouldn't you want to use a Server RPC, not a Client one?
TryToRevive is happening on the Client, but it calls Answer Revive, which runs on Server.
That Hello Print String isn't being called when a Client attempts to execute these nodes.
Besides, I've tried that at first. Calling AnswerRevive (Server) directly from Circle, but it didn't work - so I've tried what I'm showing above, and it didn't work either.
I can't see why this wouldn't work, unless that component is invalid. Coming from GetActorRevivableComponent.
I don't believe it's invalid. I mean, I'm doing this:
Here, try this really quick.
And it seems it's being created both on the server, and on the client.
Do, GetPlayerCharacter->CastToMyCharacterClassWithComponent->GetComponent->TryToRevive
See if that works. That'd directly get the component. If that works, something is wrong with your function that's getting the component.
But yeah, as long as that component is on the client owned actor, called from that client, and the component is set to replicate, those functions should run fine.
I know, right? That's what's intriguing me.
OK, just tried that.
OH, WAIT!
It didn't work, BUT
It made me realise our misfortune. Pretty much, my Client is calling TryToRevive from a Square component it doesn't own. 🤦♂️
I mean, the TryToRevive is residing inside the Square component of another PlayerCharacter. Thus, although my client is aware of it, it doesn't matter b/c it doesn't own it.
That puts me in a tight spot. Side question - can I call a server RPC from an Actor the server doesn't know it exists? lol.
An agnostic RPC of sorts.
Not really. Any RPC has to go through a replicated actor or component.
Fair enough. Well, many thanks for your help! It definitely not only clarified my problem, but also addressed it, ha!
Merry Christmas, @kindred widget! 🎅
hi
i click on button then i create widget, on create widget do i need to destroy the other widget or just make visibility hidden ?
i dont want extra cpu usage guess of an hidden widget?
@twin juniper Invisible will just hide it from view, Collapsed will stop it's tick and keep it from being used in the slate draw calls.
Is there any way to replicate a variable map container (dictionnary) in blueprint? By default, it isn't replicable, so I tried to make it update via a replicated server event, but the value returns as null.
Thank you sir.
@low sand I don't think that TMaps are networkable at all. Generally either use structs, or find a way to break them down, send them and reconstruct them on the other side.
5 seconds answer :
i finely login into my server.
what box i need to click to move in a deticated server ?
i dont know how to move replicated please help
It's all very generic
I think it's already replicated?
it is
in the game mode i disabled all the UI and started the new one at the normal map, solved
I'm trying to pass a reference to an actor component via RPC, but it arrives null. Is it possible to do?
as long as its net addressable, yes
i'll take it you spawned your component at runtime
How can I ensure that? It's a component that I use to manage the inventory, so I want it to be always accessible but I don't know where to start with that. (BP)
any replicated component on a replicated actor is net addressable
It's part of the character's BP, and it spawns through the game player start
and component on the CDO of a replicated actor is net addressable
Both the actor and the component are replicated
any component on the CDO of an actor loaded from package is net addressable
any component on net addressable actor spawned at runtime, with exact same name on client and server (relative to actor) and that had SetNetAddressable called on it is net addressable
then the pointer should just work
Hmm.
is it a component on the CDO?
What is the CDO?
class default object
also make sure the component ref you put is valid
if you can see it on component list in BP, the answer is yes
but when you do does it even execute?
you'd better put some screenshots here
@winged badger since you are here, I would like to know if it's a bad pratice to connect to a session (using steam for example) with IP instead of the classic flow
I've noticed that I call a similar RPC function from the Pawn and it works, but it doesn't from the PlayerController.
using steam yes
its NAT punchthrough works via steam sockets
Jack: I'm not sending a ref of the PlayerController, the client's PlayerController is sending a ref of a component that exists on a player pawn.
a picture is worth a thousand words
What do you want a picture of?
when?
BeginPlay?
@winged badger thanks !
Nope. Basically, it's an inventory system. When the player drags an item and changes its position, the player controller sends the new container to the server so it can update.
So, it's not called before the ref can be created, it's called whenever you move an item.
imo Crita just move your RPC to character or playerstate
actually
don't send the RPCs for that at all
just make a local translation map
server doesn't need to know which slot your items are in
Why?
equipping is different
but as for that box in there, is it at 0,0 or 7,4
makes no difference whatsoever
as long as client can still communicate gameplay interactions with the item properly
Multiple players can access the same inventories, so I feel like they should be synchronized
No?
The player pawn
show me the RPC
no way to tell if those slots are vaild at the time of sending here
They are
I've tested both in debug and print during run time
if I remove the RPC and run it locally, the function works as expected
if I run as RPC server, it triggers an error message saying the ref is null
anything else in the log, warnings?
Not really no
so there are 2 inventory components here
if the rpc is on playercontroller it will never succeed for a remote client
It's not for a remote client
one is on playerpawn, the other?
PlayerController moves item on local GUI -> Sends intent to server -> Server applies inventory update -> Server rep notify new inventory
zlo: In this case, both are on the same player, just moving an item from one slot to the other. It's the same function wether you shuffle your items around or if you change from one container to the other
which one comes as null on the other side?
so one of them works, the other doesn't?
verify the target server side after the RPC
Yeah, seems like it. I'll double check
Oh no wait, yeah I get why it would do that. The function is located on the inventory container component, so it assumes that the "FromContainer" is the container executing the function
Yeah, target works fine, it's the ToContainer I'm confused about
so whats different between the 2?
(way they are instantiated, or different replication settings)
Take item from ContainerA in X,Y and put it in ContainerB in X,Y
ContainerA is Target, ContainerB is ToContainer
(not sure what you mean, but same component and same replication settings)
but I think I know where it might come from
LogNet will also log any NetGUIDs its unable to resolve
although, i don't remember on which verbosity level
Difference between on the client and server
one print is before the RPC, one is after
How do I compress an FRotator?
I understand AActor has Role and RemoteRole for checking network execution context, but what about helper functions that wrap these checks for different use cases? So far I've found HasAuthority on AActor and IsLocallyControlled on Pawn. Are there others?
AActor
HasAuthority (dedicated server or listen server)
!HasAuthority (client)
Pawn
IsLocallyControlled (listen server or client)
!LocallyControlled (dedicated)
I think casting each value to a float should compress the rotator, if I'm not mistaken
it won't
if you don't need a roll
you can just turn it into FVector_NetQuantizeNormal
It's the rotation of my actor, the roll is necessary
Then should I cast to int and remove the decmial?
@lavish cypress that is not always correct
why would you compress it to start with? finished the game, profiled the network, its using too much bandwidth so now you're optimizing?
Basically
FVector_NetQuantize is half the bandwidth of a normal FVector, right?
I'm looking for the rotator equivalent
@lavish cypress HasAuthority doesn't mean its server, it just means its a server spawned or loaded actor
client has Authority over all Actors it spawned locally
there is GetNetMode() as well
no, FVector_NetQuantizeNormal is half the size
but it can only do magnitudes of 0-1 per component
which is why its a popular choice to compress a rotator, with a caveat that you can't restore roll information from a vector
Wouldn't casting each value in an fvector to an integer work pretty well, assuming I don't need perfect accuracy?
how would that work? int32 takes same amount of memory as float
Hmm, perhaps using an FFloat16 would each value would work
Half the bandwidth there I would assume
still no point unless the game is at the beta stage
I'm moving into beta this month or the next
It's fully playable. Pretty much just time for optimizations and bug fixes
well, read the NetSerialization.h bottom third of the header for inspiration
template<int32 MaxValue, int32 NumBits>
bool WriteFixedCompressedFloat(const float Value, FArchive& Ar)
template<int32 MaxValue, int32 NumBits>
bool ReadFixedCompressedFloat(float &Value, FArchive& Ar)```
noteably those 2 functions
(Thanks for the help guys! I managed to fix my issue!)
the networking docs are not that bad, as far as replication flow and net addressing goes
you should re-read them occasionally until they fully sink in @low sand
I've been reading the wiki and the netcode compendium, but my issue was not really something that I've seen covered in those so far. I'm not even sure how to put it into words with my beginner level :p
its not really fully digestible at the beginner level
thats why re-reading the more complicated sections every couple of weeks is a good idea
Oh dang, is there a way to check for a server otherwise?
I've been using HasAuthority() based on Tom Looman's tutorial
GetNetMode()
enum ENetMode
{
/** Standalone: a game without networking, with one or more local players. Still considered a server because it has all server functionality. */
NM_Standalone,
/** Dedicated server: server with no local players. */
NM_DedicatedServer,
/** Listen server: a server that also has a local player who is hosting the game, available to other players on the network. */
NM_ListenServer,
/**
* Network client: client connected to a remote server.
* Note that every mode less than this value is a kind of server, so checking NetMode < NM_Client is always some variety of server.
*/
NM_Client,
NM_MAX,
};
:0
My ue4 career is a lie
Thanks man, that's probably why I've faced so many mp issues in the past
you can pull it from Actor or World
Do you use role or netmode more often? Or do you create helper functions to aggregate them
Sometimes I wonder if the presence of role or netmode checking throughout code is a code smell and I would be better off designing code to function properly through context hints rather than depending on global states
But it doesn't seem always possible to avoid checks
I want a better solution to writing some code and then getting undefined behavior on netmodes I didn't think about when I wrote it
i often use Role because the IDE colors the ROLE_Authority and such differently
so makes it easier to skim the code
(i use role when either role or netmode would do)
Can I use FFloat16 as a function parameter?
I get an unrecognized type error
Even with the include
no
On a listens server how do you stop clients from spawning and just falling through the level? it seems the levels are only streamed on the client and not server so there no ground collision.
@kindred widget Just wanted to thank you for help. I don't know what exactly was the problem (engine/ bad include/ lack of GetLifeTimeReplicatedProps function or whatever - compiler didnt throw any error), but tried everything and finally got it working. Thank you man ^^
Is there any way to dynamically reduce the replication frequency of a single replicated UPROPERTY (without changing the NetFrequency of the entire actor)?
I guess I can 'exploit' the push model to just mark it dirty every X frames && per change rather than just per change but that seems indirect
I haven't net profiled it yet but it could be well over 25-30 floats worth of bandwidth for every player
when I reach my final classes
(at least, on the initial bunch)
and the thing is it's not all extremely needed - because my actors are already net synchronized through an input stream, the uproperty is only important for corrections, which are needed only like once every 10 seconds
so when I'm simulating multiplayer on my home screen, I am guessing my fps is affected by having n windows open at the same time (with n the number of players). Is there a way of simulating being a single player in a game of n players?
Pardon, Zlo, this function/enum is really interesting. It's not available in Blueprint sadly, so I'm trying to wrap the function in a CPP function library.
Any idea how to get around the fact that the enum is not defined in EngineBaseTypes as a UENUM()?
I ended up in the thread below, but not quite grasping the way forward. I tried the TEnumAsByte workaround.
https://answers.unrealengine.com/questions/427309/ustruct-type-must-be-a-uclass-ustruct-or-uenum.html