@jade gazelle tried what you said without luck. a player loads the game to the main menu, in the game modes BeginPlay, i run a function that sets the character class variable (a UClass*) in my game instance to equal my survivor base class (so its not null if the player doesnt select anything). then the player clicks a host game button which is a simple server travel to my lobby map. then the player would click the start button (keep in mind this is all temporarily so i can figure this character selection deal out). the start button would seamless travel to the game map. the game map game mode runs postlogin which casts the NewPlayer playercontroller to my playercontroller class, then calls a client RPC on that player controller and passed in the casted NewPlayer playercontroller. the client RPC got my game instance, called a function that returns the UClass of the character class variable that was stated above, and sends it along with the playercontroller to the server via a server RPC. the server RPC checked to make sure the UClass and playercontroller were not null, then spawned the UClass actor and possessed it. the problem i keep having is the game crashing when it tries to spawn the UClass. i went ahead and deleted all the code (again) to start from scratch (again) and did a little test, i tried spawning in the UClass while i was in the lobby and it still crashed. for whatever reason i cannot seem to run spawnactor with my UClass. if i do ASurvivorBaseClass::StaticClass() to get the UClass it works, however i will be having several different classes so that wont cut it
#multiplayer
1 messages Β· Page 481 of 1
When you multicast does that also run on the server or only clients?
Yes, I have my gun set up so that it goes from interface->Run on server->Multicast->local copy. This way it displays its effects on all clients, but I realized that for some of the abilities the gun has, it doesn't need to do all of the calculations on all the clients. It only needs to do it on the server. So I was going to toss in a has authority to separate those out
are you spawning an actual projectile or doing a line trace for the bullet?
@somber glade
It's not a bullet actually, it's a different kind of ability. It does do a line trace though. Basically it's line tracing to the target to see if the target has a certain gameplay tag before it goes ahead and calls to an interface to perform that function on the character itself. If that passes, then there would be a visual effect from the gun to the character, but that hasn't been built yet. I figured that not all the clients need to check that tag. Only the server needs to check that tag to see if it exists and then if it does, I could repnotify a bool that would play the particle effect
maybe set it up like this? client clicks to shoot weapon, calls Server RPC to shoot the weapon which is just the line trace. in the Server RPC, call a multicast RPC function to play the effects/animation of the weapon such as muzzle flash and recoil animation. then still on the Server RPC, let it do whatever calculations it needs to do, if the gameplay tag check passes, simply call another multicast RPC function to play whatever the visual effect is?
okay I'll try that
just seems like a simple solution without having to replicate anything aside from 2 function calls. and if you want to possibly save some server calculations(idk how demanding what your trying to do is going to be), you could perform the line trace on the client, call a server function that call a multicast function to do the shooting animation/effects, then while still in the same client function, check if the client hits something, then have it do the calculation to see if the target has the correct gameplay tag. if it does then call a server rpc to perform the line trace and check if it hit a target with the correct gameplay tag, if it did then have it multicast the visual effect you were talking about. this way the calculation and line trace is only going to be done on the server if the client thinks it hit something, if the client hit something with the right gameplay tag, the server simply checks to make sure it actually did hit the target with the right gameplay tag (to prevent cheating) and then runs the multicast function for the visual effect
Hi!
I want to know what network limits are?
Single packet buffer size 64KB?
What does the maximum array size 2048 mean?
Can I send only 2048 variables?
@ocean geyser Okay The one thing I am still trying to understand is when a call jumps from one actor to another it still runs with the same authority right? So like if I have an event on Actor A that is running "has authority", and it calls to some event on Actor B, I don't need another "has authority" on Actor B right, because that event is only being called from A if it has authority?
@somber glade correct, any code that runs in an if statement that checks for authority will run on the server, even if its calling something on another actor
@gleaming vector there was a case of that on #cpp couple of weeks ago
the Outer did not replicate
after renaming it on server
he did have to set Outer client side OnRep
to avoid LogNetTraffic: Error: UActorChannel::ReadContentBlockHeader: Sub-object not in parent actor.
that
it was Meatman, 29th of June, don't know how to link that tho
moving a replicated UObject to another Actor
iirc, the Unreal instead of replicating an Outer, just assumes Outer client side is whatever Actor was responsible for the initial replication of the Object
yeah
you should be fine as long as you have the information to mirror the server-side rename on client
yeah, just do a Rename client side
yeah
biggest issue is that these are in an array
i'll experiment with it tomorrow
FFastArraySerializer π
the docs for it are in NetSerialization.h header
i've done it before
Hey guys, do variables created in animation event graph are able to replicate ? The option is there but it does not seam to work as intended
Usually the work flow of the animgraph is to read variables and do things client sided
so the good way is to replicate things on the actor bp side not on animation bp
Thats the usual workflow, yes.
ok, thanks
@thin stratus you might abort on helping me, got it fixed
Thank you for all the help, it was literally the weirdest bug I ever encountered
Don#t worry, haven't had time to look into it anyway. But glad you resolved it
A dangling PS, two controllers owning the same pawn, owning clients executing code they shouldnt...
Ect
All because PossessedBy doesnt do SetOwner(NewController);
@jade patrol the UAnimInstance is not supported for networking by default, and would take a moderate amount of work to... hack it into supporting replication
i recommend against it
Can someone help me? I'm a bit confused. I'm looking for the easiest way possible to have a simple and very small backend for my multiplayer game. Basically all I need is an online mysql database which holds a username, level, gold amount and some int which represent unlocked stuff. No login system, no other fancy stuff, just what I summed up nothing more. I've tried setting up a localhost with bitnami which is all great, but that's just local. How would I bring this online? I know that i can get a free webhost which includes a mysql database, bring my php files in and it should work. Except everyone around me tells me that won't work since most webhosts block bot requests (such as requests made from unreal engine clients). So what is then the easiest way to get this up and running for my alpha test community? I also know there is Gamesparks and stuff, but that is either payed and requires c++ knowledge which is kind of lacking atm since I havent programmed in c++ in ages. My game is a blueprint only game for now. Any ideas?
sorry for wall of text btw π
Get yourself a quite VPS for a few bucks a month
I'm very much willing to pay for a server up to 15/month
can you recommend the best one for games?
Will your multiplayer game have dedicated servers ?
I mean, if it doesn't, there's no point having your service at all
but not at the moment
but how would data be stored of users if I don't use an webserver?
In save data
I've read about SQL data and baking into a build, but wtf is that even? xD
sounds like voodoo magic to me haha
How do you think video games store progress ?
All that data is currently saved locally using save data from unreal, but I want players to be able to play the game from anywhere and any pc and I want their data to be somewhat safe. Like if they accidently delete their safe file they lose all their progress
I've also read about that, but cloud save only saves a copy of your save file, doesn't do anything else
user can still manually delete their save files and users also have to enable the cloud saving manually
Cloud save on Steam syncs the files between all machines so you have the same file everywhere
And it defaults to being activated
You don't need to enable it
You can always manually delete a file, yes, but is that really an issue ?
It kind of is, as the level system in my game is pretty serious xD
I mean
We're talking "user goes to the file and deletes it and then launches the game"
Not "user formats the machine"
that sounds great for a singleplayer game and a simple test game, but for a real multiplayer game it seems only logical to me that the data of the players is saved somewhere online and protected?
Yes, but that only works with dedicated servers.
I mean which multiplayer game has local save data?
All MP games that are cooperative, rather than competitive
well, I guess, but the fact is that my game should be rather competitive
The problems of an online server to store the save data are :
- you'll pay for the server, you'll need to maintain if for as long as you want your game to be playable (so like, 5 years)
- any breach in security will result in data modified, or lost, which will kill your game if it happens
- you can't have clients writing the data, because clients cheat, so you need all data modification to happen on servers you physically control
- you can't let people host their own game servers, so the cost of game servers is higher
- playing offline isn't possible anymore, which will kill your game if you have like 3 online players like most indies
Obviously if you're working for Bungie and you want advice on Destiny 3, then yeah that's what you need to do
But are you working on Destiny 3 ?
π
I get the point, thanks haha
but hmmm I dunno
how about gamesparks?
would you recommend that?
I'd recommend not doing a competitive MP game as an indie, it's suicide
If you're doing that, I don't know, I don't do competitive MP games π
already to late for that we've been working on our current game for over a year and a half and are going to be on Gamescom this year π
it's a very casual multiplayer game though. I mean, we're NOT trying to be the next Overwatch or whatever. Just want players to be able to get a sense of progression and be able to unlock and buy some stuff
Well yeah I'm just saying this stuff costs a lot of dev time, and if it's not perfect your game will die immediately
I understand
but in all honesty it doesn't really need to be like insanely protected and all that. In fact we've got our own local server which is already operating a discord bot 24/7. Would be cool if we could just get a database running on that same pc, be able to post and get data from it, nothing more.
Once / if our game get's bigger we dcan think about upscaling and more security
gotta work around the current requirements of our game, which can potentially scale with more users / popularity
I mean, if you have a flaw in your server and someone connects to it and wipes the progress, your game is dead
I see what you mean
If you don't care about insane protection, just put it in save data
It's way simpler and cheaper and safer
People will cheat by modifying the save data
can the save data be encrypted?
But as long as it's just unlocking random shit, no one cares
It doesn't matter, everything happening on the client's hardware is unsafe
well, the thing is that the game will be a one time purchase, no micro transaction and in-game currency buying and so on. So in fact people kind of pay for the game experience itself, the gold and level you get by playing is just a bonus really
so I guess you're right that it's not a big deal if users mess with their own safe file, the only thing they will have is some more fancy clothes than other players
So just put in save data which items you've unlocked and how much ingame money you've earned, and when people change the data (they will) it's fine
the game is already like that
The worst case is much less dramatic than "someone wiped all progression for everyone"
i was just looking to change into an online system
but guess I'll leave it like it is then
thanks for the insight
As long as you're not playing on dedicated servers that you physically own, with only dedis being allowed to talk to the online service, it's the same
well, we do want people to be able to host their own dedicated servers
will that be a problem?
It means an online service will be exactly as safe as your local save data
Anyone will be able to hack everything
Except maybe not just their own data π
We just want to provide our community with a dedicated executeable which they can run to host their own servers, nothing more. Just to give the game to the people really and let them do with it what they want
That's great
Just, that means you can't have trustworthy save data
It's a compromise
Yeah, but the save data is not like a crucial aspect of the game, it's an extra to make it a bit more fun and give players a goal. The game is still very much all about the actual gameplay. Kind of like counter strike. Remove the skins from counter strike and it will still be a fun game
that's kind of what we want with our own game
Then keep it local in save data
alright
People will hack it, and it's fine
it won't be dramatic π
Just consider that everything happening outside your own hardware is unsafe
That's just how it is
Once you've registered that it's easy to understand what you can do or not
Thanks a lot for the info. Im going to keep the save game local for now ;)
Is is possible to give preorder / special edition bonuses without a master server or separate game build on Steam?
It's fine if hackers can get the skin, but just wondering if I can flip a bool in game instance that'd unlock certain rewards for certain people somehow without needing a separate build
Alternatively if it isn't possible, is it at all viable to run two builds and just flip that GI bool on one?
If youre on steam, are you setup for any kind of code redemption? Seems like thats the more common route
Wouldn't code redemption require some kind of online check / redemption which would mean your inventory would have to be networked somehow?
If steam can handle one time codes then it can probably work actually as long as it syncs with the save data
Weve use code redemptions pretty commonly, steam for sure has one time codes, but I have not been thru that pipeline myself.
For sure youd need a way to talk to steam, in game, about what that user has redeemed so you can decide to push an inventory item on them
Also going that route means you can open up taht pre-order bonus for sale or other giveaways in the future alot easier than having to send people a 2nd build
Great advice thank you
I will look into those codes and see if I can get it to work without any master servers etc.
question. i have a game instance and that game instance sets a variables value when the game is loaded. if the player hosts a server (not dedicated) from the game, does a new game instance get created for that player? or is it still the same one?
there's only one game instance per... game instance
the only time it's not is with PIE sessions
a listen server doesn't behave the same as dedicated server mode in the editor, it behaves more like non-dedicated with multiple players where the hosting player is ROLE_Authority over everything
@lost inlet then i cannot for the life of figure out what my issue is. the code works just fine in the editor, but when i test outside of the editor is crashes everytime i try to spawn my UClass that is saved inside the game instance. can you do me a favor and skim over this and see if you see anything strange?
https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1646781-uclass-spawnactor-crashes-game-when-testing-outside-of-the-editor
Ive been working on a simple character selector that carries over from the client into multiplayer. Last night i had issues that caused me to completely remove
ok did you actually look at the crash in a debugging session
@ocean geyser So you know, there is 'SpawnDefaultPawnFor_Implementation()' in the Game Mode class which is used for exactly this kind of thing
It takes a controller, so you can query what pawn the player wants to spawn as from the controller, or player state maybe, and spawn the correct one there
Couldn't tell you why the class is/isn't valid though looking at that
negative, im just reading the crash reports
UE4Editor_TheHouse_0073!ATheHousePlayerController::Server_SetupClientCharacter_Implementation() [C:\Users\codyd\Documents\Unreal Projects\TheHouse\Source\TheHouse\Private\Player\TheHousePlayerController.cpp:44]
UE4Editor_TheHouse_0073!ATheHousePlayerController::execServer_SetupClientCharacter() [C:\Users\codyd\Documents\Unreal Projects\TheHouse\Source\TheHouse\Public\Player\TheHousePlayerController.h:16]
that i did not know about, ill look that up now
would i need debugging symbols to do that
yeah
well if you have PDBs by your game exe, you already have them
this is an editor crash anyway, so just press the play button from visual studio
also judging by the module name, is this using hotreload?
yes. the crash doesnt crash when testing in the editor, only when testing outside the editor such as right clicking on the project and selecting Launch Game or by packaging and launching it
in the editor it works as intended
the log above was taken when i clicked launch game on the project, the same crash happens on the packaged build
also you can have a batch file which is start Engine\Binaries\Win64\UE4Editor.exe Project\Project.uproject -game -log -waitfordebugger, and then you can attach the debugger to the game process before any startup logic is run
Or you can just launch "Development" straight from visual studio, so long as the assets are cooked
Instead of 'Development Editor'
I recommend using Debug / DebugGame Editor if you actually want to debug anything though
you can debug development builds fairly easily
You can but thanks to compiler optimization you'll always run into weird debugger behaviour
he said it crashes in standalone game mode too, and that's what the above will do
that has been the case maybe a handful of times out of many
and this is probably something that's not hard to spot too
Maybe, but it's still worth pointing out. Stepping through code in 'Development' is useless a lot of the time
The Debug mode exists for a reason
ive tried as well by setting a timer that waits 3 seconds before setting the UClass in my game instance in the game mode on begin play as well, the log prints as if it succeeds
ill try stepping through it to see if its setting the UCLass properly at the start
Worth pointing out that if the UClass* is not a type of ACharacterBase, then the code will crash.
The template function SpawnActor does a CastChecked<> internally - so the class may be valid, but might be of the wrong type
the UClass is a class thats derrived from ACharacterBase. ive also tried spawning it without using a template and without possessing btw
its showing valid when it gets set
https://gyazo.com/9ec336f1d6f8e036799978d65581d206
you can always use TSubclassOf<ACharacterBase> for your GI function, which will do type checking in the blueprint editor
TSubclassOf is a wrapper around UClass
noted thank you!
alrighty heres what ive found out so far. when the game launches, it sets the variable SelectedCharacter to the UClass being passed in and it is setting SelectedCharacter to the correct class. when i call GetSelectedCharacter, its showing SelectedCharacter's name is invalid
What type of variable is SelectedCharacter?
UClass
Is it a UPROPERTY?
negative
In that case, it's almost certainly not loaded
Make it a UPROPERTY() TSubclassOf<ACharacterBase>
are your messages not sending as well?
Yeah.. maybe it's Discord not my interwebs
But virgin media have the worst router ever made so hard to know sometimes
Why should i use NetMulticast. What does it do
netmulticast will make a function run on all clients and the server. lets say you have an event that you want to trigger, like a door opening. instead of replicating the doors movement so other players see it open/close, you could simply call a netmulticast function that has the code in it to make the door open/close. just an example
Can't do it with Server ?
Multicast can be useful for one-shot events that need replicating
Anything that determines the games current "state" should really use variable replication though, and that includes the above example re the door
So i can do it with Server and replicated variables but NetMulticast is simple to do that?
Well it depends, they serve different purposes
hmm
IMO You should always use replicated variables for game state. Think about late-joiners, actors going in and out of relevancy range etc.
yeah, exactly what it's for
also good for culling areas!
You also can't guarantee a multicast will even arrive, especially if it's unreliable - and in really bad cases when it's reliable too (but you have other problems anyway if it's the latter case)
Tl;DR - Variables for State, RPC's for Events
^
E.g, notifying everybody in the server that "Player b killed Player A" is a good use-case for a multicast
Whether a door is open or not is arguably a state-based thing, and should be done with a var
If i decrease health of character with netmulticast it will be decrease all clients health?
sorry for english π
you shouldn't do that. Health should be by default an onrep var
my english not good im trying to understand π
so you can trigger effects and things when the HP becomes 0 hehe
- further considerations
What I tend to do to ensure a sane networked environment is having everything that is relevant for the game state work with netcull active
even if the final decision is make it always relevant
so when you'll have people joining the game they'll get their stuff updated properly
if your thing is stateless you'll end up with situations where when a player joins a match he won't have the right states on certain objectives, such as an open door.
@high current Btw your stuff on heatmaps is SUPER duper interesting
As promised, here is the 3D HeatMap breakdown, done in #UE4 4.15 as it is for @utgame but the principles behind it are 100% valid
Medium article:https://t.co/Cx2GQRstUp
UT forums link(project files):https://t.co/BNuMCCCLLs
RTs appreciated
#gamedev
THREAD
https://t.co/gw7D...
but I get confused where it comes to "visualize the saved data"
its actually a thread
ignore the medium link
just scroll
I did an ooopsie with the formatting, Ill move it to a separate medium article at some point
oh so just look at the twitter comments?
I'm mostly interested in movement data to ease level design
I touch on that, but in essence its the same as the rest of em, just that it runs on a timer on the server
And because I name stuff incrementally with time, then when the visualizer reads the values
it can start from the beginning of the match and start adding spline points
oh so just retrieve player position by name with a lower tickrate
for every recorded location
what do you mean incrementally?
So lets say you jump in the game
once you spawn
it will start recording
Vor_M1
Vor_M2
every 0.5 it will create a new map entry
with that as its key
and your location as the value
oh nice, so you iterate by the added substring
if you die, the next recorded key would be Vor_M145_D
thats how the visualzier knows to stop connecting this event to the next one when you spawn again
so that there are no huge ass lines across the map from respawns π
I forgot to mention this in my post, but I also record the names of every player that joined in a separate array
oh so it's always (FName, FVector)
so that I can extract only the data of one player, make it into a new map
?
and loop from that
yes
always
If you download Unreal Tournament editor
you can actually get the heatmap from the forum post and look at my code
So guys i should do pickup fonctions with NetMulticast?
not unless you need an effect to run when picking up or an animation. you can just pick it up and destroy it on the server + whatever else such as adding to inventory
@high current open source squad hehe. Just a little question, for a game like UT, how many entries in your map you got from a normal match?
cant tell you exactly how much(i mean i can look if you need and exact number)
but a 10 minute match with 6-10 people is between 200-350 KB
in size
nah, not exact, just an stimate to see how big could become with 40-64 ppl
it really depends on what tick do you record the movement, ill actually boot up UT now to tell you the exact tick,
ah okay. I could record at a lower tickrate I guess
you generate the .sav at the end of every match I suppose
- keep in mind, this was 4.15 with blueprints, so if you do c++ i am guessing you have more options when it comes to variable compression?
And if you generade a random unique int, for each player
then you can scrap the characters in the strings
the problem is joiners-late joiners
I am guessing a numerical string is lower on size
I would need to manage that myself and it's lame
uint8 could do it, but you need to map it appropiately
And yeah, I actually save the thing on Edn Play
and I am using Event Login (i think)
for the joiners
so I really dont care if anyone joined for 30 seconds
or 30 minutes
yeah that I know, however if I generate an unique integer I need to map it to their subsystem id
so if they leave and re-join
they'll be recatched
which would be I guess a separated map uint8 - players in game
If I really want to compress a lot
I would just have a map, with player name as key and then its int as a value
event login just adds uniquesto those
yeah no, can't rely on player names
they can get repeated
at least with our subsystem
another option would be just using https://api.unrealengine.com/INT/API/Runtime/Core/Math/FIntVector/index.html
to save a few bits
Structure for integer vectors in 3-d space.
cant you get local machine name'
lol XD
well thank you so much for the rundown
I think we are getting way too granular with the details hehe
and then someone pranks you and breaks your system by managing to switch CPU's and rejoin the same session
π¨ banned
π
I'll profane a bit your original implementation
but the idea is cool as heck!
Didn't think about the .sav stuff
Does anyone know the correct way to get the current server time in a BP? Does the BP need to be replicated to get the server time?
There is a server-synchronized clock in UE4 already
One sec, I'll tell you how to access it. It's not very good though, I personally modified the algorithm to use NTP and make smoother corrections blah blah, but it gives you a real time in seconds, synchronized on all clients
As long as it's within a few seconds it should be fine, the effect I'm using it for is slow and subtle
GetServerWorldTimeSeconds on GS
It's a slightly laggy time source, but it's good down to ping msec
Yeah, that's the one
You get the GameState and call that function on it
it updates fairly infrequently, i had to increase the rate at one point
I don't remember if I submitted my NTP PR, but many other people did
My problem was that it wasn't smooth enough and did not account for existing value when making the correction
So it would go in sync and out of sync at random based on luck during that time when it syncs
predicting ahead of the server time was something i would hate though because i want the last syncd time from the server, not a prediction where the server is now
smoothing would be good though
@lost inlet check out the NTP protocol
As long as I can call it once and have it be within a second or two it should be good.
It's just a way to make a better estimate of servers time given more knowledge
As I just want to call it at the beginning of the game and use it as a time offset for a material
in order to keep them synced between clients
It can give you exactly what you want, I just added smoothing myself on top
but i don't want an estimate of the server's time
i want the time that was last synchronised to me, which is not an estimate
That's an estimate...
not really when it updates, the only bad thing is drift
If you simply send current time from server to client, the resulting value is an estimate with precision of ping mseconds
The time you get is only accurate to some multiple of ping reliably
In my case I'm syncing physics so I want the clock to be synced to server at least with 10-25 msec precision
If not better
The only way to get a true non-estimate time from server is to have server sit on the same machine or have it be connected with a high-speed LAN (and even then it's still technically an estimate in both cases, as there are overheads and undefined timings)
in my case, it was for telling the server "i saw something on my screen here at this server time" for a CSHD validation system
which doesn't need an NTP implementation
in the above example, you don't actually want to compensate for the RTT
How do you know at which server time the player sees something? Well, doesn't matter, if it works, it works π
for CSHD, the server keeps a ring buffer of player positions at a given timestamp
and it verifies it based on the time sent from the client and the supposed position they hit
and for that, you need a somewhat accurate timestamp of what the server time was for the last update you received
which is kinda what that GS value provides
in source it was easy because you had the sync'd-every-frame gpGlobals->curtime
The GS value is fairly inaccurate FYI
But if it's accurate enough for that, good. It wasn't accurate enough to sync physics
Unless they have fixed it in latest versions and I wasn't paying attention
i had to make it a bit more accurate because the default behaviour was not good, including having to call ForceNetUpdate
could anyone help me figure out how to fix my helicopter jittering/rubberbanding? I'm running it on a dedicated server and the helicopter is a BP. here's a video that shows the issue: https://drive.google.com/file/d/1clKPY_V5uCLkQu2SFU_1ZZDl29SBJlAd/view?usp=sharing
i suppose an alternative is working it around movement timestamps
cmon Tapa you gotta be able to look at the video
I know last time you said it was "too large"
you shouldn't have to download it to watch
btw, I used synced game time from the GS in UT for some stuff, during development, scraped it at the end, but I dint notice it being off sync, + their HUD clock is synced nicely, so it might be worth a look in the source
@lost inlet that's not a bad idea, movement stamps happen to have a better time sync implementation π
In CMC at least. But they conceptually don't need to be as precise π
Which is terribly amusing
ServerMove sends a client timestamp which you could get a server world time from
@cerulean escarp yeah, I say it, looks like classic server correction case, maybe try turing on the netcorrection visualizations
to confirm
k I'll try it
I have no idea how to enable netcorrection visualizations @high current I looked for it but I couldn't find it
ah so I just put that in the console
I am not sure, haven't used it before, might be needed in the binaries, but hey doesn't hurt to try the console during pie
yep it started working in the console
how do I 'read' the outcomes
like what's good vs bad
I think green is within the margin of prediction and red is when its forcibly resetting the position, but honestly no clue, I have only seen it, not used it myself
uh oh
every time it draws the green or red it has both green and red
and then it just doesn't even draw anything when I'm flying the helicopter
wow I'm stupid
I'm using AddWorldOffset to move the helicopter but I didn't have an RPC set up for it so it was only updating the location on the client
welp
Guys how do I avoid variable race conditions?
Can't really, just have to code around them
how are you getting into a race condition?
I have a replicated TArray for my player inventory and and I am trying to setup an RPC event ClientOnInventoryLoaded() to be called for from the server after the inventory is loaded. So when the server finishes loading the array I want to call the client rpc that way the client can do it's stuff after the server loads the inventory. But my problem is that by the time OnInventoryLoaded(), is called on the client, the client's inventory array hadn't actually gotten replicated yet so if I try to perform actions on it everything is null.
Guess I could do a wait delay thing but I'd rather not do it that way as there has to be a better way.
What is ClientOnInventoryLoaded doing?
Best bet is to use an OnRep callback and use that to do whatever you need once the inventory is received.
You'll never get that working reliably otherwise
Setting the current weapon to the weapon in slot 0 of the inventory array.
Surely CurrentWeapon is a replicated var too?
Yeah it is
But I need to call a client exclusive function on current weapon that does the setup for the weapon on the client
OnRep functions sound like the way to do it IMO
I did on rep but then if I do that there is no way to tell if the inventory is finished loading for the first time within the on rep function
You just check it in both
so if (IsValidIndex(CurrentWeapon) && CurrentWeapon != INDEX_None) { EquipWeapon();} etc.
my inventory sends a client rpc when the weapon is "Given" to the player, this is handled inside the inventory, so the inventory has to be ready
i dont give weapons outside the inventory
avoids these issues of "what is going to happen first"
so I've got a map that runs at a solid 120 FPS in the editor even at fullscreen, but when I run a dedicated server the map runs at a fluctuating 50-70 FPS that is constantly changing. what's the best way of diagnosing and fixing this?
Well first thing would be to run with a listen server if you can and see if the issue persists
Game is effectively running twice when you have the dedi server in the background, so a bit of performance loss would be expected.
Shouldn't be masses of difference though usually
Depends on the game
yeah I ran it on a listen server and the FPS was up to what the editor was at
it's only when running a dedicated server
would you say it would be safe to assume that the FPS will be as solid as in the editor if I have only the client running on my pc and the dedicated server running on a different one?
it hugely depends on your test scenario
just having a lot of logs printed will drop your FPS like a brick
in this case - if you have tons of replicated Actors, standalone game without dedi doesn't need to evaluate anything for replication
as soon as server/client model comes into play, that changes
did you turn off the FPS cap?
Hello, I'm using repNotify on some variables in a blueprint, the variable changes affects other client when sent from the server, but not when sent from a client to other clients?
@sour river Replication is authoritative, only the Server can affect the change of a replicated variable on other Clients.
If you want a Client to change something, you need that Client to send an RPC to the Server, for which then the Server can make that change on their behalf.
Ok I see thanks
Got it thank you!
Let's say I have a racing game, the users can turn on the headlights/indicators/braking lights etc..
How would I go with replicating that to all clients?
On press headlight button > send RPC to server > switch variable with repNotify ?
@sour river u can have Replicated Variables and whenever user (lest say client) turn the indicators, it should actually call the server to do this job for him instead of client itself, and as i said cuz its replicated variable it will be all over network and every body will see it
But how can I execute a function on other client when that variable changes?
void OnIndicator(){
if(Role < ROLE_Authority){
//call server RPC)
}
else{
// its server running the code so its good to do whatever u want here
}
void OnIndicator_Implementation(){
// now its server call the function
OnIndicator();
}
what do u mean?
Not sure I understand...
I'm using BP, the replicated variable is a boolean
If the user changes its indicator, if it's set as replicated, all other clients will see it changed correct?
But I want to execute some functions when that variable changes (turning on/off a spotlight)
How can I detect on remote clients that the variable has changed?
@sour river Yes use RepNotify
That's what I'm using now, but it's only calling onrep on the server
In the RepNotify function is where you would turn the Headlights on or off depending on the new state.
Is your RPC being sent to the Server?
let me give some information maybe ull understand it.
when variable is replicated u can use something like OnRep function so whenever the variable is Replicated the OnRep function get calls. and about the question How can u detect on Remote client the variable has changed : look when u do something as client u send what ever the action is to server for handle that, and it Replicates that all overnetwork but the variable will only change for the specific client
Okay I think I get it:
Client calls RPC to server > Server switch the onRep boolean > replicated to all ?
Yes
Since the Server is modifying that boolean, it will cause the Replication system to identify that change and then tell all other Clients about it.
That makes sense
magic
Thanks guys
@ocean geyser i still dont understand why SetReplicated doesnt work properly for u in the constructor
QUESTION:: guys what is my mistake here? i thought UMG has nothing to do with server so its separate for every player,
im printing logs on the screen and it shows the amount of item(consider as bullet) the player has. fyi, whenever player overlaps a bullet item it adds 3 bullet to the overlapping Pawn. now as i said im logging the amount of bullets whenever player overlaps the item, and it works fine, for example , if client overlaps 2 items, 6 is going to be printed on screen, and at the same time other players are updating their own bullet numbers by overlapping and there is no conflict between them, i mean everybody updates correctly, now here comes the problem. im trying to show the bullet number on players screen, when ever server overlaps the item, it updates screen for server correctly and when ever client overlaps the items, nothing happens on client screen, HOWEVER it overrides the server Screen, for example if server was showing 9, now it will override to somthing like 3(if client overlaps the item) and server's bullet number just Overrides by every client, for example if there are 2 client and one server, server will update its screen by each time these clients overlap the item. what's wrong here?
i mean everything works pretty much on logs, nothing gets override on screen, every body keep their bullets. but on screen its a deferent story
here is how i send data into screen if its helpful
further info : i print the Bullet amount in Player Controller just before sending it on screen, and it works pretty well and flowless. so the only thing i myself am suspicious is Blueprint side(the picture above)
Not sure I understand but shouldn't Player index not be 0 ?
@sour river why not 0?
it is just updating server's Screen
i myself think that GetPlayerController[0] is just returning Server's PlayerController
Are you sure?
I'm not an expert, maybe players are not sorted, just my 2 cents to help you out
@winged badger @pallid mesa OnRep doesn't work
deserialization of the UObject happens before the OnRep
and since the failure is in the ActorChannel deserializing the object, I need to know about the Outer switch before that even happens.
i think i just need to duplicate at this point
Duplicate per now, I'll try to setup something similar on my end and experiment a bit with some ideas I have on the top of my head
is the only way to change the netfrequency of an actor component just to.... make it an actual actor ? i guess thats owned by the parent and such? im not sure so sure if spawning a replicated actor component for its parent is cheaper then spawning a replicated actor in this situation im not sure if this is normal practice
On a side project I had, the data was stored on an actor, as well as the proxy, that way is extremely easy, now... You might still want to use Objects for this. I'll hold off until I can replicate it
@gleaming vector
thanks
it's a difficult problem
because like
object pointers can be passed around
but they can't be replicated
Tried the FFastArray approach?
unless they have hte same outer as the actor replicating them
that still happens after deserialization
the issue is that the ActorChannel complains
so, the flow is
Object gets renamed to new outer -> Object is serialized and sent to client -> client reads data bunch, deserializes the object -> realizes that the object already exists (because it does), but the outer is different -> fails to resolve the object
but, yeah, i'mm switch this to a duplicate rather than a rename
may the GC have mercy on me
Bless you xD
Be aware and leave room for a future change, just in case
As soon as I have some free time I'll try to replicate your scenario and see this non-sense by myself
Seems interesting
It is similar to a recent Issue I had with ownership and possessions π
π€€
a replicated health variable i have doesn't seem to replicate to clients in a standalone game as opposed to PIE. EventAnyDamage runs on the server, so it should change the replicated health variable, but it doesn't seem to replicate back to the clients for whatever odd reason
@gleaming vector pretty sure that issue a month ago had the Objects workign just fine
it was just complaining
and to complain
it has to be both resolved
and know which Actor it should belong to
Someone was interested in the game clock sync thingie
realized I have had this in my tabs since like forever
When implementing real-time network multiplayer in a game, one very important tool is a reliable network clock.
correction: the replication doesn't happen if i run the game from the main menu, but does happen if i run it directly from the editor
*from that level
@high current the concept is good, but the implementation there is sloppy
as in, it has an error
it caches the server time, instead of ServerTimeDelta
and then just returns the server time
which means whenever you call the GetServerTime, you'll get the time on server when you sent the RPC
not adjusted for the time that passed since
I still haven't read it :D, but thanks for the tldr, I will go trough it (has code snippets so it will take a while)
yeah, shouldn't it return server time + RPC travel time
no, the idea is to cache the difference between ServerTime and your GetWorldTimeSeconds
so you just add those 2 up for current ServerTime
because it can't complain without resolving haha
what do you do when you rename it?
i mean, its probably not enough to just change the Outer
you make the new Outer (which is an Actor) hold a reference to it as well?
yeah, I... idk its 4 in the morning, ofc you can get client world time, duh
gnite or good morning i suppose for some
gn
i store the object in an actor, yes
and ReplicateSubobjects it
basically, I have an actor that holds items in the world (for pickups and stuff), and I have my pawn who has an inventory
the Item itself is a UObject instance
I'm trying to pick up the world item, transfer the UObject instance from that actor to my inventory
if I don't change the outer of the actor, I can't replicate it down
if I do change the outer, when it's recieved by the client it complains
what if you had a TWeakObjectPtr<AActor> Owner and OnRep_Owner does the Rename?
inside the UObject
that is, does the rename if Owner != Outer
oh and if Owner != null, just in case
Unreal loves to crash when it has Outer null
for anything
is there any way to dynamicly turn off an onrep functin?
like at runtime make a variable only replicated, but not replicatedUsing
Vehicle movements in multiplayer are very jittery/laggy... Does anyone have a solution to this?
@timid moss and what would you gain by it?
you can just return from the top of OnRep function if some arbitrary condition is met
To much to explain lol
yeah but it will still be called from the server
wait, we're talking about blueprints here?
no
srry i knew that i just messed up
but the server is what calls it
it runs on the client but the server initiates it
not quite
the bunch is received, deserialized, and then the NetDriver checks if there is an associated OnRep function, and how many parameters it has
then calls it, indirectly
server "initiates" it only in the sense that it changed the value of replicated variable, nothing else
k
so adding a condition not to execute OnRep would require editing some low level networking code in the engine
having the OnRep function just do nothing based on a condition is super easy though
@sour river enable physics substepping for one
@gleaming vector Thanks, unfortunately that didn't fix it.. :/
What do you mean by that?
Do you think this is a settings issue in my BPs or a modelling issue?
no, you'll have to dive into C++ and override some functions
Trying with the blue vehicle from VehicleAdvanced works
namely int he vehicle movement component and actor
to put it lightly, vehicles suck
Okay.. thanks! Will dive in
can a client player controller making an RPC set something on the game mode directly or do we need to go by way of the instance or game state first? When the 3D widget is pushed that would end the game, it uses the PC of the player who pushed it to make an RPC, so I'm just looking at the best way to get that information to the game mode.
Server RPC, in the server rpc simply access the game mode, cast it(if needed) to do whatever your trying to do on the game mode
Right, I knew that clients couldn't normally cast to the game mode, but I wasn't sure if they could or not after making the server RPC
anyone know of a way to test for client disconnection for if a player force closes their game/altf4? i tried logout but that didnt appear to run
yes, remember, as long as your on the server you can really do anything you want which is good (and bad). just do proper checks, the validate function is there for a reason π
If you had a client disconnect, couldn't you just try to run a test event on them? And if it failed to return anything you'd know they were gone?
some kind of "run on owning client" that returned a bool.
or would that just crash when it tried to call to the client?
im looking for something to trigger when the client force closes their game since it doesnt seem to be triggering anything
it would just crash the client i would assume, but the client would already be closed so it wouldnt matter lol
I just wonder what the server would return in that situation like if you had a function to get a bool, but the client didn't answer. How long will the code wait to resolve that function if there is no answer.
aparently there is something in the game in the game instance
i dont think you can receive a variable from a client with a simple function call?
game state has your player array. Is there someway to monitor the player array for changes? I assume it removes the player if they disconnect.
hmm possibly. i just really thought Logout in the gamemode would of detected it within 10 or so seconds. im guessing its thinking its lag and its just waiting for the client to respond?
idk i suck at this crap lol
Me too, that's why I live in this channel π
I don't know what the UE4 tolerance is for timeouts regarding lag.
lol nice. its probably setable
seems like the only way is via a heartbeat kind of way. send a message to the client every X amount of seconds like you said, if it doesnt respond then theres probably an issue. really thought UE4 had something already built in for this
you could also tick the game state and look for changes. If a player is missing from the array who was there last time and you don't have a logout event for them, you could clean them up. I'm not sure what might be more efficient, each client sending in a heart beat or just checking the array
probably not ever frame, maybe every 2-3 seconds is frequent enough to catch disconnects.
if they force closed the game (or pc cut off for that matter) then i dont think they would be missing from the gamestate
really? Might have to test that to see
maybe, shouldnt be to difficult, i just havent made a gamestate class since i dont need one in my lobby as im testing lol
Good idea, do you happen to know how a listen level handles max # of connected players? if i set it to 4, and at some point during the match one drops out, would the host keep itself advertised and could someone join automatically?
not entirely sure on that, how do you stop advertising the server now? or is it automatic
I don't know. I haven't gotten that far yet. I've got advanced sessions tied into the VR expansion plugin I'm using. I was using server travel to start the game, but I've ran into a bug with that that I can't, through days of straight debugging, solve so I simply switched to using the lobby level as the play level until I can figure out what the issue with that. So what happens is when the host makes the game he appears in the little lobby room, and all the players who join also join that little lobby room on the level. When they pick their avatars and start, the game mode just unpossesses their "menu" avatars and puts them in the new ones in a different part of the same map to actually start game play. I'm just wondering if someone drops out of of the game, if the server would show up as say 3/4 players and if someone new could join. If so I need to add some code to handle auto assigning them to a team in that situation.
well i guess you will find out once you test it. hopefully it will as long as the player disconnects properly
well nvm Logout is running when i force close the one players game via alt f4
yeah this week I might be able to get a test in on that.
so it is detecting it? Well that's good
well me and you will be working on online sessions at about the same time then lol. si, idk if it will be detecting it when i test via steam on separate networks though
or if it just has some form of handling for closing the game via altf4
You may also need to check what happens if a player crashes..if you can induce a crash
maybe put some kind of button event in that would reference a null point to force a crash to see if that works
that will be easy, my code always crashes
haha
thankfully mine doesn't do that as much anymore. It just refuses to do what I want.
thats almost better lol
its funny when you look at how many issues you had when you first started in UE4, and then look to where you are now that you atleast have a clue to what your doing
I had some epic issues the first project i made. I ended up having to replace several files, one by one in my project to solve a crash on editor start up
yikes that sucks
in blueprint I had a cast to something.. I think it was a projectile. But then the projectile had an assumed cast back to the weapon type, I duplicated the weapon at some point, and somehow.. I don't exactly know how, but the old weapon really didn't like that the projectile or whatever it was was updated to attach to the new weapon. So for about an hour I was trying to figure out why my editor was crashing every single time I started it. I was already using source control, so I went back and forth pulling directories out until I narrowed it down to the directory and then the exact file, and replaced it with an older version to figure out what was going on. I still don't understand why it was giving me a crash on editor start.
yea thats frustrating, especially when it wont even load the editor to view BP classes and change them
The worst part was that the old gun wasn't even in the scene. That was the real mystery. I get if that BP had an error or whatever, but when the gun wasn't even in the scene, it should still load. I ended up deleting the uasset, starting the editor, then pasting it back in and then editing it and fixing it there.
yikes. sometimes when you move or replace BP classes, ive noticed their still "there" in the level
Yeah, I've managed to have some real strange errors crop up in what I've made thus far. Ah well, it's always a learning experience.
ta da
learning is always a major plus. this has been my biggest project undertaking, all my other stuff has been small little things strictly for the use of making tutorials, but man code piles up fast
whats your previous experience before UE4?
when I was young in the 80s, I taught myself to program out of the back of the msdos manual which had a whole section on GWbasic. did qbasic/visual basic in the 90s in school, then did javascript, python, css, a little c++, and network engineering/sys admin stuff most recently before this. Programming wise, nothing quite as heavy as this.
you?
well you have a background that covers quite a wide variety, nice. started school at the local community college for a CS degree (still have not gotten my associates degree), finished all my required CS courses for the degree which got me familiar with java and assembly, got bored while doing the rest of my required courses so i taught myself some reverse engineering skills, C#, and currently am learning UE4
Nice, being able to teach yourself is always a good skill to have.
yeppers, and a must for programming
im getting a weird behavior, i have a function in Player Controller which just returns a Value that i want to show in UMG, im trying this way to expose the value into BP,
whenever i play on a dedicated server, this GetLaser function doesnt get called at all.(im printing logs, whenever there is a server as player it prints the log every frame but on a dedicated server it logs nothing at all and after that BP runtime Accessed none error)
which it means its filled with default value, so what's going on? i thought PlayerController is a safe class for working around UMGs
@pallid mesa there is no such a node, i searched, but there is GetOwningPlayerPawn
i myself think i made a mistake on that BP, cuz as i said whenever i run it on a dedicated server BP runtime error happens,
but whenever server plays there are no BP runtime errors, and of course only Server side gets the Correct UMG
it turns out that get player controller returns player controller of clients too. i tested the recommended one too its the same behavior
but why it returns a Access none whenever im playing on dedicated server?
using the getowningplayer you are getting a null aswell?
yes
that shouldn't be right, unless you are trying to execute this weirdly
GetOwningPlayer always returns your owning client version of your controller
which would return null if your controller is null
the weird thing is that GetLaser function returns a true value for every player in C++
oh get laser is server only as far as I can see
meaning that you have to bring the value that getlaser is returning to the client
if you use the style guide correctly, it should be server only
ah yeah i was checking what happens if i use BlueprintAuthorityOnly
let me remove that part
but you gotta ensure first getowningplayer returns your controller right
i dont use any Variable for storing of Player Controller so i dont have an issue with filling value to the BP variable,
as u mentioned that GetOwningPlayer Should work properly
just for clarification can this be the reason im using the sequence node?
@pallid mesa ah im getting closer to the result, by removing that BPAuthorityOnly now server doesnt update its value when client overlaps items. now the only thing that remains to fix is this nullptr issue, thanks for efficient help Vor.π
whats the node?
your controller
getowning player?
self
still the same null issue remains
it cant get the widgete? or player controller is null ?
okay so owning player is receiving now self which is your BP PlayerController and yet GetOwningPlayer is returning you null?
yes
are you like... totally sure that is what is happening? Print please the controller value
LogBlueprintUserMessages: [LaserHUD_C_0] Client -2: BP_PlayerController_C_0
now this is not dedicated, server is playing too
LogBlueprintUserMessages: [LaserHUD_C_0] Client -2: BP_PlayerController_C_0
LogBlueprintUserMessages: [LaserHUD_C_0] Server: BP_PlayerController_C_0
i just checked it and i didnt set it to be replicaated
hehe
but it was
the error remains still.
oh again whenever client overlaps server updates the UMG
((:
create this widgets only on the LocalController that's for sure step one
another big difference is that I use the HUD class
to create all the widgets
so that might differ
try moving your stuff around I gotta go, I'll be here in some hours
sure thanks.
@brittle karma
^ BP_PlayerController
and the widget binding
this works out of the box
is similar to your problem
i moved everything to HUD and its fine now, there are no BP errors anymore
fine, however if you do it that way It'll work aswell
however I recommend better to use the HUD class
that's the reason of its existence
yeah using HUD makes everything much cleaner, thanks
π
@pallid mesa in the first picture u send uve used IsLocalController inside PlayerController?
aye
Main reason you get these errors is cause you blindly use BeginPlay
This calls on every instance of the actor. So for a replicated controller it's calling on server and client
That's why you need to limit to local playercontrollers
And also why HUD doesn't create the issue as it only exists on local players
Even your dedicated server was spawning a widget
Does anyone here have any advice on the best type to use to identify a player? For example: Player 1 has PlayerId of FString, int32, FText, etc?
That property would be stored/retrieved from a database
So like a primary key for that player that will always belong to that player, like a steam ID
a guid would make sense
Ok thanks
steam ids are 64bit integers
if you arent linking with external services you can use whatever
normal 32bit integer autoincrement primarykey is good enough
you can have another table that links that your-game-specific playerid to a steamid or other service id
Should I store my player's inventory in the character or PlayerState?
I feel like PlayerState is a bit overkill, especially since the inventory would be replicated to every client
my inventory is transient for a map
so i keep it in PS, so i can restore if after player disconnects
aight
Can I use replication condition to only replicate the inventory to the owning client?
easily
alrighty
if (bReplicateToOwnerOnly)
{
DOREPLIFETIME_CONDITION(UInventoryComponent, Inventory, COND_OwnerOnly);
}
else
{
DOREPLIFETIME(UInventoryComponent, Inventory);
}
Like this right?
(inside GetLifetimeReplicatedProps)
@solar stirrup set your inventory array to replicate with the owner only. if your trying to set it up to where you die and all the items are dropped, you can multicast the event and pass in the inventory array to that multicast function, that way you shouldnt be replicating your inventory to all clients when you dont need to
well, that's exactly what the code I sent above does, thanks for confirming ^^ @ocean geyser
(bReplicateToOwnerOnly should be false for things like chests etc)
ah i see what you mean. good idea
Does anyone know any techniques for hiding lag compensation in spectator?
In terms of weapon firing and issues where it looks like you are shooting far off of the enemies when they are really hitting them on their client
^^^^^^^^^^^^^^^^^^ I'm also interested
You could replicate the target for the spectators
Have them aim themselves
Approximate accuracy should be good enough there
Well, if you are spectating in first person, perhaps about the spectator should get actor position, and forward vectors from the client that they are spectating, instead of the server corrected value, no idea if its possible though
I am guessing you are letting users spectate without delay?
but like vor, I am interested in hearing proper methodologies for that kind of stuff, so far I havent seen many games tackle this correctly
maybe perhaps overwatch, but havent seen esports stuff in a while, might be mistaken
What is the issue exactly? I've been dealing with something similar lately but perhaps I'm mis-understanding the problem π
When spectating it looks like the player you are spectating is shooting quite a bit away from enemies and are still landing shots
Since on the shooters client they are shooting at the enemy
But from the spectators point of view they are way off
Especially troublesome with moving players
I recently had to make my own spectator system for Unreal Tournament, and everything was fine during live play, I have a round based game mode so dead players are constantly spectating team mates. So I would say that Epic managed well in that department, perhaps you can see what they did: https://github.com/EpicGames/UnrealTournament
Good point yeah I'll dig into UT
Aight so
We're planning on making our own movement, replicated and all.
I've been told to either make my own movement component with a Pawn, or reverse engineer the CMC. Which, apparently, probably has 90% of the engine's size (jk)
Does anyone have any pointer, blog post, tutorial or anything that would help me on this journey
Because Epic really didn't make it easy for us
If I have to reverse engineer the CMC, God help me
Welp, looks like reverse engineering the cmc is the way to go
what is your movement supposed to do
I just want to have complete control over the movement @high current
since we're probably going to add a couple of things like special combat attacks that make you move differently and stuff
(and it'll allow me to refine my knowledge of the engine)
you can write custom movement modes in the CMC
I am guessing the thing you are really after is the movement prediction of the CMC
you can write your own movement and copy that from the CMC, you don't have to rewrite the whole thing
unless you want to ofc
@solar stirrup
are you going to utilize physics for your movement?
eh, physics or alternative gravity would be the only reasons why I wouldnt just use and modify the CMC to my needs
but thats just me, and I am a noob here π
or if I need my character to walk above 90 degree surfaces lol
@gleaming vector did you get it working with the OnRep_Owner?
havent tried yet
outside of work game project?
π
I'm working on charging an ability and then releasing it. I have 2 separate functions; one for spawning/charging the ability, and one for shooting it(detaches the actor from the character mesh and activates the projectile movement).
When I shoot it, the projectile always moves along the path of where i spawned it
instead of where im currently looking
@ebon nimbus what kind of character are you using? are you using the third person character where you can rotate the camera around the character without the character rotating? if so you will want to use your camera forward vector and not the actors
question with the onlinesubsystem, i have a lobby that has a player cap, when the player cap is reached i want no more players to be able to join until a timer has finished counting down, but if a player leaves during this time, the server reopens and people can join again. i have this all setup and when the player cap is reached on the server, i call UpdateSession and set bShouldAdvertise to false, the problem is this does not seem to prevent people from joining the server. i also tried setting NumPublicConnections to 0 and that still didnt prevent people from joining. any ideas? i could do this on the client to prevent them from joining but NumOpenPublicConnections from the results of the found server returns 0 always so i cannot get the correct player count
Hey guys, I'm trying to make a lag compensation system and the way I was going to go about it was to keep a buffer on the server of hitbox transforms at a certain time on the server.
Then when a hit is sent from a client the server finds the time that the client sent the hit and gets the hitbox transforms, Then does a trace to see if it hit.
Would this be the correct method of going about lag compensation or is there a better way?
Also not sure if UE4 syncs up animation states on the servers / clients by default does anybody know?
Would also be interested in a discussion about methods of rolling back server state to match client state to give clients a more precise aim feeling
@ocean geyser sessions aren't stopping you from joinin afaik. You need to update the MaxPlayers variable in UE4
Specify it when opening the server in the OpenLevel options
E.g. ?Listen?MaxPlayers=8
Then it will auto kick connecting clients if the game already has 8 players
not a bad thought, i having it automatically find/connect to servers and since there will be a "pre lobby" with only friends, i need to get the current player count of the servers that are found to make sure there are enough free slots for the amount of friends connected in the pre lobby
Hey all! I have a question about some profiling stuff. Was wondering what a good Count amount in the Actors tab is for something like 10-20 seconds of profiling? Been cutting down a lot of call with dormancy and all that but don't really have any data saying "X number and Y bandwidth is good for this duration". Obviously it depends on the server but some numbers would be helpful to know what I should be benchmarking for
i was practicing and i am stuck at this, why this doesnt work? when this DecreaseHealth function is being called i check if its server and if its not i call RPC function and in that RPC function again i call this DecreaseHealth but this time as a server and i expect server to do the job for client, but result is something else. it only works for server and there is a conflict between client and server, server gets the client data on its screen
void AMultiplayerBallsBall::DecreaseHealth()
{
if(Role < ROLE_Authority)
{
Server_DecreaseHealth();
}
else
{
Health -= HealthDecreament;
if(Health > 0)
{
ARollerPlayerController* PC = Cast<ARollerPlayerController>(UGameplayStatics::GetPlayerController(GetWorld(), 0));
if (PC && PC->IsLocalPlayerController())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Health %d "), Health));
PC->SetHealth(Health);
}
}
}
}
void AMultiplayerBallsBall::Server_DecreaseHealth_Implementation()
{
DecreaseHealth();
}```
clients health(blue bar right above) is always 0,
i tried the code without the first if block( where checks if it has authority) and client get the blue bar on its screen too, but i think its a wrong aproach cuz server should do it for client right?
The actual var is replicated right?
yes Health is a Replicated var
'Health'
by the way that bar on the server screen show both client and server itself , if u look at the picture there is a different health number printed on screen
isnt it a reasonable approach? when that decrease health function is being called i check the authority, only server can decrease the client's health, so i call RPC and it do the job and decrease the health for client. but why this only works for server? I used RPC for Movements or Firing exactly this way, they are working fine
clients call the server rpc
but
authority should only be the one adjusting health
damage should only be handled on the server
no need for RPC's to adjust health
server should be authoritive, only server should apply the damage/reduce a players health, cllient should NEVER tell the server to change someones health
@meager spade well that's right and in this case client asks server to reduce its health, is it right?
no
client should never ask server to reduce his health
overlaps/damage should be handled server only
assuming we are client and we want to fire, we should ask server to do this for us right?
with RPC
Yes, but only the initial "I want to fire."
Everything after that should be checked by the Server, e.g. Enough ammo and the actual LineTrace to deal damage.
well if i want to reduce Player's health every second, i should ask server?
if i dont it will only happens locally
No, the server should just do it.
The only thing you ever "ASK" the Server to do, is forwarding Player Input
Everything else should already happen on the Server anyway
So only your "I want to fire the weapon" should be an RPC
Everything after that, may it be a bullet spawn, a line trace, a debuff that ticks every second, should just happen on the server
void AMultiplayerBallsBall::DecreaseHealth()
{
if(Role < ROLE_Authority)
{
Server_DecreaseHealth();
}
else
{
Health -= HealthDecreament;
if(Health > 0)
{
ARollerPlayerController* PC = Cast<ARollerPlayerController>(UGameplayStatics::GetPlayerController(GetWorld(), 0));
if (PC && PC->IsLocalPlayerController())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Health %d "), Health));
PC->SetHealth(Health);
}
}
}
}
void AMultiplayerBallsBall::Server_DecreaseHealth_Implementation()
{
DecreaseHealth();
}
this code is only happening on server right?
client only asks the server and server do the rest
i dont get it why
Cause it allows cheating lol
Client can just call that function on every AMultiplayerBallsBall instances
And wins the game
Plus the code in the middle:
if (PC && PC->IsLocalPlayerController())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Health %d "), Health));
PC->SetHealth(Health);
}
Is only ever called on the Server. Idk why the PC of the Server needs to have Health set
i thought every instance has its own PC and everybody will call its own /:
You limit that part of your code to AUTHORITY
And then you check "IsLocalPlayerController"
So that's only true on the Local PlayerController of the Server
So basically the ListenServer's PC
ok i need to follow more tutorials, im totally confused lol
they somehow modified the "initial bunch for late joiners/net cullers" code in 4.23
and the possession issues that existed back in 4.22 doesn't happen anymore
so it wasn't exactly a possession issue (which would need a proper revision btw because there are still some flaws in the code)
so apparently now is not needed anymore to explicitly set ownerships and call unpossess manually
However, do it at your own risk. Just saying.
vor: Spends multiple hours and days on fixing a bug.
Epic: Oh, yeah that was fixed in 4.23.
"seems to be fixed"
but yeah, the story of my life xD
I need to deploy one test for QA with the minimal setup on 4.23 because I am still skeptical
Its almost as if they have everything fixed, and just look for pull requests, then release them themselves just to screw with you
Btw, I randomly got to thinking about mouse accuracy over network, how the server sees stuff and so on. Would it be at all useful for the server to look at your windows mouse pointer speed, mouse polling and DPI, to determine what's the maximum screen pos that you can move between updates
to figure out if you are aimbotting
I would imagine that can be fooled by most aimbots which will just interp screenpos,but still. Wondering if its actually viable
Ah... aimboters. The problem with aimbot is that everyday it gets smarter and harder to detect due to the "natural movements" some aimbot aplications make.
If you want to invest in technology to review if someone is aimboting or not, it might be needed a human analysi... or a trained a neural network able to take that decision with several data from the "suspicious player".
But dropping a player just because he did a 360 shoot or something harder to achieve for a normal player is a no-go
You can try to detect these "weird situations". Track them, and then if the "weird situation" count exceeds a ratio, then evaluate the player more concisely.
But imho that player would have been reported already by several other users
the best effort you can make is to implement a hit leeway system, where you can't manipulate where you spawn your traces/projectiles in the client
I am just thinking out loud, I am not in the position to be doing cheat prevention anytime soon π
it's a cool topic tho :)
best solution for cheaters I have seen is when Respawn recently introduced cheat based matchmaking
if they detect that you are hacking, they just put you in a pool with other hackers to matchmake against
without telling you
Hi there! I'm struggling using steam. I want to show players' profile picture but since sending SteamID over the network is not working I'm struggling with it. Do you know what's the best approach for it?
The issue was fixed for characters, not for Pawns.. So... yeah I guess if you are using a pawn you'll need to explicitly do the proper ownership calls https://www.youtube.com/watch?v=4eusRdusrCg .
π€¦
How I tell all Clients to run Execute console command?
Could I use Game mode for this
server can get the playercontrollers, and send a client rpc
to execute the console command
thx
@brittle karma an example, if your checking to see if a player was shot via a line trace, you perform the line trace on the client, if it hit something then you call a server rpc to perform the same line trace, if the server hit what the client hit, then you simply call your lower health function. you dont call it from the client like that, you should only check if the player has authority in that function. if a client tries to call that function, it will run on the server as well so the client can call the function as much as he/she likes because it calls to the server right away
@ocean geyser
as i understand we use that authority guard to run the code on the server only and replicate the value to the clients, right?
but what i dont understand is when to use RPC and when to use replicated variables.
for example in a tutorial the guy used an RPC for pawn movement and said that client should ask server too run the codes for him, now i want client ask the server to decrease his health, but as guys said it is a wrong approach
what do you have that would normally decrease your health? what even? you would want the event to run on the server, and have the server call your take damage if it deems it necessary
time
i want to decrease the health by passing of time
one basic question,
if(Role == ROLE_Authority){ // some codes here}
this only runs on server right?
so if it only runs on server so how its gonna change values for client?
if we make the variable Replicated it will do this for client? but how it recognize which client's value should be affected?
why would you send the server a RPC to decrease clients health based on time?
server is aware of the rules
and the situation in the world
doesn't need the client to tell him what to do
with exception of user input
i thought it might be a good protection, so the client asks the server to decrease its health
so what about this scenario? client overlaps the item. should server handle this one?
server is aware of the overlap
this is an example of authority check coming into play
as the overlap will run separately on client and on server instances of item/character
void AP_Laser::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if(Role == ROLE_Authority)
{
InstegatorPawn = Cast<AMultiplayerBallsBall>(OtherActor);
InstegatorPawn->UpdateLaserAmo(LaserPower);
}
}
in this overlap event for example. that authority guard is not necessary?
cuz as u said server is aware of this event
but here is my confusion if it doesnt run on client so it will only works for server
i don't see where the confusion is there
what if client overlaps the item? the authority guard will fail
and?
and client wont call that Update function inside if block
clients pawn overlapped the item at (roughly) the same time on server and on client
if you're thinking that server and client share the same instance of your pawn or your overlapped item, they do not
they each have a separate instance of every replicated Actor, and every Actor loaded from package'
which are assigned a NetGUID so the NetDriver can resolve the object reference over the network for replication and RPCs
when i play as a client and i overlap the item, it passes the authority guard, im thinking ok our role in the game is not authority, but why we passed the if(Role == ROLE_Authority)
because you are misunderstanding the term "play as client" or because you incorrectly assessed that it passed the authority check
one or the other
option 3 is that you spawned your item locally
heres an example of what im talking about. i created a timer on the server, every X amount of seconds, the players hunger/thirst(in your case, health) gets lowered. the hunger/thirst variable is replicated and being changed on the server, so when the server changes it, the client receives it. make sense?
https://www.youtube.com/watch?v=eo4uwbDLKcI
In this tutorial we will be covering how to make a simple Hunger/Thirst system that decrements a little bit over time. We also encounter our first issue(that...
so client actually has authority over it, but the item does not exist on server
@ocean geyser i have watched it and yeah it makes sense i just am practicing and seeking the terms and new stuff, thanks (:
@winged badger please take a look at this short video, if u look at the logs on the screen, client calls the function inside that if(Role == ROLE_Authority) after overlapping the item,
if its regarding overlapping events, the overlapping should occur on the server as well unless you created the overlap box component thing on the client so the server doesnt know about it. in the overlap event like you said, check for authority and you should be fine, only the server will run the code from there
so here is what i understand, whenever client overlap the item, that overlapping event automatically runs on server for the client?
should yes. the server knows where each item is(if it was created on the server), so the overlap event should run on the server because the server can see that its overlapping
guys I am having an issue: I am uising interp to constant function to interp a parameter of a material to smoothly make it glowing. In the delta time parameter I put the delta time of the tick and I set a constant value for the interp speed. The problem is that for a client with more FPS, the glowing "animation" will be done much faster than for someone with lower FPS. What should I do so the "animation" takes an equal number of seconds to be done for everyone?
multiply the speed of the animation by DeltaTime
oh wait
u already use deltatime?
can i see your code?
FInterp nodes / whether constant or not are not the most reliable
i tried multiplying the speed with something that would make it slower for clients with more fps and faster for clients with less fps but it wasn't that great
im pretty sure you need to plug in a speed to the interp speed paremeter
Ah yea, well you speed needs to be something other than 0, and on top of that, you need to be setting in the variable after you interp it, so that next interp is closer
your current variable should be the one you set last frame
ok ignore that image I just made something up really quick but it didn't prove my point. Here is what my actual situation is:
im trying for this one to set the location of a actor
for clients with better performance, it goes faster than for the clients with less
i need to somehow make the speed dynamic so it is the same for all the clients
but i don't know how
As I have said, interp functions are a mess, and since you are using BP and not C++, it will be tough to make your own
you can try using a fixed delta time, instead of relying on the clients on
set it to like 0.16
hm ok
I mean I tried this before and it looked ok but I am not sure whether it's reliable or not to do so
any reason why you are using this instead of a timeline?
hm ok let me try with timeline I guess
@ocean geyser At this point ive used a first person and 3rd person camera, as well as the player controller, and just made up a random transform. All the same result
Guys can an actor component have RPCs?
yes
I have a question. So I have an actor component for my character called inventory and this piece of code is in itInventory[0]->ClientCallOnEquip(Character);Character is a reference to the owner of the inventory. (I pass this reference in so that I can get the character's mesh for some later functionality in the OnEquip method). So what this piece of code does is call a Client RPC on the weapon actor that then calls the OnEquip method on the owning client so that I can do some client specific effects when the gun is equipped. So with that being said, my problem is that when I pass in "Character" when calling the Client RPC (like in the code above), it is a good reference, but then for some reason when I call OnEquip(Character) within the client RPC, Character then = NULL. So why is it that once I get on the client on my weapon actor the Character reference is no longer valid? And How can I fix this?
Hi All, trying to find out why some variables are not replicating, I have done something similar on another blueprint which is fine, so not sure what is causing this.
Simplified, setting a variable on event begin play with authority of the server, if a client joins, so has no authority, it should in theory through replication have the variable set by the server, the player joins after the server is created, not at the same time:
im having a very1 weird issue with my character not replicating attacking any help would be greatly! appreciated
this the bluprints for them
Is combo 1/2/3 a RepNotify? you arent showing us your full code regarding your issue
@main owl i recommend checking out https://www.youtube.com/watch?v=6w8_eC5qlSs
This video is a basic explanation of what network relevancy is and why it must be considered when making network content in Blueprint. A link to the wiki for...
Yea have watched that, was not helping in this situation. Even when using a multicast, the variables are not replicating.
the answer in that was use a multicast with a repnotify