#multiplayer
1 messages · Page 210 of 1
Only images, I havent got to the point where I want to store anything in playerstate yet
It should be just updating an image at this point
ok lets assume your goal is to sync an image
do you have a replicated onrep variable of type image in your character?
I can make one
Made a 2d Texture Variable
Assigned it what image i want
to see if it will work
set the variable to replicates
Here's the general form
Input -> ??? -> run on server event //happens clientside
Run on server even -> ??? -> set replicated variable //happens serverside
OnRep_Variable -> change stuff in response to that variable changing //happens everywhere
you aren't setting Prayer 23 and you're not USING it in the onrep
what do you want to do when Prayer 23 changes?
wait do you have a variable per prayer? Do you have Prayer 1 through 23?
just have CurrentActivePrayer
ok no there's a much better way to do this
why not make a class of some sort called BasePrayer, probably an actor
give it a variable PrayerIcon
maybe text PrayerName
then what you can send around is WHICH PRAYER YOU SELECTED
by class ref
right now your enum is sorta acting as that
So Make a new actor, give it a 2d texture component, refrence that actor, then set image?
not component
just a variable
then make variable public?
you don't need to instantiate prayers yet, you just need something to pass around to talk about what prayer you're concerned with
Alright, sec
Then the variable you''ll be repnotifying is of type BasePrayerClass MyCurrentActivePrayer
Hi how strong the replication system is against cheating?
I would expect a multiplayer game to send movements inputs as "w_pressed", "space_pressed" etc, but it looks like it's convention to send directlty the position of the player, however we know we can't trust the client
how does this work?
thanks
replication by default has nothing than, replication
you as the dev have to handle how you send data to the server and other users
Could you rephrase that, I have zero experience in networking through Game Engines, I only know how it works in multiplayer games made with frameworks (for example raylib)
from scratch
I watched some explanation of replication system
but still not really into that
You can't really stop the client from sending invalid data.
What you can do is check on the server machine if the input is possible
yes exactly
E.g. in shooting game, client may send data on which actor it hits.
The server will then check if the shoot is possible at all
however if I structure the game to send my position to the server, it's easy to understand that anyone can easily cheat the game and send fake positions to the server
so anyone can teleport themselves
so I would expect the client to send input events instead
Again by validating on server side
If the move is invalid, roll back
Or kick the player for cheating
isn't it harder to check if the movement is invalid? compared to record on server side the movement since "w_pressed" til "w_released"?
If you look into character movement component. It already have networked movement.
It have client prediction movement but server authorities. Players can move ahead, wrap the movement data and send to server.
Server validate the move, if they don't sync, correction will be made
Why do you need to check if a client press w or released?
You can look at character movement component. Or watch a video by delgoodie for the break down.
because doing so removes the need to validate data, which isn't always that easy (depends by the game I guess)
checking inputs is no safer than checking location, if you check inputs then cheating tools will just simulate the inputs to reach a given location. which would be fairly trivial to fake. instead you send less data back and forth between the client and server by just sending location data and verifying whether that is within safe margins.
Not at all
mhh, I mean simulating w press for a given time is exactly like pressing it phisically, you still need time to reach location and you have to avoid obstacles, teleporting is worse imo
however, the question is, how does the server work in ue
?*
Don't understand the question but you can read the pinned materials in this channel
They hold the best source to learn basic replication
A server is just the host computer/machine not sure what the question is about
And speaking for my self, since I never publish a mp game and it's my first project.
I'm not gonna reach too hard, let cheaters cheat.
It's harder to cheat if you have dedicated server
Then just validate important bits on server side
Don't overthink cheating, if you are not making competitive games
in a game made without an engine I would just make an external program listening to a specific port, parsing data received from clients and perform the critical game logic,
but in ue there's just blueprint components with replication checkbox, will I have to write an external program as well? or does packaging the game provide the server as well? etc etc
sorry for the nooby questions but I can't wrap my head around ready-to-use stuff
You're making this way more difficult than what it needs to be
You have to build the server separately
its a build target you setup. last i checked you had to do it from c++ in the ide but maybe theres a way now in editor
Well not specifically in c++, but from engine built in source
Dedicated sever need source build
in case I would build the server in my own, but what should I expect to receive from ue clients? xml? I mean I can't really underatand how all this premade stuff is not confusing to anyons
You are making it sound harder than it should
Just look at pinned material and get comfortable first imo
For the most part you don't have to think about it just click the replication box and make sure its setup to broadcast to the correct people with 1 of 2 (or both i think) options
It is confusing to a lot of people. That's why help exists. That's why there are mountains of documents and tutorials covering this stuff.
You're just making it way more difficult
Written tutorial for multiplayers are tend to be helpful
For the built-in stuff like movement, I'm assuming the built-in character movement is built to industry standards, so you probably don't have to think about all that. But I do get your question.
Videos like this made it click for me pretty easy: https://www.youtube.com/watch?v=OVeo3cVTIcU
👨🏫 My Patreon link:
https://www.patreon.com/kekdot
Download Project Files | Premium Tutorials | Courses
🕹️ Get our Game on Steam | The Anomaly Project:
https://store.steampowered.com/app/2960770/The_Anomaly_Project/
🧑🏻🚀Get the project files here on Patreon: https://www.patreon.com/posts/66842088
In this video we take a look at the basi...
Soo many harmful videos on YouTube tho
Like many is just straight up wrong
I would only recommend the pinned material and a written tutorials
Thats true, you just have to go into it understanding that, watch for something that doesn't seem right and find another source to double or triple check, like anything in life
Yeah but people can't tell if someone doing the wrong thing when they just start
Legit saw a video spawning with multicast
And thousands of viewers thank him
Lots of victims
ChatGPT is a godsend for me learning things even though it can be wrong half the time it usually says some keywords I can research more. But I already know how to code so its easier for me to notice things that are obviously wrong
It's just written tutorial are made by thoughtful people with the goal to educate
Youtubers are there for view imo
So they don't give a flying f if they say a total bs
Not saying all anyway, I found some video very helpful. Would be lost in cmc without delgoodie videos
I don't think that YouTube videos in the form of tutorials are usually meant to just generate clicks. If they are bad or teach wrong stuff then usually because the person simply learned it wrong and doesn't know better. Maybe they already learned it wrong from a different tutorial.
Most of those are probably actually convinced that their way is correct due to working and not having caused any issues, yet.
I do have bias or straight vendetta, seeing too many avoid casting and bad mp info on youtube
So the base idea was to use ALS for the main character
and a simple blendspace for the enemies
(that would actually see ALS in their screen)
this shouldn't be a problem if the hitbox of the chars is big enough to cover both the ALS version and the blendspace animations
what do you think
first of all ALS is only for singleplayer, and second it would be still too heavy to replicate over the net
also I can't use community replicated ALS
I switched to my old laptop lately and can't get C++ build tools to work the right way
I'm struggling
I´m spawning these items only on the server, but there are disparaties between the clients, how can I solve this ?
The spawner is already placed on the level so unsure who does it belong to and if there are different isntances per server client
are the pickable actors set to replicate ?
It was a weird one so essentially I had to replicate the static mesh comp because I was setting a visual representation with the data asset on the construction script
Heya dudes, how can we get the client's Number/Index/ID?
PlayerState.PlayerID gives me the total number of players created. So after a while in the editor it's 460. Just looking for player index 0, 1, 2, etc.
Why do you need it?
Find their index in the game state's player array?
Though I don't think that's guaranteed to be the same everywhere or even in join order.
Referencing players by index never ends well.
Indeed
Yeah this should work. It's just for spawn positions
UPROPERTY(ReplicatedUsing=OnRep_Driver, EditAnywhere, Category = "Seating")
ACharacter* Driver;
UFUNCTION()
void OnRep_Driver();
my onrep function doesnt call? am i missing something? im setting the driver variable through a server RPC and did replicate the variable in getlifetimereplicatedprops
the variable does set too
I must be missing something obvious. Client to server and server to client is working. But client to client my physics constraints isnt replicating
does unreal sends a network packet as soon as i trigger replicated code (e.g. moved something replicated). or does it waits till end of frame ?
All replication is end of frame. Assuming it gets past consideration. Replication can also take multiple frames before it's sent.
so the repnotify only triggers on clients when i change value through blueprints?
oh interesting. thanks a lot! do you know if ue does some .. "optimization" before sending (like compressing the data or discarding multiple changes to the same value in one frame?)
im sure it does on cpp. since ive used it.
yeah i tried but it doesnt seem to work, the onrep doesnt seem to trigger through cpp until i actually call the onrep function when i change value and even if i do unless im setting the value from bps the func is not getting called on clients
have you also set the variable as replicated by oerriding virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
yea
also i vaguely remember reading some doc that says that either on rep or a server/multicast behaves differently on cpp than bps. on one of those it doesnt trigger on the server. sorry i cant remember.
its all good, it does seem to be behaving weirdly, im doing the same attachment code i did in bps yet it doesnt seem to work as it did in bps
You set state, once or hundreds of thousands of times in a frame. At end of frame objects are considered for replication. If that object passes consideration, it will check for changed replicated properties. Changed properties are sent and when sent they have a function ran on them that allows you to pack stuff however you like if you choose to override it for the data type.
Regardless of C++ or BP. OnRep will run on the client if the server sends a value, and when that client receives it, it is different than the value the client had when receiving it.
thanks so much. thats really helpful. :)
For server though, in BP it will run the OnRep when setting it. In C++, you have to call the OnRep yourself manually when setting something.
right im yet to fully test my func, i did get it to fire func but i see that i do have to set the value through bps if i want to
did this too
and yes ive gone through this article before
You are saying that if you set the value in C++, you do not get an onrep on the client. But if you do it in BP, you get an onrep on the client?
yeah
You're 100% sure you're setting the value only on the server instance of the object?
yes
i know has authority can return client but im using an actor which isnt owned by a client and am setting the variable only after checking if local role is authority
also i dont think the function is running as it should or it did in bps
Is this the same value or two different ones? Like you're setting the C++ defined property in BP?
That's a new one. O.o
and the function was just attach actor to actor at some socket, it doesnt seem to actually fire up on client
it worked in bps
the same exact code
Worth noting that actor attachment is replicated. You don't actually have to set it on clients usually. This is why Unreal Tournament uses a FPS and TPS mesh in it's weapons. Cause it can't easily override the attachment behavior.
but when i attach only using a server RPC my character isnt attaching like properly. it jitters and lags behind the actual attachment pivot. when i attach using on OnRep for clients, atleast when i did in bps it would work properly and smooth and actually attach
what im more confused about is why isnt this attachment firing up on client side as it should/did in bps
(good to know )
is there a way to check if this attachment is actually being fired on the clients? or force it to fire up on clients because im sure it isnt
nvm i figured it out, cpp is indeed a bitsy weird though
Hey all, new to the multiplayer scene and having a troubling time with a networking/audio problem.
I have an audio manager on clients only (no server as audio only can be spawned on clients)
I would like to send a message from my audio manager(B_AudioManager) to a different server bp (let's call it B_Score).
Basically saying:
When all clients send you a message saying their audio timer is done, do a thing.
But I can not figure out how to send said message. If, on my B_AudioManager I
- get the client version
B_Score - Then try to call the event,
CS_DoThing, -
- which then calls
SC_DoThing(replication RunOnServer)
- which then calls
the server version of that event never calls.
Hopefully that makes sense. I've tried watching a few different YT's on multiplayer replication, but I still can't seem to get my head around sending info from a client to a server. I do know that in general the server calls the shots. So it is a bit backwards to have the client tell the server what's up. Bare with me, and maybe I am just approaching this from the wrong angle
Thanks for the help!
Where is this bp?
The B_Score is located on the GameState as a component
Ahh, that makes more sense. It's in B_Score
Can you just take a full screen shoot of #blueprint message
This bp
Especially include the top right corner that shows what class it's derived from
I can only grab some of it, NDA
I do have component Replicates enabled
For a start client don't have ownership of game state
Calling server rpc there will just get dropped
ok I think that make sense. Gamestate only ever lives on the server right? Then info is replicated to clients. So a client can have a non-owned GameState? not sure the lingo here
Not true, everyone have a copy of the game state but only the server owns it.
Ok, that's what I was trying to make sense of thank you.
When calling RPC you need to be aware of ownership
In general only the controller and character are owned by client by default.
So you will probably have to route the rpc there
Ok that's good to know. Is there a way to tell who owns what? Or is it a bit more of an abstract concept that you can' t really check? Follow up Q, how do you apply ownership, if I want my client to own the AudioManager?
You use set owner node (have to be done by server) but it's not recommended to do that.
Normally always limit what client can have ownership on
Soo far, I just use my character and controller or component that lived in either of the two
is this a saftey measure kind of thing?
hmm I see ok thank you
Security is one of the reason
Also only 1 owner can be set to an actor
So who's gonna own the Audio comp? The server? Player 1? Player 3?
When you think about it, not very useful
Fun thing about audio, server can never own audio components. They must live on clients
try and spawn audio on server and instant error
Not aware of that, I will look at it later maybe
Like what audio comp? The kind you attach to actors?
Like why not?
I would be surprised if I crash but I will take your word until I try it
Both. So either a SpawnAtLocation or SpawnSound2D or SpawnSoundAttached.
Crash is a stretch. more like you will get an error saying invalid and no sound plays
Nah, why wouldn't they work
Server is just another computer, that is happend to be the host
And I used those nodes too, don't see any problem
Idk what to say, just tried spawning a sound 2d via a server specific event and it never played, putting an isValid on it says not valid
The error you are talking about is it accesses none error?
Server rpc = hey run this on server version of the actor
So like it must be what you are doing 100% maybe share the code for others to look at
Let me set something up quick to show here. I'll recreate in a fresh project
Ok pardon the quick slap together. Just threw an actor component on a GameState
client. Sorry not sure if I screen recorded that
yeah standalone and listen will work as they create the client version locally
should of specified that to start, my bad
?
wait I think I see what you are saying. Yes it will still play a sound on the client since the actor component is on both
Game State exist in every machines
but we were talking about having a spawned audio component on the server
regardless of spawning something, the print string should just show if it work or not
Yea still work
no problem what so ever here
got ya. So in this instance. the server owning version can not spawn audio. Which is fine. I only ever want it on the client. but it means in order to avoid errors I would have to always put in HasAuthority checks
So the owning server can't have a cashed version of the audio component.
So if I played a sound from the server, and wanted to AssignOnAudioFinished. The server owning version would never occur. The client would, but the server no
For example, this does not work on the server
actually nvm it work for me
but I found something interesting
the game is mute for the first few seconds when running multiple window
when the client joins
what does your bp look like?
I get this. This is straight on the GS
I moved it straight on the GS, no issue either
You are in client net mode as well with 1 player right? I must be missing a bool somewhere
im on listen server mode
ah that's why. try client mode
because the server in listen server is also the local client it will play it
I see
@reef flume well if you are playing as client net mode, you are aiming for dedicated server?
correct
because there would be no point in playing a sound in a headless machine
makes sense, no speakers lol
it's all just processing and output text, no render
yea no audio either
I just crashed after changing it to client mode
gotta love those
but prob make sense, why play sound on headless machine 🤷♂️ , maybe someone that actually knows can clarify tho
so then allll the way back, and sorry I should of said dedicated server, if I want to have my audio on a client, tell a score counter on the dedicated server, how do I do that?
This Looks Cool
what's the relationship between audio and the score counter?
now that I think about it, it doesn't have to be audio. could be any event.
I have a audio count down that is driving a score counter via Quartz. so really it's just an event
Server RPC is the only way for Client to communicate with server
Is this the proper way to do rep notify?
Rep Notify gets called when the variable value gets updated (On Server and Client in BP), (Only on client on cpp)
"proper" is very subjective, that image really tells nothing
though I don't know why you are over complicating it.
On_Rep Emoji -> Update widget
why do you need event dispatcher there
So then in how would I send info from client only to the Gamestate, as per photos
Route it to something the client owned
controller or character
Hmm ok so then really it needs to go
AudioManager->PlayerController->GameState
Even though the AudioManager is a component on the GameState
AudioManager->PlayerController->Server rpc there
To update the widget?
I would just have a direct reference to the widget and update it
anyway the idea is widget just read the replicated variable
OnWidgetInit-> Read the variable -> Display
OnVariableReplicated (OnRep) -> Get Widget -> update widget -> Display
I guess I don't know how to update it without an interface or event dispatcher, casting?
No, just grab the reference to the widget
Scores should live in player state
if each players have individual scores
yeah that was a poor example on my part. should of just said, it's a thing on the gamestate for "reasons"
@reef flume It can be as simple as this
if you need to access all the player states, lets say to display the score of all players
you can go.
Game State -> Get Player Array
those are your player states
gtg, gl
Take care and thanks for the help from a fellow RedPanda
So this works now (except that it doesn't replicate) and I get these errors along with it
You are trying to access a widget that don't exist
Need to point the reference to an actual instance in the world
You are leaping top far diving to multiplayer if you don't know how to use reference. The difficulty is way harder because you will need to handle not one but multiple machines
At the time when on rep called the widget ref points at nothing
Hence the error accessed none
Also need to be aware of race condition here
How is it able to update then?
If the variable replicate before the widget is created then you will get the error
So have is valid check
Simply don't update widget when the widget is not created and it is not yet set
OnRep-> widget valid? Update widget
Else do nothing
is valid removed errors, still works
Race condition it is then
There is latency in multiplayer, you mpst likely haven't even test in a battle tested environment
0 ms is fake multiplayer, you will need to add some latency and address race condition when working in mp
Havent even got to the point to know to address that yet :/
I'm still stuck for days trying to get am image to replicate. I figured out how to replicate some static meshes with tutorials and documentation you recommended before. And I understand the basic concept ( I think). I just want to learn how to do this one thing so I can apply it to everything else
Simply marking the variable e.g. texture 2d as replicated will make the variable replicate from server to client.
If client need to change the value, do server rpc
If server need to change the value, just set it right away
If client need to react to the update , use on rep
Just try to replicate a texture 2d, forget about your widgets and these event dispatcher and enum
Some common advice is to read the pinned material 8 times , practice, fail, repeat
But once you understand replication, it's actually very easy when it click.
Unfortunately replication is probably the easiest concept to understand in MP. There are many other challenges ahead
Don't feel like I'm going to get that far if I can't figure this part out
I will do this and then get back to you, sounds easy
Make the client and server able to change the color. Then make sure everyone see the same state (color)
Do not use multicast
If you are stuck with that share your code here
hmmmm, working with multicast, need to do more research, might take me longer than I thought, thank you
does anyone know how to add an impulse to a client? whenever i add an impulse on a client it just corrects no matter what even when doing a multicast.
Alright : bottom (component overlap) easy peasy
Top (Event Dispatcher) only working on server and not updating or changing on clients (besides server client combo and only when it calls it itself)
V key pressed -> if server-> Set the material variable
If client -> server rpc that set the material variable
On rep update material
switch has authority?
You can use that to filter host vs client in most cases
Client can have authority if the actor it's in, are spawned by them self.
😮
If it's replicated actor and spawned by the server then it's fine to use switch has authority
Okay, all of that makes sense to me, mostly (I think)
Trying to think how that applies to my 2D texture dilemma
What node(s) can I use besides has authority to tell if its a server or client calling
or is it just this?
An RPC marked as Run On Server, will only ever run on the Server...
You dont need a HasAuthority to check if a Run On Server RPC is being called on the Server...
Yep, just read that on the forums. I'm going to pull up something that I got to replicate properly. Then ask why it doesn't work on anything else.
Maybe what I labeled each of these things is not what it actually does and I don't understand it properly
SetIsReplicated just marks an Actor/Component to be considered for replication. Calling that function doesnt actually replicate anything.
If I remove that node, it doesnt change on the clients
Sure, im just speaking more to how you have the comments
Update Clients of Server change
🤔
Technically speaking, thats just a byproduct of calling SetIsReplicated
You should be able to just set bIsReplicated to true on the Add Static Mesh Component node.
In the details panel
So things can replicate on the server without seeing the results of it being replicated?
No, again, you are confusing terminology.
Having issues with details panel, going to keep reading what you posted and read more on the forums
ohhhhhhhh so you do use cast XD
what's wrong with casting?
here
yea I never said anything about casting, what I said was why do you need event dispatcher
maybe you were replying to something before that post
you asked for an overhead icon
I did above with a few lines
don't make it overtly complicated than it should be
though I think the problem boils down to not knowing how replication works
you should attack the pinned material again
I will check it again, but the things you posted are golden, I thought you were saying to set it without casting, interface, or event dispatcher, which is why i posted the only other thing I could think of
you are still using dispatcher in your post tho
im only casting because im using widget component
because the getter node return generic type
last time you tried that you have accessed none error
yeah, but i made it like that because I was trying not to use cast or event or interface
using cast or not is not the issue
you can certainly do what you have above
but your issue was you didn';t set active player widget ref
or there might be race condition happend
e.g. widget created after on rep is called
casting is just a type check
no error doesn't mean it's fixed
it can even be a silent bug
the point is since order is not guaranteed in multiplayer
you need to know how to address incoming data
I guess I only know some of what I don't know at this point. And trying to learn a bit at a time. This is defiantly going to help me understand /know more of what to do/when to do it (I'm hoping). So thank you again, a ton. 😊
Hey Guys! I have a problem with the replication? I Guess?^^
Ich have a multiplayer game. and i want to set the selected player meshes on start.
Only the player itself sets the mesh so every player on his own machine...
I mean the meshes only get refreshed locally… client 1 can’t see the new mesh of client 2 ^^
My BP_Player is replicated. All needed variables too…
Don't use Multicast
Set the Struct
OnRep(Struct)-> Set Mesh
or if you don't need those info and just need to set the mesh in the client, make the mesh replicated variable
Server : Set Mesh,
Client: OnRep(Mesh)-> Set Mesh, that's it
Oke ill try it this way - thanks 🙂
So the server sets the struct variables...and onRepNotify it should set the mesh
so server calls this:
thats the method that gets called on the player:
Thats the RepNotify:
same result ^^
If you used multicast everywhere, you might want to start refactoring
don't use multicast for any stateful behavior
this may account up to 95% of the casses
or more
No i do not but i tried so much stuff 😄
Break your S Curr Character
Get the mesh
Set the skeletal mesh from the mesh inside the S curr character
WOW!
it works 😄
But can u explain why its working that way?
even if i set the custom event rpc to not replicated it did not
So you are not understand RPC and replicated at all.
#multiplayer message
you can see some example here
I already refactored so many things with this authority calls and stuff...im getting better...but still a noob I guess 😄
But thanks...I already did some tutorials and explanations about rpc calls and thats everything is better than multicasts ^^
its not about the question of better but the context it is used
If you need to do something stateful, don't use multicast
if you want to do something fire and forget where it wont matter if some players don't replicate the behavior then you can use multicast
Like a chat message, where you just want to broadcast your msg to the players currently in the game
Yah cosmetics etc. that isn relevant for the game
for example
But Thank you!
For the quick help! 🙂
im gonna refactor everything now where I use an RPC call..if its necessary 😄
Hi. I have a question. Is it possible to force the server side to render a specific shader or Actor? I am working on water in Unreal and as you know, the standard Unreal Engine plugin does not support multiplayer and synchronization due to the lack of water rendering on the server. Therefore, I am considering options such as using server rendering, so that some information can then be transferred, for example, Fluid textures - simualtion textures, to the client side, and then use this data to calculate physics.
Server does not have GPU, so I don't think it is possible.
Lets say i can buy GPU on server or something like this.
- if this is not possible, then how does Pixel Streaming work? Some hack?
I have another question. When I call a function from the server that calls a method on every player … the player should call a dispatcher that is executing for a example a hud update… but I don’t want to replicate my local widgets and I only render my widgets on client side. (Which is the common way I hope?) What’s the way to let the players call their dispatchers and refresh the hud when the server did the main call?
Because the server has nothing to do with it - it’s only client sided … is it like calls from server -> rpc owning client -> refresh hud?
Or, which in my opinion is more correct - Server Call Update Dispatcher -> client recive event- client call self dispacher ->hud recive event.
I am sure that Pixel Streaming will require Server has GPU.
Like so?
GameMode -> Call „dispatch yourself“ on every player controller
PC -> Receives call from server -> Calls Dispatch yourself (owning client rpc) ?
does the pc has all of its local components when it’s „wrapped“ in an owning client call?
widget don't replicate, so you can't even if you want to
also widget just strickly READ
dont even put any shared information in it, widget just read the variables from else where
Why does the server need to tell the player to refresh their hud?
sounds like design problem
hmm
HUD update when HUD update,
e.g. when client array of item structs get updated for example (the variable lives in player character/ player state for example),
on repnotify -> Update widget
Ah ok 🤣 I think there was a complete misunderstanding on my side 🤣
I've not seen anyone mention Online Beacons in a while. Anyone here using those or are they perhaps deprecated or something?
Not a lot of people get into the situation of needed them
They were originally a concept to allow Players to register to DedicatedServers before actually joining them.
Something something Unreal Tournament.
ye used them in HLL for that + server queues
Then people started to use them for MainMenu Friend Invites.
I assume Fortnite also does that or at least something along those lines.
only matters if it takes an eternity to load your map
For the Server queue?
The Friend Invite stuff is more of a feature than a solution.
For reserving space in a server I mean
Yeah okay
server queue was just a feature we added
Yeah I only ever had to use them for that Friend Groups that queue up for Games, like Fortnite, CS, Overwatch and what not
#online-subsystems should have pins that help with getting started with them @coral badger
Yehh I've used them for a pre-server game Lobby system as well. Was just wondering if there are other use cases.
anything where you need a light connection to a server I guess, and want to transfer data via replication. That's it really
Anyone can throw some wisdom on fast array?
Regular struct does delta replication right? While fast array would replicate the whole object.
If that assumption is correct, why do I want atomic replication for large data like items?
Wouldn't that be more performance heavy to replicate the whole thing instead just replicating the difference?
Structs, TArray and Fast Array all do delta replication
Fast Array also does delta replication of the internal structs by default (you can turn it off)
The main advantage of fast array is per-item callbacks, and that you can change the order without causing a massive delta, which is what you'd get with TArray
TArray can still be faster and cheaper. Plus custom delta serialization prevents you using any shared serialization, so FastArray can be slower with POD types and lots of connections
Calling it "fast array" was a mistake
i thought Fast Array would always be faster that TArray, since i learned that an array will replicate all entries after the modified index
would checking server connection be a valid choise for this? I was planning on testing ot to get a sense of the server ping before commiting a full join
nope, untrue
TArray calculates delta by comparing elements. The problem is that when you move/delete an element, usually every element after that will then be "deltad"
my whole inventory and other systems use those
If you're using POD types and your array doesn't change size/order, TArray will be massively faster and cheaper
If it doesn't have UObject/FNames in it, you could benefit from shared serialization with lots of connections.
could being the operative word
but yeah, on a OnRep of an array, how do i know what changed ?
i have a UObject in it
no shared serialize 4 u then
im doomed then, i dont want to remake all of it yet
Profile it, find out if you are doomed or not
yup
Problem is people assume fast array is better, but it's not always the case and unless you look at how it actually works under the hood and understand it, you can't make the best decision.
but how can i know if it can be improved ? for know i can only guess its bad if i get lag spike
fast array for inventory is probably fine
Quick question about replicating movement using standard MovementComponent inside PlayerCharacter. I am teleporting players on the server only, but this does nothing with the Client, ie. Client is not teleported AND on the server, the client's position goes back where it was before the teleport (client overrides the movement). I am using just the standard setup, anything obvious here, what am I missing? Does teleport need to be handled on clients, as they are the authority of the character? I am so used to that Server has to do everything.
are you 100% sure you use TP on server ?
Yes I am 100% sure. Inside the Actor, that handles the TP logic, I have a if (!HasAuthority()) return; and also the Logs suggest that the TP logic is run on the server (when the players enters certain collision box)
From the Server POV, it looks like the Client teleports for a frame and then goes back to where he was (like the Client overrides the position)
SetActorLocation should replicate by default right? I mean if I set a player position like that on the Server, it should update on the client? Works like a charm for non-player actors 🤔
Instead set actor location, isn't there teleport node?
Does not make a difference
How are pointers to actors, objects ect sent through in context of multiplayer / replication / rpc. Are these sent in some form of ID?
ye
Servers/Clients create mappings between those IDs to the local pointers so they can identify objects
when are those created ?
my guess is:
- server knows the UObject exists
- created netid
- sends netid to client (with class instance data ?)
- client recreate its local version of the uobject with the class instance data
- assigns it to a map with the given netid
for a replicated actor the server sends the ID with the actor spawn packet.
For objects which can be addressed by their path name, you just use the path
what is the type of the actor spawn packet ?
so ican check what is inside
the path of the class def ?
or the path of the asset, or the object in the level, whatever it might be
What about SoftObjectPtrs / SoftClassPtrs. These are just paths to assets as FStrings so there is nothing unsual about sending them through net, right?
So in fact, what worked is that I am sending a Client RPC from Server to the Client, inside the PlayerCharacter actor, that teleports the player. I still do not understand why doing this on the server (without Client RPC) does not work.
nope its kinda small
im making a multiplayer racing game and have the player select their vehicle in the main menu then it loads them into it when they create the session, but when i have the second player join the session it doesnt seem to spawn the vehicle pawn, does anyone know what i can do to fix this
Good to know, ty
Heres avideo of the issue
hello,
one window is both client and server and another is client only. On Spawning the objects (using game mode), i m giving possession to the player controllers iteratively. But for the (server and client ) person , how can check out of the two spawned object which one is possessed by it?
so i need to tell the gamemode to spawn a seperate pawn for the other clients?
no game mode is spawning all the players together one by one
when the host clicks the start button
so what is the solution?
its my question , i m not answering your's problem😅
oh, you should use a question mark lol, its also very similar to my issue i just posted
what is happening , if you start game after joining the session
what do you mean start after joining?
on clicking play button only you are spawning ?
i think you are spawning only on clicking the play button , and when user clicks on join its just switching your level without spawning the player
you need spawn player on joining
yeah i think you are right
anyone help me with this ?
you think i should look into how to spawn multiple players?
the alternative is , you need to send an RPC event to server on joining succesful
yeah that you can look into
when server get the rpc event , it will spawn player for you and gives you the possession as you already did
ok thanks
Why is the niagara effect not visible on the server? This is the multicast event called by an run on server event.
I, again, feel like this is a fairly stupid mistake I am just overlooking.
multicast only works if it's called by the server
It is
and don't forget the receiving end
well I don't know, you gotta show proof that it's called by the server
show the code maybe
it's called by a run on server event. It's working for the client, the server also runs through this and prints correct values inside the macro at the end
it's just not visible for him
what costs more between an RPC each tick or a onrep var change each tick
inside the macro the server is printing correct values here as well
I m stuck at this problem , please help , if you know😅
one window is both client and server and another is client only. On Spawning the objects (using game mode), i m giving possession to the player controllers iteratively. But for the (server and client ) person , how can check out of the two spawned object which one is possessed by it ?
I think there is a misconception
the 1st window is the server
not both client and server
it's simply the server
isnt there a "get possessed" node
okay , but isLocallyControlled must give true for that
isLocallyControlled will check if the actor is locally controlled or not in respective on whos calling it
this one is true for the liste nserver
i mean for host , which is also a part of game
Don;'t see how that connects between client / server tho
isLocallyControlled just check if the actor is locally controlled by the machine that's calling it
this here is the macro
Players normally have a pawn they posses, for the pawn they posses, isLocallyControlled will return true on the machine that owns the pawn/actor
The material change and timeline are working for the server. Just the niagara effect is not visible, although it's valid
here i m assigning playercontrollers, but it is giving true for client , which is correct, but for host it is throughing false for both object
this is the loop
Oh now I see. I set the particle size to 1000 and apparently the server is spawning the particles in the center of the map although it's set to snap to target :/
so nvm, It's not a multiplayer issue then
In my experience no attachment rules ever really work lol. So i always set the position again after attaching
top left: client
bottom right: server
any ideas why the camera rotation is replicated from client to server (screen 2), but not from server to client (screen 1) ?
none of the camera spring arm and camera is set to replicate
well anyways i think i can use RemoteViewPitch from GetBaseAimRotation since its reped
is game instance client side?
there is no networking element to game instance at all
im trying to set a vehicle of the players choice in the menu, that theyll spawn with in game, but currently both players spawn with the hosts choice of behicle
the variable was stored in the game instance and cast to by the game mode
id like this to be per player
it's both but they're not networked
a game state is networked
so its some kind of pure local
?
its local and isnt networked
i personally call something local when its running locally on a machine (so client + server)
Is it possible to get PreDestroyFromReplication for an object you hadn't received from the server before? Like the initial bunch for that object was just its destruction? I had a crash as client joining a game in progress, and the crash was inside PreDestroyFromReplication, and the initialization for that object hadn't run at all yet (its triggered by an OnRep)
It's finally working! thank you everyone that helped!
P.S. the texture that I was testing everything with was corrupted so I wouldn't have gotten it without your code ColdSummer
I have Pawn, and a camera in it, when the player rotates the camera, it changes the Mesh rotation in this Pawn, and I would like the Mesh rotation to be the same on the Server and clients
someone can help?
Both pawn and camera component have options to adjust their rotations according to controller (which is what actually being rotated when you use AddControllerXXXRotation function). You need to select the ones you need according to what you want to achieve
I also have elements in the actor that cannot rotate
with this option the entire actor is rotated
Pawn's Use Controller Rotation X options directly apply the selected rotation axis to the Pawn actor itself yes. But the result should be the same on all players. What is your issue here, not wanting a component in your pawn to rotate with the pawn?
I'm creating a tank
Could use GetControlRotation and retrieve the X component?
some ideas?
Then you wouldn't want your pawn to use any part of the controller rotation. I haven't mingled with vehicles before so there is probably a better way to do this but you need to rotate your barrel and turret part according to base aim rotation's pitch and yaw respectively
While your rotation inputs still adds rotation to controller and movement inputs using add movement input with your world direction being the forward of your actor
That way everyone can update your tank's instance themselves according to base aim rotation
Anyone know why chaos wheeled vehicle component causes a crash when running server but not standalone?
Hi, I'm trying to open a map from client1 on button click
however the map doesn't load
this is what clicking on the button prints on the server side
tag me for answer please
thanks
Happs u forgot adding player start?
not in L_Grid
I have two player starts there
mh but wait
I think I understood
basically I'm launching the server saying that L_Lobby (that doesn't have player start) should be the default one
how do I prompt the client to start from a specific level?
no it doesn't
and doesn't need to
it's a lobby
with join button
i need to launch the client to a specific level instead
There is server default level and the client default level. When u launch the game it will launch that level.
U can then open a different level though.
When u connect to a server u open that servers level
no no okay I managed to do it, just passing the level name as argument
but now when the map loads, the input doesn't work on the client, so the player is not moving, and the server prints this
[2024.09.12-19.55.01:530][565]LogNet: Client netspeed is 100000
[2024.09.12-19.55.05:679][654]LogNet: Join request: /Game/Levels/L_Grid?Name=DESKTOP-4K9SVM7-65C0AA104C4C4ACBDB68B88512B914FA?SplitscreenCount=1
[2024.09.12-19.55.05:690][654]LogNet: Join succeeded: DESKTOP-4K9SVM7-65C0
[2024.09.12-19.55.06:105][663]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:107][663]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:150][664]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:198][665]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:249][666]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:251][666]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:254][666]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:291][667]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:292][667]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:338][668]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:340][668]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:385][669]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:388][669]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:432][670]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:480][671]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:481][671]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:526][672]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
[2024.09.12-19.55.06:527][672]LogPhysics: Warning: COLLISION PROFILE [ALS_Character] is not found
Hi!
I am trying to get OnRep_ReplicatedMovement() this called for my custom pawn.
I am trying to do this on the server side code but still this doesn't get triggered
FRepMovement& repMovement = PawnOwner->GetReplicatedMovement_Mutable();
repMovement.Location = m_position;
PawnOwner->SetReplicatedMovement(repMovement);
PawnOwner->ForceNetUpdate();
here, for ref
/** Used for replication of our RootComponent's position and velocity */
UPROPERTY(EditDefaultsOnly, ReplicatedUsing=OnRep_ReplicatedMovement, Category=Replication, AdvancedDisplay)
struct FRepMovement ReplicatedMovement;```
according to what I have learnt - when ever the replicated object gets manipulated then the OnRep_ method gets called. This is not happening in this case and I am debugging this on the client's exe.
or basically I am trying to get OnRep_ReplicatedMovement on the simulated client by changing its value in the server
Best advice if no one has given yet, would be to add print strings so u understand the problem
Cuz it could be many things like server not knowing about your input, or there being a non-multiplayer related issue
So like first know if the server knows of the input, then add like breaking points like that to know where the issue happens

yes but anyways I think i will drop ue for this project
ue with dedicated server for my project feels like a spaceX rocket to travel 5km
makes no sense
ain't no way im downloading +200gb engine source code and compiling it from scratch just for this
What's ur project? & For what?
there is a grid 16x16, two players search for a match putting each 100 coins, fight with Pump, AR and fortnite builds and who wins takes all the coins
you can then cash out the coins into real money
for example 1€=100coins
this may not be compliant to UE rules so I will adapt it with some workaround like gift cards and tickets instead of a virtual currency
what you think?
U can do it with ue though u could also do it with other engines. I was wondering if it was a game or just an app. I guesh do what u think is best.
Though if u intend to make more games, id recommend regardless of decision start installing the source build
Worst case scenario u'll have it ready for a future need
Even if u end up using a diff engine for this one
yes for sure I can do it in ue
but it's too much stuff forna relatively small project
Well thats a bit dumb to stop for so little
But do as you want
no dude trust me, there is no way I can manage to download all that stuff
trust me you don't know my internet provider
anyways thats not the only thing
good day, quick question. if i have an actor that's owned by the server, then the server reparents (attachtoactor) to the pawn. would that object become an autonomous proxy on the client for that pawn?
Attaching doesn't change anything on ownership
thanks, oh for a moment i thought the parent and the owner where the same thing. maybe for components?
To find ownership components go to there owner (the actor holding them)
But its only the case for components attached at compile time (95% sur)
owner = ownership
parent = attachment
(95% sure)
any common reason why client to server replication is fine, but client to client replication is not working?
because that's not a thing
Variable replication is Server -> Clients only
I mean the server and a client both see it, but the other client doesn't get notified
show code
replication was the wrong word there
The general form is that a client informs the server of something through a run on server event, and the server sets a replicated variable, which eventually makes it to everybody
maybe im lacking that variable
show code
sorry its sorta a mess atm
that is very cursed
lol i've been trying everything I can think of
so I'm guessing you want to hitch something to something else right?
Press key -> if close enough, hitch
Networked physics is cursed enough on its own but it's doable
First off, don't try predict the hitch. The client side should just be input -> tell the server something
Input -> I wanna hitch (run on server)
I wanna hitch -> is there something close enough to hitch to? (get overlapping actors) -> yes -> hitch to it
Now whether or not setting constrained components on the server is enough is neither here nor there
right. But when I try that I get worse results than this method oddly enough. Lemme retry and show you the results from that method
How are your vehicles moving to begin with?
vehicle movement component
It might be that the fact that the 2 things are constrained is not replicated
is the constraint component replicated?
it is
Check that everyone agrees what the 2 constrained bodies are
tick -> get constrained components -> print them
idk why I havnt thought of printing that out of all things lmao
so are you suggesting something like this?
It's been a while since I've done this but it is doable
get rid of that on component overlap node
the fact that it gives you anything useful at all is a stroke of luck
you don't care about the last thing you began overlapping, you care that you're overlapping something hitchable at the time you press the button
right right
yeah that was giving me issues in the past
so how should I check if something is overlapping without that?
get overlapping actors
for each -> is it a wagon? -> proceed
I honestly forgot that was a method of getting overlapping actors
there's basically an array of overlapping stuff hanging around and the events fire when it changes
I was scratching my head thinking I dont remember overlap being this weird lol
doubt this will fix my issue, but it needed fixing nontheless so ill give it a try
If I were doing this I would at start with making sure everyone agrees on what's constrained (and the ref frame for it)
then I'd look at the physics replication settings of the wagon and possibly the car. Make sure everyone agrees on everything. Do you know for sure that your car is replicated correctly?
for sure, no. but from all my testing it they have been extremely stable with no issues
if i have very simple use case of max 6 elements to be put in an array, i do want this to fire up OnRep func whenever the item is added, does it makes sense to use fastarray or should i just stick to normal TArray replication
okay I cant figure out how to check if they all agree on whats connected. But I did setup the overlapping actors check like you suggested. Now it seems the client that is pulling it is experiencing the wagon lag behind by a large margin
If the array is going to be relatively small then no you don't need to take the extra steps in optimizing that one single thing
a normal Array is just fine
as always, if you want to be sure everythings okay it only takes about 2 minutes to pop open the network profiler and see
where can i host a free unreal server build? its for learning, it will have aproximately half CAU
on your machine?
mmm, could be, but im looking for cloud mainly
then you need to pay or use some free tier
i think i will self host, otherwise aws. thanks erererererer
or unity multiplay i have to look at that
its just going to be 6 elements at max, im sure of it, i do think i can just use a normal array, atleast the more i think it seems more viable
there's nothing wrong with using a replicated TArray if the number of elements are relatively low. I assume you may be worried about the network traffic. If you want to keep costs to a minimum while not overcomplicating things, I would consider making your actor dormant, and making use of force net update.
my actor is a bitsy important so ive set it to always be releveant and yes i was worried about network traffic and reliability in general.
does anyone know how to add an impulse to a client? whenever i add an impulse on a client it just corrects no matter what even when doing a multicast. please help
Looking for locomotion guide
Whats your issues with MP & locomotion ?
I am just trying to get the idea how can I build my own locomotion from scratch and handle replication
I know that Epic released their locomotion system but it's quite advanced
XD
by the way, how can I export their animations from the locomotion project - exported i mean it use the manny skeleton and mesh instead of the UEFN one
Is there any considerations to replicating a UDataAsset reference? My understanding was that they would 'instantly' replicate fully, as they exist locally already ?
I dont fully remember, i remember having issues with that.
Anyways my recommendation would be to not store a DA at runtime (for example as a Inventory Item), but instead use them as static data that is used as a initer
So create some method to grab this data on init , instead of storing a reference to it?
My current setup just pointed to these like this;
UPROPERTY(BlueprintReadOnly, Replicated)
USqsQuestLine* QuestLineDefinition;
While it seem to 'work' I'm seeing some weirdness but it could ofcourse be elsewhere
Thats my preference yeah
I mostly do that because i want to store more data at runtime then in the DA
So instead of editing the DA i edit my runtime object
i do the same, but separate them in the instance so to speak
It also depends how heavy is you DA compared to its potential runtime version
SqsQuestLine is DA (static for all intents and purposes)
SqsQuestLineInstance holds a ref to the DA, + whatever runtime data i have
IMO if i had a quest system i would only replicated specific data like the quest title and description
And a soft ref pointing to a location ping actor for eg
Well you can test how it goes with that
There is a lot of differente ways of doing
And to complete/add peogress to the quest use whatever source to do a server RPC
The only issue atm is that some stuff dont update in the UI, while if i inspect the reference at the time, it got the correct data
weird
Can you show how you rep that to UI ?
And the supposed good value at runtime
during inspection
(currently mid refactor, so this is just all testing)
when hovering the variable it's "out of scope",
if i print its value, it's correct
Yeah thats a BP limitation
You are forced to hover the original struct/object var
Sounds like its not replicated
the TB_Description was collapsed -.-
I had this issue when i first tried a inventory composed of DAs
the sub textblock was visible.. making me think it was the TB_Description
yey, it works!
So is the DA ref replicated ? Or do you only need the texts here
yes, everything replicates as it should
the DA contains all the static info about everything related to that quest line
On your screenshot i dont see any usage of the DA
QuestLineDefinition is the DA
Quests also holds a QuestDefinition to a Object inside same DA .. (one could say its redundant, but its for ease of access in widgets)
and Objectives/Failconditions yet again holds a definition. plus the runtime data
its weird that here its showing null
which part?
no idea about this anyone? 😦
so inside your OnRep_ReplicatedMovement you got no calls ?
you do not need to call SetReplicatedMovement here
you already changed it
i was just trying out if this could call it out but no!
nope. It doesn't get triggered. I think in CMC it gets triggered through some physics but I am writing my own simple system.
is this actually being called on the authorative client?
is bReplicateMovement true?
I have been trying to change the value on the server and kept a breakpoint by using the client's application
this is not physics related
yes
you can just test this in a single application in multiplayer PIE, make sure you actually watch the play in editor context string too
etc
{,,UnrealEditor-Engine.dll}GPlayInEditorContextString
is this a replicating actor at all? is it even created on the client?
APawnAgent::APawnAgent()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SetReplicateMovement(true);
SetReplicates(true);
bAlwaysRelevant = true;
defaultSceneRootComp = CreateDefaultSubobject <USceneComponent>(TEXT("SceneRootComp"));
RootComponent = defaultSceneRootComp;
// Create and initialize the skeletal mesh component
SkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("SkeletalMeshComponent"));
SkeletalMeshComponent->SetupAttachment(RootComponent);
PawnAgentMovementComponent = CreateDefaultSubobject<UPawnAgentMovementComponent>(TEXT("PawnAgentMovementComponent"));
//MaxJumpHeight = 5.0f; // Desired maximum jump height
//Gravity = -300.0f; // Gravity
// Calculate initial jump velocity based on maximum height
}```
I have set the things in the ctor
but I am trying to change the value from the movement component but on the server
what's the point of defaultSceneRootComp here if it's the same type as teh root component already...
besides the point I suppose
cool, I asked you if you are doing that now
is this code actually running on the server?
the code that changes the FRepMovement& repMovement?
UE_LOGFMT(LogTemp, Log, "{WorldString} Set repmove here", GetDebugStringForWorld(GetWorld()));
yes
yes that's running on the server I am 100 percent sure
this dumb logging thing should help show which context it is being ran in
okay, I'm not 100% sure lol
it done in server rpc
Is the object also replicated to the other client as well?
that object is in Actor.h
it's replicated yes
Is it actually being created on that client?
I'm not asking what checkboxes you pressed, I'm asking what is ACTUALLY HAPPENING
could be as simple as a missing Super:: call somewhere
basically I want void APawnAgent::PostNetReceiveLocationAndRotation() this to get called whenever the position of the actor changes and I can update the position for the simulating client
you can actually override OnRep_ReplicatedMovement interestingly enough if you want to
i did not override PreReplication or anything. It was getting triggered on the client yes
what is getting triggered on the client? I'm confused
yeah but still I guess it won't get called if its not getting called for the parent
PreReplication method on Actor.cpp
also LocalRepMovement.bRepPhysics being true precludes a call to PostNetReceiveVelocity
can you just breakpoint AActor::OnRep_ReplicatedMovement ? 
Or override it just for debugging purposes
i have the source code. I can put a breakpoint there
unsure if it will work without debug symbols
i am running it on Debug Editor build
that's not what I mean, I mean debug symbols for the engine
a rather large optional download you need if you are doing any non-trivial C++ stuff
isn't downloading the source code and building it enough to create the pdbs for the engine?
or you can just do the simple thing and override it to see if it's called
yes, but you never mentioned you are on a source build?
here 😛
sorry, I assumed you were on the binary launcher build
no issues 🙂
having the source code does not preclude it being a binary build
both of them have the source code...
yeah ofc. Yes but i did build the whole engine here
okay, just breakpoint it then?
you don't need my permission to try to solve the problem lol
one moment. So to get the breakpoint triggered i think i have to run it under one process.
also, i am getting this warning when I run it
ensureMsgf(!NeedsInitialization(), TEXT("SetIsReplicatedByDefault is preferred during Component Construction."));
would it matter for now?
unless you want to get that ensure literally every time you run the game then leave it?
SetIsReplicatedByDefault appears to skip the extra call to UpdateReplicatedComponent
yeah everytime i run the game through VS this pops up
then... why didn't you just do what it says?
Just use SetIsReplicatedByDefault ...
I'm not certain if it matters for this but it's definitely skipping a lot of extra work
thought i could do it later. Bleh. Wanted to test out stuff
SetIsReplicatedByDefault where do i need to call this?
This is just a change to the source file? this is a file you are changing anyways 😛
This is the part where I tell you to just... look at the error
no it's my custom movement component
it must be coming from where i wrote
I think it would be really beneficial for you to figure out what a callstack is and what it means because otherwise C++ debugging will be quite difficult
next time you see the ensure, look at WHERE it is coming from and what could change
anyways, I am not sure what do we need to fix first. Keep a breakpoint in OnRep_ReplicatedMovement here or fix the warning?
xD
both
also you never proved it's being created on client and server with anything
if you are compiling with the editor open or something do not do that (Unless you know what you are doing, live coding can as a rule of thumb can change cpp stuff)
this gets triggered but only on the first few frames and I highly doubt its getting triggered because of my code
this is not a callstack
ensures are designed to only cause a breakpoint the first time they are triggered each run
this is to avoid being stuck pressing f5 forever on "bad but not a crash" kinds of errors
yeah, this is a received bunch
It would be easier to override this to see if it's being called
as this could be any replicating actor
you also hid which actor it's for... I don't understand how I can do this seeing only small pieces of isolated things at a time
ok i am overriding it and dioing super::call in it
also please just fix the bad SetReplicates call now rather than ignoring it
sure.
one moment
Also make sure you didn't miss any Super:: calls in your overrides, like beginplay etc
yes sure!
in the mean time i want to ask. I think you made your own rollback netcode right?
How did you manage to deal with packet loss?
I have seen unreal has done it with acknowledging the moves and sending back to the client but the new moves are sent regularlary and with regular packet loss the gap between the last ackd move and current move would increase. How did you manage this?
I'm not an authority by any means, I don't think I have something viable yet
with packet loss you just... spam moar packets lol
I don't want the server to acccept whatever the client has done in those packets which were lost
so there must be a solution?
a server correction?
I think the reality is eventually you just have to correct the client to be where the server expects them to be... if the server missed some old unreliable move RPCs then oh well
yeah but that would make the client to keep on sending the new moves and the server is still processing the old moves. With more packet loss - older moves and so on 😦
btw overriding didn't help either
I didn't say it would help, I said it would let you see if anything was calling it
no, didn't get called. Let me show things are happening on the server
I still haven't seen a simple output log showing the object existing on both other client and server
these are my logs in the server code and server logs
what exaclty you want to check?
UE_LOGFMT(LogTemp, Log, "{WorldString} Set repmove here", GetDebugStringForWorld(GetWorld())); I gave you this exact line here to pasta in (If this doesn't compile my b, I think it's accurate though)
add this log to the pawn's BeginPlay as well
missing include
uhm. Doing it with normal log. Running it
Is there a reason you need to run it outside of the editor here? I personally prefer just doing stuff like this in PIE
it's not a perfect test but it should be more than good enough for stuff like "does this replicate at all"
Can I switch a player's APlayerController instance mid match? To perhaps a difference type?
the player controller is more than just "what buttons you push", it's kind of the object that owns the connection to the server
I want to let players spectate the match if they're dead
I figured maybe changing the controllers to a spectating controller would work
it's not simple to swap out from what I can tell and I have never seen a project that needed to
Makes sense, I figured it wouldn't be trivial
those the logs kept inside On_RepReplicatedMovement() and BeginPlay()
PIE means another window for the client and not in the editor itself?
Spectating does not require changing the player controller at all, by default NAME_Spectating actually just spawns a spectator pawn (defined by the gamemode) locally and partially possesses it
Oh right, doing it via a pawn makes so much more sense
how do you mean partially possesses it?
it's possessed but not THE pawn of the player controller, it is actually the spectator pawn of the controller
the server doesn't know or care about it
Makes me wonder how fog of war works in multiplayer
Ah, gotcha
I guess what can be seen must be defined by server
If you want to do things the ~unreal way~ you can do this to start spectating (dot his on the server to the player that starts spectating)
// start state "spectating"
MyPlayerController->ChangeState(NAME_Spectating);
// make sure to yell at the client too
MyPlayerController->ClientGotoState(NAME_Spectating);
there is nothing stopping you from just making a new flying pawn and possessing that to make spectating a thing, spectating (the unreal player controller NAME_Spectating state) is entirely optional
it is techinically used when joining before you get given your pawn etc in the default case I think?
but in most cases this will be like a brief stutter before you start walking around
I would guess that at the initial couple of seconds before the pawn is spawned for the client the controller is in a pawnless limbo
gotcha
the unreal setup is fine except for a few omissions in spectators not being respected as the current pawn ( PlayerController->GetPawn() does not return it, but GetPawnOrSpectator does)
That works, thanks a lot for directing me to pawns
I feel like I need to take a step back here, lol...
learn what a pawn is first... please read the getting started docs
I was about to actually use this system I wrote some time ago that I called 'player experiences' which was just an input controlled camera that became the player's view target, potentially letting the original pawn still get inputs
i don't like this multitude of options
the alternative is to ignore those options
your setup is actually probably a pretty good idea, the view target + input is all you need in reality
but it might omit some key things like the server knowing where your viewpoint is from the possessed pawn (distance based relevancy?)
exactly my thoughts
I would highly recommend at least possessing a real pawn while playing
yes ofc
thankfully all of my actors are always net relevant so this will never have horrible consequences 😅
also if you want... you CAN add actor components complete with server RPCs + replicated properties to a player controller
if your concern is "why do I have to stuff all of this darn stuff in the player controller" or something
but the pawns are there for a reason I guess
sorry to bother you again but here are the logs
showing where things are called.
The call on the clients come from begin play and On_RepReplicatedMovement which I think is being called only when I play the game. Not when the values are changed
How on earth are you getting a -1 client ID?
are you passing in a nullptr?
ah, no read the ternary wrong
I guess -1 is the pie instance of standalone processes
yeah. It happened because i launched it on PIE yes
I suspect something else is overriding the repmove here (the value I mean, not the function)
I would just launch it all under one process for stuff like this (just to make it faster to test, no it is not an accurate test that way)
try setting the position of the root component rather than manually changing the rep move
I think it's gathering movement and seeing the position hasn't changed
let me try
See AActor::GatherCurrentMovement
which is what fills out ReplicatedMovement
you can actually make a seperate property for your own replicated movement if you like and disable the old one if need be
right. I noticed in high ping
These are the values of the local client over 10 frames
local client - 1,2,3,4,5,6,7,8,9,10
server - 0,0,1,2,3,4,5,6,7,8,9,10
remote - 0,0,0,0,1,1,1,4,4,4,8 etc
so the remote client is getting the update in a bunch rather than receiving every single update. This seemed weird and I tested the Third person template in Unreal and they were updating the values regularly even on high ping using PostNetReceiveLocationAndRotation
I am not sure what was happening here
thats why i was looking into it
is it changing anything in the onrep? Is it set to Onrep_always?
no i changed things on OnRep when I noticed the simulated client isn't getting regular updates. I didn't use it before when I noticed this issue
anyways its weird. I'll try this stuff on a different project now
At this moment I think i need to focus on how to deal with packet loss