#multiplayer
1 messages · Page 563 of 1
Replicates Movement only works for the object you've checked it on. But either way attaching an actor to something shouldn't be done with RPC's, should be done via replicated vars.
Since it's stateful
If you want to ask the server to attach you need an RPC for that of course
in this case it is a request to server to equip() whereupon the end of it performs the attachToComponent()
My guess is you don't want weapons to replicate movement then
You probably just want them to attach themselves locally when they are "equipped", and detach when unequipped
You can drive all of that from just the equip state.
@gaunt kestrel this one
Hello there,
I am using Steam for multiplayer, so I can easily browse and connect to my dedicated servers using the Steam server browser or my in-game
anyways, guys does any 1 have any experience with connecting to dedicated servers BUT having steam enabled?
i cant connect with a rap IP/port
and pinging the server is not working atm
for some reason
@chrome bay hmm, makes sense (and that is where I was heading). So then that sounds like a case for continuing with the net_multicast approach so I can notify others that something was attached?
However, regarding my movement assumption... Perhaps all this effort to not enable "replicatesMovement" could be redundant too since I'm assuming that attached components would be sending redundant network traffic. I probably need to make sure that is the case and for that I think I need to take a dive in the UE4 source code rabbit hole (or finally learn how to properly monitor network traffic via logging/profile, which I still don't know how to do yet)
You can use a Rep Notify so that clients know when the item was attached
They'll call the RepNotify when the variable is received by them, and they can handle it accordingly.
E.g, "IsEquipped" being true attaches to the owner etc etc.
Replicating Movement isn't cheap - if it's a weapon that just attaches to the player, there's no need to replicate movement or attachment at all.
Since all of that can be determined by the client based on it being equipped or not.
Or, better yet, the pawn can do it based on it's replicated "current weapon" property or something
Better that than multiple weapons replicating their equipped state and fighting with each other / creating race conditions etc.
you're awesome my friend, that makes much more sense to me on approach now. Not sure why I didn't think that route already
still stuck on this: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1483622-connect-to-steam-dedicated-server-via-raw-ip
Hello there,
I am using Steam for multiplayer, so I can easily browse and connect to my dedicated servers using the Steam server browser or my in-game
any 1 with experience with steam and dedicated servers can lend a hand?
do your dedicated server logged in to Steam?
i just tried to connect without problems, but not by ip, by sessions making
no, they are just servers in the playfab azure cloud
sessions is not the same thing
im not trying to use sessions because the servers are dynamicly spawned by playfab in a virtual machine
i've started dedicated server in google cloud run
without login it is easy, in docker container
but login with SteamCMD is a pain in the ass
i have never even looked at steamCMD
it is command line client for Steam
have you read the thread that i linked? have you used the ping method described there?
Hmm - still got a really weird issue: We have a level that procedurally streams in levels (i.e. procedural dungeon generation). Everything works perfectly in PIE, but as soon as you cook a server build: The navigation and AI movement just stops working completely.
Navigation is set to dynamic, have a large bounds volume surrounding the whole area of the dungeon. 🤷 starting to be at a loss as to what could be causing it
Im trying to allow one player to see way further when they switch to an "overhead view" mode but the default relevancy that makes sense for first person gameplay prevents that. Is there an easy way to extend relevancy on an individual basis?
Like if there's a way to just say that, for this one client their net cull distances are extended that'd work
Is there any significant difference in designing a networking system for 2v2 vs 10v10?
Depends on the game, but you should always try to setup some of the basic architecture to scale....
Super new to multiplayer, thanks.
So it it's 2v2 then you just change some values rather than building it up to support more people...
And does the same apply when considering a 60-100 person BR game?
Actually @magic helm did you play Tribes back in the day?
Lol BR is a whole different monster... But that's the sort of "depends on the game"
Sadly no, but I've watched enough streamers play it
There's a mod in Tribes that allows you to make a "football" server.
I'm intending on recreating that.
So I need something that will work for up to like 20vs20.
Oh cool! I assume with a handful of people playing and the rest are spectating?
Spectating was possible, but most people could just hop in and out at will.
It was a pretty casual thing.
I mentioned in a previous video that there was a Football game mode for Tribes.. and I found a server with a couple people playing! So I cut up some footage from my football match for you all to enjoy! I haven't played this game mode in forever, so I'm not very good anymore un...
Here's the only video I could find on youtube that shows it.
But yeah it shouldn't be too bad... If it's drop in and out, you just gotta setup the persistent part right and make sure the sessions max player count feels good for what you want
Think I can get it done with the Network Compendium?
Trying to find a nice starting point that will more or less get me there.
@chrome bay Regarding your advice to @lilac bear earlier, is it that the weapons are spawned on the server, replicated to each client, and attached on each client via a RepNotify boolean on the character? Do I have that right? And if the character is replicating movement, the weapon won't need to be since it's attached?
A RepNotify of "Current Weapon" probably. You would likely have a replicated array of inventory items, and one of those items would be "equipped" at a time.
You can drive everything client-side from that one var
And the weapon typically shared network relevancy with the owner, and doesn't replicate movement at all, since it doesn't need to.
This is the approach ShooterGame uses pretty much
Works well
So CurrentWeapon is an array of Actors?
current weapon is just one actor
but presumably you would have "inventory" which would be an array of actors
Ah... I never thought of OnRepping from an actor reference...
didnt fix my thing yet so ima try again, has any 1 worked with steam and dedicated servers hosted in a third party? im trying to connect to my playfab servers but im not having much luck
@waxen socket @chrome bay my current inventory system allows an array (equipmentSlots) which can have multiple weapons equipped (on a spaceship) and these weapons can be grouped and fired in any combination (Think Mechwarrior or ChromeHounds). However, Jambax's suggestion has given me a solid approach to achieve what I'm looking to do :)
@limber gyro I realy wish I could help on that one but I'm not quite there yet, I do have some Steam functionality but I've got to resolve some MP issues before I dive into that mess 😄
I got ripped off and a dev and they left me with some pawn with bugs, how come if I put 2 or more players in and pick offline I cant see the players replicated if I pick play as listen server or play as client I can see the players??
then your pawns are replicated just fine, just spawned on the owning client
I have an inventory screen widget that shows the contents of the inventory.
It works perfectly fine in singleplayer but in multiplayer the clients' screen wasn't updating correctly.
Only solution I found was turning on substepping and adding a delay with a duration of 0
Why would that happen though? How does just a delay fix it magically
timing is important, what calls that update?
the fact that delay till next tick fixes it
When anything gets added or removed to the inventory this also gets called
suggests you don't have an optimal order of execution
rather then a replication problem
you'll need to be way more specific
This widget dont need to replicate, it just wasnt updating correctly on client side
BP
its the inventory widget itself
Nope
its called from the inventory component with an event that is "Run On Owning Client"
RPCs don't wait for Actor to have its turn to replicate
they just fire immediately
so they arrive and/or are processed before the replicated variables are set
so it should be called from OnRep_Contents
hm, ok I'll try that
it should also not call into the Widget directly, but rather call an event dispatcher
and send the contents as a payload
and your widget finds your inventory component when its initialized, binds to that event, and calls one UpdateInventoryScreen by hand for good measure
just in case the delegate fired before the widget was instantiated the first time
Yep, instead of calling the event right after "AddToInventory" I put it to OnRep_Contents
and now its working correctly
without the delay
Thanks!
watch for cross wiring, its possible here
cross wiring?
if you were to find the widget from the game code, and call the update directly
and the Contents was replicated to everyone, not just the owning client
then OnRep would cause Player1's inventory widgets to update when Player2 picks up a banana
Hmm, I'll just test that real quick
its possible Player2's pawn would not be able to find Player1's widgets and it doesn't break because of that
but in general, you never want game code, with exception of single actor managing the widgets (Custom HUD class) to ever reference the widgets
Ah yes there is another problem now
The Client's inventory widget updates correctly but not the Server's inventory widget doesn't update at all
So what am I supposed to do
Ok just settled on the best solution I could think of.
I made an event dispatcher to the widget with the payload of contents like you said.
If the player is Remote that dispatcher is being called by the On_Rep.
If the player is Server the dispatcher is being called by an event with "Run On Server".
On_Rep only worked on clients for some reason
I'm sure there are way better ways to do it but it works lol
its fine
if you did it in c++ you'd have to do it that way, since c++ won't call a replication callback on server
also
your Server RPC there called from a server is just a normal vanilla function
I made it in blueprints but On_Rep still didn't call on server.
And yes I forgot running a "Run On Server" on a server doesn't do anything special.
@winged badger hey man do you happen to know how to connect to a remote server when unreal is using steam? u seem to be one of the most knowledgeable people here so i thought i might ask
im trying to connect to a playfab server
never worked with playfab
what about any remote server with steam?
a thread in the forums is telling me to use "pingServer()" so that steam recognizes the server and returns an ID, but the callback always says the server didnt respond
sounds like a port issue.
indeed it does, but i tried opening the ports specified by steam and the error still persisted
and yes i did try both udp and tcp
hi guys just been doing more research into MP and tryna get the ropes of it all. Been finding it quite tough but MP games are my jam so I must learn! : P
Um i had a question regarding Listen Servers since the player is the host (server), if you wanted to spawn an effect that is not gameplay critical/important and doesnt have to be perfectly replicated (identical) on every machine. Since its a Listen Server and you want ALL machines to see the fire effect including the host of the game, you'd still have to spawn it on the server and on client machines, right?
Whereas if it was a dedicated server you could just spawn the fire effect on all client machines only
I'm just trying to figure out how you'd go about spawning a screen effect that is applied when a player takes damage, on the player that is hosting the server
hey guys, i'm using the skeletal mesh merge found in here https://docs.unrealengine.com/en-US/Engine/Animation/WorkingwithModularCharacters/index.html
it's working perfectly fine in the editor, but in it crashes the server in a packaged build.
the image shows the error i'm getting: debugging it seems to be related to LOD models being 0 on the server
any idea why and how to fix it?
Describes the different methods you can use to create modular characters comprised of multiple Skeletal Meshes.
How to spawn every player as a random character in multiplayer?
override HandleStartingNewPlayer, do not call parent function, spawn a random character and possess it with the player controller thats in the event's input
@midnight karma UClass* GetDefaultPawnClassForController_Implementation(AController* InController) override; override this function inside GameMode and write your logic to provide random pawn class to spawn
We are having bit of a strange problem. Our missile launching logic goes so that client calls server function giving the launch rotation and location as parameters to the server function. But as the server gets more stressed by more actors the missiles on the server start going into a bit different direction than what the client tells. The rotation parameter is Frotator and the start location is FVector_NetQuantize. Can the accuracy of server rpc function paremeters be automatically dropped the more the server is under load?
@winged badger your approach needs a lot of additional handling to be done.
it doesn't, thats equivalent of calling RestartPlayer which default implementation does
additional handling is just put it on a PlayerStart
unless you're making UT, GameMode code won't do much for you out of the box
but with my approach I don't need to do addition posses, etc, and engine will take care of rest
additional handling is just put it on a PlayerStart
@winged badger ``` AActor* ChoosePlayerStart_Implementation(AController* Player) override;
it has a significant drawback in BP
/** Return true if FindPlayerStart should use the StartSpot stored on Player instead of calling ChoosePlayerStart */
virtual bool ShouldSpawnAtStartSpot(AController* Player);
I don't use BP, so can't comment much
function that doesn't let you respawn player anywhere else but on the cached StartSpot in the controller
its best not to trust GameMode code to do what you need it to do
our GMs are almost entirely overriden without Super calls
as our game is nothing like UT 😄
I m working on my MOBA game 5 vs 5, so on every player's machine total of 10 Characters will be spawned. So on PLAYER A -> Will his owned Character will be spawned first and then remaining 9 SimulatedProxy Characters, or the spawning of 10 characters will be random???
i mean sure, GetDefaultPawnClassForController could be plugged into SpawnActor node in HandleStartingNewPlayer override
which might even be convenient
yes
but here, i much prefer to be explicit, as it is a very convenient place to construct your entire player-related object graph
then let GM just call RestartPlayer
Are FVector_NetQuantize values compressed depending on server load/ping?
and we have 2 controllers + PlayerPawn + ObserverPawn + PlayerState
no, they are always compressed
but only when NetSerialized
its a normal FVector with NetSerialize function overriden
Yeah but can they be sometimes less compressed/less accurate depending on server load?
no
@winged badger can you help me with my question , please??
ok
I m working on my MOBA game 5 vs 5, so on every player's machine total of 10 Characters will be spawned. So on PLAYER A -> Will his owned Character will be spawned first and then remaining 9 SimulatedProxy Characters, or the spawning of 10 characters will be random???
if you transitioned from a lobby, which is likely in this case, via seamless travel
players will spawn in order depending how fast their CPU is, pretty much
after it loads a level, PC sends ServerNotifyLoadedWorld RPC
ohh so its fair to assume the spawning in random order
which then calls HandleSeamlessTravelPlayer then HandleStartingNewPlayer
which spawns its Pawn
yeah, but if the load times are more or less the same
then you have replication playing a role in which order the playerpawns show on client as well
as there is no guaranteed order in which 2 characters spawned at or nearly at same frame, will replicate over, if they have similar net priority
This is really good explanation which is not documented anywhere, Thanks a lot brother
note that server won't start replicating stuff over until you finished loading, so if you're among the last one to load
all player pawns are free for all, all evaluated in the same frame with same net priority
Is it possible to replicate location and rotation of a character smoothly on a moving object? Currently my character will grab a ledge and calls a function to update the ledge transforms and set the character location/rotation from the ledge transforms. This is all currently running on tick to allow for dynamic changes. However I need to replicate the character location and rotation and have no idea how I would achieve this smoothly without firing RPCs on tick which I know shouldn't be done. Thoughts?
you can also use GenericPlayerInitialization() which is called both from seamless travel, and first time in
@gleaming niche is this for me??
yeah just following up on the stuff zlo was saying
its called both fgrom postylogin (first time) and seamlesstravel, after player controller is created and before the pawn
I have a strange case where a certain enum value doesn't seem to be replicated, but other values do. E.g the value EGamePhase::Idle is not replicated while EGamePhase::Round is replicated. The value is changed on server and replicated to clients, along with a ForceNetUpdate();. I haven't been able to wrap my head around this..
@chilly tinsel RPCs on TIck some of the time aren't the end of the worrld, as long as they are Unrealiable
but this ledge scenario sounds like something client should be able to simulate on its end
@rain coral is that a single variable?
@chilly tinsel doing some custom CMC work would allow you to have it handle everything, and it does send Unreliable RPCs on Tick
@winged badger Yeah. After digging, the issue seemed to have to do with changing multiple times per frame without me realizing, so that part is solved.
@gleaming niche GenericPlayerInitialization() is called on server as it is in GameMode, originally my question was when server spawns the character on client including my team mates and enemies, so will server first spawn myself on the map and then remaining SimulatedProxy players or will it be in random order like FCFS.
it will spawn pawns for player in whatever order they connect/finish loading as for creating additional pawns/actors, that depends on your own stuff.
will they come in order on the client side? It's not guaranteed
even I had the same thoughts , but I wanted to get it confirmed from experienced devs here.
however, it shouldn't even matter, since as long as you have something so you know they belong to another playercontroller; even if they aren't possessed directly, you can check that.
yes
@winged badger Ahh I'm currently multicasting as I can't think how I would simulate this action on client side and tell other clients its happening without asking the server to multicast it (Forgive me my knowledge on replication its growing by the day) just to purely test I set up RPCs on tick and the client suffers with desync issues when hanging on a movable object and net corrects when I let go of the ledge however I think thats because I've made the events reliable, i'll try without them being reliable and see if that does any better. To edit the CMC that would require C++ knowledge right? I'm willing to try but would love to see some learning resources on the basics of extending the CMC. Just for reference here is the current hacky set up.
Also i'm aware I could probably clean up having two RPCs in exchange for a SetactorLocationAndRotation node and sending both the location and rotation through 1 RPC
if client can deduce from its location that its hanging from a ledge
or have a replicated pointer to ledge actor/mesh
it can deduce its own rotation correctly
and if it can deduce its own rotation correctly the CMC should handle the replication?
I still don't follow "if client can deduce from its location that its hanging from a ledge or have a replicated pointer to ledge actor/mesh"
Appreciate you taking the time though!
if you do you don't have to replicate it
editing the CMC is not possible from blueprint and without at least being comfortable with c++
its one of the ugliest classes in the engine, monolithic, 13000 lines of code, strongly coupled to character, playercontroller and assumption of what net roles are going to be
Yup thats me out then.. somehow simulating on client end or cutting out the dynamic ledge detection might be the way forward
Appreciate your help, if you or any others think of something just @ me. Thanks!
Good afternoon. I've learned before that objects such as dynamic material references do not replicate even if you set them to do so. It would seem that replicating references to spawned actors is quite common however. I'd like to ask if there's any caveats to this? Maybe it's very expensive or otherwise best avoided?
Cheers.
Actors and ActorComponent can be replicated by default
UObjects can't
like UAnimInstance, or UMaterialnterface
you can also replicate asset pointers
for Actors and ActorComponent pointers to work, they need to be NetAddressable
without going into more complicated uncommon scenarios
- any Actor loaded from the Package (preplaced in level) is NetAddressable
- any replicated Actor is NetAddressable
- any ActorComponent on the CDO of a NetAddressable Actor is NetAddressable
- any dynamically spawned replicated ActorComponent on a replicated ACtor is NetAddressable
- any asset pointer is NetAddressable
and thats the end of the list @waxen socket
to replicate changes in a dynamic material you generally want to have the client instantiate its own DMI, replicate the parameter and OnRep set the parameter on the DMI
Yes, that's what I do.
So if a character spawns another actor and stores a replicated reference to it, that character will have a reference to the spawned actor on the client as well. And calling functions of that reference on the client will run on the client's instance of that actor.
with a caveat that the referenced Actor on the client might not have replicated yet
what happens if a client sends a invalid reference over the network does the server crash or does the engine check it for?
the reference to it replicating doesn't mean the Actor did already
I've experienced that desync before, yes... 😕
@faint dock depends, generally the server gets a nullptr
but if you send a RPC via an object that server doesn't have, it will disconnect you
Wow. Harsh.
so the server can crash right?
only if it recelves a nullptr and then attempts to dereference it
okay good to know thanks
Zlo, if you don't mind, I think I need some clarification on projectile replication. To pick up on our previous discourse.
If I read it correctly, you spawn non-replicating projectiles on the server and all relevant clients?
Hello, I'm once more looking for some help.
Since a while ago, the delay until the movement of characters starts to replicate to remote client has become unbearably long. I sometimes wait up to 20-30 seconds before the movement is updated on the remote client. It takes longer in an actual network with several computers and less long if I have two clients on the same pc.
This used to be no issue at some point. My character class has gotten a few new replicated properties in the meantime but not as much as explaining this long delay. In between I also moved parts of of the character class to c++. The unreal version has been upgraded a number of times in the history of the project aswell.
I actually have a similar problem with a replicated struct variable which also only starts to replicate after a delay of 5-10 seconds. I think the same may be the case with many other replicated variables.
This chat has already provided me invaluable help with other issues I've had. So I hope you also know something this time.
i don't spawn projectiles at all
just particle systems
and yes, every machine spawns its own
Oh. Do you not have any slow projectiles?
i do
i don't instantly apply damage either, but use math rather then projectile collisions to figure out what to hit
its not a perfectly precise algorithm, but for the number of bullets flying around you can't really tell the difference
Would you recommend that approach for 100 or fewer projectiles at a time?
hey guys, i have question regarding TCP sockets and protobuf usage. I have it setup and working, however for TCP - im not sure if its good to keep same socket open for each message but implement some kind of delimiters for protobuf messages, so that on my server I could split stream in packages, or instead - for every TCP message - create new socket, send data and then close it?
Most likely there will be at least 1 TCP message every 2-3 seconds, most of network job happens via UDP, and only important stuff(that needs to be delivered for sure) is done via TCP
This seems to help with my problem:
https://answers.unrealengine.com/questions/964067/really-slow-replication-even-when-playing-locally.html
Quick question about mobile games and architecture. Lots of games have segmented userbase with servers... are these servers dedicated servers or just servers with scripts and databases?
@fierce grove servers with script and database are actually game backend service, so most of the people do end up using available options like Gamesparks, Epic Online services, etc.
I'm playing with playfab these days
Playfab is not worthy
I tried using it in past, and it was unable to parse my 2 level nested json object, so I quit playfab the instant.
I think they did some work here
You should try out epic online service
Now I have moved a lot and I can't switch back to playfab
@clear sand you are doing some interesting work here. Protobuff traditionally doesn't work with plain tcp . Are you using any wrapper of tcp
so for a tile based asynchronous multiplayer adventure game I can just work with Epic Online Services no need for dedidcated servs
For backend service you can rely on Epic Online services.
For dedicated server hosting it depends on your choice and your richness
not sure I need dedicated just good scripts to get players on adjacent tiles
Can your players interact with each other
Are you only interested in their location??
If they can interact with each other then it's multiplayer game.
yes of course
Just a suggestion to you, can you exploit this for need rather than to a script.
I was looking at it
This is the same technology which most of the early taxi based startups use to do realtime tracking
So what was your observations
@clear sand you are doing some interesting work here. Protobuff traditionally doesn't work with plain tcp . Are you using any wrapper of tcp
@rich ridge Well, it works. After all its a stream of varints, but for me its not clear how to split messages if it works in stream mode(not sure how to call it) without actually closing socket after delivery is done. Im not big guru of TCP internals, so might miss some point here
I didnt use any wrapper, just regular ISocketSubsystem.CreateSocket()->Connect
Basically this is simple heart beat system for now, which connects game server, logic server and client itself and checks if its online
Later, I plan to reuse sockets for exchanging messages between servers(MMO)
And this is what confuses me - what is the cost of reopening sockets everytime I need to send something, as Im not sure how many data will I have to send at later stages of development
You can keep your socket open in background thread
And in this way your client is always connected to server and thus server knows that your client is online.
Yes, thats not a problem - however I plan to reuse socket not just for heart beat but also for sending other data such as actions data(e.g. do that, calculate this)
Probably as an option - keep hearbeat socket open forever, while after data requests close sockets and create new for next ones
That's not a good idea, one socket connection can serve your all purpose
That was initial idea
And if you open more number of connections, the load on server will increase
but I dont know how to delimit messages on my server. I'm using golang for TCP listening
I mean - protobuf does not have delimiting, or I just didnt get how to do it
Ohh
probably as an option - wrap protobuf message into wrapper which will consist of protobuf message itself + size of message, so that on server I could delimit stream by this info
Why don't you send message size to server first and wait for acknowledgement and then send the message
simply because 2 requests > than 1 request. Im aiming for some good performance shit here. And also using TCP along with UDP makes UDP to loss packets sometimes, so less TCP better for UDP
Anyways thanks for convo, I think I got idea on how to keep 1 socket and get rest of data exactly when I need
👍
There are few protobuff protocols available, if you could build it for UE4 it will work great
What you mean few protobuff protocols? I only know google's one, which I built and included into my ue4 project
you mean QUIC ?
Yes my bad
Welcome
whats the best way to disable player input in a multiplayer game
DisableInput() and EnableInput() are client sided
would it be best to create a replicated variable
and use an OnRep to call Enable and Disable input
Is there a way too ensure that a Client RPC was called from the server?
i want to ensure that Client_EnableInput() is called ONLY from th e server
i dont want clients to be able to call this lol
I'm spawning an AI controlled character on the server but when it's spawned it doesn't fall to the ground, stays floating
@quick flint Unpossess is the only path that you can't hack as a client
@winged badger really?
no game is unhackable, and trying to make one is... suicidal
you just need to make it difficult enough so its not worth it
@winged badger but won't the timer stop running
lol
like if i unpossess()
my timer won't run anymore essentially
to possess
what is stopping the timer?
pretty sure rpc's and similar thinghs like timers dont run
when not possessed by a controller
who says timers dont run?
So I've got another question. If I have a repNotify function which requires some replicated values to be set ahead of the repnotify function being called (on clients), how do I go about insuring that happens? Do replicated variables update in order with rep_notify function executions? (re-reviewing network stuff to try and answer my own question now)
got c++ handy, or BP only?
thing is with c++ the order is predictable
and you can override PostNetReceive to execute logic after all replication(callbacks) are done
BP is a bit of a mess tho
working to do all networking in c++ so that's some good news Zlo 🙂
I'm not spotting where eXi goes over this though in his awesome network Compendium doc sadly :S
http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
in c++ the replication order is the DOREPLIFETIME order
while some special cases (like fastarray) will call its own replication callbacks immediately during its replication
replication callbacks typically go after the entire replication is done
and then goes PostNetReceive
with blueprints, i really have no idea, and since i avoid networking in BP like a plague, never was all that interested to put in the research
the fact that OnReps in blueprints are not replication callbacks, but setter / property changed callbacks
as they fire on server, and even locally on clients if you change the variable locally
makes me think they don't really have the callbacks called after the variables are all set, and the order BP replicated the members in is probably the order in which those members were first added to the blueprint, and can't be changed
"... order in which those members were first added to the blueprint, and can't be changed" if so... yikes :S
its the method that requires least effort to code in
and given other serialization failures BP can sometimes make, it would be consistent with the rest of the engine
well, it could be changed if you deleted and re-added a member
for it to end up on the bottom of the order
note that this is more of an... educated guess, not the result of actual research
you would also need to both compile and save the blueprint between deleting and re-adding the member
Makes sense, i appreciate the caveat, luckily I don't need to concern myself with BP stuff yet :)
so DOREPLIFETIME order makes sense to me, so then if I have some important repNotify functions that require various values to be set I just need to make sure the var for the repnotify comes after the important variables that must be replicated first?
or override PostNetReceive
that one executes after all OnReps that came as a result of receiving a Bunch
so it is the simplest, most solid way to go about it
oooo... "PostNetReceive" and "Bunch" (don't know either). Sounds like I've got some reading to do 🤓
PostNetReceive is a UObject function
that doesn't do anything by default iirc
Bunch is a... packet for that Actor on its ActorChannel
ah I see! That is an interesting method for PostNetReceive override. I'm definitely going to have to keep that trick in mind 🙂
I have been curious about changing dereplifetime conditions during runtime but I suspect that is frowned upon or not possible. Which is fine, I don't think I'll actually need to try something like that. Is it possible to change the order at runtime for that either? Seems like something you'd also want to avoid
i prefer not to be dependent on the order
so never dived deep into that
generally, its a multiple states scenario where they depend on one another
but then i just stuff those into bitfields
thanks yet again Zlo, I'll dive into this some more and hopefully come out successful now 🙂
Hey there I've built a costum movement animation and it just stays at it's idle animation... for the other player... it means the animation is local only. replicate movement is ticked... also the needed variables are replicated... still can't seem to get it working correctly
So the closest I've got is... the Clients can see their own animation but not the animations of other clients.
Server can see his own animations but not the animations of clients... and the clients can see the servers animation
Setting the visibility of components is replicated? When I set the visbility of a component from a local controller and that controller is on the server host the visibility also changes on the clients?? Is that normal behavior?
That seems weird to me
Visibility was replicated iirc, yeah
i had the same issue with a widget component, host would set the visibility and it would propagate to all clients.
you can make a subclass and un-replicate it if you want
there are a bunch of new macros to use in GetLifetimeReplicatedProps that will remove parent properties from the list again
For some reason
Overriding OnPossess() and creating a variable to my pawn in the player controller does not work
it sets it
but then on APlayerController::PlayerTick() it says its nullptr
how is this possible lol
{
Super::PlayerTick(DeltaTime);
if (HasAuthority() && PlayerCharacter)
{
if (GetWorld()->GetTimerManager().TimerExists(PlayerCharacter->DeathTimerHandle))
{
float timeLeft = GetWorld()->GetTimerManager().GetTimerRemaining(PlayerCharacter->DeathTimerHandle);
Client_UpdateRespawnTimer(timeLeft);
}
}
}
void AHVS_PlayerController::OnPossess(APawn* aPawn)
{
AHVS_Character* MyCharacter = CastChecked<AHVS_Character>(aPawn);
PlayerCharacter = MyCharacter;
Super::OnPossess(aPawn);
}```
how?!
lol
this is some bizarre shit lol
yeah, when you do vanilla spawning
PC will not have a Pawn yet, before Super::OnPossess
it also won't run on clients
i recommend overriding SetPawn in the PC instead, which will
and really? sending a RPC to update a timer? On tick?
So inside of PlayerController, I noticed there is Tick() and PlayerTick()
does PlayerTick() only run on the client?
hint: time passes at exactly the same rate on clients
its special to APlayerController too
PlayerTick is part of the CMC abomination iirc
i think i should just use tick
because when i tried it
it seems like its only calling on my client
HasAuthority() is always false lol
its always returning 0
for that? you shouldn't use the tick
what should i use then lol
you need to start the timer once
on client
it doesn't need updating unless its paused/resumed
well the death/respawn is on the server tho
the server holds the timer handle
for the death
and i pass the time left
client can start their own timer
to a client rpc
for UI
and count down without wasting a shitload of netweok traffic
for custom Pawn work, override SetPawn, not Possess
one on the client, one on the server?
yes
hm
simulate everything you can get away with
then where would i check
for the time
on the client?
in tick still?
but only on the client?
depends where you need it
it doesn't even need a timer
just the time left
so if the client is aware of time it needs to respawn
it just needs to cache the current WorldTimeSeconds
and time to respawn would be CurrentWorldTImeSeconds - CachedWorldTimeSeconds + RespawnTimeSeconds
time left
accessing a timer to read the time left is somewhat inefficient
nope
i mean
you would display some kind of widget
to show the time to respawn
it would need the time you died and the respawn duration
and then it can just tick it on its own adjusting its text
hmm
wait so where are we caching it
every frame?
or how i mean
UFUNCTION(BlueprintCallable, Category=GameState)
virtual float GetServerWorldTimeSeconds() const;```
For example, this
if i were to use this lol
doesn't matter
client can cache its own time when it dies
and since there are other things already replicated to let it know it died
it doesn't actually need any networking to display the tiem to respawn
So let me think about this, let's say when my Die() function is called, we get the current time using the above function (just as an example)
we set it to a variable called "CachedTimeUponDeath"
and then we have a way to always get the current time, using the above method
right?
So where are we doing CurrentTime - DeathTime + RespawnTime
maybe im overly confused lol
pretty much
and you send death time and respawn time to a widget
and let it handle the rest
remove itself when its down to 0
to whatever displays the remaining timne to the player
so probably to the HUD which isntantiates the respawn widget and puts it on screen
sorry, i didn't word that correctly. Time has to be updated at minimum once per second
SO where would we be updating "TimeLeft"
to use the new time
this would have to be on tick
I need help please
I can see the running animation from the server owning character on the client but not the client animation on the server
float TimeLeft = GetWorld()->GetTimeSeconds() - TimeDied + GetDeathTime(); @winged badger
like this?
and then i could just do this on tick?
void AHVS_Character::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
if (GetWorld()->GetTimerManager().TimerExists(DeathTimerHandle))
{
float TimeLeft = GetWorld()->GetTimeSeconds() - TimeDied + GetDeathTime();
}
}```
only problem is, AHVS_Character has no Controller when we are dead
why do it in the character?
the controller should be the place for that stuff
and why you checking a timer
use one or the other
eh
a timer or a time check
i can use my variable
but thats besides the point lol
the math is wrong
float TimeLeft = GetWorld()->GetTimeSeconds() - TimeDied + GetDeathTime();
is wrong i mean
getDeathTime() returns number of seconds until we respawn
time died is set to getTimeSeconds() upon dying
GetWorld()->GetTimeSeconds() - (TimeDied + GetDeathTime());
how is this nullptr if its inside of HasAuthority()
i guess authority != being on the server
is anyone here, I have been robbed by a dev and they left with me with a C++ plugin thats un-finished but I only need to replicate it but for some reason the custom even loses its options to replicate when connected Bind/Unbind Event to and I cant figure it out, if someone can please help again the dev took my money and ran . I posted it on the paste bin for blueprints you can look at the code. https://blueprintue.com/blueprint/o5t04a9e/
I have an AI controlled character spawned on the server but it doesn't fall to the ground when spawned, tried to spawn the controller of the character manually but it still doesn't work properly
I think I'm missing something that blueprints implement automatically... Making my first fully C++ character, and I've managed to get far enough to repnotify a bool. Works perfectly. But after that I noticed that only my server character can move, and my client doesn't see the server moving. I'm used to just using AddMovementInput in blueprints and this works automatically. Am I missing something else that I need to do in C++?
did you set bReplicates and bReplicatesMovement to true
(or something like that naming ....)
@kindred widget
Both show true by default in the blueprint child of that C++ class.
I'm just a bit confused because... If I create a new class based off of Character with just this and setting the camera component to UsePawnControlRotation true. This works perfectly.
Doing this in a C++ class inheritting from Character means movement only on server. Client won't even move and can't see the server move.
you bound it to the playerinputcomponent? (the actions/axis)
Server player can move.
Is it even executing on client?
The C++ code looks good, maybe try to debug when/if it is being executed
Event is running on the client. This prints the correct Axis from the client's screen.
Are there any includes I need specifically for networking besides #include "Net/UnrealNetwork.h" in the cpp file?
Nope, otherwise it would not compile
Well this is odd then. Haha. Here I thought movement would be easy and the repnotify would give me trouble..
Yeah, it is... Is it not moving at all? Or is it rubber banding?
If the player is not moving at all, is is probably not networking issue.
Client isn't moving at all. Not even enough for a server correction jitter. Server moves around just fine, but client can't see server move. On the client the server is still standing still where it started.
But with the same setup, same settings for PIE, just a blueprint version with the same inputs basically, it all works perfectly fine.
if you remove the repnotify does it work
Do you have GetLifetimeReplicatedProps for the RepNotify
What are you repnotifying?
Right now just a simple crouch key. Doesn't do anything but print.
Would you mind showing us the declarations of MoveForward etc?
Might be something there
Sec, removing the RepNotify stuff to test that.
Is this a Character or just a regular Pawn?
Character Movement handles all of the network heavy lifting - the default pawn class has no such handling.
What blueprint i need to use to change character? Like set skeletal mesh but for character
Notably, the Server won't be moving the Pawn - hence it won't move there.
Character. And I suppose it has something to do with my RepNotify. Commented all of it out and it's working fine with the same movement controls.
Glad you found the cause
What RepNotify?
Is it safe to run client RPC's on tick, or would it be better to set a replicated variable with a repnotify on tick
?
i want to set a "Match timer"
and have it show up in UI
Do neither
then how do i do a match timer
Replicate an "end time"
mmmm
AGameState::ServerWorldTimeSeconds should be good enough to compare to for a simple timer
GetWorld()->GetGameState()->GetServerWorldTimeSeconds()
im pretty sure this is replicated
already lol
Yeah
Well, you can, but it won't be elapsed time
and do no rpc's
It'll be the current world time on the Server
In that case yeah, you can use that
btw
binding UI widgets to a function in UMG
is really poorly optimized
lol
no one should ever use it
they need to fix that shit
UPROPERTY(Transient, ReplicatedUsing=OnRep_ReplicatedWorldTimeSeconds)
float ReplicatedWorldTimeSeconds;
@chrome bay
i was right btw
it is replicated by default
this is in GameStateBase.h
yeah I know 😄
But for most games the "elapsed time" isn't neccesarily the time the server started up
yeah
It's not a very accurate timer but it's good enough
so here's what i realized
Make sure you don't use that directly though, use GetServerWorldTimeSeconds()
ServerTime doesn't start until you call StartMatch()
in GameMode
i tested it
so if u use "bDelayedStart = true"
it wont start ticking until u call StartMatch()
it takes into account, pausing
Oh sorry yeah, I'm usually using RealTimeSeconds for timers and stuff
I also have a question, so please let me know once you figured it out, I do not want to hijack this conv. @quick flint
@split siren wats up
I have a design question if I may. Long story short, I want a player to draw a card from a deck on server.
Deck - TArray<ACard*> and exists only on server
Hand - TArray<ACard*> is replicated to client
When I move card from deck to hand on server, client hand gets updated. But I would need to indicate action (draw/discard) and specific card. So client can run specific animations.
If I move card from deck to hand on server and then do "DrawOnClient(ACard* card)", "card" on client is null because Hand was not updated yet.
Going slightly mad over it, what would be the "proper" way to approach this?
how to change one character to another
I can check on client the difference between last hand state and new hand state, and guess what happened between these two states, but it feels hacky.
@midnight karma PlayerController has Possess function that should be able to do just that.
The server is the authority
I just need to inform the client what he/she drew.
But if it is a newly created card or a card player does not know about (aka, not in his hand), I can't simply send that card object player drew from server to client.
So the ultimate goal is to this
Server - "Hey client 1, you just drew ACard* card"
Client - "Ok, I will create new widget for this card and play a draw animation"
I can't seem to find anything that I've done wrong with the repnotify from before. From what I've looked up, it should be fine. It compiles fine, it works fine. But it also breaks my character's networking besides that repnotify.
Hey all,
new to networking in Unreal... I've come across an issue that I'm sure is super common.
I have a couple players in my game. In the level, there are lasers attached to walls that act as an alarm. The players can shoot the lasers and deactivate them.
My authority player can shoot the laser, deactivates them, no worries. However when a client shoots them, I get this message:
No owning connection for actor BP_StationaryLaserTripWire2. Function Server_ReactToSpyShot will not be processed.
The "deactivation" is called using an RPC on the StationaryLaserTripWire.... how can I resolve this issue?
You can't call RPCs from a client, from an Actor that the client doesn't own.
The RPC is called from the actor, the laser, in the level.
The laser calls this RPC once it is shot
Right. But your client doesn't own that laser. So your client can't use that laser to call an RPC
Makes sense....
What kind of weapon are you using? Projectile or line trace?
Line trace
Your weapon is a separate actor from your pawn?
Yes
Set your weapon's ownership on the server, to be owned by either the server version of the client's player controller or pawn, probably pawn. Then you can use the weapon to call apply damage on the laser. This'll play on the server from a client owned actor. Then you can just use the damage interface to disable the laser when it takes damage.
Okay, thank you very much, I'll try to implement that. Appreciate it.
@kindred widget So the weapon is spawned at run-time in the BeginPlay of my Spy character. How could I get the server's version of the client's player controller? I've taken a look through some google searches and looked through some various C++ functions in VS without much luck
you are assigning it
to the player
probably spawning it from the player pawn
or one of its components, no?
I don't remember exactly how I did it. Mine was in blueprint. If I recall right, my test was on begin play in the actor. I did a switch on authority, if authority, spawn weapon and set self as owner. Weapon class also has to be replicated.
@split siren FastArraySerializer 😄
Yes, when it's being spawned, it's owner is set as the character that is calling to be spawned
you don't need to set the owner as PC then
as PC owns the player pawn
just call SetOwner() on the weapon
and give it PlayerPawn as argument
@meager spade no clue what that is. Thanks for the pointer! Need to look it up
Did I do something wrong here?
@split siren it does a client side call when an element is Updated/Added/Removed from the array
Epic
@winged badger
void ASpy::SpawnWeaponAndAttach()
{
//if there is a weapon selected, spawn it and attach it
if (WeaponToSpawn)
{
CurrentFirearm = GetWorld()->SpawnActor<AFirearm>(WeaponToSpawn, FVector::ZeroVector, FRotator::ZeroRotator);
//attach the firearm to the right thigh socket
CurrentFirearm->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale, "RightThighSocket");
CurrentFirearm->SetOwner(this);
CurrentFirearm->Instigator = this;
}
}
@kindred widget you ran into one of epic's fails
So there I'm setting the character as the owner, no?
Another victim of ancient documentation?
if you have only a single replicated variable in the class, and its RepNotify
it won't replicate
this is more of a bug
It is replicating. It's just breaking my movement.
In the GetLifetimeReplicatedProps ?
@kindred widget what are you doing with crouch?
you just call Crouch/UnCrouch on the client and server..
Nothing yet. Just testing. But simply adding this repnotify broke my movement.
i don't see why you are trying to reinvent the wheel
its just odd, you should also be sending this stuff in via the packed moves
but crouch is fully replicated
by default..
More of a learning experience. Never used C++ networking. But yeah! That fixed it. I missed that because the docs show you the specification from AActor.
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = this;
//spawn using SpawnINfo
Cool... so what I showed you was the code I have now, but it still generates that error where the laser's RPC isn't being called.
there are some cases where the 2 are not exactly the same
when sublevels are in play
"No owning connection for actor BP_StationaryLaserTripWire2. Function Server_ReactToSpyShot will not be processed."
yeah
you send RPC through the weapon
and then hit the laser with weapon's instance on the server
then it works
ahhh.... okay
@kindred widget ``` PlayerInputComponent->BindAction("Crouch", IE_Pressed, this, &AKaosPlayerPawn::StartCrouch);
PlayerInputComponent->BindAction("Crouch", IE_Released, this, &AKaosPlayerPawn::StopCrouch);
}
void AKaosPlayerPawn::StartCrouch()
{
if (!HasAuthority())
{
ServerStartCrouch();
}
Crouch();
}
void AKaosPlayerPawn::StopCrouch()
{
if (!HasAuthority())
{
ServerStopCrouch();
}
UnCrouch();
}
void AKaosPlayerPawn::ServerStartCrouch_Implementation()
{
StartCrouch();
}
void AKaosPlayerPawn::ServerStopCrouch_Implementation()
{
StopCrouch();
}```
what is wrong with that?
@split siren it does a client side call when an element is Updated/Added/Removed from the array
@meager spade Is it possible to add extra bool to that call? Example for add, to indicate if it was added from deck or discard pile?
@split siren its a custom struct
I see, thanks
FFastArraySerializer replicates FFastArraySerializerItems
read the NetSerialization.h they even put an example of implementation in there
@odd sundial use 3 backticks ` before and after the code block please
that struct will have have say your card suit, card value, and any state about the card
@winged badger So, the fire method RPC is being called on the weapon, and it implements a ISpyShootableInterface... does this change anything?
not reading that 😄
Thanks, I didn't know how to format that
what is ReactToSpyShot?
2 backticks make a single line
its the key sharing a key with tilde on most keyboards
{
FHitResult HitResult;
ASpy* FirearmOwner = Cast<ASpy>(GetOwner());
if (FirearmOwner)
{
if (TraceForwardFromCamera(FirearmOwner, FirearmOwner->ThirdPersonCameraComp, HitResult))
{
//debugs
if (bShowDebugs) { DrawDebugSphere(GetWorld(), HitResult.Location, 20.f, 8.f, FColor::Green, true); }
FString ShotActorName = HitResult.GetActor()->GetName();
UE_LOG(LogTemp, Warning, TEXT("The spy shot: %s"), *ShotActorName);
//if the actor was imlements the 'spy shootable' interface, have it react appropriately
if (UKismetSystemLibrary::DoesImplementInterface(HitResult.GetActor(), USpyShootableInterface::StaticClass()))
{
ISpyShootableInterface* SpyShootableObject = Cast<ISpyShootableInterface>(HitResult.GetActor());
if (SpyShootableObject != nullptr)
{
SpyShootableObject->ReactToSpyShot();
}
}
}
}
PlayFireCosmeticFX(HitResult.Location);
}```
Therrree we go...
better
delete the old one then 😄
@kindred widget ^^
read my post, what is wrong with just doing that?
so now you need ServerFire function which is Server, Reliable UFUNCTION
So I actually do have that...
that sends the hit package to server
and server can then unpack that and reproduce the hit
I have a question I setup a dedicated server last week with https://github.com/EpicGames/UnrealEngine with a static IP Address it was allowing me to connect to my game fine last week and not now if anyone could point me in the right direction do let me know thank you
read the output logs from both the client and server @upbeat crystal
its the first step at being pointed in the right direction
ok thanks
Nothing really. This is just experimenting right now. Never touched networking in unreal. Learning how the repnotify and stuff works.
So testing multiplayer in editor looks easy. But for testing multiplayer in a build,
Will I have to implement utilities like connecting to a game at an IP first?
you need a static IP Address on a separate PC @chilly mist and port forwarding on your router I just set up a PC with Windows server 2019 installed for my video game
you can get by without port forwarding if all PCs in the test are on the same subnet
I'm mainly concerned with the build. I can test on a same computer, with multiple instances of the game, just like how it's done in editor.
Will I still need to implement connecting to an IP first?
I like how it's very convenient in editor, where I just set player number to 4 and hit play.
I don't know if it can be that easy, in build.
it can't
and it gets even more fun when you're testing production steps
cooked the game 10x this morning and uploaded to steam 5 times in order to test with 2 PCs in real environment
Why do you have to do multiple times?
Anyway, that's good enough to know for me to decide what to do next. Thanks!
because i was making alterations until it worked to my satisfaction
obviously, didn't get it right on the first try
Can anyone explain to me why the role of my spawned gun with my spy actor as it's owner will always have the Role_Authority, while the spy owner itself will actually be accurate? (Authority on server, AutonomousProxy when playing as client, etc)
{
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = this;
CurrentFirearm = GetWorld()->SpawnActor<AFirearm>(WeaponToSpawn, FVector::ZeroVector, FRotator::ZeroRotator, SpawnParams);
//attach the firearm to the right thigh socket
CurrentFirearm->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale, "RightThighSocket");
FString GunString = UEnum::GetValueAsString(CurrentFirearm->Role.GetValue());
FString SpyString = UEnum::GetValueAsString(Role.GetValue());
UE_LOG(LogTemp, Warning, TEXT("Gun Role: %s"), *GunString);
UE_LOG(LogTemp, Warning, TEXT("Spy role: %s"), *SpyString);
}```
Basically... my weapon is spawned from the character at BeginPlay... trying to implement fire / server_fire methods, but my gun thinks it's role is always authority
because each instance of your pawn spawns its own weapon
Could it be... I need to test it's owner...
when it runs beginplay
Agghhh
Quick question: So how does one make certain components show up in multiplayer but not on the characters own screen? I.E trying to make it so everyone else sees the full body of the character, but the player himself doesn't see that
Same with Vice Versa
@wild frost there are settings that are something like "owner only see"
or "Owner not see" or something, it's found in the blueprint and you can also set it in the ctor using C++
@meager spade Thanks for the pointer to NetSerialization.h. If you don't mind, I have one more question. The Fast TArray Replication is for Structs only, so would you recommend remaking the card system so Card (currently an Actor) would be a Struct or can I keep Card as an actor and inject Fast TArray Replication somewhere along the way?
@odd sundial Sweet thanks!
what this mean on log i have no clue LogOnOnlineSession Warning OSS No Game Present to leave For Session it is running on my Server and running on my other pc and no warnings on my other PC
@split siren you can store a pointer to the card
Oh, inside the struct
or just have the card as a struct or a simple UObject, depending on how you want to do it
That's smart, thanks
Hi! I'm trying to replicate shooting in my game, but there seems to be a problem. If I spam the LMB, the bullets keep spawning good for a moment of time and then some of them keep disappearing. I'm not receiving any errors from UE about any wrong variable or something like that. Sometimes when they don't spawn at all, after a time, some of the not-spawned ones get visible again and I don't think it's because of the camera because if I get closer to the bullets, they still don't spawn back in. If I play offline, everything seems to be fine, but if I play as 'Listen Server' or as 'Client', the problem is still there. Everything seems to be replicated and set as "replicated" as it should be, but I can't find a reason why some of the bullets keep disappearing or not spawning at all. I can see them not spawning because I've set the bullet speed to 500 and the bullet size is half the size of the Third Person Character so I can see what's happening
Gonna need to see your code or something to help @whole orbit
@whole orbit are you only spawning on the server or on the client as well?
(Ideally actors should only be spawned on the server)
Hey guys! In a game with listen server using seamless travel to transition from one map to the other, I'm getting an unreliable behavior on the hosts BeginPlay, it seems that sometimes when it takes a while for the host to load the new level, Begin Play is not called, and all the initialization code I have fails to run
is there a more reliable event I could use?
BeginPlay is ALWAYS called
its going to be the main pawns people pick when joinin
alright if your player controller is owner of something that something is gonna be always relevant to him.
Ticking always relevant means that even outside of net relevancy distance, other players who are not owners of that pawn will still get replicated information regarding that pawn, which is a waste of bandwidth. On the other hand, dealing with actors coming in and out of networked relevancy can be tricky at times since their proxies on clients are completely destroyed and recreated upon exiting and entering the net relevancy distance
interesting so it has to do with distance
Alright all... I had this same issue before, and I've already sought help on here but I guess I don't understand how to rectify the issue, so I'm back again.
I have some characters in my game. In the level, there are lasers. If a player shoots the laser, it disables the laser.
When the listen-server player shoots the laser, the laser becomes disabled for the server only.
When the client player shoots the laser, the laser becomes disabled for the client only.
In both cases, I try to disable the laser with a server RPC without luck.
Also, when I shoot the laser with the client, it gives me the following error:
"LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_StationaryLaserTripWire2. Function Server_ReactToSpyShot will not be processed."
I understand this has something to do with the actor that ends up calling the 'disable' function on the laser (the character Spy has a separate gun that is instantiated at run time- it's the shooting from this gun that causes the laser to disable).
What am I missing here... how come the disable isn't being replicated to all when the server shoots, and how do I correct the error above when shooting with the client?
Can I configure my default pawn class to replicate to owner only?
I have to build UE from source, to be able to build a dedicated server??
Well looks like so...
Is it necessary to test the game with a dedicated server?
Or will testing with listen server suffice?
im trying to build unreal from source, but when I try to run "setup.bat" it is giving me the error "'setup.bat' is not recognized as an internal or external command,
operable program or batch file."
has anyone else had this problem and know how to fix it?
nevermind the source code didnt install properly
it actually doesnt exist
@meager spade True but I've learned that things can go wrong in the final build.
Well I guess I'll have to do the extra work if I want to test dedicated server.
you can launch dedicated server standalone also
without source engine
you only need it for making a exe
"X:\UnrealEngine_master\Engine\Binaries\Win64\UE4Editor.exe" "%CD%\Gaia.uproject" TestingLevel -server -log -nosteam
for example
I guess the standalone is still launched from editor, not from a final build, in this case?
its ok for testing tho
hello again peeps, so im trying to connect to playfab servers with steam enabled but it always throws the error :"incompatible_unique_net_id", a forum post says i can modify the prelogin function to remove the check and allow the connection. My question is, if i do that what exactly can go wrong?
early on its pointless making dedicated server binaries all the time
Ah do you mean it's okay for my own testing,
But if I'm distributing my game or plugin, I should get source build of engine, and test with a build of dedicated server?
But during development, is it not enough to just use what the editor provides, namely increasing player num then selecting to use dedicated server ("running as client" option)?
had a discussion in here a few days ago about not using the actor class for things like buffs because of the concern of replicating that many actors, and someone brought up using uobject and just replicated a struct representing the object to clients instead.
in a situation like that, do you think creating a separate component specifically for controlling replicated buffs for player UI is the best way to go about doing that, or just having the buffs component try to automatically handle this (and somehow determine whether it is attached to a player or not before doing so)
this is in blueprints, which is why i'm not jsut replicating the UObjects
@vivid seal If you're talking BP only, it depends on how complex your buffs get. You can easily just have an ActorComponent that holds active buffs or other data about an actor (StatsComponent?) and just have buffs be data.
@vivid seal If you push this system to the logical conclusion you end up with GAS.
For something small and light, I'd just make a component which holds all the stats the buffs can touch and have it manage buffs.
Something like a DOT or HOT or armor buff is ez, but something more complex like "You spawn a dragon out your ass every time you take a prime number in damage while facing the opposite direction" would be a bit much for it.
i was kinda hoping to support that last one 🙂
it looks like i can pass object classes through RPCs so i might just have a struct sent on buff apply that includes the object class, stacks, duration, etc. and have the client basically maintain their own set of buffs
i had the same issue with a widget component, host would set the visibility and it would propagate to all clients.
@meager spade Sorry const, I know this was quite a long time ago but I'm going through catching up on chat and was confused about this comment. I thought UI/UMG/widgets were something you don't really replicate so why would you have an issue with visibility being propogated to all clients? :S Care to elaborate a bit to edify?
Widget components
Its based on scene component. We run listen server so when host showed the widget it would replicate it to all players
hmm, guess I need to review what widgets are intended for, I always thought those were just for UI objects and didn't think it would be derived from scene component, but I guess that makes sense, just never dived in far enough to notice
@vivid seal If you're gonna get really complicated with it, especially in a multiplayer setting, just bite the bullet and implement GAS.
i was following a thread and a user said " My solution was to remove the check in PreLogin and then yeah it created problems converting between FUniqueNetId types. So I Made a routine that could convert everything into a NULL online subsystem unique ID (which is basically just a string) and the server just keeps those around."
but i cant figure out how he turned those ids to null, any ideas?
he's not saying to convert the actual id to "NULL"
they mean OnlineSubsystemNull
(if that is your interpretation as well, and you don't mean something else, then my bad ;))
how do u do that then? he made a routine so i am assuming he wrote code somewhere? i have no idea where to even start
@vivid seal I used a component to keep the script separate
It’s all running server side so the client really only gets a struct with the buff data. I tried using the class like you said but I have stacking buffs so the struct worked better
I thought that pawn control rotation was replicated automatically? Am I thinking of something else?
Oh, that's for the controller. I swear there was a rotation property for pawns or characters that was replicated by default?
Ah. GetBaseAimRotation.
Hello, I need to apply something on let's say 40 actors by RPC-multicast. I guess is much better to send 1 RPC with array of 40 actors then 40 RPCs (multicasts) right ?
What's the context? What are you trying to do?
@split siren it does a client side call when an element is Updated/Added/Removed from the array
@meager spade HI again, I have implemented the Fast Array Serialisation for the cards, but I am still hitting the same problem as with previous approach. As recommended, I have includedACard* card;in the ArrayItem, but this pointer is null in PostReplicatedAdd on Client. Other variables in the Item Struct are replicated correctly.
is the Card Replicated?
Yes
Always Relevant?
bReplicates = true;
bAlwaysRelevant = true;
tho tbh i would have constructed the card locally
the struct would have held the card details, the card owner etc
then create the visual representation client only
Now I am totally inclined to do the same, though I would love to know how would one replicate an object.
Not in this instance, but I am sure sometimes it would be handy
a UObject requires an actor or actorcomponent to replicate via
you override ReplicateSubObject function and pass in the UObject
UObject's can't replicate on there own
That is why I made Card to be an actor itself, it is dirty solution but I am still learning
Having the card as an object rather than struct would also make it slightly easier to do server calls. PlayCard(ACard* card) than managing structs with unique ID fields.
In any case, thank you for the help @meager spade, I really appreciate it.
What is better ? Call 40 RPCs of one ACharacter or call 1 RPC with array of 40 ACharacters ? 1 RPC should be better right ?
depends what you are doing?
Is server waiting for reply from client during a client, reliable call?
//On Server HelloWorld_Server(); HeavyCalc_Client(); //Reliable, Client Goodbye_Server();
According to my testing the answer is no.
In my case in AOE attack when I will hit 40 enemies and I want to apply dmg to all of them and then play VFX blood effect on all of them on all machines then I am sending currently 40 RPCs but its does not seems to me correct. I should rather send one RPC with Array of 40 enemies
you can simulate that
without using any RPCs
especially when there is 40 of them, odds of a simulation being slightly inaccurate and someone actually noticing is exactly zero
it literally tells you GetWorld() returned null
i have no idea where you called that from
but generally controllers are instantiated after the world is loaded
you also called that function on the CDO
which doesn't have a World
see below in Autos this is Default_...
so, don't call that function on the CDO
the fact you did raises some red flags on the whole approach you're doing
Is it just me or does networking in UE4 feels a bit loosy goosy? Nothing is guaranteed and order does not matter. Just managed to call a client function on an object before BeginPlay was executed. Not a complain or anything, just an feeling..
Good afternoon. I'm spawning a replicated actor on my server and then using it to fill a RepNotify reference on my character. However, the OnRep function is only called on the server no matter how long I wait. Does anyone know why this might be?
@waxen socket I assume the goal is to inform the client when actor is replicated and "ready"?
Yes indeed. I'm spawning a weapon and the OnRep function should attach the new weapon on each client.
I have no clue how to do it but I would also be interested in a proper approach.
Is it possible to calculate ping for listen or peer 2 peer based servers?
If so, is that at the net driver level or is it subsystem based
Gonna need to see your code or something to help @whole orbit
@odd sundial
@whole orbit are you only spawning on the server or on the client as well?
@gilded vapor
Please see the following image:
Everything in the 'Bullet' blueprint is set to 'replicated'
@waxen socket Disclaimer, I am not sure how good of a practice this is, but you can call a client, replicated method after you spawn the weapon on the server to attach it.
AWeapon* myweapon = SpawnActor.... myweapon->AttachToClient(APawn* targetClient); //this runs on client only rest of the code
This kinda works for me, but it executes on client before Begin play, so it is a bit weird.
Yeah, OnReps can run before BeginPlay.
OnReps do run before BeginPlay, always
after they are done, PostNetInitialize is called, which calls BeginPlay on clients
provided World started play
Zlo, do you know why an actor reference RepNotify would never run on a client?
because the Actor is not replicated?
either one with the reference or one being referenced
I've set them to Replicates = true.
and always relevant = true?
referenced Actor not being relevant
if this is start of the game, there is always blueprint shenanigans as an option
Naw, it's an event.
c++ will call OnReo when NetGUID is resolved
And the OnRep is being called successfully on the server.
i have no idea if the BP is smart enough for that
When are you setting the reference in relation to when the actor with the reference and the actor you're referencing are created?
On overlap with a crate, I'm running a function in the game mode that loops through all the characters, spawns a weapon, and sets that weapon to be the value of CurrentWeapon on each character. CurrentWeapon is set to RepNotify.
that is weird @waxen socket
Oh, what's weird is I just saw it work one time.
so all your characters not only use the same weapon class, but same weapon instance
But it rarely seems to work...
Yeah. If you've ever played Pac-Man 256, my powerup system is just like that. If one character touches a pickup, everyone gets powered up for a limited time.
i mean you do spawn a weapon per character?
ok
you can try going the other way around
make sure weapon has the character as the Owner when you spawn it
What you mean by simulate 40 RPCs
Could anyone tell me how I'm supposed to create a fluent strafe movement without having to replicate the Movement Axis Value ?
and then have it do Cast<AMyCharacter>(Owner)->CurrentWeapon = this; on BeginPlay
It's odd that it seems to work every once in a while... It's like the replication is delayed. Is it against the rules to replicate an actor reference?
as then you only depend on replication via a single ActorChannel to setup your dependency, not two of them
its possible that if weapon replicates before the character does, it works, and it doesn't work if the weapon actor replicates second
i don't have a high opinion of BP networking, especially OnReps
in any case, weapon notifying the character its there instead of character replicating the weapon ref should get around any problems
@gleaming bobcat you don't simulate 40 RPCs, you simulate the attack on clients
Thanks, I'll try that approach if I can't figure out why the replication for the actor reference seems to take so long.
you don't do any damage, but you let it play effects, sounds... etc
but it can be quite off
@quick flint if you need to do that, you're doing something wrong
I want to get all Characters, and have their Widget component rotate towards my camera
so u can see health bars
if u have a better solution let me know
lol
that doesn't have to do anything with networking
each widget component rotates towards local player's camera on tick independently
it does though if u only want to get the relevant actors
on each machine
other players have their own instance of the widget
that will be in screen space for them
Playing with the NetPriority seems to make my actor references replicate more quickly. Thanks for your time today Zlo, have a good one.
so they'll see it
@waxen socket that is not a foolproof solution though
packet loss can break the replication in order of priority
and putting too many priorities too high will cause additional problems if you have any network congestion
Oh, I don't intend to rely on it. It's just interesting that there seems to be something slowing down the replicating on my actor reference. I'm gonna try to the owner solution you detailed.
As a rule of thumb, do you often replicate actor references in your work?
fairly often
but usually replicating a reference to the owner
in a new actor
not replicating new actor reference in the owner
as its just a more solid approach
and avoids replicating stuff i already replicated often
my abilities (skills, inventory) have aspects - range, damage, duration...
Ability (a replicated ActorComponent) knows them
and when it needs to spawn an Actor it spawns AbilityActorBaes derived Actor
which has a custom spawn function, and replicated pointer to AbilityOwner
so on client when that Actor replicates, it has valid AbilityOwner, always, then it loads the aspects from the AbilityOwner
(aspects are also never replicated, but AbilityComponents pull them from static data depending on what level they are at)
so as a result when i spawn a grenade, i get a grenade that knows its radius, damage, falloff, etc... by replicating only a single pointer to an actor component
and if i want to incread damage of a level 4 grenade by 100, i just increase its L4 damage in the datatable and everything autoacjusts
Lovely. Thank you.
@quick flint i would not argue unless you understand
what Zlo said is correct
healthbars in our game above enemies are in Local Space
not world space.
that is down to you to handle on the local side
we subclassed WidgetComponent
and have checks
which hide/show it when needed
all done locally
no replication at all
I have widgets that are always right on the host but, on map change my clients always have the widgets overlap (the previous ones aren't removed so there's 2 of the same widget) I put in remove from parent on map change but, still not working, any thoughts?
hello again every one, im still trying to fix a "incompatible_unique_net_id" issue, and some one on the answer hub suggested overriding the prelogin function and passing the ID as a connection option, im trying to do just that with the following code
{
const FString& SteamId = UGameplayStatics::ParseOption(Options, "SteamId");
Super::PreLogin(Options, Address, SteamId, ErrorMessage);
}```
the thing is SteamId is a fstring and it needs to be a FUniqueNetIdRepl
how do i convert that
?
How do I use get base aim rotation to replicate the pitch of my character?
If you have an array of structs that is replicated, if you change a value in one of those structs, does it replicate the entire array down again?
it will replicate the changed element
keep in mind array replication is not atomic and OnRep may temporarily fire with invalid entries in the array (especially when resizing it)
In this case the array size is constant with just values inside the structs changing
Would that still cause random OnRep calls?
no
you should fill the array to the correct length on the CDO so it will not start out with the wrong size and have to replicate all
I am doing it on begin play currently but is it still fine to do something like MyArray.Add(FMyStruct(EMyUpgradeType::UpgradeType, 0)); in the constructor?
yes
Cool didn't know that thanks!
the CDO is created by running the default constructor
any values you set in it will be considered default
So it's as if you had the BP and clicked the plus sign X times on the array property if it was exposed as EditDefaultsOnly except you are doing it in C++?
yes
Great ty!
Gonna try again, im trying to connect to a server with steam enabled but because of steam being enabled it complains of "incompatible_unique_net_id" so i am assuming the server is using the regular IP net driver and the client is using Steam's. i tried just commenting where it checks if the id is compatible but although i managed to connect the server crashed
what are my options here? i read in a thread that a guy just set everything to NULL but i have no idea where to go to do that. Can i do something else abou it?
This may sound nonsense, but is there any way to create a replicated variable where the Client changes are reflected on the Server? So if the client changes it Server eventually gets latest value.
Usecase: Client camera. I want the client to be able to move its camera locally, but I want the server to keep track of its position. Maybe Unrealiable RPCs from Client to Server every 50ms or so is the way to go?
@floral crow you could use a Server rpc and call it from the client to set the replicated variable, but replicated variables are essentially replicated from the server, to clients
also that would be essentially really bizarre to do it that way in my opinion
How do you handle this normally? How can spectators know what you're looking at?
This is a "free camera" game, so I have no pawn to keep track of
so you just want to replicate the position?
there is a value called bReplicateMovement on every actor @floral crow
and it replicates the position of the actor
But I don't want server to have to do the movement. I want the client to move freely, and the server to passively observe its position with as much accuracy as possible. It doesn't matter if misses some data, hence eventual consistency
you could set a variable on the server that is not replicated @floral crow
but then the variable will not be replicated to clients
but it will be set on the server
Will TMap replication ever be supported?
Does ue4 use onlineSubsystemNull by default?