#multiplayer
1 messages Β· Page 60 of 1
open xxx error is handled by OnTravelFailure ? π€
If you are using C++ you may want to look at overriding in the Engine
/** Allows subclasses to pass the failure to a UGameInstance if possible (mainly for blueprints) */
virtual void HandleNetworkFailure_NotifyGameInstance(UWorld* World, UNetDriver* NetDriver, ENetworkFailure::Type FailureType);
/** Allows subclasses to pass the failure to a UGameInstance if possible (mainly for blueprints) */
virtual void HandleTravelFailure_NotifyGameInstance(UWorld* World, ETravelFailure::Type FailureType);
im writting some automation to launch headleass clients and I want them to shutdown if failed to connect or disconnected
headless clients?
thats guys , I go try, my code base has grown so that asking here is better than changing the code and waiting to compile
π
You probably want to use the NetworkFailure one as that handles basically all scenarios from what I see.
See: ENetworkFailure
yea its client without render -nullrhi
I have written client AI that plays the game
π
Chaos monkey?
w8 I never heard that work
im doing that to test the perforamce and gameplay since I dont have 100 coworkers
xD The encysampedia π€£
This is why I'm still sad that one topic on this was on UDN.
But honestly it probably came down to just bots yeah lol.
oh i just figured out the reason why data isnt being replicated its because its because its being executed on the client
im using StateTree for my AI btw, its new without any doc but I like it
will a dedicated server execute BeginPlay on a player controller?
BeginPlay is called in all network contexts
that is what i thought
except when your base class forgets to call the super
if (GetWorld()->GetNetMode() == ENetMode::NM_DedicatedServer)
{
Request->SetHeader(TEXT("User-Agent"), TEXT("X-OnlineServices-Server-Agent"));
}
else
{
Request->SetHeader(TEXT("User-Agent"), TEXT("X-OnlineServices-Client-Agent"));
}
can be summarized in one line btw
should i use this to test if code is executing on the server over if (!HasAuthority()) ?
What if you want a Listen Server to execute it?
I dont
HasAuthority means == standalone , listen server or ded
You should look at what HasAuthority is doing.
GetNetMode() < NM_Client all the way for those kind of checks.
And then IsNetMode(NM_ListenServer) or whatever for specific stuff.
This is not completely true btw. And generally why I don't like HasAuthority(), client side spawned objects return true for HasAuthority().
Hi, im having an issue with getting this timer started, if I put it on begin play it returns false, unless i put a small delay before it which will then go true and start the timer but I know putting a delay there isn't a fix, any ideas how I can have this timer called only for the locally controlled player properly?
My theory is that when i spawn the BP_Caretaker class in the GM, the begin play's firing before its possessed or something causing it to go false
If this is a listen server, then yes. That's exactly what happens, which you can easily verify by printing a message indicating which event runs first by overriding the OnPossessed event or whatever it's called in BP π
OnPossessed is only called for the Server.
Yeah i tried putting it in there too but didnt work, i need it to run on client i believe
I'm interested to hear why you preferred this - do you hate AIControllers a lot?
only the BP_Caretaker class should see it
@blazing spruce Do you have C++ access?
The whole character class is setup in BP, but i dont mind using C++ if theres no other way lol
You have a few options in Blueprint only.
For Clients its best to wait till the PlayerState exists.
This is an alternative.
Unless you want to properly expose the PawnClientRestart to Blueprint from C++
I mean, ideally you also take network performance into account. Which you don't get with typical AI.
This is my recommendation, but if you want to stay in BP only then the above image should cover you.
After it you would check for Locally Controlled etc
You dont get with other tools too
They said they use ST
@fossil spoke There's a BP event for that called ReceiveRestarted
See APawn::DispatchRestart
Im guessing that got added in 5?
Im still on 4.27
π
Give me a second to check where they added that. But could very well be the case.
Interesting that is overridable on the character class
Yeah.. UE 5.
so i could use that?
nice! ill give it a go, thanks!
π
My multiplayer system works when I play it in editor standalone mode 2 clients
but I cant play it with my friends nor I with 2 clients
Its using steam online subsystem with spacewar settings
Thought you meant something else, my bad π
As in "why don't you just use regular AI instead of clients"
Thats why I asked though π
(β―Β°β‘Β°)β―οΈ΅ β»ββ»
APawn still provides a way to do netcode
Yeah but that does not nearly simulate the same performance as actual clients that send over network data etc.
Maybe CPU wise, but definitely not network wise.
In the context you are speaking of it would be just a matter of having client or authority role
And having a "client" AI is more costly
An actual client has packet drops that need to be resend, sends healthchecks, has actors that become relevant / irrelevant etc. all while also interacting with the world which in return sends stuff over the network. If you just simulate that with server side AI you don't get any of that.
I think you misunderstood me at first place
Generally in other engines and many games AI "logic" is not a part of the netcode either, and to replicate some necessary behaviors to clients you can still use APawn, so I couldnt see the reason why would completely ignoring server-side AI and using a fake client based AI be an option
So it was a question regarding to curiosity
Made me thought they have a custom architecture or something else, no idea
Since having a client AI is more disadvantage and an advantage in many cases
I assumed the idea was to have clients that run AI like code to mimic players actually doing stuff in the world to test server/network performance.
Not yours, but the person creating it.
It's on my imaginary todo list as well for some day as it is an absolute pain to test performance properly. But I don't have the server space for it π₯²
Also Battlefield V did it too btw π
You might want to provide more info
In this 2019 GDC session, EA's Jonas Gillberg discusses the development of AutoPlayers, autonomous bots that are used for scenarios ranging from full 64 player soak tests to specific scripted test cases.
Register for the all-digital GDC 2021: https://gdconf.com/passes-prices?_mc=sm_x_3pvr_un_x_gdcsf_x_x-yt-gdc21
Join the GDC mailing list: http...
It's a bit generic tbh. But they explained how they used bots to test performance, used it for QA purposes as there was no way they could cover 64 man games with their QA team at all times etc.
But overall not disappointed I watched it.
@low helm Again, it all depends on your game, you need to pick a number and target that.
Every game is different, every game is designed and architected differently, that all contributes to what level of performance they can manage.
You need to pick a number from the beginning and say "We want to be able to support X number of Players, how do we design and build the game to facilitate that."
I wonder if there are any good examples of Listen Server games that have shipped with player counts above 4
Probably, but just because someone else has doesnt mean you should, or that it fits your game.
Valheim is 10, L4D and DRG and Vermintide all do 4
Well my use case is mostly standard shooter, CMC and AI are our biggest costs, and nothing there is really unusual
So comparing myself to others seems fairly appropriate
If your game is a large world combined arms combat FPS like Squad or HLL, its not going to do well as a Listen Server experience.
Your target audience is going to have wildly different hardware and network capabilities and all of that plays into a Listen Servers experience for all users connected to it.
right
That is typically why you see low Player counts for Listen Server games.
You cannot hope for the best scenario, you have to expect players to be running on a potato.
Yeah so some players could handle 12-16 connections but some run the game on toasters
Exactly.
Ok cool I think I'm starting to get a better picture of what to expect. I just want to have a hypothesis before I begin testing....like Listen servers probably handle 4-6 players on bad hardware, twice that on good hardware, and twice that on Dedicated Server
And see if that hypothesis bears out
Sometimes I join a DRG server that performs really badly with just 4 players
You HAVE to have a target before you build the game. It just doesnt work the other way around, you will simply end up making a game that doesnt work for the performance you end up with if you decide about what number of Players you want to support after the fact.
When I start 2 editors and open the game as standalone, one can join another
but it dont work after packaging project
Like I cant start 2 game instances and make it work
You also have to be realistic about what you can acomplish.
No point saying "We are going to make a 120 Pop Battleroyale experience" if you dont have the talent, experience or expertise to actually do that.
Don't worry I tried to remake WoW 6 years ago
Learned that one the hard way
But it was fun
Everyone in their early days in this industry has had those lofty goals
And 99% come to the realization that its just not how it works.
Look at it this way, if it was easy, everyone would be doing it.
But how many WoW clones exist that were made by tiny ass teams with no experience?
Being realistic gives you a CHANCE at being successful.
Yeah and these days cloning WoW isn't enough anyway
Even if you could
I want just enough people in my game so that artillery coming from a rear guard makes sense, so yeah I'll probably be working towards 16 or 24 players
Thing is, you need to incorporate realistic expectations into your design goals and outcomes.
If you want that as an ingame experience, 1 player shooting a single artillery cannon might not be enough to sell it.
So adjust your design goals.
Instead maybe they command a group of cannons ?
It is a game after all, you can bend reality.
Yeah the players in the rear guard manage cannons and supporting reusable rockets
Bending reality is usually because you are sticking within your lane of competency.
yeah that makes sense
So yeah it's not just 1 player with 1 cannon
It's more like you manage a miniature base
Which provides combat support
Whatever the case is, be realistic about your goals, about your time scale, about what you can achieve. All of this will inform your design and the final product. If done right, you have a chance at success instead of no chance at all.
Artillerymen get this little grid camera and dial in each artillery peice manually, no pings
Yeah cutting scope has been a multi-year project for me
To get down to somethign realistic
Where the circles indicate target and radius
Cool, we are drifting a bit offtopic though.
True, I really appreciate the conversation
I hope this was helpful.
Paypal is ready π
You dont owe me anything. Only that you heed the advice π
Is there a way to make a function as only able to run on the server? Not a server RPC or HasAuthority, im curious of any specifiers or anything, I read about one but cannot find it, maybe it was an older unreal thing? I just want to ensure a client cant call a function an if (HasAuthority) seems hacky using it everywhere
@digital pendant Whats the question?
Its not hacky to use something for its intended purpose.
BlueprintAuthorityOnly will cause any nodes with this specifier to not be executed on Clients.
im not sure if you will be able to help, but I have an older project that I am coming back to and one of my endpoints seems to not be getting called.. when my game ends it will pick a winner but it seems that the endpoint execution is getting skipped.
Not sure what you mean exactly? The HTTP request isnt being sent?
If there are any GAS gods hanging about, please check my post in #enhanced-input-system
Ty! β€οΈ
either its not being sent or its sent with the wrong authorization and gets ignored.. trying to look into that right now.. it may be something as simple as wrong password
You should be able to view incoming requests on the API Gateway.
i have another lambda function that verifies that this message comes from the game server so it might be failing that check
nothing shows up in cloud watch, I am unsure where to look for api gateway
Can anybody check this
Im still trying it but stuck...
unless you have the clients connecting to a dedicated server it wont work, unreal will spin up a dedicated server in the background and connect the clients to it
or do you have it setup as P2P
I have an host server bp when someone press host server button
and others are connecting with ip
Im sending the photos of it in a sec
When somebody click host server it open loading level with listen
then,
this in level blueprint happens,
you arent creating a session
ah ok
where is problem can be?
Im not exactly sure, i dont have experience with P2P, but I found this which is similar to what you are doing
π§π»βπGet the project files here on Patreon: https://www.patreon.com/posts/hosting-joining-66351331
In this video we take a look at how we can Host and Join multiplayer games using the Session nodes from the Default Online Subsystem integrated in Unreal Engine.
We also go over what an Online Subsystem is, and which different Online Subsystems ar...
should this listen be ?listen or smth?(nope it s true as video shows it like this)
That dude in video make it like me
with few differences, Im checking it
its session create is a bit different from mine
Yes, it seems he has the functions set up a little differently. maybe follow him
maybe if you watch his set up you can figure out whats going wrong, i dont think it matters much advanced vs regular session node
thank you, I think this is the problem, I should use find session instead of open level for joining
Thank you for help
π
how do you check for game package number/version for preventing multiplayer joining of different game versions?
does anyone have any info on having a user cross a threshhold and getting passed to another dedicated server?
like load balancing the actors data between two servers? ive seen it done for minecraft w/ zeromq
Is it completely valid to call game mode functions from a server spawned actor if its guarded with a HasAuth()? I'm struggling otherwise to see how a non locally owned actor can call and send info to the server
example
void AProjectile::OnOverlap(blahblahinfo)
{
if (HasAuthority())
{
foo* ptr = GetWorld()->GetAuthGameMode<foo>();
ptr->HurtActor(bkahbhlahinfo)
}
}
There are third party tools to help with multi-server setups, SpatialOS was one of them but I'm not sure if they still exist.....they're based in Ukraine I think
I once wrote a super simple version of this in Blueprints though, where walking into a portal in World A connected you to World B on another server, the address of which I could plug in on the server side of World A
But this wouldn't include any information sharing between servers, like WoW had where servers would share duplicated copies of actors on the margin between 2 servers
what really throws me off is like... how should i share the memory?
like
when i share the player location to the second server, should i just give it the vector location
or am i thinking about it wrong; is it about the player input and the current location of the actor
Does anyone know why when I set the number of players to 2 (to have 2 windows open) or more we can't see each other's character ?
Ping me if any answeer please π
Are you changing your play mode as well?
thanks
If I get your question correctly (and if I'm not wrong) you can't send information (calling RPC) to the server by using an actor that you don't own, as a client. You need to use one of the actors that you own (PlayerController, PlayerState, Character etc.) to send a server RPC and handle your logic there
@opal pulsar @upbeat basin since the overlap usually happens on everyone who has an instance of an actor, you are totally free to just limit the code to authority. The rpc part that Layso wrote is true though
If I execute console command "servertravel somemap" in a multiplayer game, will the new level still be listening (ie, other players can still join)
Yes
how do I stop the listening, so only the lobby players are the ones who can join?
You can't stop the listening itself. But you could update your session to not be advertised and joinable anymore.
Or if it's not about sessions you could kick the player when PostLogin calls and you aren't expecting them.
You can also pass ?MaxPlayers=
Along with your server travel and behind the = you pass in the number of lobby players, then other players would be denied due to server being full.
Ultimately I would solve this with keeping track of all the UniqueNetIds that were present in the lobby and then using PreLogin or Login to check if someone is allowed, otherwise return an ErrorMessage.
But PreLogin and Login require C++.
And the Session updating requires either C++ or a Plugin.
If you only do BPs, then your best bet is the MaxPlayers setting and/or handling new players in PostLogin in your GameMode. Not sure what you can use in Blueprints to identify them though
@deep coral
gotcha
really, what did you do to solve this?
Im trying to fix this rn
Also, this should be work right? I dont know if the problem is my bp
hello, i am back trying to understand why I don't see my player controller log message being printed in the dedicated server output. I see the player connect in, however before i tried connecting to a dedicated server i could always see the beginplay being called
GameSession class has IsAllowedToLogin or some such, called from PreLogin in GameMode, not sure if its blueptint native though
Probably, not near PC to check
just need to check, if i run "C:<YOUR INSTALL PATH>\Engine\Binaries\Win64\UnrealEditor.exe" "A:\MyProject\MyProject.uproject" -server -log what build is it running? it doesn't appear to be the development server
i put lots of debug log lines in and they don't appear
that sounds correct, unless you set a way to replicate then it won't
Would anyone know why all the clients can move fine, but the host cant? cant even look around, they can still see everyone else moving though
that is probably way too difficult for someone to answer, i would suggest looking into the movement code
Only using the third person example one. Was following kekdots multiplayer tutorial
i don't know that tutorial
i am trying to figure out which build of my code "C:<YOUR INSTALL PATH>\Engine\Binaries\Win64\UnrealEditor.exe" "A:\MyProject\MyProject.uproject" -server -log executes, because its not the development build as i thought, i've almost tried all
no worries. How can i call something only on the host and not the client?
Has authority node, or rpc call through an event
@torpid girder It certainly does execute "Development Server"
Try actually switching over your build target in VS in the top left instead of whatever "Quick build" may be.
right i've changed some log lines from error to warning, they should reflect if i quick build
ah, so i can't run a server and client on the same machine
i just saw i was breaking things
You definitely can unless you enabled something specific that disallows it. I just did it when I took that screenshot.
when i ran the server, it hooked into VS and i was able to hot reload it
not sure why it hooked in this time
sigh and i am still running the old binary
ah this is interesting, if you run "C:<YOUR INSTALL PATH>\Engine\Binaries\Win64\UnrealEditor.exe" "A:\MyProject\MyProject.uproject" -server -log from the project directory it connects to visual studio
hey can i change the speed of packets sent between client-server for the movement replication?
Hello, I have a question regarding rewards for players. In my TD game I have an event in my Gamemode thats called "RewardOnEnemyKill" which should give a base reward like gold to every player in the game. Each player has their own multipliers for gold gain based on a skill tree. Now I'm wondering where I should add this bonus to the reward. Should I add this "reward logic" to my Gamemode Event which just gets the bonus from the PlayerState? Or should I add this logic to the PlayerState and add a function AddReward that calculates the actual reward inside the PlayerState. But that would be some kind of reward logic and I'm not sure if I should keep this logic inside a PlayerState cause it should just be a data class. Does anyone have any tips or best practices for this?
i just used null subsystem to make p2p connection
hey can anyone explain me what is the different between MaxNetTickRate,
NetServerMaxTickRate,
LanServerMaxTickRate,
NetClientTickPerSecond,
MaxClientRate, and
MaxInternetClientRate
when i call rpc unreliable on event tick, does it will follow the tickrate speed or follow the game FPS speed?
afaik the network thread runs at a different frequency than the game thread so it is not guaranteed that calling an rpc on tick results in the rpcs actually being sent evenly at the same rate. But I'm not sure so better if somebody more knowledgeable confirms it
I'm going to be honest, the net tick rate limit code is the most confusing thing I've seen all day π€£
I know for sure that dedicated servers tick at the speed of: NetServerMaxTickRate
But I can not figure out for over 30 minutes now already what exactly limits or does not limit clients and also listen servers.
Hey all, I would like to know what would be the best way to handle a client - dedicated server scenario
-Client downloads chosen character through Chunkdownloader and sets it as its pawn
-Another client downloads a different character through chunkdownloader
-They both join the dedicated server
- Will they be able to see each other characters on the server map?
- I think, not, and i would have to have something on the server that send some asset/ chunk ID to the connected users and they would download the other users missing character..
-Or i am over complicating things?
Are you referring with "pawn" to an entire pawn class/blueprint or similar or a dynamically downloaded mesh? Big difference there.
Mesh sorry
Well.. I mean pawn would be more ideal, as they are currently in their own separate blueprints, but if mesh is easier than probably i would go down that route
Both clients will need to download both meshes, Unreal does not replicate entire dynamic downloaded meshes and thus the clients don't know what to load otherwise. So yes, you'll need to let the server know "Hey, I'm using mesh X" then the server accepts that (or denies if not owned or whatever?) and lets the other client know "Player Y is using mesh X! Go download that mesh and apply it afterwards."
If you want to use completely dynamic pawns the server now also needs to download them as it has to spawn the actual pawns.
Also do note that your collision should not be different with this per mesh otherwise the server still needs to download it just for the collision because you don't want clients running around with different collision on the server vs client. But that depends on what you exactly did I suppose.
The server will be packaged with all the list of possible pawns, and they should have the same collision as they are all technically the same characters with different meshes
But yeah, sadly i am not really expert on the topic and I only recently started to use ChunkDownloader
I don't really see why you're dynamically downloading meshes then though? Unless you have a set of certain pawns that can have an infinite amount of different meshes created by others or something?
Or is it something like DLC content?
Hmm something like that Thom, because the idea is that after user logged in, they will receive a chunkID and based on that ID they download their character through ChunkDownloader. Then they join the Servermap, server will know about all these characters. But I am wondering how another client who will join the server with character model A will know about the other user's character model B vice versa.
Sorry if my explanation is not clear.
If you set a replicated variable on the server side pawn with which mesh was selected by the corresponding client then a new joining client will receive that and can also start loading the mesh.
Can you please explain what do you mean by server side pawn?
As in the pawn that exists on the dedicated server.
And if I would try to download different pawns? Would that be a completely different topic? Thanks for your help so far.
I must say that goes beyond me, I donβt know if the server can properly replicate a pawn that the client needs to still download.
Maybe by spawning it locally and trying to make it net addressable, but not sure honestly.
Are these majorly differing pawns, or are we talking cosmetic modifications like Fortnite skins?
We can say like Fortnite skins.
Right, much appreciated for your input anyway.
Would strongly recommend not doing anything outside of Unreal's normal networking. Lyra does this at least by replicating Character Parts through a fast array.
Creates own network protocol with custom dedicated server written in NodeJS >:D
Right, cheers Authaer i wil check out that sample project, in the end I will probably stick to just replacing meshes then. That seems like a more stable approach.
If memory serves, they just do a FastArray, and each one contains a pointer to a ChildActorComponent. I know the stigma around them, but it's actually a pretty decent approach. Even the character's Manny/Quinn mesh is one of these.
The last time I used child actors my project didn't work in a packaged build any more lol.
I mean to be fair you can do the same thing yourself with normal attached actors. But I assume if they're using it in Lyra, possibly in Fortnite, they've probably fixed some bugs on them.
Could be, this was back in 4.26 or so I think.
So it has definitely been a while π
Cedric is about to either ask the most complicated question of the day or about to correct someone who was wrong π
Has anyone solved a setup like this before?
A "main" Character that is representing a Player, so if it dies it would count as actual Death (Score wise).
And a "remote-controlled" Character that the Player can temporarily control while the main Character stands still.
And handling that main Character being affected by things and even dying while controlling a different Character.
The issue is that I need to possess the other Character, but I still need the main Character to be handled as being controlled.
If I don't do anything, then the main Character will be unpossessed, and possibly counting as SimulatedProxy for the Player (even locally).
wow Thom, wow
Hope you can answer this for being such a nice person
It was not meant to be rude, sorry if that come over like that π
All good :P
I struggle with this, cause I have GameplayAbilities that are set to predict to execute locally first.
But if the main Character is not possessed then those will fail the NetRole check.
I could possess it with an AIController in the meantime, then it would probably execute the GameplayAbility on the Server.
But then it would nuke the Controller and PlayerState pointers
And killing it would not count as a Death to that Player anymore
What exactly would be the problem with temporarily nuking the pointers though? Worst case you just keep a weak reference to the appropriate controller I guess. But trying to truly posses two pawns at once seems like a nightmare.
Could just implement a getter for both the player state and controller that first checks if there's no 'override' and otherwise just grabs the actual owner etc.
A random other thought would be to perhaps spawn two player controllers with the same owner? I don't know how well that works, but in theory it's pretty much what splitscreen does.
Wonder if you could override the player pawn's Unpossessed, and not change ownership or controller, or playerstate? Wondering what would happen if you just left those as is while possessing the other pawn. Have not tried.
Why I didn't want to suggest that is because there are internal references to both from each other, player controller references pawn while vice versa is also the case. Then you need to also fix up those links which I'm not sure is as great either.
I'm also a bit hesitant on those wrapper getters cause we already have a big project with tons of calls to the native getcontroller/getplayerstate functions
hey devs , asap question , i got float variable and passing it trough Client RPC but when rpc runs passed value is got reset , as you can see on scneeshots before to send in to the RPC its 130 but after it reached RPC its 0 , any ideas why ?
Can you progress one step further so the break is on the cast node and see if the float value changes?
Also you are calling a CLIENT RPC on the GameState
That will not work
GameState can only process MULTICAST RPCs and only on the Server (by definition of Multicasts)
CLIENT RPCs require the Actor to be owned by a specific Client
Which GameState is not
oh okay , by the way are u the guy who wrote Network Compedium ?
Yes
wow, it teached me a lot , awesome article ππ»
(: glad it helped
You can override the PreLogin in gamemode if you just want to print it or something, but I don't see any exposed BP functions that allow you to access it.
Hello, if I'm trying to handle rewards for players in a multiplayer game in the Gamemode BP by giving every player a base reward, but that reward gets multiplied by an individual multiplier for each player, should I do the multiplication inside the Gamemode as well? Or should I do that in the PlayerState where I have the actual currency variable and the multiplier?
Like this...
Calculating the actual reward in the Gamemode and only saving/adding the correct value to PlayerState
Or maby like this...
Calling a function from PlayerState that takes in the base value and calculates/saves on its own
Second option would have "logic" in the PlayerState. Not sure if thats ok or if i should just keep this in the Gamemode
It's odd that each player gets a different multiplier.
But generally speaking I would keep all of this in the game mode. Should be part of the calculate function.
Hi guys,
I have been working on Linux dedicated server size optimization but I tried to exclude debug files and pakbaklist to remove unsed content gng into server build. But still the generated build is 120MB. How can I reduce it ? Engine Binary files are taking about 110 MB how can I optimize the memory here
It's gonna be a coop game where each player has its own level and skilltree independent from the current match that is being played. This will give bonuses to the currency gained as well. That is why they will have different multipliers depending on their skill tree
Alright I will try to keep it inside the Gamemode then. Thanks for your input @kindred widget
Guys I have one question i have stored values here in player state when I open my game etc but when I join session all these things are getting like removed and I dont have it there anymore how I can restore them?after joining session
and I cant use seamless travel as it is just joining session from online menu not from server to server
I have easy login where I put for example Kamil Kamil it will log me save name there + team etc and then I hit play it will join session and its empty
If you dont use seamless travel your playerstate is lost between levels i think
You could use the GameInstance to save whatever you need to persist between level changes
i cant use seamless travel because its not moving between levels I am on server after joining session not before
Login (offline)->Menu(offline)-Here is data lost->play(online)
Well then you can still use the GameInstance to store the info you need and then read them whenever you have that transition
I am doing login via varest
but cant that player hack in multiplayer game somehow?
and change it
As the GameInstance exists for each client: yes they could
so then I cant make it like this π¦ I cant store anything in game instance
If you're going to store data like teams on the client side then you should change your approach regardless if you care about cheaters.
its there because in player state id didnt persist
anyways client have also access to player state
so how then
Having access to some data versus being able to store that data on the client and expect it to be used again is a totally different story. If you don't want clients to be able to cheat you will want to keep the data on the server. You can for example get their unique id and store data along with that in the server game instance or as a file somewhere to persist throughout game restarts.
so if I store something in player state? then me as player cant access it ? because I can access it from server and client too
then what is game instance good for
if i take case that client can cast to playerstate then also can hack it
The player state is shared across all clients correct. The game instance was an example as it persists throughout the entire lifecycle of a game, if you change the level it still exists.
i know
but then its not usable for MP
- also if I just store value in player state and have variable lets say TEAM there and dont multicast it then its stored only locally for client not for server than obviously I can hack it no?
But what's the point of storing a team locally in the player state if you're not doing anything with it on the server? Also you can very much use the game instance in multiplayer, just because it can't make network calls it self doesn't mean it's not useful and again it was an example as you were asking for ways to store data for longer than a single level.
sorry if I am talking shits just want clarify it
ik i can use game instance I just want use it in right way and store there informations which can players change seems not okay same like store damage which can cause player in his blueprint propably not right
so all things which I want to be not editable by player should be stored in player state yea?
also then what if I have pawn which is AI and it has variables these should be in playerstate too? but it doesnt have playerstate as its only AI pawn
That's not what I'm saying whatsoever. Like I said, if you want something to be away from the client you should keep it server side. You can share the data with them through the player state, that's completely fine. But don't store the data on the clients side and then have them later on send that to the server as that will allow for cheats. You would instead persist that data on the server through 'something' capable of doing that and then when needed use that data that the server stored again so it doesn't have to come from the client.
The golden rule in terms of cheating is very simple:
If a client can send over the data then that specific data can be manipulated by someone. Don't ever just assume it's safe. Unreal does do some validation with certain stuff already, but by far not everything.
okay and my last question
How I know client cant access player state variables and change it
IF
I have stored things there
and I am for example not multicasting their storage
It can't. A client can not magically change variables in the player state on the server. It will have to make a request to the server with "I want to change this data" which can only be done if either Unreal provides a way for it or if you make a way your self. If you do provide a way and don't properly deal with that request or can't properly deal with it then it becomes an issue.
also if I understand right till variable is not set replicated server doesnt know about it,/not sure if I have also use set via multicast to store it on server
A multicast can only be called from the server. So at that point you're already on the server.
ok lets say RPC
hm I have mess in it
in singleplayer games you also have playerstate but there is no server it means then there you can hack those data?
You can't possibly protect data in singleplayer, correct.
Singleplayer games happen on someone's device, you do not control that device. If someone wants to do something to their game they can do so because nothing stops them from doing so.
Unless it's like stadia and played remotely. Do not be stadia.
And that's exactly why cheats exist in multiplayer games, you do not control the device people play on. If you make a RPC from client -> server that allows someone to change their nickname as an example then they could in theory change their name to whatever they want it to be because they own the device where that data comes from. A regular user won't do this, but a cheater could if they wanted to.
That's why like I said you keep data on the server that you don't want clients to be able to change. They can't magically manipulate server side data.
but imagine my situation till I Join session (arena) my game is offline and all things are in player state /stored then I want persist that data to my session yes? but if you saying in singleplayer I can change data then someone before joining game can change his TEAM or name in player state (possibly hack game) and after joining game he will have another name + team
SO how to protect from this?
You don't. The moment it's offline they can do everything to it they want to. You can't expect that data to not be changed if a cheater wants to.
hey, i implemented multiplayer and i want to simply send a message to all players OnLoginPost. The problem is that it gets only called server side i created a custom event that is replicated multicast and then print something but i just prints for the server does anyone have an idea how to solve it
You have to multicast from an actor that is replicated to clients
Are you doing this from within the game mode or calling it somewhere else? The game mode has no network capacity it self.
so then there is no way how to protect from cheaters well...
i am lost
so what i did is i added the OnPostLogin event inside my gamemode and then i created a multicast function inside my gamestate is that correct=
?
If you expect to import data from single player then there's indeed no way to prevent cheaters. @real ridge
Hello! Apologies for interrupting, I have what's likely a bit of a scrubby question, but hopefully quite quick to answer. I know that OnRep functions will let clients know when one of my properties is replicated down to them. Is there way to get an OnRep for transform-related stuff? Like an OnRep for my clients when they receive a new actor location?
The only way is to heavily validate imported data.
its my only way because all my login, lobby stuff works on websockets and varest
so till i join session
i am "offline"
E.g. you check if osmebody says they have 2000000 rounds for their pistol, you ban them.
That still allows cheats, you can't guess how that data should be valid or not. You can validate it to the point in a state you expect it to be, but you can never fully make it cheat proof π
this is too hard theme
hah
but thanks for talk
I am more confused as I was
:DDDDDDDDDDDDDDDDD
@real ridge TL;DR there's no way to prevent people from changing data that comes from a singleplayer/offline mode and is then sent to a server.
There just simply isn't a solution to that.
If you want it to be cheat proof, don't send the data from the client to the server, if that's not an option then you'll have to live with that being an option to cheat.
Aye. Sadly!
Well banning is probably a bit ott. Mistakes can happen with data.
Which is exactly my point, you can't know what is valid data or not. Maybe a new player has 500 coins to name an example, but perhaps someone that played the game for years has 50.000.000 coins mean while. If you "guess" it could only have been 20.000.000 and ban them for it then you're getting rid of innocent players which is why it's just really bad to do that.
Also speaking of security stuff, does anyone know if Unreal checks for NaN/infinite floats/doubles?
I'm kind of guessing it doesn't right?
It does in dev, not in shipping, I think.
π€
It's checked in TVector somewhere, I think, if you want to check the conditions.
Thanks, will take a look in a bit π
Utility to check if there are any non-finite values (NaN or Inf) in this vector.
I would doubt there's any implicit checking for NaN/inf for RPCs/replicated values
There's checking when it converts between types. vector to rotator etc
#if ENABLE_NAN_DIAGNOSTIC || (DO_CHECK && !UE_BUILD_SHIPPING) with these conditions
And when those types are assigned/created
It's basically everywhere.
That one feels to be more related to debugging though.
Where should I create my widgets? I wired myself to the begin play of a custom HUD class but I am getting an error that Blueprint Runtime Error: "Accessed None trying to read property CallFunc_Create_ReturnValue". Node: Add to Player Screen Graph: EventGraph Function: Execute Ubergraph HUD Ready System Blueprint: HUD_ReadySystem (only happening on dedicated server, listen server doesn't error)
Where should I create my widget and append to screen? π€
Yeah that's happening b/c dedicated servers don't have widgets iirc
but they do have HUDs? π
I guess so.
I don't remember exactly, tho
What you can do is checking if it is locally controlled
A lazy solution though
Yeeeep, dedicated server has a HUD π
well, locally controlled should be okay π€
Even though the HUD is named, well, HUD, it's still an Actor, you know. I mean, you may find some utility on replicating stuff there. (Never was the case for me I may point out)
server is returning true π
server as in dedicated or listen
dedicated
When you say 'dedicated', what exactly are you talking about?
That's not a dedicated server if you can see the message.
Yes
If this is what your NetMode looks like, you're not running on a dedicated server
ohhhh π€
Honestly "as client" is confusing as heck because it does run a dedicated server if you go standalone.
(Though I see no other way to do that lol)
(I mean, not the naming thing, but not spawning a dedicated server when two instances are clients)
You can launch a dedicated server through the command line from the uproject.
Oh like that. Well sure, but that it's different when not running standalone is weird.
100%
ok, but then what can I use to ask "does this thing has a screen?" π€
Though isn't this "dedicated server" lifted by standalone game a listen server simulation?
Now we gotta step back a little I guess
Because this got invalidated
If you can see the message being printed it's a listen server because dedicated would not show that message as far as I know as it needs to be a separate process.
But I'm not 100% sure, but it makes absolutely no sense to not be a listen server.
π
IsLocalPlayerController && !IsServer maybe lol?
That in case you want to simulate a dedicated server
You don't want to ignore the listen server though because then that one has no UI.
What's weird though - is your HUD marked as Replicates?
I guess he was developing it as if it was a dedicated server so it does not matter
hud never replicates, it can't. 300% sure of that
Ideally though - if you're aiming a dedicated server, you should setup things right
Yes that's what I expected but you can make it replicate since it's an Actor afaik
That's why this makes no sense in the first place because HUDs indeed don't spawn on dedicated servers. Don't ask me how they spawn on listen servers though as they use GetNetMode() == NM_Client.
Don't ask me how they spawn on listen servers though as they use GetNetMode() == NM_Client.
Is this legit? π
If that's legit, unless the server instance is a client itself - which I'm quite sure it's not - I mean, I find myself clueless.
The server is not a client, I can pretty much tell you that.
But once again, they weren't running as a dedicated server. That's the whole problem with this.
That's what I expect otherwise my GetNetMode() == NM_Client would all be broken.
It's controversial then
if ( GetNetMode() == NM_Client )
{
SpawnDefaultHUD();
}
@frank birch are you spawning a hud yourself?
Or just replacing the default one?
I got a very weird issue :
I'm overriding OnBecameViewTarget in my character
this character calls a function which, at some point, checks if the player is locally viewed
When the player first becomes the view target, IsLocallyViewed returns true if the player is playing offline or is the host
however, if the player is a client, OnBecameViewTarget gets called twice for some reason, and both times IsLocallyViewed returns false
Checking IsLocallyViewed after that returns the correct value however
IsLocallyControlled is always correct regardless of if it's checked on the host or client though
oh, you gonna love this
(Play as Listen Server and Play as Standalone returns false, Play as Client returns true π )
I mean, @twilit radish, this is weird. Because this is broken as well. In "p2p" sessions I'd expect my server PC to have a default HUD.
nope, just setting it as default in my GM
I guess we were wrong then π
Play as Client is meant to be a Dedicated Server environment.
One can argue that it might not be a separate process, but code and branch and whatever wise this is a dedicated server
And print strings are very much visible in client windows in pie when printing on servers
Even draw debug 3d stuff is visible cause epic multicasts those
With a listen server yes. But you can't possibly run a dedicated process inside a client as that's not a dedicated server?
That's just a listen server π€·ββοΈ
I think the process is at the editor?
Regardless of that
Play as Client is not a Listenserver
.
But then... why is my "not-so-dedicated-server" spawning a HUD object? π€
Now this is where the real question is lol
Also
For the ListenServer HUD question
The line you looked at with the NetMode
Is not what spawns the HUD for the ListenServer
Not sure if that was clear
I was meanwhile also looking at where it could spawn specific for a listen server, but I didn't find anything so far. Where does that happen?
void AGameModeBase::GenericPlayerInitialization(AController* C)
{
APlayerController* PC = Cast<APlayerController>(C);
if (PC != nullptr)
{
InitializeHUDForPlayer(PC);
void AGameModeBase::InitializeHUDForPlayer_Implementation(APlayerController* NewPlayer)
{
// Tell client what HUD class to use
NewPlayer->ClientSetHUD(HUDClass);
}
void APlayerController::ClientSetHUD_Implementation(TSubclassOf<AHUD> NewHUDClass)
{
if ( MyHUD != NULL )
{
MyHUD->Destroy();
MyHUD = NULL;
}
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = GetInstigator();
SpawnInfo.ObjectFlags |= RF_Transient; // We never want to save HUDs into a map
MyHUD = GetWorld()->SpawnActor<AHUD>(NewHUDClass, SpawnInfo );
}
That's also the function I usually use to spawn my UMG HUD
Cause BeginPlay can't be reliably used
Also you should have noticed that SpawnDefaultHUD is not the correct function, as that has no idea what Class you selected in the GameMode :P
/** Spawn a HUD (make sure that PlayerController always has valid HUD, even if ClientSetHUD() hasn't been called */
virtual void SpawnDefaultHUD();
That's mainly due to HUD having a shit ton of debug draw stuff in it I guess
Ok that's definitely my fault for not thinking that through π
I was like "spawnactor<Ahud>" - that probably checks out.
/** The editor will act as a Client. A server will be started for you behind the scenes to connect to. */ PIE_Client UMETA(DisplayName="Play As Client"),
why? π€
Cause it doesn't call if you ServerTravel from Map A to Map B and both use the same PlayerController class
Cause the PlayerController will just persist
In my defence Cedric, "suddenly" having ahud supposedly on a dedicated server definitely made me question "as client" lol.
ohhhh, riiiiight π°
with AGameMode that instead of "swapping" it somehow survives the old controller, right?
Always question the person trying to make you believe the DediServer has a HUD :D
This is true only if you use seamless travel - which is advised that you use it whenever possible
That's exactly what I did. And that's why I thought it wasn't a dedicated server. I did indeed not think of it being a player being spawned inside the game mode π€£
Fair, I forget "Seamless"
And both PC are the same class
And you are using AGameMode instead of AGameModeBase
(if I understand all I read this week correclty π
)
Pulls up Wizard's blog
exactly
I didn't mean it. I wasn't sure of it. And I let it explicit.
I am living on eXi's guide and the wizzard blog π
π
// Standalone requires no server, and ListenServer doesn't require a separate server.
const bool bNetModeRequiresSeparateServer = NetMode == EPlayNetMode::PIE_Client;
const bool bLaunchExtraServerAnyways = InRequestParams.EditorPlaySettings->bLaunchSeparateServer;
const bool bNeedsServer = bNetModeRequiresSeparateServer || bLaunchExtraServerAnyways;
// If they require a separate server we'll give the EditorEngine a chance to handle any additional prep-work.
if (bNeedsServer)
{
// Allow the engine to cancel the server request if needed.
FGameInstancePIEResult ServerPreCreateResult = PreCreatePIEServerInstance(
ErroredBlueprints.Num() > 0, false /*bStartInSpectorMode*/, PIEStartTime, true, PlayInEditorSessionInfo->NumOutstandingPIELogins);
if (!ServerPreCreateResult.IsSuccess())
{
// ToDo: This will skip client creation as well right now. Probably OK though.
UE_LOG(LogPlayLevel, Warning, TEXT("PlayInEditor Session Server failed Pre-Create and will not be started."));
return;
}
// If they don't want single process we launch the server as a separate process. If they do
// want single process, it will get handled below as part of client startup.
if (!bUserWantsSingleProcess)
{
const bool bIsDedicatedServer = true;
const bool bIsHost = true;
const int32 InstanceIndex = 0;
LaunchNewProcess(InRequestParams, InstanceIndex, EPlayNetMode::PIE_ListenServer, bIsDedicatedServer);
PlayInEditorSessionInfo->bServerWasLaunched = true;
}
}
Sneaky in the background then smh.
// Create the instance. This can end up creating separate processes if needed based on settings.
// This code is separated out of here so it can be re-used by the Late Join flow.
CreateNewPlayInEditorInstance(InRequestParams, bRunAsDedicated, LocalNetMode);
Also
// Fixed tick setting
if (InRequestParams.EditorPlaySettings->ServerFixedFPS > 0 && bInDedicatedInstance)
{
PieWorldContext.PIEFixedTickSeconds = 1.f / (float)InRequestParams.EditorPlaySettings->ServerFixedFPS;
}
Things you find..
Ew.
The server indeed had a HUD, so sue me. lol
But why on earth would you ever expect a dedicated server to have a player?! π€£
Nothing is ever going to make me even think about that someone may have spawned a player inside the game mode lol.
I think they aren't actually starting a Dedicated Server
The Editor is a Dedicated Server
Basically the PIE Session is marked as DedicatedServer and will then skip creating some things
Actually.. That makes a lot of sense.
And the Client is an additional window, same as if you play as a ListenServer
I was running Unreal Insights not too long ago and the editor was also considered part of that after I added the custom launch parameters.
rings
But where does come that from?
Wdym?
π€ who is doing that?
Honestly, I don't even want to think about it any more. My brain can't handle this x)
Argh lol
I still need to figure out my main Character + other Character issue.
I don't want to.
Multiplayer is so not fun if you have a Designer that actually doesn't want to create standard UT.
I'm postponing a really annoying scenario as well, here at Slackers since AM.
Ah, I have a TSoftClassPtr<xxx> in a UDeveloperSettings
When I boot the editor, it does not work first time (null reference) - but if I just go to the actual Project Settings menu and re-select the class I selected before and play it again, it works
π€
The thing you select
Is that in a different Module?
Cause I had that issue when I was referencing something from a different module, and the variable initialized before the module loaded so it couldn't find the asset
I mean, not really sure. It's just a class within my project.
I open my editor, this is how the settings look like. I click play. It doesn't work (nullptr)
For me it was a class coming from a plugin
If I just select None and put W_Cheats again, it works (not nullptr anymore)
Now that you asked, am really not sure
Oh, sorry yes
It loads with W_Cheats
Since it's Soft Class, are you loading it anywhere?
Now that you asked... probably not. Doh.
That would explain why it works after you actively select it
Which probably loads it
Is it safe to say that load on select happens syncrhonously?
I know I'm asking too much but just in case you know it from the top of your head...
I assume so
bool AUTRemoteRedeemer::DriverEnter(APawn* NewDriver)
{
if (Role != ROLE_Authority)
{
return false;
}
if (Driver != nullptr)
{
DriverLeave(true);
}
if (NewDriver != nullptr)
{
CurrentFuelTime = MaxFuelTime;
Driver = NewDriver;
AController* C = NewDriver->Controller;
if (C)
{
C->UnPossess();
NewDriver->SetOwner(this);
C->Possess(this);
AUTCharacter *UTChar = Cast<AUTCharacter>(NewDriver);
if (UTChar)
{
if (UTChar->GetVelocity().IsNearlyZero() && UTChar->UTCharacterMovement)
{
UTChar->UTCharacterMovement->AddDampedImpulse(FVector(0.f, 0.f, 4000.f), false);
}
UTChar->StartDriving(this);
UTChar->PlayerState = PlayerState;
}
DamageInstigator = C;
}
}
return true;
}
Also, I'm disappointed
They do the same thing I do
But they don't have GAS back in UT times
sigh
Maybe I just have to check if the Character is possessed or not and based on that change the Prediction Enum on the GA
Or just have a Child for non-possessed Actors
AController* C = NewDriver->Controller;
if (C)
Also please don't do that
Freaking C
C lmao
neat
Hello! Apologies for reposting, I have what's likely a bit of a scrubby question, but hopefully quite quick to answer. I know that OnRep functions will let clients know when one of my properties is replicated down to them. Is there way to get an OnRep for transform-related stuff? Like an OnRep for my clients when they receive a new actor location? Thank you!
Nevermind, that was totally not what it was supposed to be π
Let's say I have Player A running a listen server and Player B connected to the server
If player B triggers a level streaming volume, will Player A also load the streaming level that player B just triggered? Or do I need to add some extra code to tell the player A to load the level.
The reason I need player A to load the level is because he needs to have the collision information loaded for the streamed Level or else player B will fall through the world.
Is this all done automatically in ue4.27? Or do I have to add extra code to handle this?
I believe the intended framework would be for you to load all the levels on the server, probably at all times
Or maybe try to do it simultaneously
Ah I see..
But no I don't think any of that is done automatically for you
So have the listen server load all sublevels
And the client will just load the sublevels when he triggers them
Yeah if your server memory can handle it then do it that way
Also has rendering implications on the server
Which makes me wonder if you can load a level without making it visible, but the collision is still there
Yes the listen server would have to have a lot of memory or somehow I can figure out how to only load collision
To properly answer. There are several methods you can override within C++ from the actor:
/** ReplicatedMovement struct replication event */
UFUNCTION()
virtual void OnRep_ReplicatedMovement();
/** Update location and rotation from ReplicatedMovement. Not called for simulated physics! */
virtual void PostNetReceiveLocationAndRotation();
/** Update velocity - typically from ReplicatedMovement, not called for simulated physics! */
virtual void PostNetReceiveVelocity(const FVector& NewVelocity);
/** Update and smooth simulated physic state, replaces PostNetReceiveLocation() and PostNetReceiveVelocity() */
virtual void PostNetReceivePhysicState();
```Note that if you use the OnRep you need to check if it's actually replicating movement as apparently there's something whacky about that according to some comments inside of it.
I tend to just turn on client authoritative movement, so I can just do whatever I want on the client and the server just trusts, nobody has bothered to hack my games yet
But that's partially because I never released them
Ah that's great, precisely what I was looking for, thank you! I'm basically hoping to use this to have the client lerp to the new position to help reduce jittering. Hopefully that's a sensible way of doing it! Hopefully. Either wya, that's really ujseful to know, thank you!
And hah, that was to be my last resort, just trying to build in some good habits
You're making your own movement system
Tbh the default actor position replication system is not great. So no, not really.
If we're talking characters then yes, you're reinventing the wheel.
I am not, really, that's a project for the future for sure. Gosh I sure would love to just use the Character Movement Component but it's not suitable so I'm doing some terrible terrible things to navigate around it. It's just for a small project so it's not a big deal
Since my pawn is wider and broader than it is tall, the blasted capsule restriction is the only thing stopping me from using the CMC, alas
If there's a way around that with the CMC I would super love to know! But I think there isn't, unfortunately! If I could just use a fat capsule, that'd be great, ahaha.
Without modifying the engine source code no.
It's definitely annoying that it doesn't easily allow this though.
It's super annoying! I wonder if it would break if I went into whatever source code prevented the capsule's half-height form being smaller than the radius.
Something to try later perhaps, I don't need it to be super amazing quality right now. I find it super weird that, out of the box, there's no convenient way of having clean networked movement if you don't want a standard capsule collider.
Thanks for the help, though! Much appreciated.
What's the difference between using a "has authority" node and putting your code on server side with a custom event server sided ?
HasAuthority will only run if you're already on the server.
A server side event will only be triggered from the server or be sent to the server if run on a client-owned actor.
Hello I have a question about a weird issue that I have,
I'm running some testing into a Listen client server that is running 2 clients and the server.
The issue I have is that some clients dont even spawn sometimes, they stay "stuck" and dont possess / spawn a pawn, my code has been working since beggining of my project and never got changed
then I don't see what it's purpose as if you're already on the server you don't need a node to tell you that you're on the server again π€
moving the spawn looks to be making it a bit better, but verry not a real a solution
LogNet: Error: ReceivedRPC: ReceivePropertiesForRPC - Mismatch read. Function: ChooseCharacter_Server
could this mean the client code and the server code are out of sync?
question time... my player's characters DO replicate their rotation, but not their position. For example, if I execute the Jump command server-sided, neither client sees it happen.. I'm guessing I'm missing a setting somewhere?
The point is you might not know you're already on the server.
That's why you have to ask.
Obviously if it's run on a server-only object, like game mode, it will always be true, but there are many, many circumstances where you have to check.
So for instance, does this code need to be on the server ?
I don't know. Maybe? Depends on your game.
Hello people
I have a zone where the player needs to overlap it between 2 hours and if it's the case validate his task (boolean set to true)
I will tell you, that code will run on the server and every client. It will be executed locally on all of them.
Just do it on the client as well. You can always validate if you're in the right zone when you tell the server you're doing things.
so I leave my code like it is ? π€
if you wanna be save and understand what's going on, I'd suggest server-side that bit of code
that way all related code will only be done server-sided and therefore at least always be identical for everyone
Like so ?
Yeah, just make sure when you do whatevre you need to do, you check it on the server too.
if your server has authority over this object? yeah
If someone joins mid game will he receive the right state of the "IsEnabled" boolean ? Or should that boolean be a repnotify ?
All replicated variables have their current state as seen by the Server passed down to connecting Clients.
RepNotify is just a function that triggers when the value of that variable changes via replication.
Any ideas for my issues ? π€
variables shoud always be replicated from server-side to clients by enabling the variable's replication (as well as the actor's replication boolean). Ah, DevilsD was faster ^^
@serene furnace I would recommend you check the logs, perhaps something in the map moved and blocks a spawn. Usually the engine will notify you of why a pawn can't spawn or similarly will tell you if something is wrong π
novice question, when your dedicated server creates a session and you give it a name, should it be unique?
the examples are hardcoded text
Well I could not reproduce the bug with logs unabled x)
I will check that out and post again if it happens again ^^
Heyo, is there any resource/guide/best practice for non-exploitable, client-predictable, RNG in multiplayer? Something like how auto-attack crits might be dealt with in a MOBA (all clients can predict the crit happening, but still server authoritative).
Im using this for multiplayer connections but it isnt working, Im using spacewar appid with developer build, not shipping
What can be the problem?
Hello! Sorry to pop up here again, weird question just in case anyone might have experienced this before. I have replicated movement working fine hip hip hurray, for now it's on a Listen-Server. The only issue is that, for some reason, the listen-server client's pawn moves incredibly slowly. i'm setting it using AddMovementInput in server-only RPC, and noticing tht it considers its velocity to always be zero, so something is causing it to reset back to zero again. Using 2 clients, the other one works absolutely fine. It also works fine if I switch to a dedicated server, which I may just end up doing.
Don't worry, this code doesn't have to be super pro and shippable, it's just my own messing around, but I'd love to know what's going on as I seem to have exhausted my leads. Any help would be great, thank you!
Hello, all. How would I uniquely identify a newly-connected PlayerController? I want to spawn in my players when they connect, but only onto PlayerStarts that have not already been assigned to other players. However, there doesn't seem to be a way to assign PlayerStarts without custom code and no way to identify PlayerControllers relative to the others in the server (such as "this is Player1 (who is also hosting), and this is Player2 (a remote client), and so on") such that I can easily spawn them where the they need to be when the game starts. Is there some functionality I am missing or is there a canonical way to do this?
There is a function that is responsible for choosing a playerstart..i think on gamemode? I think you would have to track which have been used with by holding onto an array of the used ones or something...but it's a pretty common thing, you might spawn a team near each other or have different sets of player starts for different modes.
You should be able to use hasauthority to tell the difference between the listen server and remote clients.
GameMode::ChoosePlayerStart is the method responsible, but it has no simple way of looking at the incoming PlayerController and relating "this is the 2nd player, they should be spawned at the PlayerStart with the tag P2".
Seems like the answer is "custom code and lots of loops"
You would assign the incoming player controller the identifier that you wish during OnPostLogin. You'd then override ChoosePlayerStart and read your custom player controller and read the identifier you've assigned.
It can be pretty easily done from the HandleNewStartingPlayer event in your game mode. From there you would have a variable called PlayerCount or something similar. Check if the player count is even, then assign it the appropriate spawn location.
Oh and then obviously increment the player count variable
I have some glaring issues; this is PIE as a client without any artificial latency and have 100ms ping, and then the concerning ActorChan_FindOrCreateRep count. I could use some advice on where to start with debugging this to find the culprit(s)
Ok, thanks this is what I am building towards, just wanted to make sure I wasn't missing any obvious mechanisms (has happened A LOT)
Yeah definitely. What I said about checking if the count was even is only really applicable for a team game. If you wanted to have all the players spawn at different locations you could in your game mode construction script get all actors of class for your player spawn, then tell each new player to spawn at the player spawn index that is equal to the player count.
are you using a character movement component? if thatβs the case, you donβt need to set up server events at all - if you replicate movement all of this is already programmed into the component.
why if i turn on simulate physics for the character mesh (replicated component), it collapses like a ragdoll on the server how i want, but on the clients the character collapses like a stiff wooden plank? i dont need to sync the physics but just make the ragdoll happen on all clients...
You should have some sort of RepNotify Variable that toggles this
Replicating the Component doesn't mean the Physics Boolean automatically replicates
Would anyone have a chance to help me resolve an issue. When i start a game, the clients can move / look around, but the host cant. He can still see the other players moving around but its as if he has no input at all
That is on the player controller
and that is on the game mode
Why the RPC though
Wouldn't it make more sense to just limit BeginPlay to Authority and then directly talking to the GameMode?
Also the GameMode already has a lot of good overridable functions to handle customizing the spawning of characters. If all you want is automatically spawn a character at a location for a player then there is no need to do it manually
For the "no input" part. Are you setting InputMode anywhere?
Are you sure your Server properly set Game only input mode?
@hollow swallow
Hey mate, i am really new to unreal, this is my first project. I have done it this way from a video tutorial series i am following. I have checked all the blueprints and they all seem to match up. How can i check that the server is set to game only input mode?
just using the listen server in the project at the moment
i tried adding set input mode game only after the possess. still no difference
Always annoying when video tutorials teach random stuff like that
Your server gets a character though, right?
Are any of the inputs for the server character triggering?
You could try disabling your spawn code and just setting your character as default pawn in your gamemode defaults
To check if it's your spawn code or not
@hollow swallow
Yeah the character is spawning in. No input seems to be triggering for him though. ill try that now
Yep that works fine
and im 99% sure my code is identical to the tutorial (which is only 5 months old if that matters?) and it works fine on his
thats a screenshot from the video of his one
Man this is such a redundant thing to set up
GameMode has override functions for retuning a spawn point for the default pawn to spawn at
The transform returning node there is not really needed here.
But anyway, let's have a look at the code
What about the Default pawn you set in the Gamemode, was that empty before? Is it empty in the tutorial?
Is there any character in the scene already before pressing play?
Can you also try to change your PlayerController code to use
BeginPlay -> SwitchHasAuthority -(Authority)> GetGameMode -> Cast -> SpawnPlayer
?
So basically cutting out the rpc
@hollow swallow
yeah im not sure, as i said this is my first unreal project so still pretty noob xD default pawn class is set to none in the game mode and in world settings, same as the video. There is no character in the scene only the player start locations. i will try changing the player controller now, 2 secs
That also doesnt work, same issue
Does anyone know why my timer doesn't the clients but works for the server even if the timer is a component inside my Game State and started by the GameMode
Iβm trying to wrap my head around network optimization. Iβm a bit confused about the relationship between network performance and CPU performance. Suppose an actor has a net update frequency of 100, when 10 would be enough. This is putting unnecessary stress on the network, but is it also having a negative impact on the CPU?
CPU has to serialize/deserialize messages etc. Also, for example if an actor enters relevancy range, it has to be created for that client, which also has a CPU cost
Itβs not necessarily bad for the network to have a high update frequency (but definitely could be), Unreal will simply prioritize that actor more and may thus check more often if anything like the replicated variables changed. It does not send out random network data if it doesnβt have to. But why this becomes a CPU waste is because youβre now constantly checking that actor while if it as an example only has a few variables that donβt change often itβs unlikely to send any data over the network. Hence why you need to consider what priority you want actors to have.
Bumping I s'pose. Anyone have an answer to this? Something messed up with my netcode making it inflate latency even in PIE
I guess you already explained the reason yourself. I'm assuming you're calling the StartTime event, which is not an RPC so will only work where the event is called, from the GameMode, which only exists on the server. So you're just calling a function on a server, which is setting a timer on the server. Making the StartTimer multicast might be what you're trying/wanting to do
Today I was ranting because we are not able to have custom net update frequency for subobjects
Did you make sure the emulation settings are not accidentally turned on in the editor? Also are you sure itβs constantly the case and not just a lag spike where it went to 100ms for a bit and then down again as it shows as βmaxβ?
I got angry so much that I wanted to modify the engine for that 
Haha yeah I did BP, project, and C++ wide searches for 'pkt' just to be safe, but I haven't used those for many years, I use clumsy for latency simulation
Its constantly the case
And its this one specific project, I tested others moments apart
Also it's a localhost connection ^^ there wont be spikes unless like you say, emulation settings are used; other projects are fine
I called a multicast function and just server executed it, as well as that when Client 1 picked up the weapon, Client 2 couldn't display the snap as Server. Why? How to solve? Help, plz... I spent all one day..
I called a multicast function and just server executed it, as well as that when Client 1 picked up the weapon, Client 2 couldn't display the snap as Server. Why? How to solve? Help, plz... I spent all one day..
The FindOrCreateRep is a hint but I don't know how to interpret that at all, I'd rather just know how to actually track it down instead of having to throw stuff at a wall and see what sticks
This doesn't work π€
GameServer doesn't replicate to clients. So RPC's and replicated variables are useless on GameMode I believe
So how / where to do the multicast ?
Inside your component, just make the SetupTimer event multicast, for your case
still doesn't work π€
Hello, inside a actor, I'm trying to enable inputs. The server can press the key but the client can't. even with a box, casting to the character and getting the player controller from it. I have 'No owning connection for actor' error
EDIT: I think I have to call afunction from the PC with a ref to this actor
I wonder if the client is missing the RPC due to later connection
This prints only on the server
I think so
Well you probably either need to setup the timer for the clients upon connection (PostLogin in GameMode can help) by sending them the current int Timer variable so they can continue from where the server left, or for me the simpler way is making the int Timer variable replicated and setting the the timer event only on the server
The Timer variable is already replicated in the GameState > Timer Component
I zoned out and forgot to ask my question...
I wanted to ask, is there a good reason to have your gameplay tick in the server and client locked to a particular time, say 16ms or 7ms?
It doesn't look like replicated from the first picture you sent, did you change it?
I realised I had 2 timer variables, 1 in the game state and 1 in the timer component, now I'm using the game state one all the time let me show you
This one should now sync the Timer value to all clients whenever they do connect as well as whenever it's changed
If you want broadcast hourly event then you can create OnRep function to check if modulo equals to 0 there
Works perfectly now, thank you so much π
hey devs , where i can save my data between maps ? So i got GM where players earns points , and after game ends it should send all players to the Main Menu where thay can see all earned points , where i can save it ?and what class or data i can use to identify user ? tried with GameInstance but didn;t worked
Why did GameInstance not worked? Are you sure you're setting the stats on the client's GameInstance and not to the server's?
yes you absolutely right , i have checked and the function which handles it only got called from server , Thanks !
Hello everyone!
I would like to ask a question about UserWidget and RPC (I am making an online game):
I made a PickUp ball, when I touch it, a button will be generated, and when the button is pressed, an event will be executed. However, for the client, this operation must use UFUNCTION (Client, Reliable). At this time, my client player can activate this button through the ball, but the event executed by my OnClicked cannot be informed by RPC to other players ( It's like I'm entertaining myself).I later added the UFUNCTION for Server and NetMulticast, but it didn't work.
I feel like the problem is related to the UserWidget, since I know the Actor has the bReplicates boolean, but the network replication of the UserWidget and the events its buttons control is getting me stuck.
Can someone help me? Thank you so much!π«‘
Hey, widgets are unable to do any networking calls them selves. They are client side only. The usual way to do things like this is to have for example a function in your player controller to do the networking.
π
Thank you for your answer, it seems that I have to find another way out, otherwise I will get deeper and deeper.π«‘
For C++ this should be it:
https://docs.unrealengine.com/4.26/en-US/API/Plugins/OnlineSubsystem/Interfaces/IOnlineSession/UpdateSession/
Cedric also has a great article on it:
https://cedric-neukirchen.net/2021/06/27/ue4-multiplayer-sessions-in-c/
For blueprints I'm not quite sure.
Updates the localized settings/properties for the session in question
This post shall give you a short introduction to handling your Multiplayer Sessions via your own C++ code. Most of you probably either started with...
can it be done through blueprints?
I don't see a blueprint node for it anywhere. There are for create, delete etc. but I don't see the same for update.
This is what seems to be the list: https://docs.unrealengine.com/4.27/en-US/BlueprintAPI/Online/Session/
Session
Cheers, ive started digging into advanced sessions now
Apologies, I was alseep when you replied! I'm not, I'm kind of doing something very cheeky and terrible using a floating pawn movement component.
But! Don't worry actually, I was running into enough new discrepancies on the listen server client that I decided to switch to a dedicated server model, as everything just works more consistently that way. Thank you though!
Hey hey, quick question, wasn't there some new features in 5.0/5.1 or planned features that allow conditional component replication?
i.e. only replicate a component to X player
I feel like i heard something about it recently but I don't remember
Using the Replicated SubObjects List This article was written by Alex K Currently, replicating components and subobjects relies on the virtual function AActor::ReplicateSubobjects. For actors with replicated subobjects, this function must be overridden, with actors needing to manually call ReplicateSubobject and ReplicateSubobjects on each of t...
Found it nevermind ^^
Hey guys, when moving to a new level my different player classes are set to the server's player class. I set the class in the main menu, set it in the gameinstance, and then I call the gameinstance in the player controller when spawning in:
Is there anything else I need to do in order for the clients to get the correct class when joining a session?
Bumping my question here, if anyone can take a stab at it
In general the server spawns the pawns / characters players posses. So I'm not quite sure why the clients would need access to that specific class? Normally the flow for spawning a player selected class looks something like:
- Player joins the server.
- Sends over what class they selected to the server.
- The server validates any necessary stuff and spawns in the player pawn and grabs the controller to posses the just spawned pawn.
From there on the pawn should replicate towards the client at some point and that should be it π
Setting the tick to a specific value is an optimization you can do to just have that actor/component tick less which in the end can save CPU time. Sometimes it makes sense to do that and other times it doesn't, you for example don't always need a perfect frame timing for something to happen.
I don't really mean in the sense of optimization though, I'm talking more about how they do it for the overwatch networking
I'm referencing a youtube video here https://www.youtube.com/watch?v=W3aieHjyNvw
In this 2017 GDC session, Blizzard's Timothy Ford explains how Overwatch uses the Entity Component System (ECS) architecture to create a rich variety of layered gameplay.
Register for GDC: https://ubm.io/2yWXW38
Join the GDC mailing list: http://www.gdconf.com/subscribe
Follow GDC on Twitter: https://twitter.com/Official_GDC
GDC talks cover...
It could be that I just misinterpreted it
In what part of the video is this being discussed?
I'm not quite sure what they are referring to honestly.
Seems to be somewhat related to their player movement code? But not sure π
It seems to me that they are simulating at a fixed rate
And interpolating between those simulation frames
guys what happen if i call rpc (run on server) unreliable on Event Tick if client has 120hz tick speed and server only has 60hz
Hi, this may sound silly - I'm new here. But is it possible to have a single server world in UE that can handle more than a thousand players? Without splitting into clusters? Of course if we have an extremely expensive and powerful server. How is it possible that WoW can handle 3000+ players, but I haven't seen it in UE yet?
Can I change UGameMapsSettings::TransitionMap during runtime? π€
should I? π€ π€ π€
Yes, GetMutableDefault<UGameMapsSettings>()->TransitionMap = ...
Don't see any reason you couldn't
If I wanted a dedicated server to quit after all players have left, where would I put this logic?
Gamemode's logout function
So I have an actor that needs spawning, and I have spawned it on Serverside, and this actor also is set to replicate. However it does not appear on the client side. Am I doing something wrong ?
UFUNCTION(Server, Reliable, WithValidation)
void Server_MoveForward(float AxisValue);```
```cpp
bool APlayerPawn::Server_MoveForward_Validate(float AxisValue)
{
return true;
}
//Movement
void APlayerPawn::Server_MoveForward_Implementation(float AxisValue)
{
//MovementDirection.X = FMath::Clamp(AxisValue, -1.0f, 1.0f);
if (Controller != nullptr && AxisValue != 0.f)
{
const FRotator Rotation(0.f, HeadCamera->GetComponentRotation().Yaw, 0.f);
const FVector NewLocation = GetActorLocation() + FRotationMatrix(Rotation).GetUnitAxis(EAxis::X) * AxisValue * MovementSpeed;
SetActorLocation(NewLocation);
UE_LOG(LogTemp, Warning, TEXT("%f"), AxisValue);
}
}```
All I did was this and it replicates the PlayerPawn movement to the server and the other clients. Why???? I thought I would have to check the location in GameStateBase class and send that to the clients or smth but do I not have to do it now or what? The client who is moving cant see itself moving tho so that is a problem
Do I update the clients locations from GameState to all of the clients? How do I do that I can't come up with anything to write into the Tick() of the GameState? Or do I make it in the gamastate at all
More coherent sentences recommend I would.
Umm... what do you mean?
I glanced over your paragraph twice, and can't quite figure out your situation. Less frantic typing a little more explanation on each point of your situation
look at this bp of a Player State
so, Increase Counter is just a variable++;, nothing to worry about.
The idea is that the user calls the RPC, that increases the variable locally (predicted kinda thingy) and then calls the SERVER procedure that actually increases the variable. When the server ticks and updates, we had the already increased value and we are happy...
HOWEVER, this would increase twice the value on Standalone and on Listen-Servers. Any tricks here? π€
Ok so...
I am trying to get all the clients to see each others movements.
Clients = Pawn classes
With only updating the movements from 1 client to the server (code above) it replicates it also to the other clients which is strange and I dont know why it even works when I thought I would have to update the player locations from server to the other clients separately.
Current problem is that the player who is moving can't see its own movement or any location change. So do I still want to update the location from server to all of the clients in GameState? Or what do I use?
How can the client not see his own movement, are you not using a standard possessed pawn using a controller?
And yes that was already a lot clearer and allows other to assist you. Thank you.
is it efficient to replicate TArrays?
What exactly should be included in a dedicated server build? For example it doesn't make sense to me that it should have login functions, widgets, etc
Client1 can only see Client2 moving and client2 can see client1. In the middle of the video there is the server. But in both of the clients screens they are standing still even when im controlling them
They are pawns who have been posessed normally
bReplicates = true;
bAlwaysRelevant = true;
AutoPossessPlayer = EAutoReceiveInput::Player0;
does this make sense?
Only call Increase Counter as a homebrew wacky prediction if I am not authority... right? π°
I want to prevent ListenServers and Standalones from Increase Counter twice π¬
I may be wrong about that, but I believe the server will have a CallStack and then execute the RPCs in order.
So supposing there's no data loss and no lag at all. In you example case, each Server Tick it would execute 2 RPCs received from the client.
You are sending too many RPCs, no advrrse effects except for extra cost
Server RPC called from listen server is just a normal function
RPC is not ran on server, SERVER is
The idea is to have some sort of prediction. So RPC increases locally (in good faith) and then calls SERVER who will correct you because it has the authority anyway
Server is an RPC
if I call only the SERVER function, I wouldn't see the value increase until after the network roundtrip
Your logic is wrong, though
please help me π°
If you already have authority, you don't need to run a server rpc. You're already on the srever.
Server doesn't mean "this runs on only on the server" it means "Send this function over the network to the server and run it there" (or run it locally if you're already on the server)
so far I follow.
Now, my logic is:
- machine wants to increase a value
If a computer is not the authority (remote): Increase locally and call the server to please increase it also.
If a computer is the authority (either I am the server or this is standalone), use the function to increase in server since I am server anyway
I would not do that.
I would do this:
I want to change thing:
- Am I the server? ** Change thing
- Am I remote? Ask server to change thing. Server validates that it's an acceptable change. Server changes thing (see **). Value is replicated back to the client (this is a setting on your variable, not a thing that you "do")
I understand, but on the Am I remote? path, I press a button and I have to wait for the roundtrip for the light to turn on (or whatever)
This isn't a delicated/cheat prone function, so I am safe to assume the user will be able to perform the change and I want to do it immediately
That is where client prediction comes in.
What you can do is assume that the server will say "yes, that's fine" and just change the variable.
But if the server doesn't change the variable for some reason, it has to tell the client that the change was unsuccessful. And the client still can't do anything with that change that the server may also have to rollback and fix.
Unless it's something very simple like turn a light on or off.
What you could do is make the light play a flickering animation until the server confirms it. That would work seamlessly.
The better and safer you try to make the user experience, the more complicated the code becomes.
Problem with your prediction method
Client predictively changes value and sends a server rpc
hey, umm
Server does its thing and says no
is there SUPPOSED to be desync happening in the default thirdperson multiplayer game?
As nothing changed on server, it wont correct client
Client now locked in invslid state
That's why you send the rpc back saying it was unsuccessful and the c linet changes it back.
It's not perfect. But it never can be.
If you search desync in here
ohhh, I thought that the server would overwrite the replicated variable on next replication tick thingy π€
Youll find people use it for literally hundreds of things
depends what you mean with desync, if you pushed that blue cube and its in a different location in server vs client, that's normal since its simulating physics
Variables aren't replicated if they don't change.
If the client changes them, the srever won't correct it until it sends new values.
Your question is equivalent to "hey guys how can i fix a bug?"
ya that's exactly what I mean
yep
wow.
And no
Physix is not deterministic
Same scenario, same machine, run it 20 times get 20 different results
I dont think theres any game engine out there with deterministic physics
so yea its pretty much expected
People try to do it.
yea theres ways to fake it
They just keep trying, bless their cotton socks.
Some made it work, with 8 physics objects total and cystom physics engine
Rocket League
yea I saw their talk
Ok, for what I need it now, (making UI change immediately and storing the value in the server) this is good enough π
I mean dark and darker has synced ragdolling
As long as your server never argues about the state of the light, it's fine, yeah.
Its more of a ragdoll that stays in sync most of the time
if it ever argues, I am going to implement the same as cpp does.
If you fail the validation you get a trip to kickedtown π€·ββοΈ
basically I think the idea is to simulate physics locally for a certain period, then at some point force a synced pose animation
the tricky part is knowing when to do it
but find the right time to force a synced animation pose + interping to location/rotation and that will be good enough
It makes sense now that I think about it if what I have in my head is accurate, that unless you use lockstep synchronization (don't update anything until everyone has the data causing a delay on everyones machine before the gamestate changes) then an object with physics being interacted with locally is going to be out of sync and all things that physics object interacts with will be out of sync as well until at the very least the data is sent to re-sync them in which case it will look like a teleportation for any fast moving objects
is that correct?
so how exactly does rocket league do it? Because I have a lot of hours on that game and ocassionally it will do something called a "ghost hit"
where someone hits the ball and you see the ball start to change momentum and then suddenly correct itself and snap back to its previous location as though it wasn't touched
usually when this happens all or most players see the "ghost hit"
the more I think about it the more I think it could be made to be deterministic unless 2 players are interacting with an object at the same time
@gray holly Rocket League swapped out their physics engine with a fixed timestamp one thatβs also deterministic. They basically predict whatever they can at that point as it will βjustβ work but still rollback positions if they get out of sync because of players bumping into each other as an example to keep authority.
Thereβs a cool GDC talk about it: https://youtu.be/ueEmiDM94IE?t=1413
In this 2018 GDC talk, Psyonix's Jared Cone takes viewers through an inside look at the specific game design decisions and implementation details that made the networked physics of Rocket League so successful.
This is probably one of the best and most difficult to develop networking models that I know
Hello there !
I have an actor in my scene, with a custom event set to 'multicast' so it executes both on server and client, which runs fine.
When I take this actor and instead of having the parent class 'actor', I put it as 'Chunk', which is a c++ derivated from class actor.
But when changing this parent class, the multi cast event won't fire on the client, only on the server, does anybody have an idea why ?
this is my class declaration : class MULTIPLAYERSERVER_API AChunk : public AActor
and I do set the replication in the declaration : Mesh->SetIsReplicated(true);
the actor is visible both on server and client though
it is better to use game mode and game state for mp than game mode base and game state base?
i just realized i have both base in my mp game
but its in c++
I am not using the game mode at all to do this
u dont have game mode in game? wtf π
I mean I have a game mode, but not transiting through it to get my multicast going π
How are you moving them?
@verbal tendon only with this (reply)
Hey, i have a problem im trying to run a custom event from a client it tries to call SetMaterialServer it replicated (run server only) und and multicast if i press k on the server it works but for the client it wont do anythink can someone help me
I see. Since you are using pawns, I would suggest using the appropriate moving component: PawnMovementComponent
I have no personal experience with that as I usually work with Characters for player controlled actors, but it should work
Replication design question: I'm brainstorming about how to replicate our units' combat for large unit counts. We do use GAS, but if we keep it will have to be modified so I'm trying to think a concept first:
Targeting will be server-only and replicated to clients. But once units are in range and start attacking, I am thinking several alternatives:
Attacks are very simple (shoot/wait until recharged, and repeat). So I could send an RPC each time an attack is launched, or maybe some boolean flag ("isInCombat") that serves as start/end point to the attack loop, which would be less bandwidth intensive, but harder to control in the future (for example, imagine that the unit activates a attack increase ability).
On the other hand, health is also calculated on the server and replicated to clients. I could add the new health together with the attack payload, but then I'd be RPCing state changes, where probably a replicated array serializer with health values would work best.
Another option would be to RPC the new health values, but only kill units after server sends a special death event.
Reducing bandwidth and CPU usage for replication is a concern given the scale of the game, all of the above would be sent in batches through RPCs or Array Serializers
No. You need a real actor. You have a choice of 3. Player state, controller and pawn/character.
You don't need to do that at all.
...and so what if you do have 15 ufunctions?
That's still a small pawn.
I'm not seeing how that is relevant.
Not possible.
I have no idea why your AInfo actor isn't just a pawn.
TIL if a client predicts an action an locally changes an OnRep value to the same as the servers then the OnRep wont run when its received loool 
Spent like 2 hours wondering what I was doing wrong
rep notify always 
Well that's inconvenient.
lol
I'm deferred spawning an actor and it's being routed through replication graph but it's ActorLocation is (0, 0, 0) despite having a valid transform set on the deferred spawn call. Any idea how I can get it to have the actor location I set at that time or do I just have to resign myself to updating it afterwards?
Are you calling finish spawn?
Yes but it hits RouteAddNetworkActorToNodes immediately from the deferredSpawn call far before the FinishSpawn
And unfortunately it seems to be before the actor has it's location actually set by the transform passed in
It's weird that that happens without multithreading.
is it appearing on the client in the wrong position?
Well I have replication decided by location at the moment
And so all of them are failing the location check and not replicating at all
Ah.
I just tried out updating the replication status afterwards and that seems to work sort of
Well it's the root component, not the actor, which decides the actor's location. Maybe it's adding the actor before the root component is properly initialised?!
But I think I'm missing some of the functionality because it's not replicating on the initial spawn
yea could be
In which case I'm kinda screwed
You could turn off replication until after it's finished spawned.
what do you mean by that?
Honestly, I'm not sure if you can even toggle rep on and off for a whole actor.
An actor has a setting that sets whether it's replicated at all, right?
Oh
Turn it on after you've finished setting up your actor.
It's overriden by rep graph somewhat
Ah. Well that was a kind of wild stab in the dark anyway. π¦
I guess I could just assume they're all valid if they're at 0,0 and then update properly once I get the actual location..
π¬
You're gonna end up with a ton of actors spawning at 0,0,0 and snapping somewhere else π
The other alternative is to somehow do it without deferred spawning.
Does regular spawning actually work?
With the locations
We have values we set during the deferred spawn we need replicated in the first spawn
But maybe I could try a broken spawn with regular spawn just to check that
You could hack that the same way hte object initialiser does it π
Unfamiliar with that but doesn't sound ideal π
Yeah.
You can statically reference the OI from a constructor without using the OI constructor. So it must statically store the currently being constructed object on a stack or some such.
oh gosh, might leave that as a last resort π
it does π
Must be something to do with the initialization that happens when actually running the construction scripts which doesn't happen till FinishSpawn otherwise
@latent heart I got it π
Turns out, to set the root component location in DeferredSpawn it needs to have a cpp root component
This particular actor was just set up in blueprint
By adding a USceneComponent in cpp as the RootComponent in the constructor it works with DeferredSpawn
π
I still have the issue that Multicasts called right after spawn don't replicate to the client like they used to before rep graph though βΉοΈ
What are you doing with your multicast?
You fake could it with PostNetInit
Or, rather, is PostNetInit be what you should be using? π
I can honestly say I've never heard of that
The actor in this case is for an ability's effect which is multicasting to show VFX
I could probably just play the VFX based on begin play or something like that
It's just annoying to go and recode them all given it was working on the old replication reliably
Is the entire point of the actor to show the vfx?
No it does the gameplay effects as well on the server
The multicast is just how it kicks off the visuals
Well, even so. It sounds like you want a non replicated server actor and a multicast to your clients to spawn their own vfx π
Well yea, because the multicast would reliably work immediately after being spawned that ended up being how they all got made XD
Compartmentalisation!
Well it's tidy having an object that represents the whole gameplay effect
It just... doesn't work trying to use it so quickly after spawning XD
Maybe maybe.
Long term it will ofc be changed
It's more how to make things work again now without all the rework up front
Plus the wondering why the heck it was so reliable under the normal replication driver
Because reasons β’οΈ
Almost as good as raisins.
Anyway, it's 2am and I've started to ramble. Time to sleep. Night!
Thanks for your help!
Good night
Np
When you spawn actors using a multicast function, is it normal that the actor detected on the server and the client ( after a line trace for example ) has a different name ?
is it possible to change the Game mode or Game State of a level when loading a level? (ie, I want to open this multiplayer level with Game mode as Team deathmatch GM, instead of deathmatch GM)?
Usually you will create a sublevels that contain all the features of the same level except they change their GameModeOverride to a particular mode. Then instead of loading MyLevelBase you will load MyDeathMatchLevel that contains MyLevelBase inside it.
if two servers are on the same level, is it possible to pass a player between the servers?
What do you mean exactly?
You can tell that Player to join another Server, sure.
like if the player was in a grey box map, there are two dedicated servers, and i called APlayerController::ClientTravel could I just send the player back and forth between servers?
same level, same actors in theory
The levels and actors in a Server have no bearing on a Players ability to join that Server.
yes but there is seamless and nonseamless travel
i want seamless and im confused on what can cause it to become unseamless
Seamless Travel is a travel operation for Clients that are connected to a Server to a new map whilst remaining on that Server.
ohh
There is no Seamless Travel between Servers, that would be considered a Non-seamless Travel.
Also known as a Hard Travel
just seems like it would be super useful lol
Its just not how Unreal is architected out of the box.
Did you guys notice that servers and clients don't have an accurate deltatime in CMC's PerformMovement() and therefore physics loops also? TickComponent works as expected, though