#multiplayer
1 messages ยท Page 619 of 1
Character doesn't fall on begin play, im sure it's getting possessed.
When i start the game as the server, everything works fine but when playing as client i can only rotate it
It doesn't fall or jump etc
How can i fix this?
So, I don't know if this'll solve it, but I ran into a similar situation. If you're not sure if the character is being possessed or not, it might not be. You can see if Run Physics with No Controller checkbox is checked in the Character Movement component.
There's also the replicate movement checkbox on the Character itself.
I'm getting a weird issue with GetPlayerState() returning null in the character class, and I'm positive that the character actor still exists in the world. Does anybody know if there documentation on the lifecycle of PlayerStates or if there's weird quirks with it?
Yes i tried that, didn't work.
What happens when you start up your Unreal Engine game? This video is a guided tour of the Engine's initialization process: along the way, we'll glimpse the high-level structure of the Engine (modules, game instances, local players, and viewports) and we'll see how all the different parts of the Game Framework (game modes, game states, player co...
Ah. Yeah, Hrm. I relatively new as well when it comes to UE, but I feel like I ran into a similar problem as when I was working on movement. Hm. I'm looking around to see if I remember what I did.
Kk feel free to dm me if u find anything
Yeah, fs. And lmk if you eventually figure out what was the issue. I also appreciate the video, I saw that the other day. It's really good!
sup. so my game mode base is spawning my enemy on the server too quickly and whenever i have breakpoints set up in my code the enemy is at like -20000 Z on the transform. any way i can prevent that from happening? would love to keep using breakpoints and not have the server send my enemies into the abyss
is it possible to replicate a TMap?
Nope
StructArray is your best bet
Or, manually replicate the changes with an RPC
(i.e. send a key and value across the network, and update manually)
i believe i may not need to replicate this information as it's only relevant on the server, but this is useful information. thank you @potent cradle
of course you can replicate a TMap, just need to wrap it and write your own replication code ..
"just" might be a bit of misnomer in this case, unless it's significantly easier to do than I know
Would love to see if you have an example though
I wonder why it's not supported in Unreal by default
Can't guarantee the keys will be available, especially if it's keyed with objects. It's quite a bit more complex, you'd likely have to replicate big chunks of it when pairs change etc.
So it would need some kind of complex wrapper anyway
It's best to just use a struct that wraps an array, and provide some helper functions
You won't ever be replicating a TMap that's large enough for the lookup times to make a difference anyway.
When I run my game in standalone mode with 5 clients dedicated server, each window runs at about 2 fps.
but if I have the window activated (and I can only have one window selected at a time) the game runs fine
any way to make all 5 clients run ok instead of just the one I have selected?
In Editor Settings there's a checkbox for "Use Less CPU When In Background" or something, it's enabled by default. Unchecked it.
at what point does it make sense to both do something on the client AND on the server? for instance, i have replicated properties for setting a combat stance for my player. does it make sense to just set it on the server and let the replication handle the rest? most of the time i've noticed that the client is a little janky when i do that because it waits for the server to tell it what to do, so i find myself writing SetCombatStance and ServerSetCombatStance often
that's some form of prediction
ie: trigerring an action on your client using your client's state hoping that will match the server afterwards
so it makes sense as soon as you know what you are doing ๐
I don't understand, why isn't this working?
I am getting all players starts in my gamemode and saving em in a variable
then I am calling "get next free player start" and spawn my player
but it's not working and my players are spawning on top of each other
any help?
You're removing before you return
That might be it
Could store it in a local variable, and return that instead
@eternal citrus
Oh, I see, try making this a local variable, the index
Then get and remove with the index you stored (still store the actual thing you want to return in a local variable too, before you remove it, though)
The point is, any pure function will be rerun for each blueprint wire that runs it
You have a random function there, it's getting a (possibly different) random item twice.
If that doesn't solve the issue, I'd debug what is actually in the array and what you get out each time
But running a pure function that returns a random value twice is a recipe for disaster if you expect the same result.
No
You're still removing the item from the array before you actually get it
^ Store the transform you get from the array in a local variable there
Then use the same index you store in a local variable to remove the index from the array
And return the result (the transform) that you stored in a local variable at the end of your function
@eternal citrus
ok
Not sure if it will or will not cause an issue, but do a get for a copy, not a getter that gives you a reference
Should overlaps ever be run on server?
or is it okay to run it client, then feed whatever comes out of that logic onto the server?
could having widget classes have a reference to game state and get variables in text bind cause network to be less stable?
@spark owl That shouldn't affect network at all. It's just a client getting local variables.
so overlaps run by default on client and server
I dont think it needs to be replicated no
so as long as its an asset you place in the map
hrm okay. That's weird I was getting a readout that it was just pinging on Client side, not server.
you can check this out by adding an authority check afterwards
and you'll see how the overlap gets triggered in both, client and server
so server to client should be
never do client to server
same for begin play/event tick
no problem dont doubt on pinging me if you still have issues with that
After travelling from a match to the lobby with seamless travel, on the lobby gamemode beginplay i call GameState->MulticastUpdateLobby, but for some reason it doesnt run on clients... if i do something that forces lobby updating again then it works,
so im wondering if on Gamemode Beginplay every player should be already set up? or is there a delay?
@the vi thanks
ah, i guess the gamestate is created and isnt yet replicated to clients
we are currently trying to make a real time multiple player game, players can connect to server map and play against each other... currently we are stuck at authenticating the player. basically we need restrict a player from entering the map if certain rules are meet.
any help is much appreciated!
hi, does anyone knows if is possible to get a value (variable) that's inside a game instance of a specific client (player controller) from the game mode (in c++)? im using dedicated server.
@ancient bramble with players hotjoining, your only options are PreLogin and options string for connecting to the server
how would i go about doing that, is there any documentation or tutorial that i can follow?
its literally one function in GameMode that handles authorization
so, no
ideally you don't want to player to try connect and fail
but rather a custom server providing "matchmaking"
that keeps up to date on the status of your runnign dedi instances
and players connect to that and clearly see where they can and can't join
anything less is not really acceptable for production
@sharp night no, unless you send it a client RPC that requests server RPC been sent back with the information
and you should definitely design your data so you don't need to do it
@twin vault you guess wrong
at least with GameState (not GameStateBase) the GameState controls the start of the match on clients
i think he is using a multicast in GameMode beginplay
GameMode starts the match, sets the match state on the GameState, and OnRep_MatchState in GameState calls DispatchBeginPlay on the world
which is bad
also so im wondering if on Gamemode Beginplay every player should be already set up? or is there a delay? GameMode does not exist on clients and no,# clients will not be setup at this point @twin vault
which gives you one very convenient guarantee - GameState and all its replicated variables exist on clients before any Actor on any client calls BeginPlay
which means, you just need a replicated LobbyState
and GameState can on its BeginPlay just update the lobby, no need to MC, no need to even have OnRep for initial state
im calling from the gamemode's beginplay, a function to update the lobby which is in the gamestate AGameStateBase::MulticastUpdateLobby @meager spade
however if you do let the server start play immediately (which you definitely don't want to do)
that MC will fail spectacularly
GameMode beginplay is always called
as no client will have a GameState
its not Kaos
the StartPlay is called
not BeginPlay
before the match state is ready to start
i thought GameMode was excluded from DispatchBeginPlay
and explicitly called from work
world*
i can try that
thanks
interesting, never really bothered with BeginPlay in GameMode (not had any use for it)
would not surprise me with UE4 tho.
yeah, thats why i double checked ๐
thank you!
Is it normal that GetOwner()->GetInstigator() and GetInstigator() can be two different Instigators? Or I'm doing something wrong?
ofc it is possible
its unusual
but its possible.
and its usually a fuckup on your part on not setting instigators correctly
GetInstigator on my weapon could be a different Instigator to my projectile for example even tho the owner of the projectile is the weapon.
but yea, you need to make sure instigators are set properly yourself, UE4 won't do that
yes, technically, i can't imagine a paractical purpose for that
no but its possible as UE4 does not enforce it
I'm a bit confused with them, for what are Instigators needed exactly?
Hi, does anyone know a workaround for repnotify for set array elem (blueprint)?
@steel fox primarily for logging damage sources, scoring and analytics
also for stuff like making AI hate the instigator of the bullet that just shot it in the arse
Only on my client, backward and side movement jitters. Anybody experience this? It doesn't jitter from the server side
Not that specifically, but Iโve had jittery animations in the past whenever I had the mesh replicated.
I found what seems to be the issue in my project, (the client motion controllers not tracking), turns out for some reason it was using Game Instance Base instead of my Game Instance
I'm having an issue after a servertravel, where the widget doesnt get created on the host (only) and the cursor also doesn't show.
It works fine for the clients.
Does anyone know about this ?
Anyone know what the ``LogNetPackageMap: Warning: Long net serialize: 113.946404ms, Serialized Object Default__BP_SomeBP` warning means?
The initial replication is very heavy for an actor or something?
I was testing two standalone instances with the client in focus and the server not so maybe that had something to do with it
Sorry no idea
I reckon your guess is right though, that says to me it's taking too long to serialise and send.
I have an event in my character that calls an event in the character that is Run On Server. the run on server event will only execute sometimes, maybe about half the time and its always called from the same place. Any ideas?
Is it "free" to call a Client RPC on the client
As in the same cost as calling a regular function?
Client RPC?
you should be able to call a client RPC function from the client without touching the networking layer
same with server RPC functions as authority
Thanks!
Much handier than having to make extra functions and check if on client or if on server for certain things
Listen server logic can get really messy as sometimes the player is the server and sometimes not, so this cleans it up nicely in some cases
ah
@meager spade Did you ever get your question answered by epic that you asked during last week's live stream?
It was regarding the ranged asset type
what was it?
Helloooo
Here's my current workflow, an actor gets spawned/replicated, and then a mesh gets geenrated
It works fine but the issue is that depending on the client connecting, the pink park (mesh part) sometimes happen before replication
Cause the client to not have the mesh infos available (it's a multicast on the server that sends them)
So I thought I wanted something from the client to notify the server that they need a mesh
BUT since the response is multicast
It will cause all the clients to update
Rather than only the interested one
So my question is, is there some kind of ... "ReplyToTheRetardClientOnly()"
is there a guide or a tut on how to integrate google play with unreal engine so we can have player name and other accounts linked to there googleplay acount? basically sign in and stuff
you could use a replicated property instead, this will be send with the initial bunsh, you also can modify what is send by the initial bunsh, checkout AActor::OnActorChannelOpen
I have a feeling a replicated property would be inneficient
Because it's quite a heavy array
you could write custom replication, you know that?
no, if it is replicated, it gets updated by a tick, but you can add a quick fallthrough to do nothing, if nothing changed, or is initial bunsh
But the isssue is that, in order to check that the replication still has to happen
And this is going to send 50kb data throught the network for nothing
you also can do: set the propety to replicate only in the initial bunsh and then update via RPC
But isnt the client going to ping for updates and shit I am not quite sure how it works
no?
Oki
the server decides when and what to send
... do some code search ... xD sec, need to look
Thaaanks sorry to bother you ๐
checkout ELifetimeCondition
cheers
and then use it with DOREPLIFETIME_CONDITION
na, you need to specify it in the GetLifetimeReplicatedProps
cheers
How do i replicate variables on UActorComponents in c++?
Oh, i forgot the set the replication from the owning actor...
Yeah components replicated through their actors, so the actor also has to do it
epic mentioned in one of their network optimization live streams that it makes sense to have separate actor holding some of the replicated variables so that we can tune net update frequency & activate dormancy more appropriately/targeted, so i thought why not separate every mechanic's logics like for example a weapon pickup system into separate actors and attach them to my player character. im really new this, is this a bad idea guys?
It is yeah. You'll get a lot of data race conditions and general management will be much more difficult.
Not really sure why Epic would suggest that, it's not really that useful to do it.
hmmm gotcha
Also a danger of incurring a lot more CPU overhead with all those additional actors. Every actor comes with a handful of replicated properties already, so it's definitely not an optimisation
Where did they suggest that?
Keen to figure out what the context is
oof sounds really bad. tysm for clearing that up!!
can i link yt here?
yeah
This week we'll be joined by Ryan Gerleve and Dave Ratti to discuss general server optimization in UE4, as well as techniques and solutions to improve your Actors' performance in a networked environment.
NEWS
Unlocking Breachโs combat with Unreal Engine
https://www.unrealengine.com/en-US/tech-blog/unlocking-breach-s-combat-with-unreal-engine
...
15:27 if the time stamp didnt work right
idk if i understood him correctly tho
all my weapons/items are actors ๐
yeah me too. I read this as "split of parts of my weapon logic into different actors" which def doesn't make sense to me
ah that would be bad
@crisp drum While you can do it, I think it's better reserved for very particular situations. Just calling ForceNetUpdate() and dropping the overall frequency is a better approach IMO
fewer race issues, fewer actors etc.
also make use of dormancy
yeah dormancy can also be super useful when used right
gotcha!!
The only downside of dormancy IMO is that when you re-open the channel it sends everything again, but for actors that only update themselves rarely - def a win
one doubt, would low frequency on my player character hurt its movement component's networking?
On a character you probably don't want low frequency anyway tbh
mmm how about one separate actor that holds all logic beside character movement? so that this could have low frequency
It's not worth the hassle IMO. Don't forget you're still only sending properties when they actually change
If the character has to do property-comparisons on the server at high rate anyway, it's almost certainly going to be less overhead to have a few extra comparisons on a single actor, than splitting it into two actors
even push model does not reduce the cost that much
And it avoids a lot of extra code you have to write to keep those two actors in sync
yeah
just get your priorities right
FYI in HLL we're using the default 100Hz rate for characters (100 of them), everything else is clamped down pretty hard though
^ same in TRS2
great minds ๐
characters always have highest priority also
wowie thank you so much guys!!! this cleared alot of stuff ๐
@crisp drum thing is, this is fine tuning, and you can only really do this by profiling your costs.
mmm
How many replicated actors you have? How many players? How many properties do those actors send? Is it better to use a RPC over a replicated property? etc
yeah that makes sense ๐
hi, I'm creating multiplayer, for networking I'm using Advanced (Steam) Sessions plugin (project is mostly BP).
I wanted to add passwords to servers (listen servers), if someone wants to create publicly visible game, but wants to set up password.
I searched in google and source code, but can't find simple and reliable way to set this up.
Only solutions that I found is client-side verification (makes no sense) or modifying subsystem so that encrypted password is sent with join request and verified on PreLogin function in GameMode, so that server can decline connection.
Maybe someone knows simpler/better solution? Thanks in advance for answers.
That's a good way to do it yeah. What I would suggest is "Advertising" that the server is passworded via a server option, then when joining you send the (hashed) password to the Server that the client entered, and it compares. You can override virtual FString ApproveLogin(const FString& Options) override; in AGameSession to check the password string (likely a hashed string)
You can send it as an additional option on the join URL, you don't need to modify the OSS to do that
You never want the server to actually send the password to the clients, that's the important part
how can I add option to URL? I've seen that URL is generated inside OSS and passed directly to PlayerController->Travel
Even in hash form
When actually joining a session you have to call Controller->ClientTravel(URL, TravelMode)
So you can just append the options to the URL
After calling Sessions->GetResolvedConnectString(SessionName, URL)
So you join the session, get the connection URL string, then ClientTravel to the server with the appended options.
If you're using beacons to handle the join stage you can do it without having to actually join the server and travel
But otherwise you need to "join" the server first to be able to send anything to it
I think we use SHA-256 ourselves, something like that
In my case this is called (probably, have to check) in JoinSessionCallbackProxy from OnlineSubsystemUtils, so I'll have to override this function to add options along with URL received from OSS implementation.
We're using Steam too, you still gotta travel
IIRC it doesn't make you travel once you join
encryption doesn't really matter that much in this case tbh
Client already knows what the string is cus they typed it out
ok, thanks for help ๐
Hey, i've got there a question about Multiplayer and testing.
My gf would highly like to test stuff with me, but i'm afraid that there's no way around doing a shipped version -> upload it -> download it -> test it
And that for every small change. Is it really that bad, or is there a way to avoid this ?
(Also, i'm doing a C++ project)
Can you explain that a little more?
Now i'm not sure what p4 sync means ๐
Ah, i see
I'm using Git with LFS
Alright, that seems like a lot better than the shipping and and method xD
But teaching my gf how to pull and co on the other hand xD
I actually do use github desktop and didn't had much problems with it so far
is there a way to force ReplicatedUsing to be called even if the value is empty ?
I'm not sure if I understand what you mean
nvm I found REPNOTIFY_Always ๐ thanks Fri
ah, cool ^^
repnotify is only called, if smth gots actually replicated
yeah
Hmm as in if the value is empty the initial rep doesnt happen at all ?
server has to actually send something
If the value is empty at serialization time, then yeah
That's a bummer
Server assumes client has the same values
Just call it manually somewhere if you need to, e.g. PostInitComponents
But I dont know when to call it
hmm
because client never knows if it is either in a state where it doesnt have the data yet OR if the data is empty
actually you do have this information
What is commonChunkData() an array of?
int
I'm not sure I understand the issue. All you gotta do is call registerClientChunk from some initialization point
yeah but I shan't call it until i have data initilialised
AActor::OnActorChannelOpen at this point you will receive the initial bunsh
OnActorChannelOpen will be called after rep ?
Can also use PostNetInit
There's quite a few places
Still not really sure i understand the issue though
If the data isn't empty, then it's been initialized right?
Making some presumptions about what that array is ofc
Yes but if the data is MISSING I shouldnt call registerClientChunk yet
only if it's meant to be empty
As in the rep has not happened yet
Not there are 3
It's an array of data, so you're guaranteed to receive the values at the same time as the size
the data is non-empty and there, the data is non-empty but not replicated yet, or the data is empty (and will never replicate)
Rather than an array of pointers, in which case some pointers might be null until whatever they are pointing to also becomes relevant
right now I cater for first 2
with onReplicate
but the last one does not trigger the hook
But just because the array size is 0 I cant assume it's meant to be empty because it might be that the replication is not finished yet
sounds like you need some sort of "bIsInitialized" state
Since I don't see anyway you can possibly determine that on the client otherwise
As in they replicate at the same time
Just double checking is actor property rep is atomic too
it seems to be tbh bc I have a position vector and so far it has never been missing
I have a log on it
Yeah but it might be than when saturated, it separates the packets. I don't think it does though
let's try it
There are a few solutions it seems - you can override PostRepNotifies(), since the property is COND_InitialOnly, you can assume that if it's zero it will never replicate and is empty
Actually that sort of answer it - it's COND_InitialOnly, so the data will only ever replicate if it's been set to something non-zero anyway, and only ever in the initial spawn/open packet
I actually set the onReplicate on the position vector
since it cannot be null
it always replicate
it works
And the replication seems atomic
At least in the editor...
You can't change the replication condition at runtime
It comes from the class-default object
Presumably that data never changes once the actor has spawned, so if anything you can just choose whether to add it to the manager or not in BeginPlay() or PostNetReceive()
data changes but I manually notify at the right moment if necessary
so yes never auto replicates
Well as far as network is concerned at least, it never changes once spawned
correct
So the rep notify doesn't seem necessary at all, just test it after the actor has been intiailized
Also, in times of packet loss - individual properties will replicate individually according to UDN, if I'm reading this right
ahh ๐ฆ
So it is possible to receive props at different times, but unlikely
well sucks to be those clients
You can force a struct to be atomic by overriding NetSerialize()
I guess the combination of empty data + packet loss if even more unlikely anyway
THanks will read up upon it
Shouldn't be a problem for a COND_Initial property since presumably it's sending all the data anyway
ah oki thanks
but yeah ultimately a rep notify is only ever going to be called if the value is sent at all, and if a value matches the serialized value (at spawn time), it's not sent (for obvious bandwidth-saving reasons)
I'm planning to change the generation to happen on client anyway at some point and only let server overwrite existing data rather
Just so that it's a bit faster
so all that wont be an issue anymore
I guess
Well it could still be if the client generated something in an array meant to be empty so i guess it's still good it's out of the waay
Hi ! I'm trying to use FRootMotionSource to predict my moves client side (using code from the gameplay ability plugin), but I have a weird glitch when I add some lag with pktlag (using 500ms), it looks like the root motion is being played a second time then rolled back
Root motion with prediction + RPC, client on the right
With prediction you mean network prediction plugin??
no, I mean I play the root motion locally and send the same one on the server, this is using CharacterMovementComponent
but I've used the network prediction plugin if you have any questions about it !
@stoic nimbus sure. Is NP plugin stable enough
Is NP exhibit any unexpected behaviour
Is NP a good friend of GAS?
I've not used it with GAS, there nothing unexpected but there's a few thing not implemented yet, most of the documentation is in the "NetworkPredictionExtras" plugin, there's def some boilerplate to write before getting anything to work
the idea behind it is very solid once you understand how to split the "simulation" from the actual inputs
Yeah , even I had this feeling that migration from CMC to NP may require to write some boilerplate code
you need to isolate everything that can impact your simulation so that the engine can replay every step properly and interpolate if needed
So whatever you have explored in NP, what are the chances that the APIs will change
it got some heavy changes from 4.25 to 4.26, had to rewrite some stuff
Ohh I see
not sure how far we are from the stable solution
I think it's best to wait till epic ships NP in fortnite.
one very simple thing I didn't realize was that there is some project settings that comes with the plugin
Can you please share that setting?
just a few settings you can configure but I couldn't figure why some interpolation was not being call
If anyone can help me figure out why charactermovement's rootmotion is being glitchy or any other way to implement responsive movement abilities in multiplayer
for android multiplayer is this right?CSharp [OnlineSubsystem] DefaultPlatformService=GooglePlay
Hey guys, what would be correct way to store some information about player on server? For ex. in PostLogin() I would want to pull in some info from server and store it with player? Can I store it just inside PlayerController or there's more elegant way of doing that?
There will be info such as his inventory, etc
Does anyone have a mirror of "building-and-hosting-an-unreal-engine-dedicated-server-with-aws-and-docker" article by Luke Brady? Not sure why the medium account was deleted
depends, we use components for this, like InventoryComponent etc. you also can put this into the PlayerState if each peer needs to know about that
For client side - I will make such component, more like a question where to store it at server? As an option - replicated component, but im not sure if this wont become an issue for 3rd parties, while they all will know everything about everybody
And also there is another part - personal data like tokens, etc, which only server and owning client should know
the playercontroller is only replicated to its owning client
ok, so its safe to put sensitive data inside playercontroller?
if i will Replicate SkeletalMeshComponent, it will Replicate position with attachments?
if you want attachments on a gun it depends on 2 things
firstly are you doing firstperson
if not then all you have to do is make the attachment an actor with the skeletal mesh as its root
then set the actor to replicate movement and attach it on the server
if your doing first person and use 2meshes for everything(i.e. not true first person) then you will need some extra replication code
@foggy idol i need replicate USkeletalMeshComponent in My pawn
for?
like its movement ?
or physics???
is the attachment a seperate actor ?
@cosmic trail docker for a dedicated server seems.. unnecessary
@glad sedge does it not help with scaling on ec2?
I'm afraid of costs with dedicated servers running 24/7
Ah, TBH it depends on what sort of customisation you're doing on the server, so I guess it makes sense
But yeah, if it's about sclaing up and down, that makes sense. Docker for just one single instance is probs overkill IMO.
yeah no, just thinking for the long term for a match making system with a bunch of dedicated servers running
yeah I've got a real deadshit simple setup at the moment
Haven't taken into account instancing or load balancing etc.
Many options these days .
yeah that medium article on docker was great, I had bookmarked it but now it's gone. The github is still up tho
where bReplicates in UObject?
//.cpp
UCPP_ItemBaseObject();
//.h
UCPP_ItemBaseObject::UCPP_ItemBaseObject()
{
bReplicates = true;
// can't find this variable
}
no where, UObject doesn't have replication abilities. First class that does is AActor
@gritty pelican
@cosmic trail https://habr.com/ru/company/pixonic/blog/475622/
but in russian language
"By default, UObjects are not replicated over the network. "
from your site
he writes custom code to replicate it
He probably forgot to define bReplicates variable in his .h
maybe
no github?
yeah you're going to have to write your own stuff, whatever he's showing there is custom
Why you replicating UObjects tho?
you may want to consider replicating a manager if you have a lot of small objects
AActor is good enough and pretty lightweight enough for objects that you can sector off into different relevancy regions with the Replication Graph
Objects will always be cheaper, so I want to try.
i find this https://jambax.co.uk/replicating-uobjects/
I would make single storage actor that can replicate it's contents(it owns a lot of smaller objects) for an inventory system, all those objects are always relevant based on the actor
I think that would actually make it even faster, you can batch send any changes down instead of having each object do its own
my inventory system does not replicate uobjects, but replicates a Fast Array struct, and the item uobject get created locally on client
found this a lot more managable
yeah that sounds like the way to go. I was thinking of replicating uobjects way back when, it's really not needed
Hey guys, OnRep in C++ works like blueprints, which means, if one user has joined server and we have updated some variables for that user on server using OnRep,
when another user going to join later, then onRep vars for first will automatically update for new User.
Yes
But OnRep do not get called automatically for the Server.
You must manually do the call in C++
if on Server i update onRepNotfied variable, its onRepFunction will not be called automatically for server ?
This happens in blueprints right
?
Correct.
You must manually call OnRep_MyVariable(); after you change its state for Server.
Blueprint does this automatically
So you dont need to in Blueprint
C++ is different
Thanks.
First time doing RepNotify from C++.
What will happen,if i update the variable from blueprints, which is RepNotified.
Do i still have to call OnRep for server
Guys this widget is not being added to Player Window Vertical Box.
Please help!
P.S. I am following unreal's multiplayer using blueprint tutorial series on youtube.
Looks like ur trying to pass a server event to a widget
Afaik thats not possible
Usually i'd do things like that via the playercontroller
Im trying to work on world streaming with dedicated server. I start my dedicated server with a map that has some sublevels, however when I connect as a client to this server - my client just floats in the air, since no levels are loaded. What am I doing wrong?
All levels are loaded on the server, something about your client is failing to complete the sublevel streaming
Any advices where to look at?
Use stat levels to see the status of your sublevels
From my client Im doing OpenLevel("IP on my server")
stat levels reports that sublevels are not loading on my client
Whatโs the name of the top level loaded?
Its the name of persistent level(parent of all sub levels)
but sub levels are not loaded at all(when in editor, loaded, they displayed as green in levels tree)
i might be missing something, but shouldnt I LoadStreamLevel() on my client manually?
Are you using world composition?
yes
on the other hand, if I jump straight into parent level - it loads all sublevels automatically
Then no, that should be already handled internally
Also I donโt think calling OpenLevel on client is what you want; https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/OnlineNodes/index.html
Describes the different kinds of Online and Error Related Blueprint Nodes.
You can use open level on the server to initiate persistent travel for the server and connected clients
But on client I donโt think that works
Isnt OpenLevel("IP") on client connects client to dedicated server?
Thats how it currently works for me
Is your persistent map set as the default game map in project settings?
no, default map for game set to menu level, and persistent map set as default for server
Is the server on local network?
yep
ok it looks like some bug
I just changed map for server from persistent to some other and then back
now it finally loads corrrectly on my client
Hrmm yeah openlevel should work then, I canโt really think of anything else without having a closer look
so when I OpenLevel("IP") it opens persistent level on my client and loads according sub levels
So the level isnโt loading on the server by default?
it was, at least were logs about loading sub levels in terminal
Hi all, I don't know if I'm being dumb, but I cant find anything online about how to override the game mode when starting up a dedicated server. I know you can pass in the map parameter like so:
MyServer.exe My_Map -log
But how do I also override the game mode?
Aight, so your client and server both have the persistent map loaded but the client fails to stream in any sublevels? @clear sand
When youโre on the client, does stat levels list out the sublevels but show them greyed out, unloaded?
In the project settings, and in world settings for the map you load on the server https://docs.unrealengine.com/en-US/InteractiveExperiences/HowTo/SettingUpAGameMode/index.html
A How To Guide for Setting Up a Game Mode in Unreal Engine 4.
@twilit stump I've done that, but maps can be played using different game modes. I want the dedicated server on boot to run a specific game mode
So the default game mode is team deathmatch, so when the dedicated server starts, it always runs TDM regardless of which map you pass in
I want to be able to do something like
MyServer.exe My_Map?Gamemode=CaptureTheFlag
So it overrides the default game mode and forces the specified one
AFAIK youโll have to make a duplicate level that loads with that game mode
Huh, thats weird. So how do other games run a "CTF only" server? Just duplicate all the levels?
I worked on a game that had open world pve and pvp deathmatch, each game mode had its own persistent level
That seems so redundant. That means I need 4 copies of every map, for each game mode
We have a way of changing the game mode in game through admin panel, I thought it would be possible to do the same thing on start up
you could create a generic gamemode that loads a specific "GameRule" that provides the GameMode with specific information, if you can't override it at runtime.
GameMode defines how players login, finding player starts, spawning pawns for players to possess. I donโt see how you can change that at runtime. Itโs just something thatโs serialized in the level/world
@twilit stump can you help me out?
well you can forward all this logic to smth you can load at runtime
Yeah, I mean you can branch the logic in game mode based on command arguments
na, you shouldn't branch it
just assign a load a Handler with virtual functions, otherwise you will get lots of if/else
Yeah Iโm tracking, theyโre asking about overriding the game mode class at runtime though. Iโm pretty sure thatโs just serialized in the world settings for the level
As said, I'm not sure if you can override it, but you can atleast load your handler dynamic on startup \o/
Whereโs your event defined?
Just a sec, I closed my project...Opening again.
BTW what is the difference between get player controller and get owning player.
Sometimes
Ah yeah, is your event in a UMG widget?
The GetOwningPlayer says target is widget. If thatโs the case you want to move this to your player controller
I thought the same and tried it basically used get player controller instead of get owning player(If this is what you are suggesting)....but I think issue persisted...
This too does not work
Update Player window Event is in a Widget BP.
hmm doesn your server load UI and is your widget somehow replicated?
It didnโt show any sub levels on client at all. After that small hack it started to work properly
hey peeps, i need to call "get all items" from a UE4 server
its steam stuff
any 1 with experience with this can give me a tip on whats the best way to do this?
Is steam best way to implement multiplayer server for indie?
Also, is it free?
its free but you wont have dedicated servers, only peer to peer
theres also epic online services now, but the documentation is not as good
What is the advantage of dedicated server over peer to peer?
you should use google for that my friend
@storm rivet Basically, better anti cheat and security. Having a trustworthy authority acting like a referee rather than trusting peers to be honest
Also, in P2P you are reliant on each peers connection speed, one weak link in the chain can slow everyone down. A dedicated server means one person on dial up won't slow everyone else down
Thanks a lot! @hybrid zodiac
@storm rivet Youre welcome! there are more complexities to it of course, and there are reasons why P2P might be a better option for some situations
Sure I will google and do my research.
Meanwhile, maybe you can pin the answer!
@hybrid zodiac
Didn't UE4 only support a server and client model?
So either a listen server or a dedicated server?
@twilit radish Yes, but I guess you can implement a P2P networking solution if you want
for android multiplayer is this right?CSharp [OnlineSubsystem] DefaultPlatformService=GooglePlay
hello guys, I would like to use a websocket connection for each player. How could I initialize a connection and then call the same websocket in other blueprints to make emits ? Or how could I make a websocket blueprint where I would put all the emit functions inside, usable by all blueprints?
why are you not using regular unreal's rpc'sยป
Because I want to use that like a Rest API, for user authentication / record player information in db / dispatch notification for everyone using ws, etc
has anyone here ever tried to replicate a spline component?
does not really seem to actually replicate anything. is it like a procedural mesh component, where you can check "Component repicates" but it doesn't really replicate anything because UDP potentially doesn't do well with replicating it?
None of it's properties are replicated
It's not designed to be replicated ultimately, but you can do it yourself either with a custom component class or just be replicating spline points separately
thanks, yeah i'll find a way ๐
already replicating procedural meshes via tcp ^^
(low poly ones ๐ )
@chrome bay while we are at it, do you know why it's only possible to inherit from USplineComponent in c++ and not in blueprint?
Do you guys have any tips on how to make jumping not feel so floaty? More so like Mario or fortnite style
i suppose you already played around with the parameters for it in the movement component?
@candid ridge the class isn't marked as Blueprintable. Might be an oversight or might be intentional, not sure.
so that's where that comes from. thanks for clarifying ๐
Overall is a "String" or "Text" better in terms of effeciency to send over the network?
Hey, I've got a question.
let's say i got the exact same project on 2 PC's.
How could i start the game (And the server, i guess ?) on my main PC while my second PC joins the server ?
Also as side note, both are in the same network
are you trying to host a listen server or a dedicated server?
I'm really new to multiplayer development in general. I don't know the difference between both ๐
Listen servers are essentially just hosted from your game.
i.e open the game click host and then you load into a level/lobby or something
dedicated servers are more along the lines of opening another application which opens a console or whatever without having the actual game open
Alright, in that case it would be a listen server
At least if it can work like this
so you would have maybe a button on a widget or a keyboard button or something like that for the player to click to host the game
I'd strongly recommend checking out Unreal Engine's youtube channel as they have a tutorial playlist of how to get a basic lobby setup
pretty easy to expand or change it.
https://youtube.com/playlist?list=PLZlv_N0_O1gYqSlbGQVKsRg6fpxWndZqZ
Gonna watch those then, but as last question. Would this system work on non-shipped versions ?
Like that PC A and PC B both just have the editor open to join a server, or would i need a shipped version on both ?
Alrighty, thanks
Of course
just gonna bump my question
Overall is a "String" or "Text" better in terms of effeciency to send over the network?
well sending text over network is always bad. Especially since you don't have localisation this way...
I'd rather send a Text GUID and load this on the client
but not sure how FText replicates, maybe it just sends the Localisation id, if present and otherwise the full string. If you generate the string at runtime it doesn't matter and you'll need to send a String
In the past I have replicated text without issue but It seems to noticeably slow down when the character length is longer.
I'm trying to replicate a description of a player's character in text from client to client Which can sometimes be up to 200ish characters
FText replicates as FString, which is generally considered expensive (more so as the length increases)
Yeah
okay thanks
Is there Any guide, how to send data to server in an optimized way, i mean how to minimise your packets, specific data types to use for networking only? i remember there is something for FVector.
Do you replicate whole structure to server ?
You can't replicate stuff to the Server, you can only send data to the Server via an RPC
Replication is always Server->Client
yes, i mean are there optimized data types , which should be RPC to server.
There are a handful of basic types in the engine, but otherwise if you want to send reduced data it's pretty much up to your game to figure out how to do that
Different projects have different needs etc.
are there any good articles, how other developers has done for there games, so i get an idea.
if i have 5 Property which i need to RPC to server, should i put them in struct and then RPC the whole structure.
Which way will be the best
?
we can make structs RepNotifies ?
how do you mean? repnotifies are done at the object level
But yes any replicated member property can trigger a rep notify
The network compendium is a good place to start (stickied in this channel)
As well as looking at Epic's sample projects
i have read that alot, i have okay understanding of multiplayer, when it comes to blueprints, i just want to do it right using c++, i always think my replication is not optimized.
RepNotifies are some kind of reliables ?
no
they are called automatically by the replication system client-side
Blueprint RepNotify aren't really proper rep notifies, they are just called whenever the variable changes - C++ ones are called when the value is replicated
okay, so only way to make sure, that if data is going to RPC are Reliables ? RepNotifies can missing too ?
I am having the gamemode spawn my inventory items and of course its working fine for the listen server but for the client, I am not getting any items and I am not sure what I am doing wrong fully
nvm I figured it out
Question: Is there something special I have to do in regards to replicating arrays? I can see an array exists on the server but not the client. The variable is marked for repliation and I do have the DOREPLIFETIME thing on it as well
The variable is in the GameState and is added during the GameModes PostInitializeComponents()
no but it may depend what it's an array of (actor references? structs?)
you can always ForceNetUpdate() after setting to make sure replication updates run next tick but it doesn't look like the default gamestate classes result in less frequent replication
Anyone have a straight up tutorial for how to make a dedicated server to test with others, that is taking best practices? Like ideally something I can set up to test what it would be like if we actually try to make it publicly playable
It's an array of a child of AInfo. I also made sure to that was set to replicate. Lemme try forcing a net update. I'm working with the same code i used in 4.25 but I don't recall this being an issue then.
thanks Swires
That didn't fix it, though I did find out what was causing it. It was just never in replication range. So setting it to always relevant fixed it for me
should i need to replicate overlap event? i mean RPC etc
what would you be trying replicate? if I remember right, any overlap events occur on both the client and server
when i try to attach actor to component in client side, my character is attached, but my character started stuttering and weird vibration movements, how to solve this issue?
@smoky ore the client side array is empty or full of nullptrs?
it was empty due to it being outside of the replication range. setting it to always relevent fixed it for me
for a game state you needed to turn always relevant off for it to be off ๐
well the game state was fine
it was the actor i was trying to store that had the issue
can anyone help with that, my character is jittering in client side when i attach my character to dragon, please see video
help would appreciated
but in server side, the character doesn't jitter
what cause the issue, this only happen when i do this :
this is rpc call
@winged badger can you help
please don't randomly ping people for help @wheat magnet
sure so can you please help why this occur
someone will help when they can, i don't have time right now.
ok great
Hey, I've been reading that TMaps aren't supported for replication, and the general recommendation is TArrays for replication. I've been having a hard time finding info on which objects support replication in the docs. Do y'all know where it might be?
That's probably the movement replication crapping itself because the animation state between the server and client are not in sync. When attached, you need to stop correcting the pawns location.
is there some way to add the ability to call server RPCs from actors other than ones owned by the PC
Not that I know of, and that could be a bad design, route through something that is owned, like the pawn or Controller.
Or just set owner if it's not something in the world that's meant to be shared.
ive got a game with multiple pawns
kinda like an rts
i want to be able to call client->server rpcs from the pawns
i dont really want to stick everything in my player controller lol
Do the client->server routing through the player controller or a flying pawn that represents the players camera
The PlayerController should have a pawn, what is it?
the latter, a flying spectator pawn sorta thing
Use that to do your routing if you don't want to do it through the controller
I'm guessing this is for selection and sending orders?
yeah
selection can be totally clientside, just have to RPC an order over with what the order is and who's the target etc
kk. i mean that's what im doing
Yah that's a good architecture. I'm sure you could probably work out some way to do RPCs in the units themselves but I can't think of any benefits and it'd make them all super overloaded
I mean why do you want to do that anyway? What's the benefit?
uhh kinda because like
you can also select items and buildings in stuff in my game, and they handle the input basically like
straight from the player controller
instead of the player controller doing any RPC stuff first and giving them commands
its so that right clicking is contextual. it can move a pawn if you have it selected or it can open a menu
etc
It's easy enough to just make an RPC with parameters CommandEnum, Unit, Target, Location etc
open a menu doesn't need an rpc
it doesnt
that's why i dont do the RPC on the player controller
i want to be able to handle it in the thing that's receiving the right click order
so telling villager to chop a tree would be like Command = Attack, Unit = Villager3, Target = Tree32
doing it as an enum really really sucks though
or if the same keys do different things on different units, you can just do like CommandInt = 3
maybe there's some way to do it with objects ๐ค
.... why the hell would you do that lol
I take it you want same hotkeys to do different things on different units?
why the hell would you enum out every single command in the game instead of using different objects?
yeah
but then i would need a big conditional or switch statement wouldn't i?
what i want to do here is avoid that with polymorphism
You can have the enums map to events in the base class
then just implement those events, the same way you did direct input
can you map enums to events?
How many inputs in total do you have?
i dont think blueprints have higher order functions right?
uhhh
just left click and right click right now
but there's about 20 different object types right now
Wait, does anyone share units?
2 players sharing units, is that a thing
why not just set all units owner to the player?
how many pawns can a controller own?
also would that affect move to commands? do those need an AI controller?
owning and possissing are different things
possessing implies owning
but owning doesn't imply possessing
oh shit lemme try that out then
Yeah i'm not sure how ownership works with an ai controller in the mix but try it
set owner needs to happen on the server but that can be done by the spawning building or whatever
I'd still prefer sending commands as that'd make building an AI that can play as if it was another player a lot more streamlined
and idk if there's any complications with enabling and disabling input on the fly that much
shoot that doesnt work
after spawning it, it gets owned by the AI controller
even if you set the owner to the PC
okay ive got an idea
i can probably spawn some sorta actor with the pawn that handles client->server rpcs
yeah that'll work
why not set the AIController owner to the PC?
that is all you need to do
although personally i would have a ActorComponent on the PlayerController that does pawn orders
you can do this?
why?
Bit of a silly question but i noticed the onpossessed event for pawns only triggers on the server, there isn't an easy equivilent function to bind to for clients is there?
or do i have to do something silly like check for a valid controller on every frame until there is one
Solution: There is an onrep exclusively in CPP i didnt see before, i can override that to get the equivilent of a client side on-possess
Turns out you can't replicate maps, does this look like an alright way to do inventory? There's 2 parallel arrays, AllowedItemSlots and EquippedItems. Different subclasses will have different AllowedItemSlots
Hello everyone, I already asked here for my issue yesterday, but I didn't find the solution yet - I will try to explain better what is my problem ...
Actually, I've bought Socket.IO Client from the marketplace, in order to use web socket communication on Unreal Engine to do all database requests in websocket (login/request informations on connection/dispatch informations for all players connected/...). I would implement that via blueprint because I think it is not needed to do that in C++. So, what I want :
- When a player launch the game, the websocket connects into the backend. After connected, player will go on the "Login Widget" to connect into the game. I have tested to instantiate the websocket client connection on the PlayerState, and I've tested to get the SocketIOComponent from PlayerState to get the current websocket connection and do a request to the Node.JS Backend. But it does not work ..
I don't know if I have to do a separated blueprint to put all Socket functions (connect/emit/emit with callback/check if always connected/trigger reconnection/etc) and call the blueprint everywhere I need .. Thanks by advance for your help ..
Are you familiar with cpp?
I have almost the same task and have good progress using cpp and grpc
I'm not really familiar with cpp and UE actually, I would have to look into the mechanics of CPP inside UE ..
Why use GRPC instead of websocket ? You choosed that for a specific usecase ?
Can TSharedPtr-stored structures be replicated ?
I think so. GAS does it I'm sure
Interesting
Currently replicating structures, but I need them as TSharedPtr later to send to UI
(to get nice invalidation on removal)
Check the abilityspechandle in gas
Yeah you can 100 percent use shared pointers
Might need to make your own netseriailizer
Do you know what can be the best blueprint type to instantiate connection to websocket and put all events functions in there ?
hey guys, im just starting with ue and i wanted to know if there is some peer to peer host option built in for multiplayer games? such as (i imagine) among us where people can join a room that one of the clients host?
and if you have a link to tutorial video that would be great too
im planning to program a mobile game
@twin juniper
Unreal Engine has a whole playlist on youtube to host lobbies via a listen server you can find here:
https://youtube.com/playlist?list=PLZlv_N0_O1gYqSlbGQVKsRg6fpxWndZqZ
This should cover what you're looking for
haha @terse prawn just found it myself i just wasn't sure it would work on mobiles
since he mentioned steam there
thought its specificly for steam
I personally followed the videos and never used steam and still worked for me.
Its just steam makes it easier for clients to connect to the server because the steam online subsystem takes care of some more 'technical' details on connections (for a lack of a better term)
Yee of course
Hey guys I was wondering if anyone knows some course in game oriented networking, I'm not talking about basics but an actual in depth course / knowledge source.
So first of all - keeping connection opened for long time might lead to memory leaks if you forget to delete object and overall consumes much more resources than if it would be just request-response approach. Second - you need to take care about reconnects since websockets might fail at any point because of network lag or just high ping. Third - its getting really hard when you want to do loadbalancing. After all - you dont need constant bidirectional streaming for things like login or any other request based operations.
While websocket seems to be easy approach, it has some downsides in long running perspective. I've dealt with websockets in web development - and I dont really like them because of lots of issues with them when trying to do something more complex than just send few messages.
There is also a plugin VaRest which provides you http functionality to blueprints. Its worth to start with simple http request for your login/signup related stuff.
Once you get familiar with UE4 and networking, it should not be an issue for you to start to use any technology that fits your needs. Personally the reason I chose GRPC because of its simplicity and reliability. It also supports bi-directional streaming, so it can replace websockets. But besides it also provides unary calls(just like regular http request-response)
At first you need to understand what part of logic should be extracted to backend server, and which should be handled by dedicated/listen server. Having that in mind you'll have easier times to understand what fits your needs
Is it possible to send a TArray<> through an RPC?
I have an event that is Run on Server and it fires very inconsistently. Why might it not fire every time?
if you have an unreliable rpc it will only run when the network allows it
but the mos likely scenario is that you are doing something wrong
Hey everyone,
I'm still having trouble with the replication of a widget in my online multiplayer setup.
I tested the code in another project using the "post login" and all the replication worked fine.
The difference with my "real" project is that I'm using the "on player swap", but for some reason my replications don't work anymore unless I use a delay node ...
Is anyone here good at that sort of thing and willing to help ?
Thanks @limber gyro
Does anyone know why my AnimNotify only executes on the server sometimes? (unreliable)
Can i make these reliable?
you should be able to make anything reliable, you just have to pay attention to the network bottleneck i think
i'm in blueprint
animnotify only executes on the server sometimes but always on the client
im trying to get it to always execute on the server
@dense ocean make sure the skeletal mesh is set properly
under optimization is the Visibility options, make sure either always play montages or its always visible and updates botnes
Thank you @meager spade this must be it.. what blueprint is this in? I can't find it in the mesh or animbp
its on your skeletal mesh component
i set it to always tick and refresh bones, no luck
is RInterpTo a good way to interpolate the rotation of the player character? If so how do I cancel the task if a condition is met?
RInterp or RInterpTo are just math functions. If you want conditions, either select between the RInterp or the current rotation, or simply don't do the rotation if the conditions is met before even using the RInterp.
Alright thanks, another question, it is okay to use RInterpTo in a networked game right, it's not going to look weird, or is there a better function for this?
i mean it depends on how you're doing the interp though
the interp itself isnt the issue
is there a way to spawn replicated actors only on some clients?
like how aplayercontroller is spawned on client, server, but not all clients?
Override isnetrelevantfor
fantastic, thanks man!
so wait im kinda confused
so if i override it then the replicated actor spawning wont happen?
I've been looking over the ShooterGame code... one thing throwing me off, is the UserId for dedicated server within HostGame:
bool HostSession(TSharedPtr<const FUniqueNetId> UserId, FName InSessionName, const FString& GameType, const FString& MapName, bool bIsLAN, bool bIsPresence, int32 MaxNumPlayers)
The dedicated server wouldn't have a valid player ID would it?
Also, I have been scanning the code base since this morning, and while most of it makes sense, I also don't see where in the code it is auto starting a session if you do start a dedicated server. It almost seems like it expects a player to fire up a dedicated server from the ShooterMainMenu slate class... even though in a dedicated server setup, there would be no player to check that option...
is it possible to serialize a UProperty
UProperty is redudant in 4.25+
redundant*
and what you mean serialize?
for replication?
i want to convert a wildcard uproperty int bytes uint8
oh ok i saw the warning
I also want to be able to convert it back
why is this in #multiplayer ?
how do i do it though ?
ok
any 1 has experience calling steam stuff from the server?
i need to call
but i dont know whats the best way to do it
is this REST call=
?
I don't understand how to open the inventory clientside, like how to get the owning player
on a multiplayer server
make that event a Client RPC
"Run on owning client"
no need for the OwningPlayer to be passed in
that event will need to be on the PlayerController or Character
Make a print string there to make sure that it is actually called, and to know by which machine (server, client?)
@meager spade Hey, Do you write your own Actor and Component Movement Replication System ?
Big Thanks to everyone in live discord voice chat for helping me resolve my issue
Hey everyone, need help
I'm trying to make a co-op game between VR and desktop. Problem is, I can't get this spawner thing working with multiplayer. I created a pawn that spawns by default, and depending either you are a desktop user, or VR, it spawns specific character and possesses it. When hosting it spawns and possesses normally, but when joining: it spawns a TPS character no matter VR or not, and no input is working Any tips?
use an optional string when joining a session
to indicate if you're doing desktop or VR
that particular logic is bound to end in a disaster though, even if its in GameMode
Zlo, do you work for wildcard?
*wildcard studios
I ask because of your avatar picture
no, ironward
oh so you work with Kaos then. That's pretty cool.
the picture above is the default pawn that spawns and then spawns either TPS or VR char
and it runs on both server and client?
you can imagine how that could be problematic
also server has no clue if client had VR pluigged in or not, unless client tells it that
well it should spawn by default every time new client joins, and pawn manager should spawn specific pawn depending on device
I'm not entirely sure, I haven't dealt much with spawn manager in MP before
@winged badger Man it worked! Thanks a lot
Now I have to figure how to get rid of the server spawned character?๐
TargetRotation, DeltaTime, TurnRateInSeconds);
Ability->GetAvatarActorFromActorInfo()->SetActorRotation(NewAvatarRotation);
Is this the right way of using RInterpTo in a networked game? Im getting weird behavior
you probably want to send the location its attempting to look at and updating it client side because otherwise you're relying on the server to do the updates which won't interpolate position updates at all
is there a better way to interpolate rotation than RInterpTo?
network friendly?
maybe AddControllerYawInput? I just have to figure out how to transform ``` FRotator NewAvatarRotation = FMath::RInterpTo(Ability->GetAvatarActorFromActorInfo()->GetActorRotation(),
TargetRotation, DeltaTime, TurnRateInSeconds);
you will have to process it on the client to guarantee smoothness like I said
though if this is a locally controlled pawn, then that might be a bit different
since it might be the pawn trying to follow the controller's rotation
then let's say I RInterpTo on the client, what should I do server side to keep the same rotation? or if there is something I could read on the topic that would help too
hi, I am implement a rewind system to do HitScan in server, in the system server keeps the pose and root of all player character, when a player fires a gun, server rewind other characters to do HitScan, included root location and animation pose. Now the root rewinding is ok, but pose rewinding is not ok, because server doesnot sync animation pose to others, we only sync the move speed, then animation bp select the animation by the speed, anyone has good idea to fix the problem? thanks
If you truly want to rewind the entire scene and check the hit per bone, then you need to have all animation run on the server in a way that is deterministic and the same as the firing client
Most games decide this is an impossible task and go with simple bounding box checks
Like, usually on a client the animation state of the player you're shooting at is derived from interpolated transforms between replicated transforms from the server, the server has access to nothing of that
You basically end up needing the client to tell the server the entire anim state and then what's the point of checking it since you're trusting the client ?
I have no idea if this is still correct/relevant or even has relevant info, but it can't hurt reading over it: https://playvalorant.com/en-gb/news/dev/the-state-of-hit-registration/
Given Valorant, being basically a UE4 Counter Strike, really needs hit registration to be "correct" and "clear", this might be helpful
And they do use anim state in the rewind
But Valorant has done very extensive effort to get a great shooting feel and I don't think it was easy ๐
And they go on with an example of animation state mismatching on server and client, where they decided to trust the only animation state that made sense - the server's - causing the client to miss correct shots
yes, server is god
You can do pretty simple verification without having to rewind the animation. Just depends how intense you really want to go, and how complex your damage model is
If your damage model is pretty simple, checking the hit as distance-from-rewound-capsule is more than secure enough
Hello. I'm trying to setup sessions with Advanced Sessions Plugin. Everithing is looking good, except that I want to be able to cancel session serch. For that I'm using "Cancel Find Session" node, and it gives me print on success, witch is great. BUT, later when I call "Find advanced sessions" On success pin gets called several times, even though "Find advanced sessions" was called only once.
You should block "finding" sessions until the cancel is completed successfully
Likely messes up if you have a pending find and cancel at the same time on some OSS'
how to block finding sessions?
Simplest approach, use bools to prevent it
but finding sessions is already in progress when I do cancel.
Hello, quick connection, I have a SET (FNAME -> Bool) that is my state machine for animation (like attacking or hit is true to play the anim in the anim blueprint)
My idea was to replicate it
Except sets cant be replicated apparently..
Do you guys have a better alternative solution to store my anim states?
Enums?
TArray of pairs of FName -> bool
What do you mean? An array with enum key?
But then I have to iterate over all keys each time?
I guess array is closest solution
Thanks
Yeah
What's your state setup? Like what are some example states?
Yea
{
Attack : true,
Hit: true
Dead: false
...
}
Then I blend animations based on that @dark edge
Why not EHealthStatus:Dead EUpperBody:Attack EHitReact:Light?
The whole point of a state machine is that states are exclusive so an email is a lot better fit than multiple booleans. What if somehow you have a bug in both alive and dead are true? If alive and dead are just States in your status in them then they are mutually exclusive
Oh I did not know those things existed
Where can I find them how are they called?
Thanks @dark edge
Enumerations or enums.
Ahhh you mean creating ONE variable as a state
Yeah tbh it might be enough
Im just kinda worried with ENUMS that it's just not as flexible
But it works for sure
I mean one per dimension or slot of State. so one variable representing what the upper body is doing, be attacking running grabbing shooting whatever. And enum can be thought of just like a Boolean but with more than two states.
Hey guys I'm implementing a multiplayer system. All I need to do is a racing with ghosts of players. What should the best way to set this up? Do I need Dedicated servers?
Is it not real time at all? Like you're racing your friend's best times or whatever?
It's not 'live'. You basically race with the best records on the leaderboard (closest to you)
Like Trials do...I don't know if you know that game!
seems like a local game, but pulling data from a server, setting up the ghosts, and just racing
If that's the case, it's basically just a leaderboard with extra data. Should be fairly easy
Do you know if you can do arbitrary save game sharing across steam or do you need to explicitly share something? I suppose that any game that has user profiles that you can just look at would be saving data that could very well be a recording of a run.
Although if that's the case, could a virus theoretically spread through Steam, hitching a ride on save games and some sort of insecure app?
right, that's it
honestly idk...I would just save position of each run and store data, in order to replicate these info online
You could theoretically do it with AWS Lambda & DynamoDB. So effectively serverless, but you'd still have to pay for AWS services of course.
Yes of course I was thinking about Amazon, no problem for money...I just wanted to be sure what's the best way
When dealing with an array set to onrep notify,, are only the array elements that are changed replicated? ie. it doesn't send the entire array over when only one specific element in the array changed?
I'm sorry i don't understand your question...But at this point I don't know exactly how to do this. My idea was to record Transform of the pawn, save the array and play next time...is it correct?
you don't want to record every frame
but a position every X frame
and interpolate between each point
(will reduce database size)
Would a good way to communicate cursor position to the server be calling two separate functions on inputAction, one for setting a replicated FVector and the other for telling the server to try and go to it?
Client must call RPC to tell server its cursor position, then if you want other players to know it you should get the server to set a replicated var. Be sure not to call the RPC every frame or you'll swamp the network like I did ๐
Remember, only server should set replicated var. The only way a client can talk to the server is via RPC.
Copy that! Thanks!
Wait is there really no other way for a client to tell a server 'try and go here' ?
only via a server rpc
๐
Well that got it to work
So basically i get the mouse hit on server, sent it as an argument via RPC to the server. But that means there has to be some manual validation ?
I feel like not checking it would open me up to some bugs/exploitation
No one knows your situation since validation is completely open ended, no one can answer that for you. But yes, you can do manual validation on RPC send to see if the mouse position was changed too quickly. Either way, not sure how else you want to validate a mouse position.
Oh i hadnt thought about sending the mouse via rather than sending the impactpoint directly
I think thats probably a safer option then, ty!
Are reliable multicasts always sent even to non-relevant actors?
ok yeah, forum posts are confusing me, not sure what's the current state. Thanks!
Oh you know what, one sec
Is there a doc somewhere outlining the opt-in push model for replication that I heard about? Can't find anything related to it.
Okay sorry, turns out I was wrong - reliable multicasts still ignore relevancy apparently
But you can disable it globally with net.AllowReliableMulticastToNonRelevantChannels (which defaults to enabled)
Had to go hunting through UDN, wanted to be sure ๐
UNetDriver::ProcessRemoteFunction is the offending location
So if the actors' channel is active, it will send the RPC
if it knows about it, cool thanks!
Hey guys, quick question: I have a OnPostLogin function in charge of Spawning the initial character and possessing, I've already got it to spawn and used the reference to call the Possess function from the Controller passed by the OnPostLogin but I don't think its really allowing possession, I've also included SetOwner(Controller) but still nothing. Anything I might be missing here? I've confirmed with SetOwner, that it is in fact the PlayerController, but printing NetOwner is not the same, and so I assume thats why its not allowing to move the pawn.
How many bytes does FName spend during replication?
as much as a string of equivalent length @gritty pelican
if you want cheap, use FGameplayTag, which is a fancy name, but one that has to be defined at compile time, so it can replicate as integer
@worn lodge that is not PostLogin's purpose
i think make int32 will be better
use AGameMode::HandleStartingNewPlayer, which is called immediately after (PostLogin->GenericPlayerInitialization->HandleStartingNewPlayer)
your problem is probably that HandleStartinNewPlayer's default functionality is to spawn a DefaultPawn for the Controller and possess it, and it runs after
if you're overriding it from BP, if you don't add a call to Parent function, there will be no default spawning done
bonus: HandleStartingNewPlayer actually works with SeamlessTravel as well, not just hard travel
Anyone has an example of a networked RInterpTo to rotate a character? I searched "RInterpTo" in this channel but answers are not really clear for me
I'm doing it on the client but I guess the server isn't allowing me to rotate it because it's not working
I'm doing it on an tick ability task inside a local predicted ability, that should work shouldn't it?
seems like the rotation on the client is wrong, but the server rotation seems fine
{
// In order to realize any kind of ability we must first realize the TurnRate task successfully
TurnRateTask = UDTPAT_TurnRate::TurnRateTask(this, FName("TurnRateTask"),
FGameplayTagContainer(), DataHandle);
TurnRateTask->OnCompleted.AddDynamic(this, &UDTPGA_InvokerTornado::CreateTornadoActor);
TurnRateTask->EventReceived.AddDynamic(this, &UDTPGA_InvokerTornado::EventReceived);
TurnRateTask->OnCancelled.AddDynamic(this, &UDTPGA_InvokerTornado::OnCancelled);
TurnRateTask->ReadyForActivation();
}
I'm trying to make a listen server game, and currently I need to manually port forward on the host then enter the IP of the host on the client to establish a connection. I'd like to bypass the IP part by having a simple server that handles matchmaking (while keeping the game running on the listen-server). However, I would still need to do the manual port forwarding on the router of the host. From what I've read online, common ways to go around that is to either do NAT Punchthrough, which UE4 does not support natively (would need something like UPnP), or use the Steam OnlineSubsystem. Are there any alternatives? And for the Steam way, do I need to publish the game on Steam and have every player create a Steam account in order for the OnlineSubsystem to work?
your listen server's router doesn't expect to be contacted from clients IP
so it ignores the message
if your host were to connect to public server, give its IP so the public server would know to send it packets, and then your clients also connect to that public server and communicate a desire to join the listen server, then the public server would send the listen server a packet instructing it to send a packet of its own to client's IP:Port and after that client could connect, as it would no longer be ignored
as for steam, the ID is 100 bucks, and yes, they would need steam accounts
This do NAT Punchthrough, which UE4 does not support natively (would need something like UPnP) is confusing to me, I don't think UE4 on layer 7 would ever need to know what's happening on layer 3, meaning if routing and forwarding is set up properly between any devices you see fit in your public topology, everything should work just fine, because why would Unreal care about NAT? I am mainly talking to myself... ๐
Wouldn't the server sending the packet to the client be ignored by the client's router as well?
it would
Or it would, but that's ok because now the server has opened it and that's what matters
but then it would be expecting a reply
so it would not ignore next client's packet
I would still need to do the port forwarding on the listen-server's router though, right?
I think I read some thread mentioning off the box support for UPnP in Unity but couldn't find the equivalent for UE4, hence this part of my message
Hey guys, my ability component that I'm working on is something that I want to work for both players and NPCs. As such, I need it to work server-authoritatively, and also support client prediction. I decided to do this with inheritance, with a basic "AbilityHandler" that works server-authoritatively, and a child of that "PlayerAbilityHandler" that overrides TONS of functions to support client prediction and rollback. I'm just wondering if this is the wrong way to think about things, as what I'm finding is that I still want to use all of the server side functionality from the parent class, so almost everything I override is checking GetOwnerRole() != Role_AutonomousProxy and if that returns true I am just calling Super::Function() and returning, and if it returns false I'm doing the "predicted" version of the function. It feels very messy but I'm not sure if that's just due my experience level or if there's a simpler/clearer way to do this.