#multiplayer
1 messages · Page 701 of 1
But just know this about origin rebasing, it sucks
It causes hitches, it breaks physics, and in multiplayer it frequently causes corrections and doesn't even solve the problem of large worlds because the server has to operate in zero-space.
If you still want to enable it, just add this to DefaultEngine.ini
p.EnableMultiplayerWorldOriginRebasing=True```
Then call GetWorld()->RequestNewWorldOrigin() to change it.
Hey guys, I am trying to rotate my networked character (uses movement component) and has bOrientToMovement set to true).
I try rotate my character on the server using SetActorRotation() and this change is replicated to simulated clients but does not replicate to my Autonomous client or atleast it doesnt rotate on my autonomous client. Anyone have any clue why this is happening, I thought server would force that rotation onto me?
(Or does something happen inbetween that im missing? I SetActorRotation straight after an RPC call to the server to rotate character)
It has bOrientToMovement set true, so it will follow velocity. Setting rotation directly will break it.
Hmm, thought it might be related, but I thought force setting rotation would work since it seems to work like that in under the hood logic.
It doesn't - the character movement logic rotates the character during it's movement tick, which operates at a very specific time
(Im only turning the character 180 degrees around)
if you change the rotation outside of that movement tick, and/or you change it different during that tick on client vs server, it will break
Usually if you want to control it's rotation you use bUseControllerDesiredRotation = true, and set the ControlRotation
I understand that, I thought it was done in this piece of code in PhysicsRotation()
It is
which takes current rotation and then tries to modify
but it no velocity is present then it just reuses current rotation
PhysicsRotation() is called as part of the movement tick
Im guessing my logic is executing after the tick then?
And on the Server the MovementTick is called as part of MoveAutonomous from ServerMove calls
So sending an RPC with the rotation will be out of sync
And it will still get a correction occasionally
aH I SEE
caps
Hmm well thats a tough task then xD
Thanks for explaining, im guessing the work around to allow 180 degree rotation is to either use a modified movement component (somehow) or try use controller rotation
The easiest way is to just set the control rotation
Since the client effectively has authority over control rotation
You mean set control rotation for the character, but that means Id still have to disable bOrientToMovement because that takes priority over using control rotation?
essentially yeah
ControlRotation is just an arbitrary rotation value that lives on the controller, usually that's what drives the characters' rotation
When not used for pawns it's just the camera rotation IIRC
Hmm ye, the character is now dependent on bOrientToMovement but I think I can look into rewritting it to not use that. May not be a big deal. Cheers.
Since you're using bOrientToMovement you could also maybe just move them backwards a bit?
i.e. just apply a small acceleration in the reverse direction
Possibly, but rotation speed is not instant, but I probably should give it a go before going with a rewrite.
Nice side project there, reminds me of something but cant remember what haha
It's not uncommon to modify the movement component a lot tbh
Ye that would be the direction I would go in, but in my current situation it may open a can of worms due to the project this is for haha (atleast at current movement state). Thanks for the help though, I got a direction to go in now.
Changing a boolean quickly on and off on the server should usually result in no change on the client.
Hence no onrep event
Your design isn't gonna work here - you want explicit RPCs instead. Multicast/client methods
How are classes (UClass) stored in db? What's the best way to add it to json to send it on server to save in db? Is it even possible?
Serialize your UPROPERTY to json and store that
I want to create an Android online multiplayer game.
Is it necessary to use paid dedicated servers?!
Can one mobile host and others can join through internet?!.I want this type.
Is there any tutorial for this?!I prefer blueprint tutorials.
Sounds like a #mobile question
Definitely need a dedicated server or asynchronous, web type servers
Hi all. New here - and I had a friend recommend this channel for a question
So I have a nice combination of Anim BP, ANim Montage and all in Multiplayer. So far everything works, State machine does what it is supposed to do and now I finally got to get deeper into Animation Monatge and notifies.
So my problem is that I have an animation notify in my animation montage and while the notify works fine I wanna cast to the player controller who posesses the pawn which is playing the attack animation montage. So naturally I thought I'd just get a ref to the controller and cast to my custom PlayerController (PlayerController is a child of "controller" I think). But the point is that the cast always fails. Actually I got no idea why. Is it generally not possible to cast to a PlayerController with getting the controller? Or is this a multiplayer issue somehow? What's weird is that the cast works fine in my AI Controller and AnimBP, but yeah I understand AI controllers run on the server, so there IS a difference. But yeah just thinking about it I believe it should also be possible to cast to PlayerController via controller reference, right?
What's also weird - the "isValid" returns "is Not valid", even though it returns the correct player name if i throw it on a print string
I am setting the ref in the Event Blueprint Update Animation - which should definitely fire before animation end
Player Controllers only exist on the owning client and the server. Other clients do not get a copy of other client's player controllers. Animation instances exist on all clients. So every client would be trying to get the controller of any character using this animBP but can't since the controllers for others on the client. The one place you're probably getting the print string coming through ok is on the one client where the controller exists or on the server.
Hmmm, so is there no way to communicate to the PlayerController from AnimBP in Multiplayer? I'd have expected that the reference to the controller should do the trick, but may it's a bit misleading that I can run "Try get Pawn owner" and cast that to the player controller at all? SInce there is no switch authority node in Anim BP it means it's generally not possible to reach the corresponding player controller from there?
I mean normally it throws something alike "the cast would always fail" if you do something on an object which doesn't inherit or so
So for a noob like me it looks like the reference is ok, but it's probably just never executed on the owning client?
Sorry for being a goof, just started multiplayer recently
This issue is in using the player controller. You cannot use player controllers for anything that other clients need to know about and AnimBPs are something that other clients know about.
In this sense, the only time you should use a player controller for storing/retrieving data is when it is specifically meant for the client or the server to know about, and no other clients.
Whatever values you may be trying to use from the player controller you either need to move to the pawn/character or playerstate.
Thanks for your valuable feedback. I will move such variables to the player character. I can query these from the playerController as well. Guess my idea was an invalid shortcut. I shall seeks more tutorials for ANimation notifies i guess. Thanks again. Really appreciated
What are you trying to do here?
Basically just setting a variable "CanNotMove" while a part of the animation is playing. It seemed a good idea to me to have that variable in the playercontroller since i process mouse clicks here. And setting the CanNotMove to false when the last (uninterruptible)) part of the animation finished playing looked like "hey this is what i will do"
Like once the character swings the sword forward it should set it to "CanNotMove" and once done set it off
Silly thinking from me like "the controller owns the character doing this animation so it could just communicate back"
I guess there is still a lot i have to learn
Right now I think imma just do it the other way round, like setting that in the character and query the variables in character on tick in my player controller, being like "hey you can't move right now"
I really need to learn much more about animation notifies
Does anyone know why changing the size of the collision capsule on Rep_Proxies is sometimes very choppy in comparison to Auto proxies / Server? I am talking specifically about the character movement component in this case. They are running the exact same code.
do repnotify variables not get sent to the client on join?
im having an issue where a rep notify bool isnt being sent to a client if they join in the middle of a round
im not sure if its related to level streaming, the object is in a sublevel
wait i think i understand, i think it is because im hiding the actor using a repnotify
that was it 😦
IsNetMode(NM_DedicatedServer) will only return true if we're connected to a dedicated server right? Nothing to do with authority or anything like that
No. If you're the client then no
What's the correct way to check multiplayer vs local play?
IsNetMode checks if the code being executed is being executed by a server of type DedicatedServer
You could be an NM_Client executing the code
That would be checking if IsNetMode(NM_Standalone) is true
Thanks
Trying to launch DebugGameServer from VS and I'm getting this check assert
seems like a common issue but no resolutions found so far
this seemed promising but still crashing
ah, missing -IgnoreChangelist flag to force it to resave
Which is now showing this dialog...
Works if I launch from commandline through uproject but not through VS debugger
I have a blueprint bool variable that's set to RepNotify with a Replication Condition set to "Owner Only". I'm seeing some strange behavior for the rep notify conditions:
- If I set this variable to true behind a "Switch Has Authority" node so that the variable is set on the server, the rep notify does not fire on clients.
- If I set this variable to true without the switch node, the rep notify fires on all clients.
I was trying to make it so that the server sets the variable and then I can have the client respond to the rep notify but I'm not seeing how i can do that?
What event are you using to set the variable?
So - it suddenly started working but no idea how. It's the Begin Play Event and I was manually setting the owner so I know it was valid.
Now I'm having a separate situation where something similar happens. The rep notify is not firing for the client when it's associated with a timer:
Is the variable already true on the client maybe?
that is because if a client sets it locally, the RepNotify will fire
its because there is no replication callback in blueprints, just a hack that calls property changed callback a replication callback
so no authority switch = each client sets the variable locally, and that causes OnRep
Hello guys.I am developing a game in dedicated server model.Whenever I launch the game in standalone client is connecting to server but when I am playing in mobile preview it is not getting connected at all.I am getting time out error.Can I know reason for it??
I guess mobile preview is specifically meant to emulate mobile, not multiplayer. Try developing your game in a portable way by working on PC, use the mobile preview for rendering checks, and work on a mobile when you're actually needing to simulate the mobile experience
Yeah I guess.Now it is working fine
Maybe it is compiling shaders something like that which results in timeout
Hi im trying to make a nametag widget above each characters head in my multiplayer game and it is working almost as intended 😄 However i would really like it to scale with how close you are to the player, or that it just disappears/becomes irrelevant when you get too far away. Any ideas on how to do this?
calculate the distance to the player / camera and hide it if distance is less than a threshold? (squared distance of course)
so do i have to do this check every tick then?
yep
would be my first approach, if this become a performance bottleneck you can still think about an optimization^^
this in the end will also do this per frame I guess
yeah i guess you are right 😄
just seems heavier to cast all actors in the level to characterBP each tick
why do you want to cast smth
in order to get the widget component from the characterbp right?
why do you need that? do the calculation in the widget^^
ahh, wait that makes a lot more sense
or in the BP of the character, somewhere where you don't necessarily need to cast or can cache the casted value^^
how do i get the other players than the owning player actor in the widget exactly?
the other player is the local player if you don't have split screen, so just get the first player controller and grab its pawn^^
oh gotcha
and if your widget doesn't know its actor, assign it on begin play
hey dumb question,is the charactermovementcomponent working with the networkprediction?
i think it should be replicated by default yea, but not sure
remember to set replicates movement to true on your character
You could do it in the material as well and let the renderer worry about what cameras are close enough to see it
howdy, I've got a blueprint setup in my ThirdPerson that scans for interactables in front of it as a server operation, I can mash my interact button as much as I want and I still get the tracer but once I actually interact with anything the whole system seems to fail (no more tracer, none of my item pickups work after the first time). If anyone could point me in the right direction that'd be great :)
I think it has something to do with game ticks but I'm not sure
You can't do this.
The InputAction happens on the client whereas the "Interact With" interface call runs on the server. The client's side will always return false and it's bad practice to drag wires across execution paths like this.
You're on the right track, but all that should happen on the client side is:
Interact Action > SR Interact Trace (Runs on Server)
On the Server:
SR Interact Trace > All the rest of what you need to happen (line trace, interact with, etc.)
I am aware this is the discord equivalent of threadromancing, but is this still the case?
@sinful tree Any idea why this wouldn't work for extra clients? This functionality only works for the host process not rlly sure why
In your Trace function you're using Get Player Camera Manager 0. You can't use this in multiplayer on the server as each player has their own index.
Probably best just to get the camera component that is attached to the character and use its location/forward vector.
I see I see, thanks for the help! wish me luck aha
im trying to replicate a flash grenade, i have a run on server to a multicast so the grenade replicates but its also replicating the flash hud to every player, anyone know how to fix this
In the event - just check if the client is facing the flashbang, only play the flash if they are (within a tolerance of course)
@quasi tide how would i add that here
Google how to check if an actor is looking at something. Then put that check in there at a logical spot. (hint - it'd be before the flash actually happens)
I guess he's not doing it based on seeing it or not, but if the player is in radius of the flash grenade
Am starting to study replication and was wondering if this was a good read? It was created in 4.14, so it might be outdated?
https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
Yeah - that is exactly what he's doing. Can still only run the code on affected actors though.
That is the best read. That is the Networking bible of UE.
Awesome, thank you ❤️
You are casting OtherActor to the player BP but not using that anywhere. You should stick the casted player BP pin into OwningPlayer when creating widget. And then add the widget to viewport(using AddToViewport)
I think AddToPlayerScreen is meant more for split screen and stuff
I appreciate the help, i ended up getting my desired effect by getting instigator controller out of player bp and casting that to player controller then having the hud created in the controller bp with an on owning client function
Hi, im trying to create a session and load a pre lobby level when the player clicks the button on the main menu but once I've created the session, can i not use the Load Stream Level node if im trying to load a pre lobby map? theres no pin for Options on this node and i need to specify ?listen in there, do i just have to use Open Level instead? or is there a way i can use Load Stream Level?
Is GetWorld()->GetAddressURL() supposed to be called on dedicated server or client?
It might be. Not sure anymore. That message was 3 years ago lol
So, I'm trying to convert a game blueprint game feature from single player to work with dedicated servers, and I'm currently getting the following error: [2022.03.21-19.57.43:006][668]LogNetPackageMap: Warning: UPackageMapClient::InternalLoadObject: Unable to resolve default guid from client: PathName: BP_ModernBookShelf_C_0, ObjOuter: /Game/Maps/AMap.AMap:PersistentLevel
I didn't know whenever to send this in here, or in #blueprint
@neon atlas is that function that you call UI function an rpc inside a widget?
Because you can't do that
Widgets aren't networked
I should have guess
What would be the best thing to do then?
Call a function in the player that spawns the actor? Or something else?
I really haven't gotten the hang of unreal networking and multiplayer yet 
You have to call it inside a client owned actor or a component that sits on one
Being PlayerController, possessed Pawn/Character or PlayerState
At least in most cases
Check out Cedric's network bible. I still often refer back to it. https://cedric-neukirchen.net/
@neon atlasWhat's the gameplay here, what are you trying to make work in multiplayer?
Thanks^^
Well, the player is able to enter a 'built mode', where they can place walls and stuff. So basically I want the function of spawning the actor (wall), and use a line trace from the player, to set the position of the actor
I will try that out, thanks^^
Start with a RunOnServer event in the pawn/character that passes over a transform + other data and has the server spawn the actor
Could be as simple as passing over an actor class and a transform.
The general flow goes like this
Client
Input/ButtonPress -> Tracing etc to determine WHERE we want the wall -> RunOnServerEvent passing over the actor we want and where we want it to be
Server
RunOnServerEvent -> Spawn actor of the provided class at the provided transform
I'm thinking in some cases, it might be relevant to set the position after getting the actor. To see it like a preview, It might require a lot of unnecessary data transfers to and from the server though?
Do you need to replicate the preview? If so, you'll want to move the RPC to earlier in the logic chain and replicate the transform and class on tick or whatever.
I think it might be relevant to do so, in some cases. I'll have to think about it a bit/evaluate if it is worth it. Thank you though!^^
If you want to do it server side, then yes. If you don't care for other clients to see where you plan on placing something - don't replicate the preview.
Thanks^^
Can i use GetWorld()->GetAddressURL() on server to get the url?
all my players share a character blueprint. Is there a way to change boolean/enum values for one specific player when they all share the character bp?
Do they actually share ONE character or do they share a common character CLASS?
How many characters exist in the world when the game is running? I think you're missing the fundamentals of how objects and classes work.
Every client uses the same character blueprint for their pawn
k then yes, they already all have their own boolean and enum variables.
MySize doesn't mean anything, it's specific to the instance of the class. MyCharacter.MySize is a specific variable, and it's different from ThatOtherCharacter.MySize
Just like how you and me have the same variable Birthday but mine is different.
Asking what the value of Birthday is doesn't make any sense without asking WHO's birthday
Start by doing this. Make a replicated variable MySize and set it to RepNotify.
In the Onrep_MySize, do the size changing stuff. If you don't know what RepNotify is then go read up on it.
Don't bother with the shrinking, just get this working with your pickup.
Ok, what is the variable type for Mysize? Is that the enum variable?
Yes you'll want it to be an enum if you have more than 2 sizes
Do you see how it could be
ESize MySize = Big (can be Big, Normal, Small)
or
bool IsBig = true (can be true or false)
I need your help! I dont know why the rotation change is not visible for other clients! For the own player it works fine, but others dont see the changes!
This events cal the methods above
Does the actor replicate, do your components replicate, do they have Replicate Movement checked, are they being moved on the server, and NOT being moved on the client?
also, don't just add relative all the time, modify some control variable and drive the movement directly by it
I already tried every replication checkbox of the characterblueprint.
Also the CMC is weird and does a lot of internal stuff unknown to you. You won't be able to just flip gravity over like that I guarantee it.
Yes, i look forward to this. Its more like a placeholder, to test it
All works fine
Only thing that doesnt work is that other clients dont see the rotation
If it's just Normal/Inverted then just replicate some bool and RepNotify on it to do the flipping
are you just flipping the mesh INSIDE the capsule?
capsule is still oriented Z up right?
Not sure if this is complicated, but I thought it wouldn't hurt to ask.
How would someone go about synchronising an animation perfectly?
I know RPC calls are the most prioritized way of sending data. But is it possible to, maybe set the animations "start offset" to whatever amount of GameWorldTime the data package is behind?
I guess thats true
I havent figured out how to properly flip the whole character
CMC is reliant on and assumes a Z oriented capsule.
This two addrelativerotation methods are the closest i got so far to get flipped body + flipped camera
So you don't
what even is cmc
Character Movement Component
ah
Start by replicating some bool and doing stuff in the onrep
And how exacly should i flip the character?
If you know a good solution to make it visible to all players please tell me
I try since yesterday xD
The only thing that has to be visible to clients is the boolean
when the boolean changes, that's when you flip the mesh
don't replicate the mesh's movement, replicate what DRIVES it
I try to understand
I get a bool "isFlipped" onNotifyRep. When i inverse gravity i just change isFlipped value and do the exact same addrelativerotations in the repNotify func?
DON'T ADD RELATIVE
ffs
just roll the mesh by 180 or whatever results in it being flipped
With what method?
However you want to. Can just set local rotation if you want
figure that out before worrying about networking it.
Hm okay
@twin juniperI would start with messing with the BP to find what combination of rolling/moving/scaling of the mesh and spring arm and camera results in what you want for the "inverted" view
then just do that / undo that in the repnotify
Yeah good idea. Maybe that way i learn it better^^
Do ListenServers not spawn AHUD for themselves?
They do not
So I have to have all my Interface logic inside the PC (when I want Listenservers to be thing)? 🤔
does anyone have an idea of why this value is successfully replicating, then 2ms later is being replaced with a nullptr?
[2022.03.24-00.54.27:534][596]LogTemp: Display: Replicated lobby leader: 0000019952165D00(PlayerState_1)
[2022.03.24-00.54.27:536][596]LogTemp: Display: Replicated lobby leader: 0000000000000000(N/A)
^ logs from the ReplicatedUsing callback. i have pretty high confidence that the server is not setting the value to null
this only seems to happen when playing as standalone or in the packaged game
Anybody knows when I load network profiled file, it appears blank?
ok so what's happening is that i'm traveling, and the server remembers the value, but the client forgets it, and the server doesn't replicate it because from its point of view is that it hasn't changed. the client logs here were a red herring
this is a property on the gamestate, i'm not sure why it survives travel on the server but not the client
ok it's a comedy of race conditions
if there are no players and a player joins, the gamestate makes them the leader. so it's losing it in the travel, but then the player connects, and it seamlessly makes them the leader (not a single tick where they are not the leader from the server's point of view). but I guess the gamestate doesn't exist yet on the client to be replicated to at that point
not really sure what to do about it. I could probably figure out a way to calculate it more lazily so it happens after the client is ready, but it feels like this could happen for any replicated property across travel. should I have the client run an RPC to demand the values when it starts up? is there a way to force replication? 🤔
but values should be replicated when the client actor is created right? otherwise you couldn't join a game halfway. so this must be some kind of really nasty race condition i've made for myself
this is killing me. I'm just trying to set a single boolean variable on the server and replicate it. there's no maps or sets involved :/ I know that if there were I could work around it in some way but.. what do I do with this?
could it be a name collision? what's your variable named?
the condition for that tooltip doesn't have much going on:
bool FBlueprintVarActionDetails::ReplicationEnabled() const
{
// Update FBlueprintVarActionDetails::ReplicationTooltip if you alter this function
// shat users can understand why replication settins are disabled!
bool bVariableCanBeReplicated = true;
const FProperty* const VariableProperty = CachedVariableProperty.Get();
if (VariableProperty)
{
// sets and maps cannot yet be replicated:
bVariableCanBeReplicated = CastField<FSetProperty>(VariableProperty) == nullptr && CastField<FMapProperty>(VariableProperty) == nullptr;
}
return bVariableCanBeReplicated && IsVariableInBlueprint();
}
this runs from the level bp on beginplay. the only "set" here is setting the boolean to true
as far as i can tell either CachedVariableProperty.Get(); is returning something wacky or IsVariableInBlueprint() is
my guess would be the latter
/** Returns TRUE if the Variable is in the current Blueprint */
bool IsVariableInBlueprint() const { return GetPropertyOwnerBlueprint() == GetBlueprintObj(); }
is this screenshot from the level bp or from a different bp?
level bp is only on server right? 🤔
level bp. yeah so I would assume it gets loaded on begin play concurrently with the client no? any variable I set there don't and can't get replicated
Anything you do on begin play on the level BP will get executed on the server and on any clients when they load into the level. So different clients would be trying to set the value too unless you use a Has Authority check.
And if this bit of code is also being executed on the client, that also means, each client would each pull their own random integer on their end, then set the selected electric boxes to true on their end only which could really be messing you up.
well potential replication issues is secondary to Galco's problem where the editor is preventing the dropdown from being used in the first place
my recommendation would be to stick a breakpoint in ReplicationEnabled() and see what's up 🤷♂️
yeah that makes sense about the client and server having two different values. so I have to "has authority" and then multicast it or what
no multicast required for replicated variables, but you'll want to put "has authority" on any code that can set the value of it
indeed, that's why I was hoping to just replicate the variable but.. I can't 😦
this bool is on the box bp, being casted to from the level on beginplay to set it to true
if the bool is on the box bp you need to set the replication value in the box bp
I can replicate the variable on the box bp itself but it doesn't show when setting it in the level bp, and also doesn't replicate anyway
so yeah you're seeing that unhelpful tooltip about maps/sets because you're failing this check
this is the box bp. replicated or not, if the level bp sets it, it doesn't rep
is the actor this is contained in set to replicate?
the problem is either this, or the level bp code that is setting the value is only being executed on a client
yes
I had this exact same problem on another bp btw but this one is much simpler so I'd rather solve it here first.. seems to be something like what wish is saying. if the bool is in a bp that is not owned by the client, such as thing box, even setting it and the bool within the actor to replicate doesn't do anything. if I update the bool within the actor, aka not from the level bp, it will replicate. I've tried combining this with rpc and multicast shenanigans as well
I must have a misunderstanding because I thought that the server owns everything so as long as I replicate what it does to those things I should be good.. right?
hypothetically yes
how does "Electric Boxes" get populated?
it is already in the level, doesn't get spawned in during gameplay or anything
No, the level blueprint can set the value without issue.
Example here.... The client prints out the string "true" after 5 seconds.
i don't use blueprints very often what even is this node
That's an array variable.
Since it's blue, it's more specifically a TArray<ObjectType>
I just tried that and got two different values
with a GetActorsOfClass node or something
Yes true.
I'm assuming Galco is, based on not saying they're getting any errors 😄
fair, in which case server should be the owner of them 🤔 so a dead end for that line of thinking
you copied that blueprint verbatim and it didn't work?
this prints true as expected, but the original issue of grabbing a random one from the array and setting it, doesn't replicate. same variable, same actor.. I have tried running as authority and replicating the variable in the actor bp but doesn't work.
What happens here is.. server prints the name of the one that should be set true. after 5 seconds, client grabs the same actor but returns false
can i see the BP for populating the electric boxes array
You can't call it this way. Each call to the random node is its own execution, pulling a different random number.
You have the random int calling to 4 different pins, and each would get their own different random number.
yeah, you right tho. this works.. still having the "you can't replicate this variable" issue in another bp though :/
You mean like this?
yes
That's because you can't change the replication type when you have the variable selected in a different blueprint.
You have to go to the blueprint where the variable exists, and change it there.
I tried that but I probably slipped up some other way. I'll dig it up and show ya
Any idea to create android multiplayer game?
oh my goodness i finally figured this out
i was setting the lobby leader in an override of AddPlayerState, but AddPlayerState was being called in the same tick that travel finished for the server, before BeginPlay had even been called on the game state! and then however many ticks later when the client actually finished traveling, AddPlayerState was called again, but as far as the server was concerned it had already calculated it
[2022.03.24-03.35.04:602][154]LogTemp: Display: GameStateBase AddPlayerState // ???????
// leader calculated
[2022.03.24-03.35.04:602][154]LogWorld: Bringing up level for play took: 0.003164
[2022.03.24-03.35.04:603][154]LogWorld: ----SeamlessTravel finished in 0.73 seconds ------
[2022.03.24-03.35.04:603][154]LogTemp: Display: Successfully retrieved lobby leader BP_PlayerController_C_0
[2022.03.24-03.35.04:604][154]LogTemp: Display: GameStateBase BeginPlay
...ticks...
// somewhere in here the client loads in
[2022.03.24-03.35.05:404][179]LogTemp: Display: GameStateBase AddPlayerState
// i already have a leader so calculating/replicating
so i fixed it by checking HasBegunPlay before i calculate the leader 🤷♂️
clients call AddPlayerState on their own, PlayerArray is not replicated
Ok so.. tracked down the final step of the issue I talked about. Character opens a lock, sends interface message to the door (which owns the lock component) to have it unlock itself. It can do that part, but it never replicates to server.
this is the interface message targeting the owner of the lock component aka the door from the first screen
clients typically don't own a door on the level, so RPC fails
you should have a "No owning connection for..." warning in the logs each time you try
So how would I work around that other than having the character class own all the doors? I tried sending off to the game state and having it do it then replicate the variable from there
You RPC to the server on the character or player controller before calling the interface.
Player Input > Line Trace to Actor (or however you may be getting the actor) > Server RPC requesting the action, passing the actor through
Server RPC > Validate player is within range to target actor to perform said action > Interface call to the actor
Interface > Do whatever needs to be done on the server, such as setting your boolean.
So like this? Character RPC to interface which is picked up by the door, sets the bool
Yep.
Still only updates on the client :/
Put a print string on that interface event. Can you confirm that it fires and only on server?
It does fire, I put a breakpoint on the initial RPC and followed it through to here
Fires on client or server?
It apparently is staying on the client even with RPC being called from an owned actor
You sure? Put a print string
How do I get the first picture to be the same as the second picture
You missing a plugin?
I'd start with "Create Advanced Session"
Ah the plugin name will be advanced sessions or something like that.
Or just copy it from the old project
Yeah I found it I am going to get it from my old project rn
Dear god above. Apparently I was calling the original rpc from an unowned actor which I thought I had changed ownership of.. Sorted that out and, now it works 😵💫
If the pawn is who's doing the lock picking then the RPC should go through it.
Yeah it wasn't it was from a separate bp that I thought I made owned but didn't. Really need to just make it a component.. one day. Thanks for helping though!
What's the best way of replicating shooting guns?
I don't imagine that making an RPC call for every bullet, is good for bandwidth. How do other games go about it?
I implemented shooting via multicast but I also need to know if there is much better way
Hi Guys,
I need a server host, to work 24/7. The game will hold 50 players most of the hours.
All 50 players will be together watch event, and could talk.
Each player will have private room also, that will show art work, and can make purchase .
I never done the server side, and I hope to find some advices, and understand better what I should use and pricing.
Thanks
show art work, as in upload it from their own computer?
Hi, is there any way to debug blueprint execution on a (local) dedicated server?
are moving platforms something that would be hard to program in a multiplayer scenario?
Yes
No, it will be placed before than developing, like a gallery
What would be a good way of spawning characters on a networked game?
My goal here is to let players have multiple characters they can control (its a squad-based game, simple AI take over those not directly controlled) however the clients always seem to spawn one extra character and I'm not sure what replication I've messed up to achieve that.
Left is host with 1 character per player (as intended right now); right is a client with two characters for them and one for host.
Changed it so players have two characters each.
Now host shows four (two each) while client shows five (three for self, two for host)
So I've been looking into creating large multiplayer maps - and it looks like all the posts say 25km is the max before you start getting floating point precisions errors, but no one explains what the repercussions of those precision errors are.
I'm assuming this just starts desyncing player positions with each other due to replication truncation? So like, if I'm at 26km away, and so is another player - we may be a few meters off from where we think we are? Or is it something else
Just curious as to what it actually affects
if you want it running 24/7, you'd be best with programming a dedicated server as otherwise the "host" would have to be "playing" the game essentially, and rendering everything visually - which is a waste of resources.
When programming you would filter various stuff so it executes logic on the dedicated server, but doesn't try to render the visuals - like if you have an emitter/particle, the server doesn't need to actually see it - it's just visual.
But to create dedicated servers, you have to get the entire engine from GitHub (the source) and compile it manually which is quite a pain in of itself, as the version of the engine in the launcher has dedicated servers turned off and you can only turn it on by compiling from the source
You don't let the client spawn - you need to have the client ask the server, but the server still has to spawn. The client is always having an "extra" because you're telling it to spawn, and the server is still spawning it - but the client is spawning its own also. Which the server knows nothing about
So initially I did have the client spawning but changed it to client calling from the GameState and the GameState handles the spawns. The problem of weird duplicates still exists though.
I'll get screenshots of the blueprint in a sec for you
25km is quite ambitious on UE4, 4Km is a more reasonable cutoff. The basic problem is that in computers, using a float type, you can differentiate 0.1 from 0.2, but not 1000000.1 from 1000000.2. Essentially, very big numbers start getting rounded - including the location of the player, which would snap randomly, first to the next cm, then to the next 10cm, then to the next meter, etc.
UE5 fixes that by moving to double coordinates, which has an exponential effect on precision - rather than a few km you can do the entire solar system
Is that true? I might actually upgrade to UE5 soon if that's the case.
I mean... need to get better at dev in general but that's a bonus.
Yup, everything's a double now. Not that most people actually need it 😛
Hmm, switching to UE5 would be much easier than trying to create zoned areas like Borderlands or STALKER, as I know players hate loading screens and requiring all players to move at the same time
But it's so early in development/release. UE4 has that nice stability to it
I would suggest that loading screens are very much relevant in UE5 - levels don't exist because of size limits
So that's in the player controller.
I'm fine with loading screens, it's more of the "all players must be present to switch" thing
And the GameState does this
Yeah you need an "Authority Switch" I think it's called in BLueprints
and you probably need a "Server" Function to send the request to the server from the client, that calls that spawn
Sounds familiar. But when I've used that before I've found that it acts funny with the host player.
Remote doesn't work for host only clients, and host for some reason was triggered by every client's beginplay call.
BeginPlay is fired everywhere
Or it was something to that effect. I'll give it a try.
^
Yeah, Replication is a pain. But BeginPlay is played by all players, and the server, for all actors basically. You have to filter pretty much everything based on Client/Server using Authority (and even that can be wrong, as clients can "have authority")
Christ.
Actually wait I think I had a solution before
Something weird was happening with UI so I used a "is local controller" node.
Multiplayer is 5x more work than single player, in my humble rule of thumb opinion
Also true.
Is Local Controller limits it to just the current PC if owned by the player calling the function, but that could be server or client - based on who called it 😛
and if you have split screen, man! Throws that for a loop too
Thankfully I'm not going with Splitscreen. Tried that at Uni. Wasn't too bad but it would just add more complication to my current project.
Okay so... I added Switch Has Authority to the start of that Init Spawn Characters function.
Coming out of remote.
Host doesn't spawn anything, both clients spawn the normal amount but nobody can see anyone else's characters.
Which is odd given its calling to GameState which is server authority and these characters should be getting replicated?
oh
Running through authority seems to actually work.
From a client's perspective
Though its just occurred to me only the host can see the UI now.
I am trying to sync a procedural mesh between both client and sever. The server is able to construct the mesh just fine, but for some reason when I get the client to load the file no mesh appears. I know these don't replicate (maybe someday...) so I am basically having everyone construct their own mesh. I don't know what could be wrong with the clients though. They fire the event and I have no errors.
There's basically no info out there on how procedural meshes interact in multiplayer, I don't know what needs to be replicated, owned, etc
I wonder if maybe it is an ownership problem but I'm not sure why that would be the case.
is it normal for dedicated servers to be huge in size even on small projects? what is included?
All of your assets, probably.
In blueprint, with repnotify arrays of structs, is it the intended behavior that setting a member on a referenced member of the array triggers a rep notify on clients only, as opposed to the normal server and client rep notify in blueprint?
but why if it is not needed to render them? and it was 70mb now it is 1700mb ... looks like something happened. I don`t have any new asset
Texture assets probably aren't needed, but your meshes are! And no idea if it's grown that much.
@little bloom are you setting it in c++?
Hi, im messing around with seamless travel, i have the command executing on the host screen once they press the Start button, its happening on the Pre Lobby game mode, its then loading up a map which has a different game mode set as the default, is this likely to cause issues since seamless travel has actors such as game mode and player controllers persist across automatically?
all gamemodes will persist those by default
game mode will reinstantiate when server loads the map
it will reinstantiate game state
but it will persist controllers and player states, even if their class is different on the destination map
you do need to implement copyproperties on playerstates to preserve data in that case
Milliseconds
hi, is there a way to have an actor be replication dependant on his owner ? Actually my weapon is replicating faster than it's owner (Pawn) and it causing me some issues on simulated while attaching the weapon
void AZircoWeapon::OnRep_WeaponDefinition()
{
// attach weapon mesh to pawn hand
USkeletalMeshComponent* OwnerMesh = GetOwner<AZircoPawn>() ? GetOwner<AZircoPawn>()->GetMesh() : nullptr;
if (OwnerMesh)
{
WeaponMesh->AttachToComponent(OwnerMesh, FAttachmentTransformRules::SnapToTargetNotIncludingScale, "ItemSocket");
}
}
so sometimes it will works and sometimes not cause the owner will replicate too late on simulated so it will just do nothing.
for example player 1 joins and then player 2 joins like 2min later, player 2 will see the weapon of player 1 floating cause at the moment WeaponDefinition replicated, the owner has not yet replicated
Also i know i can easily fix that by switching this code to my Equip function, but WeaponDefinition is only set one time when the weapon is given to the player so i prefer doing this.
got a repro recorded, as you can see it's rly random. player 2 has the weapon of player 1 attached but player 3 see the weapon of player 1 floating, so it's some race condition
I don't know many specifics but I know you can limit the net replication frequency, maybe it can help?
it will be worse 😄
the race condition is in the same actor, it's between Owner and WeaponDefinition
sometimes Owner replicates before WeaponDefinition and it's working, sometimes the opposite
I was wondering if it is possible to get the real-time Ping and Bandwidth values (the ones shown in Stat Net) to display in a debug widget in a packaged project 🙂
Ahh I understand, damn
could maybe also attach the weapon with OnRep_Owner 🤔
alright got it fixed 👍
you could go to the source to see how stat net is showing those
and use them on your widget
i know some people already talked about things like that (something like the fortnite net stat)
you can maybe find the messages if u search for it in this channel or #cpp
good idea, I'll read a bit and see what I find :D
Just replicate whatever data is used to construct the procedural mesh and have server and clients create it.
I wish it was so easy. In my case the mesh data comes from a file, so I can't reliably replicate it due to the built in limits on UE replication
Do both server and client have the file?
If not, you'll have to parse the file to some format that can be replicated.
Yes, I have been trying to simply have both read their files and load it into the procedural mesh component but for some reason the client still gets nothing
Replicate the file name or whatever you're using as the identifier
If it's a UASSET then you can just replicate it by reference.
You presumably made this, so just make the client do what the server's doing.
Hello, I have a question about net Dormancy and NetCullDistance
When I set Dormancy to Dormant all or initial, the actor is not culled from client after cull distance is reached
Is there a way to fix this?
Or these 2 does not work together? Like dormant actor doesn't need to care about cull distance
Hi, ive got a transition map set for loading, but none of the level blueprint code for the loading map gets ran while it transitions, any reason why this is?
Anybody know how to get set view target with blend working for multiplayer? The pitch isn't replicated by default so you can't see when the actor is looking up or down
I have a replicated pitch variable but I'm honestly not sure what's the best way to handle this
Make sure you are doing SetViewTargetWithBlend on server
So the server needs to call it and not the client? Thats all?
Yes
Looks like this is a bug that won't be fixed, there are workarounds though, see this: https://community.gamedev.tv/t/transition-map-problem/74101
I have the Transition Map set to the correct map in the project settings and I have the level blueprint print a string to the screen and display my loading screen widget as in the video, but when I play the game, I only get a black screen while the map loads. Not even my print string shows up. It is like the BeginPlay node is never being run.
hey so im working on a game that has some minigames, and basically I need the minigames to work purely client side, and then I need to have the player possess the pawn in the minigame, and then go back into the player when they are done with the minigame. It all works on the host, but not on any client. What do I do to make it work? I have each minigame packed into a single blueprint, with the whole setup.
I really dont get how it all works.... Just ping me if you can help.
It's hard to tell without seeing what you are doing. So that's why you should be posting the relevant code.
If you want to make sure something is being executed on the client, you have a SwitchHasAuthority(in BP) and you use the Remote pin
Also possession happens on the server, so if you're doing that on the client already then it won't work. That's why you should consider calling a client RPC
Why does the player need to possess a pawn in the minigame?
I guess if the actor is dormant then it won't replicate stuff to the client anyways. So it has nothing to do with NetCullDistance
so that they can control the character in the minigame, to play it
I guess he possess some other pawn that solves/plays the minigame, and he possesses back the player character when that's finished
Still that's a general question, show code so people here can help you
Yeah probably. But I wonder if a forced updated occurs, non relevant clients will receive the flush or not? Need some test.
I would say no, but I'm not sure
So im asking sort of generally here because all I can show is code that doesnt do what I want it to do. I basically just want the concept I should use in turn, like "every time X happens you need to do Y". Oh also im not 100% sure I can share the code as I signed an NDA, idk if that would violate it...
You could do that without possession
That might help then. Thanks. Doesnt really answer all my questions, but if im gathering this right, possession kind of makes this a lot harder than it has to be right?
Yes in multiplayer. Because possession is typically driven by the server, and you said you want the minigame to be clientside
welp, again, thanks for leading me in the right direction. I'll see what I can do working with other people.
I did some testing. The forced update doesn't reach out to out of cull distance clients. They only receive the update when coming back to range again. It's just the actor is not destroyed on client like a normal awake actor.
Also Blueprint seems to do some automatic flushing when changing a replicated variable on a Dormant actor.
I guess it's an intended feature?
It's the intended behavior
Thanks that clarifies some confusion.
If I want to get started, how do I test my multiplayer project as a solo developer
What do you mean by "as a solo developer"?
That won't make any difference if you're working alongside a team
You test your stuff and make sure everything is going as planned
I mean if I have a side project for example where I want to develop a multiplayer project on my own (hobby project)
how do you test to make sure it functions correctly on low ping for example
or functions as expected rather
If you're asking about the ping then there is a console command you can type that goes as: net PktLag=<YourPing>
This might help you as well:https://ikrima.dev/ue4guide/networking/debugging-tips-tricks/
Gamedev Guide: Programming with Unreal Engine, Houdini, Math, & Graphics
Lag Simulation nice this looks like exactly what I was looking for!
For other stuff though, you would make general debugging(watching values and so)
Hi, one small question, how do I disable animation on server? From my reading, Character Movement Component will replicate both transformation and animation. My game design don't particular care about animation sync, so I want to remove that for better server performance.
Does anyone have some experience with the Physics Handle in multiplayer? I notice the interpolation for it looks really bad in my game and I'm wondering what the best practice for it is.
is there a way to replicate rotation?
Rotation of what?
a bone
If you mean this one, then see this: https://forums.unrealengine.com/t/replicating-bone-rotation-modify-transform/374171
I've put an Actor to Dormant All, but it's still calling its ReplicatedUsing methods on clients. Does anyone know why?
This is a bug that won't fix: https://issues.unrealengine.com/issue/UE-62354
The solution is to move to C++
Well I guess your'e in C++ already, right?
yes that is correct
Does DormantAll work for you?
Yes
can i show u my code? it's very short. It's a test really
It's what it is. Your actor shouldn't be sending any replication data
That's what you should be doing
i lied when i said it was in code... some of it is blueprint
Lol
The ReplicatedUsing failed me there
So it's not working for you either? With replicated using??
No, that's not what I meant
You shouldn't be setting this in BP probably. Try doing all this behavior in C++
See if it fixes your issues
okay will do
It works!
Thank you for your help.
I can see that you can use ForceNetUpdate() even if it's Dormant or Initial. That's really handy.
I imagine the idea is you can save a lot of Server performance by having replicated Actors to dormant and if they need to update something on a rare occasion, you can use this call without even turning them Awake. Is that correct?
It's kind of like an RPC call, except you can adjust its Net Priority ?
It's not really an RPC. What it does really, it calls FlushNetDormancy which makes the actor Awake for a second and then makes him Dormant again or whatever state he was before
But it's similar to what an RPC does
Gotcha.
From what I understand, the server checks all replicated actors and their replicated properties on tick, which can be heavy if you have a lot of replicated actors and properties.
But this would be a way to save some performance for the server, right?
Yes for sure
@somber bluff I'd suggest checking out the third pin in this channel.
I'd also suggest https://www.youtube.com/watch?v=TEojA3VBXG8 (not mine)
I'm working on a custom replication system for large (up to 2k) amounts of unit positions. To summarize it, what we do is to move the units in both client and server (by sharing commands and executing the movement code in both), and send a server update every second to keep everything in sync, with some smoothing. It works very well, and the bandwidth is reasonable, but I am worried that shooting RPCs from 2000 actors is too much.
Would it be more performant or advisable to "package" the updates (for example, by sending positions in arrays) so that we do much less RPCs (but still sending the same amount of data)?
I would expect the latter one being more performant due to package overhead, but I honestly dont know how unreal handles it at the end. Interesting question!
The problem is that sending arrays means to keep track of the index to later make it correspond to an actor
And they must be in sync between server/client 😮
And sending the actor reference probably results in much more bandwidth consumption
yep, that's the issue
Unreal allows to share/RPC object or actor references right?
Although thinking about it, I could setup a system with custom IDs (ints) stored in a Map that stores the reference. So I could send the ID with the positions and then lookup the Map. A int16 should suffice
i wonder if at 2k actors, compression of data would be a benefit, or just more work than its worth
seems you've already optimized it by reducing sync frequency
so perhaps thats the better method
perhaps bandwidth is no problem at all
object pointers are sent as FNetworkGUID, which is basically a uint32
so maybe saving 16 bits is not worth it
yeah , but not sure if object pointers are synced ?
yes yes they are
Ah cool
So I can just create some actor that batches the RPCs and send an array of locationX, locationY, pointer
locations are uint16 so 64bits in total
64 * 2000 =128Kbps
Given that this is the mega worse case scenario, it should be fine
at 2k units, perhaps replication and bandwidth is the least of our problems x)
128kbps even my old ISDN could handle that
depends hahaha
we have solutions for rendering and custom movement/collisions, that perform well. Networking worries me more since there is a hard limit to what os achievable, and less options to improve performance
yeah there's a fixed ceiling, so most of what you can do is reduce what needs to be sent , and the frequency of it, if its not important
sounds like you've got some RTS going , so i assume its all quite important 😛
haha correct
I'm happy that this seems to be working out because I didn't want to do lockstep
Don't forget though it's only a FNetworkGUID once it's been acked, before that it'll usually also involve an FName somewhere
Doesn't matter long term ofc
But short-lived stuff it can be a hindrance
you mean that it might involve more overhead than 32 bits for the payload.
?*
Yeah like, if you spawn an actor at runtime - it also needs to know the class name. If you've never spawned one of that class before, it's the full FName of the class.
This is for units, whose lifetime should be minutes (or seconds if they are killed as spawned xD)
Yeah nothing to really worry about then
classes get GUID's acked too so that evens out as well eventually
Yeah, also most units share class so
Excelent, thanks for your input
Also RE replication etc, I've had great success experimenting with using FFastArraySerializers' ReplicationID as a game-level handle too.
Using that currently to ID items in an inventory system, worked out really well. The only downsiee is you're limited to int32 handles - and can't default them to 0
Interesting. But I want to RPC and not replicate, this is why I was avoiding the FFastArraySerializer
My current idea is to batch the updates, so that I do for example 200 units, 200 units after 100ms, etc. So each second all get updated eventually
I was not counting on the packet overhead for the individual rpc that I do currently. So by sending pointers and batching the updates, I might almost save bandwidth, or have a very small increase, while increasing the performance
yeah, the packet overhead is not that big of a deal usually - but if you're sending the same RPC many times in one frame, it's better to send one with a batch of data
and/or find ways to pack it
ye I was sending one rpc per unit
Are there cases where packing data for single RPC's would decrease performance? If not, then why dont UE handle this by itself on the backside i wonder
Not really something it can do easily tbh
I'd say, that RPCs are supposed to be individual functions called for a specific reason of the user - therefore the engine cannot know really the intent of it, and whether it is acceptable to delay it for packaging/batching
Also RPCs are used in the core of many systems iirc, so I can see how they want to have a strict control on how they work
Also just as a side note, UDP overhead is 28bytes per packet in IPv4, and 48 in IPv6 - so batching the updates and sending a pointer actually is barely a bandwidth increase.
Don't forget the headers that UE adds to identify them also, there's a 2-byte header per RPC iirc that identifies it, and additional header to identify any subobject (if a component etc.) and the additional header identifying the actor channel to send it through
Damn
The actual outgoing packets will be batched ofc
That kinda explains that the bandwidth was higher than I expected from my maths
Yeah that makes sense
yeah, the network profiler can show them, can't remember the exact numbers
IIRC batches are sent per-channel so you only pay the actor cost once per network frame - but identifying the individual RPC has a minimum 2 byte header + extra header if it's in a subobject like a component
The latter is why Epic put the RPC's for character movement into the character class
Probably a micro optimisation for Fornite
btw now that we are on it, do you happen to know how to get the ping + bandwidth values from stat net to display in UI? Wanted to make a debug widget. I couldn't find a way to map the commands to the classes
Nice to know, thanks
Yeah you can get them from the NetDriver IIRC
excelent, thank you once again :D
Hey, is there a bool I can set so that an actor isn't relevant to its owner, so it's only replicated to the simulated proxies, opposite of bOnlyRelevantToOwner
Is there a way to run RPCs on server on "neutral" actors, i.e. not owned by any particular player controller? When I try to do so I get the expected "No owning connection"... message and nothing happens. But I really would like to avoid putting all of my RPC logic in the player pawn/controller if possible.
I also tried assuming ownership of the actor from inside the player pawn (a RunOnServer RPC that just calls SetOwner on that actor to the pawn) and then tried to run RunOnServer RPCs from within the actor (not the pawn) graph, but that doesn't seem to work either.
No. RPCs to the server can only be executed on owned actors.
To get around this and trying to keep the logic on the other actors, you may want to see if interfaces would be useful for you. Eg. Using an "Interact" interface where you RPC on the character, and then the server calls the interface on the actor. The actor can then respond to that interface as needed.... So if it was a door, it can open. If it was a lightswitch, it can turn on. If it's an NPC you can talk to them. Etc.
Using an interface would limit the amount of RPCs you'd need to place on the character or controller.
I see... Disappointing to know, but thanks for the answer! Followup question, calling a multicast replicated event can only be done from a RunOnServer event, right?
there is not, to own something requires it to be relevant.
If you want other clients to receive it, yes.
if I have an actor that is spawned on the server and I set the owner to be my player controller, and inside IsNetRelevantFor I return false if the actor is owned by the viewer, that's it being not relavent to the owner right?
and it won't replicate to the owner
I would imagine so, but at that point the client who owns it - would be entirely out of sync from that point. So the repercussions I'd imagine would basically break it
I've not tried to over-step relevancy like that. There is usually better ways
does anyone know a way to change the replication condition of ReplicatedMovement?
I want to set it to COND_InitialOnly, however the member is private so I can't use
RESET_REPLIFETIME_CONDITION_FAST(AActor, ReplicatedMovement, COND_InitialOnly);```
I'm having issues with 3d widgets and the widget interaction component.
I've been using it for a long time and it's been working perfectly, but now it doesn't seem to generate on_hovered or on_clicked events when in multiplayer. It functions perfectly in singleplayer.
I think it may have something to do with user/pointer index but I haven't had to change the user/pointer index before and it's worked perfectly
I've noticed that the Ping value that I can get from PlayerState->GetPing(); is quite different from the one shown in Stats Net. For average simulated network, GetPing() returns 40ms, and Stats Net is showing around 120ms. It could be that one calculates the whole round trip and the other just one of the directions, but it's weird.
There isn't. However you can use SetOwnerNoSee if want it to be hidden for owner
This might be an abstract question, but is it heavy for the server to turn dormancy on and off on an actor?
Let's say you have 10-20 actors that are set DORM_Initial and you use ForceNetUpdate() every 1 second on each actor.
If i don`t replicate health variable and uses RPC for damage events (subtracing from health variable locally) is there a way to sync the initial health value ?
RPC that too
but when?
i`m using replication graph, is there an even for when it was created on player x screen?
How can i reach my character from an Animation notify? The thing is I want to write a variable "ANimation is playing" in my character. However trying "try get pawn owner" simply won't work. Any better way to get back to the character who triggered the animation?
Does anyone know what exactly the SpatialBias in the rep graph's grid spatialization node does?
A little unsure
So guys I have few problem in my game so I try to ask,sorry for my English maybe will be not the best, So I made dedicated server on my pc local server using unreal engine 4 I found turtorial on this Then I tried to make map etc I am logging there by IP 127.0.0.1 so and my problem is that If I run my server and then game from the folder and join there with for example 2 clients then divide my monitor to 2 windows with both clients and start play jump or something else I still see from the other client laggs very bad laggs in the client I am playing it's okay but from others it's horrible, but if I run game from editor in unreal engine 4 by hit play button it's okay no lags or anything else (but I need run server from cmd again) but here is another problem my first spawned client has everytime copy of himself which is not moving it's spawns at same place as first client and he is there..... And last problem is with physics replication of some objects for example I have Ball there or cube which I am moving by character and their move is also lagging. I. can also send some videos to explain problems better If anyone can give me a tip please
I am not sure why it doesnt appear on the client
Show the code that adds the cursor to the viewport
Creating widgets and adding widgets to viewport is done on the client
so i can just get rid of that all together?
Well if you are in class HUD, you don't need it at all, as you're on the client for sure. So Just remove the node Switch Has Authority
no crosshairs show up at all then
Weird hmm
If you're removing all widgets on begin play, then how you still have that widget up there that shows score?
this node casts the score
Ok, which node creates the crosshair? I can't tell from the names
What is the best mulitplayer soultion without opening ports?
this node holds a container that allows me to put in any widgets that i want shown on my screen rather than one at a time
It clearly has to do with whatever you're doing in that widget.
Debug your code, try uysing PrintString on EventConstruct and see if it's being constructed.
It just doesn't make sense that the former widget works, and preceding ones probably and this one doesn't
I want to create an Android online multiplayer game.
Is it necessary to use paid dedicated servers?!
Can one mobile host and others can join through internet?!.I want this type.
Is there any tutorial for this?!I prefer blueprint tutorials.
Hey guys 🙂
When I'm running the project as two players, one of them being the Listen Server, I've noticed that the Listen Server is not spawning my gun system's controller or something, as I'm unable to fire my gun. The server is able to spawn widgets & such, but the gun system is locked out it seems. Everything works fine on the client side. Any takes on what could be causing this?
What do you mean by not spawning gun system controller?
Also the server shouldn't be creating widgets. Widgets are client only
You might wanna show code
If I send an uint32 in a RPC, and that number (2 for example) can be represented with less than 32 bits, do you know if unreal's net compresses it by default?
I'm currently sending int16 for unit positions, and I can divide the number (since there is some precision threshold) to get smaller values. So for example if position is 25, and the threshold is 2, I RPC 12, losing 1 unit of precision. However this might be an unnecessary lose if the net package is still sending 16 bits no matter what
so im getting this error
LogNet: Error: ReceivedRPC: ReceivePropertiesForRPC - Mismatch read. Function: ServerMoveNoBase, Object: and i dont fully understand what it means
hey, if you have a function that is used for ReplicatingUsing, do you need to have use UFUNCTION macro on it? I can compile fine without it, but not sure if it will cause any issues
There isn't much about this error anywhere, and I don't remember having it, but those might help a bit: #multiplayer message
You can compile without it, but probably won't get called
I think they are. FNames are what generally not compressed. See first and last lines: https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/ReplicationPerformance/
Excelent, it seems it does indeed 🙂
Thanks!
was there any fixes known for it tho?
I've seen in some thread they had it in 4.18.1 and they updated to 4.18.2/3 and it fixed the issue for them
When it started to happen though? Have you noticed?
Hey, i've a little issue with advanced sessions and steam advanced session, its working fine on local network with 2 steam accounts, but online i can't found any sessions of my friends but they can join each others. I'm from Belgium and they are both in France
The problem may be because I'm in a another country ?
System are p2p
Just changed the steam region to France and now is working, can someone confirm is just region lock with the 480 test app ?
You might wanna ask in #online-subsystems
I'm learning multiplayer in blueprints, and I have a quick question.
So, if you use, get player controller, and then 0, does that return the clients controller? I am pretty sure it does, but not 100%.
I'm trying to make a score system that will show the 2 players their own score on their screen, so I need a way of getting the clients' player.
this is also just a learning project, so I'm not really worried about preventing clients from being able to manipulate stuff if using player controller will allow that
that nodes a bit problematic. Theres ways to get the correct controller from most classes. For example you can use GetController in your PlayerCharacter, or GetOwningPlayer in widgets.
also, you cant get another players controller. controller is only on the server and owning client
yea thats what I meant, I just need it to get that clients controller, because I just want them to be able to see their own score and nobody elses, at least not until the leaderboard screen, but thats a different battle.
Hi everyone, I had a theoretical question: if I have several boolean values to replicate, is it more bandwidth-efficient to just define them all as separate replicated boolean properties, or to pack them into a byte and use bitwise operators to set and check certain bits?
Ordinarily, the bitwise operators would be more efficient since a boolean value has to be minimum a byte in size anyway, but I think UE4 does some packing of its own in the packets that get sent out, so I wasn't sure if I was stopping that behind-the-scenes magic if I was trying to do it at my end instead.
The reason I ask is I want to replicate a lot of data in the form of structs, to the point that saving even just a byte per struct could save multiple kb/s in bandwidth usage
If you want to save bandwidth, I'd first try to avoid replicated variables and do RPCs instead. I very recently had some similar situation, and batching updates (sending arrays of structs instead of sending individual structs) also seems to be worth
I don't know exactly about the booleans, I remember reading that Unreal packs booleans but cannot find the reference right now
@prisma snow Hmm OK. Which RPCs are you referring to? Multicast?
I'm basically doing a Total War type game with thousands of soldiers. They can't be actors because its too much overhead, so they exist as just a struct dictating which platoon they're part of, if they're dead or not, if they're crouching or in melee and so on. Each company contains an array of structs for their soldiers, hence my dilemma as to whether my struct should contain 8 bool properties, or one uint8
Welcome to the RTS club. They called us crazy for using Unreal 🤪
Yes, I refered to multicast. I don't know to which point RPCs save more bandwidth than replicated variables, but definitely they are more performant (replicated variables are checked regularly to see if they changed).
For your question, I'd say it depends if the properties are generally going to change all at once, or independently - If you want to just change one, better have individual bools, so that you only have to send the changing ones, and either manually or automatically they'll be packed on the net transfer
According to our friend Jambax, Unreal does pack bools:
If you take a look at FBoolProperty::NetSerializeItem() - you’ll see that regular UPROPERTY() serializtion does actually serialize it to a single bit (and of course, the required header/offsets UPROP) I’m not sure why serializing it via the << operator uses four bytes, it’s probably an oversight of FBitArchive or perhaps it’s to handle bitfield...
Ah interesting, maybe I'll unpack my bools then
I would expect max one or two to change in a given frame
And yes, Unreal isn't known for its RTS credentials, but I'd argue no engine really supports this kind of use case out of the box, and so far we seem to be doing OK! Had to be saved by 4.27 though: previous versions had catastrophic bugs with hierarchical instanced static meshes which my whole game hinges on :-P
Yep, indeed. The biggest issue though tends to be the multiplayer aspect, the rest is achievable with time and work
Indeed, my game targets the age of muskets when soldiers marched in tight formations. That means I thankfully don't have to replicate the position and velocity of each soldier unless they break formation (routing, hit by a cavalry charge etc) so only a small number of soldiers need movement replication at a given time
It's a really interesting challenge, small optimisations can make a huge difference at that scale
Nice, otherwise you're in for a nightmare
Depending on the pace of the game and other factors (unit count) I've seen different solutions applied
but I'd argue no engine really supports this kind of use case out of the box
It's not free ofc but just if you are interested:
https://www.oxidegames.com/products/nitrous-2/
I found it by chance a while ago
@peak sentinel That is really interesting! I'll take a look. Our budget wouldn't even buy us a McDonald's happy meal, but could be one for the future :-)
Our budget wouldn't even buy us a McDonald's happy meal
I feel you bro
Score should live in PlayerState
Blueprint Runtime Error: "Accessed None trying to read property Weapon". EventGraph Function: Execute Ubergraph WG Current Ammo Blueprint: WG_CurrentAmmo.
why does this happen?
Current weapon is null when it tries to get it
Also don't get player controller 0 pls
it works on standalone tho
It might be tied to Adriel's comment about not getting Player Controller 0
Maybe it hasn't replicated by then. Also in multiplayer you don't want to get PlayerController 0 pretty much ever.
Zoom out and show all the logic
It's probably not working because your current weapon variable hasn't been replicated yet when you happen to be creating the widget.
My himch is you should be setting up UI in the onrep and not whatever you're doing here.
@jade fractal equip weapon sets the current weapon, but then you immediately try to use it in the next node. In multiplayer won't be replicated by then. Use the on rep to update the UI
woot
Rep notify is absolutely awesome for anytime you want something to happen when something changes.
so AInfo is child of actor, how is that better than using an actor?
is it a lot better to use an uobject?
Is it possible to use Firebase and EOS together? I want to use Email and Password as login but use EOS with P2P as Session Handling
I need the server to handle what happens to instanced static meshes (overlapping an instance, removing it, spawning an actor in its place)...but calling a server function or just replicating an instance to remove the instance does absolutely squat for the client
Is someone able to explain to me what "Play as client" and "play as listening server" mean. I know there's documentation but they don't word it to make sense on there lmao
play as client means you're simulating there being a dedicated server.. if you play as listen server.. then well, your first client is the server.. you can really see the difference in these when using the "Switch Has Authority".. because if you're playing as listen server.. IT has authority.. its a server but also has a screen and a player controller... when playing as client.. it's running a dedicated server.. so players are never authority
listen server is a bit more of a pain to program for but you don't need to have any separate server machine for your end product.
yea you might need to multicast it yourself.. or use a rep'd variable for the clients to get the info they need to derive the state of things.
I'm seeing something kinda weird, I'm trying to pass a networkversionoverride on the command line, as in something like
UE4Editor myproject.uproject -game -ExecCmds="networkversionoverride 1234"
And the server sees that I am indeed setting a number, but it is getting a random number - not the one I pass it.
(I'd use net.IgnoreNetworkChecksumMismatch but it seems to be setting it in the console logs, but not respecting the request, that although other exec commands like resizing the display do work, so console exec commands are working otherwise)
ok so when a player dies and spectates someone else I want the spectator to see the hud of the player, anyone know how to implement this?
use playerstate as a context
can u elaborate
if your HUD is made so it can take a pointer to a PlayerState
and initialize/run on its own from there
your problem becomes trivial
as you can then just push another PlayerState pointer to it to have it display HUD for another player
note that PlayerState does have a way to fetch its Pawn here
so if you can access PS, you can access its PlayerPawn as well
you obviously can't store any information displayed on the HUD in the PlayerController for this
as clients only have their own
im newish to unreal, could you give me an example of what the code would look like with bps in the player state?
its not the PlayerState code that matters, its the HUD
your MainHUD (not AHUD derived class, but widget) has a pointer to PlayerState, instance editable, exposed on spawn
and when you create it you connect the PS ping into the widget
widget after that doeesn't get referenced by the game code until its to remove it from screen
but manages itself, hooking into even dispatcher broadcasts for notifications
i can't give you an example, as im way too lazy to write one
Thanks for the explanation. The tutorial I'm following is in an older version of Unreal where you couldn't choose to play as client or listen server it just ran as a dedicated server by default I think. But in the tutorial he does use that Switch has authority node. Would I be better playing as a listen server in that case or doesn't it matter?
what do you mean when you say "has a pointer"
pointer = reference, a variable of your PS type that is injected into the widget at the time widget is constructed from the same code that constructed it
Unreliable RPCs are those that save more bandwidth than replicated variables. Replicated variables can save more bandwidth than Reliable RPCs.
There was a #notGDC talk about that lately if you're interested: https://www.youtube.com/watch?v=UstLLZbkmOQ&ab_channel=OmidKiarostami
For #notGDC 2022 I gave an informal presentation for people interested in multiplayer programming in Unreal Engine. This is a recording of our discord hangout.
We go over tools UE5 has for multiplayer development, good ways to use them, things to watch out for, and have a live coding session with examples.
00:00 - Intro
05:15 - Networ...
15:57
Excelent resource, thank you! Glad to hear it, we use unreliable RPCs indeed
To be fair in this regard, bandwidth should be the last concern in using those three. They're just differing implementations that all have differing specific uses.
Well I agree. There are cases where you should be using a reliable rpc and you can't do nothing about it.
But having the bandwidth concern in head should be good for someone to ask himself if they need the rpc to be reliable or not
Hello Everyone, Im new here, new to unreal etc. I wanna do something (I think) is pretty simple ... id say 80% of it is working already....
The Host starts a session and changes the level from the MainMenu to the World
The client connects to that and also changes the Map to World. The last part aint working....
I get the following error (blueprints inc as well)
You can not travel in PIE
aka I have to make a "build" to test it?
yes
😮
brb xD
Never made a build before,might take some time :S
Okay,i Hvae found where to package the project,but once I do so I get 😦
Ill reinstall UE 5... dunno whats causing this yet, google says its the SDK kit and .NET etc... ive reinstalled em all..nothing worked 🙂
There is a long ass thread with so many fixes, pick the one that works out for you:https://forums.unrealengine.com/t/issue-packaging-resolved/231242/32
As annoying as it may seem I found the only fix was to completely uninstall/reinstall UE5 from a clean slate. This only seems like a temporary fix though as the same issue appears again after a few days. Must be some internal bug where someone hasnt added the correct pathnames at a certain junction.
@fathom aspen Yeah thanks, as mentioned ive tried what google found already 😄 SDK Kit... .NET and now im reinstalling UE5... Ill let you know ^^
Not entirely sure wether to go to plugins or to multiplayer but I think it also applies to the normal unreal online sessions.
I'm using the advanced sessions plugin and need a way of checking if the player already is in a session or not (host only) I looked and there is a "is player in session" node but that requires a unique net id and I'm not sure how to get it
Anyone here used the interpolation feature of the projectile movement component? I'd like to shortcut a bit my research 😄 https://gyazo.com/7f3cf43251d47b1b51fc833809c4b944
Well turns out that I set all of this in BeginPlay for sim proxies and autonomous proxies:
if (ProjectileMovement && ProjectileMovement->UpdatedComponent)
{
ProjectileMovement->SetInterpolatedComponent(Mesh);
ProjectileMovement->bSimulationEnabled = false; // I really want this to be false
ProjectileMovement->bInterpMovement = true;
ProjectileMovement->bInterpRotation = true;
}
And I have this weird delay in which the projectile spawns, halts there for a sec and then starts moving. I guess it's because PostNetReceiveLocationAndRotation() didn't still kick in for an interpolation to happen... but I'd like to solve this in a non... let's say - very intrusive way - I thought about enabling simulation until PostNetReceiveLocationAndRotation() kicks in but... I'm not sure I very much like that solution... anyone here know if I could do something else to paliate this?
Extra info: Projectile is replicated and spawned in the server for a fully server authorative approach. Not doing any sort of prediction atm.
Feel free to @ me, I'll be out for some hours!
2Hours later and reinstalling basically everything related to Coding/Unreal engine... I can package my project 😄 Back to my issue.....
In Editor it does actually change from MainMenu to World Level, in the packaged version it DOES NOT.
so we gotta solve that now first, before we go back to my original issue 😄 Ill show you my BP for the "creating Lan server"...
listen server?
So basically what I want to do is:
Client 1 Starts a server and changes,obviously, to the World-Map
Client 2 Connects (currently via open(127.0.0.1)-Command,cause I dont know if there is a better way yet^^) to that server and joins the same world map 🙂
you need to start listen
Preferably yes, dedicated server stuff comes down the line once i got the "basics down" 🙂
Im listening 😄 (i know you meant to start a listen server^^)
How would I go about that?
UKismetSystemLibrary::ExecuteConsoleCommand(PC, URL, PC);
``` in blueprint, you want ExecuteConsoleCommand like this
is there anything after "listen"? if not..ill try that now 🙂
never used the Open level node, so not sure if you can pass ?listen to it
You might also be able to accomplish this in your openlevel node
If you hit the down arrow in the node, put this in options:
?listen
Oi,i see... sec changeing everythign back LOL
@opal stream hm?
you only want to do it on success tho
Nice,lets see if that works in a build 🙂
on failure, you want to throw an error
This too. Pass the pin from OnSuccess.
kk,changed that too 😄 Yeah for now idc too much about if its "on success" etc.... still learning the basics,but oviously its best practice to give errors etc ^^
I come from Unity3d and have got 1k + hours in C#.... I dont understand c++ yet,so i give this blueprint stuff a try 😄
For the record, that little clock symbol means that node is asynchronous. So the regular execution pin will run even before that task is probably finished
Hm, it says "Hello" but it basically shows the MainMenu screen after I click the button that does this:
So CreateSessions seems to work,as it prints "Hello" but ti doesnt change the world (It does in PIE though)
Ah I see. So better use the "OnSuccess" pin 😄
Wait I just realized the project is way too small. Do I have to tell the "Package manager" what levels to include?
Aight,ill try that 🙂
Looks like it worked. Yay. But they cant see each other yet, so I guess theres a replication issue ^^
AH no, ... thats now where my original issue is I think 😄
I assume this is wrong.....:
Im 99% sure that the "Open Level" node is useless entirely, as the Host will "tell" the client what level to load.
Might even cause the client to disconnect again
Yeah I assumed as much, but even if I disconnect that node, the players cant see each other 🙂
can you connect to a dedicated server using a domain name instead of IP?
@modern cipher a domain naim IS an ip 🙂
So yes. you can connect via HelloThisIsMyGame.com:PORT as well as 123.456.123.456:PORT
could you point me to what I need to do to get the client to connect and get to the same level as the host(i assume the last part will be done automatically)?
Hi everyone 🙂 I’ve been working on Networking / Multiplayer logic with Blueprint. I started to make a serie of tutorial videos about it. The main purpose of the tutorial is to build a logic that allows 2 or more players to join a lobby and travel through different levels with each other. That’s the first time I ever make a video like this. I’...
There isn't really more to do than calling open <ip>
Hm,thats weird, i guess something else is wrong then :/
What and where is your server located?
Does the same happen if you launch the server locally?
local
No,im totally new to Unreal etc 🙂
It's open 127.0.0.1
ah,lets see
And it's a Dedicated Server that you build or what are you trying to connect to?
Or is it a ListenServer?
Ah wait. It "works"(more or less)... i dont see the other player but its there,as im colliding with it
kk, so its just a "rendering issue" now of the player 🙂 But they connect to each other after removing the brackets!
Cheers
Thx for the hint 🙂 But I "knew" I was kinda there...and the guy in the video takes a different approach to me 🙂
if you build your game to work as dedicated server... you have to actually have a computer or some playfab or something that's the dedicated server in your final product.. and also to build a dedicated server package you need to use a source build of UE4.. if you don't know what that means.. it means you have to download the gigantic 120 gigs of Unreal from github.. and do a bit of setup to get that working...... long story short.. Listen Server is the way to go for small scale games... it IS a bit more of a pain to code for but ya know... YOU can host the game on YOUR machine that you actually play on.. and if you put your game on steam it works fine... here's a link to my game on steam that works like this. (This game is mediocre but it did land me a job lol) https://store.steampowered.com/app/1568730/Heroes_of_Eldemor/
Heroes of Eldemor is a Medieval RPG that you can play with friends over the internet. Simply choose to host a game in the main menu and then invite some friends. Launch into a world in the throes of war as you Choose Your Side in the conflict at hand. Fight with melee weapons or a bow. Earn coin and hire some soldiers to build your army so tha...
You know what I don't want to download 120gb so I think I'll stick with the latter lmao. Thanks for the insight man much appreciated:)
No problem!
One thing you'll never want to do the is Get player controller 0
Well.. it depends
But ya.. listen server is a bit trickier because the server is also a player
little things like.. when you're firing off some particle effects.. you normally might just do a SwitchHasAuthority.. and just fire the effects off the Remote.... but wait.. the server has a screen too..
I just upgraded a project from 4.26 to 4.27. I'm seeing a behavior where if the server's pawn is spawned too far from the world origin (guessing 20,000 units), clients are unable to see the server pawn, or specifically anything parented to the collision capsule.
The server pawn's mesh and capsule are visible but positioned exactly 1750 units in the -x direction and at 0 in the Z (so stuck in the ground halfway) from where they should be. They don't replicate correctly.
Even stranger, a hidden collision is still enabled where the capsule should be and it's movement replicates correctly.
"Always Relevant" is enabled.
Anyone seeing any behavior like this or recommend troubleshooting steps?
Again this seems only related to 4.27 as the same project works in 4.25 and 4.26.
might be the culling distance ?
I tried increasing 2-3x but it didn't seem to have an effect. Also would it matter since "Always Relavent" is enabled?
Hi, does anyone know how to fix this?
So guys I have few problem in my game so I try to ask,sorry for my English maybe will be not the best, So I made dedicated server on my pc local server using unreal engine 4 I found turtorial on this Then I tried to make map etc I am logging there by IP 127.0.0.1 so and my problem is that If I run my server and then game from the folder and join there with for example 2 clients then divide my monitor to 2 windows with both clients and start play jump or something else I still see from the other client laggs very bad laggs in the client I am playing it's okay but from others it's horrible, but if I run game from editor in unreal engine 4 by hit play button it's okay no lags or anything else (but I need run server from cmd again) but here is another problem my first spawned client has everytime copy of himself which is not moving it's spawns at same place as first client and he is there..... And last problem is with physics replication of some objects for example I have Ball there or cube which I am moving by character and their move is also lagging. I. can also send some videos to explain problems better If anyone can give me a tip please
here I can show videos of it so you can see
So I recently added a bunch of foliage to a series of multiplayer maps, when I use the open the level node with the port and IP, depending on which map the multiplayer game is on, it will load really fast with the maps with low foliage, and it will load really slow, and sometimes timeout on the maps with lots of foliage.
TLDR: opening multiplayer levels is slow when there is lots of foliage
Anyone have an idea how I could deal with this? perhaps some setting that would make loading the foliage faster? or maybe progressively load the level somehow?
Just to follow up...it seems to be an issue where instanced meshes set to "Static" don't properly replicate collision on the remote Server pawn only. Very strange...
I'm currently doing some NetProfiling. Are there any standards that I should be looking for?
For instance, is there a standard for how high my OutgoingBandwidthSizeSec should reach at max?
well.. I'm not a guru on this but.. for sure you want to make sure you're not at your max that's set in the GameIni
I think its game.. might be engine ini.. but I think it's game
I cannot give you a standard/definitive answer, but what I do/did to profile my game:
- Test the worse case scenario
- Research or test similar games (similar genere, gameplay, etc) and see how they perform in those "extreme" conditions, their average bandwidth consumption, etc)
- Try to find if there is some evident problem with your current net usage.
- Playtest your current build with extreme conditions (might use the editor simulation, that allows to simulate ping and package loss), see how it behaves (lags, rubberbanding, etc)
Interesting. Where do I find GameIni again?
RootFolder/Config
your config folder for your project
Iirc it's DefaultEngine.ini
But I had problems making it work, I think the settings might have changed from one version to another
hmm
The reason I'm asking is because I'm testing out how "heavy" NetForceUpdate is compared to standard replicated net frequency.
why would it be heavier?
from my profiling, it is twice as heavy.
I placed 300 actors with a replicated variable. The variable changed every second.
Experiment 1: They were all Awake and updated 10 times per second.
Experiment 2: They were Initial (same as dormant) and used NetForceUpdate every second.
The second graph spiked twice as high with OutgoingBandwidthSizeSec
Hey fellow UE4 devs, I'm hitting a roadblock currently for my 3D multiplayer platformer game
The issue is I can't get the players' camera manager to work. When I'm playing with 4 people, only the listen server has all the camera functions behaving like it should
Looking at the map when the game is running, I only see one player character controller, so only one camera manager then? Is this correct?
How should I get all the different clients to have a camera manager (in the character controller) that properly applies camera effects, locally? This shouldnt be replicated right?
oh and I'm using blueprints 🙂 I come from a art and design background
so are you just having trouble referencing the different player controllers in the game?
or i forget if camera manager is in the character class
it's part of the player controller
I think so, but that's the thing. No matter the number of players, there's only one player controller. Is that correct even? I read in forums that's its alright as long as players are playing online (not locally)
Im not sure if I understand you exactly, but a simple way I keep reference to all player controller classes in a session is an array in the gamestate
yeah if you just do "get player controller" node
then cast to
it will only give the 1st reference
what you should do is this
This is what I have in my character BP
on beginplay in your player controller class, run a custom event run on server reliable, use the "get game state" node
cast to your gamestate
on your gamestate you should have a custom event run on server, reliable to add the player controller class to an array variable of your player controller class
then this way you can use the gamestate as a way to reference every player controller in the session
gamestate or gamemode I suppose would do the same?
no they're different things
if you haven't created a custom gamestate class, you should do that
if you look in your gamemode class, it has an option for which gamestate class the gamemode will use
gamestate is a place where you can keep all valuable info that players will need access to
Yeah I haven't yet. ohh. interesting.
and then idk if you know what playerstate class is, but it's basically a way to keep all info for players referencable
so like you could put the players name, position/team etc as variable in a playerstate class
and another thing you can do is when you do that event on begin play for the player controller class where it casts to the game state, you can also cast to your player state, so this way, you have a reference to all player controllers on your game state, and then the player controllers have references to their player state classes
so you can easily get any variables you need
Read about the player state somewhere, yup, that makes sense 🙂
Thanks for the info so far ^^
But then, in order for the client players to get assigned a camera manager... ?
If I understand properly I need to make an array of player controller in the game state... which would allow me to do that?
this is a bad approach fyi. You may as well just use the PlayerState as the game state already has a reference to each of those. The controllers only exist on the server anyhow.
yes, so explain exactly what you're trying to do for me
well, server and owning client
nice I had a mini heart attack xD
don't you have to use cast to every time tho?
Only if you need to access specific things from your own child of the player state class
In that case you would just create your own array of player states and cast + add to it on PostLogin (which is roughly where the GameState class does it)
And if you need access to that particular player state's controller, you can just get it then
So. My player controller has a camera manager attached.
For example, when the player does a certain action, the camera changes some values for extra juiciness.
In the character BP, I have a ref to the player controller and the camera manager.
So that I can call the function from the camera manager Set X camera
- image*
It works on the server, but none of the clients actually have any of the camera functions applied... which makes me think they're not being referenced properly or something??
when you say "get it" you mean cast to?
no
the player state already has a reference to the controller on it
but it's only valid on the server or the owning client who owns that controller
ok but it's just the class of playerstate right? not the specific class that's being used correct?
the reason I set it as it's own variable is so I wouldn't have to it everytime
Do you understand inheritance?
I think so yeah, if I made a custom player state, it would be inherited from the base player state class correct?
1 sec i'll read this
Correct
You'll have access to all of the public variables from the base player state class
the PlayerController is one of those
You would just cast to the controller when you need it
yes but that's what I was trying to avoid, I thought using cast to is inneffecient
You can store an array of player controllers, but it's generally seen as a poor approach to do that when the player state exists
in BP it can be
in C++ it can be as well. Casts can get expensive.
well yeah I would be using it a lot
What would you need to cast for?
like yeah I did it that way where it's using the specific cast variable
to get access to the camera manager?
I can't remember exactly off the top of my head, I just remembre thinking "i'm using a lot of cast tos, I should set these as variables so I don't need to constantly cast to"
set the player controller variable on client
well how often are you really casting? why not just cache the cast result somewhere if it's going to be a problem?
Yeah, generally if I"m accessing a particular class a lot, i'll just store a reference to it.
That's what they're doing I think
im not doing anything lol, I was trying to help mooncube with a problem
tbh, I don't quite understand exactly
I think maybe like I said, your reference to your player controller on the character isn't being access because you maybe set it on server, when it's actually the client that needs a reference to it
also
the client already has a reference to their own controller
do the custom events as on client
they will never be able to see other player's controllers
yeah, the engine already stores the owning controller on a character
unless you do some modifying that's completely unnecessary
and a controller owns its relevant player state
ok but it doesn't have the direct reference as I said, it avoids needing to cast to all the time
where did the cast bad meme come from all over a sudden
sorry guys I'm kinda new to multiplayer 
hoping to make it a bit clearer... I have multiple characters but only one Camera Manager in my scene when it's playing
Yes, cameras only exist on the owning client. They're not replicated afaik
nor should they be really
Yeah
and the issue is clients do not apply any of the BP_CameraManager bp code
i like your character design
also in the world outliner, you can cycle it through each client's world
from view options
ooooh I didnt know that, interesting. Hold on
if MP is important, I would also PIE in play as client mode which mimics a dedicated server setup
so the first PIE window will behave as a client on a server rather than a listen server
so in the client's world outliner, the BP_CameraManager is still there.
yes so they have one
so something your PCM is doing is likely relying on stuff that occurs only as the host
for example, do not expect the character to be valid in BeginPlay
so I should do it on which event then? onPossess?
Yes
but that only runs on Server
there's a client version of it, but I don't think that's exposed to BP
PostLogin?
I'm not sure if the client event has a BP-ready delegate
So the idea is to grab a reference to the camera manager by an event on the client, but later than begin play
which is why making a BP-only multiplayer game is pain
Well worse case, you just make a Owning Client event and just call it from OnPossess
but yes, I agree
In any case, if you're going to be making a dedicated server game, you'll need to download source anyways
well a listen server more than true p2p
So something like that?
I think I get it tho. The players not being ready/valid on beginplay was probably messing with the references to the camera manager.
I'll refactor a bit my existing code to account for that 🙂
THanks for the help guys ^^
Catch you later!
Can TSoftObjectPtr be replicated?
Do i need to load the mesh from disk if don`t need it server side?
should be able to be
ReplicatedUsing should be enough to make it replicated. You don't need both.
I still do both tbh
It is never called client side, but is it worth ? will it avoid the mesh to be loaded on server?
I never done both, thought it gives errors/warnings
why would it give errors
it makes it a little more error prone if you don't need the onrep later
Yeah you're right
the OnRep is never called on client
What UE version are you using?
Seems like this was an issue in 4.21
Also is the OnRep a UFUNCTION?
5.0 preview 2
yes
do i need to set the value server side in a special way?
some function?
Are you sure this code is being executed on the server?
ye
it is here
but this function is not getting called after i change SK_ChestMesh
GetLifetimeReplicatedProps
it is getting updated client side, but not calling my function
If you are trying to change skeletal mesh on multiplayer my advice is to use on rep function so it will call a function when it gets replicated so it will work fine
How does it work? RPC?
That's what she's doing
Have you tried something that's not TSoftObjectPtr and see if the OnRep gets called?
You need to replicate it for what ?
I don’t see any use case where you would replicate it since it’s an asset
You do not need to replicate it, clients already have it, it’s an asset they have it in their game
Yes, with normal pointer it is called
You might need to load it tho
heya, QQ. Is there a quick start guide on async multiplayer games, or how you structure or think about client vs server?
The biggest obstacles I've seen with onreps is they don't fire if the new incoming value is the same as it was before on the client, make sure that isn't the case
You should not replicate it anyway
I've built tons of things in other tech, languages, etc, but UE is its own thing so asking
i want to avoid the load of this asset on dedicated server, am i doing it right?
i don`t need the mesh on memory for any purpose on dedicated server
Replication have nothing to do with that 😄
but SoftObjectPtr does, right? it is lazy
