#multiplayer
1 messages ยท Page 532 of 1
the repnotify has only a destroy actor for now
you dont need to destroy actors on client side if your pawns spawned by the server
and the switch has auth doesnt really matter cuz this function is inside the event any damage
the actor isnt spawned in
yes i realized that by now, however reading your text i assumed it is onrep event, hence my confusion above
yh sorry abt that
in a multiplayer game i think spawning a player character is generally a good idea as you can properly understand the life cycle of that fella
put print() nodes or breakpoints and see whats happening with the onrep event
kk
i think its possible your pawn could not destroy because some other actor may hold references to it
the client can damage it
when the thing "dies" it gives the client xp and everything
just doesnt destroy the actor
I dont remember exactly but perhaps placed actors cannot be destroyed.
also i havent considered anyone joining the late until now..... i have to do something abt that as well now lmao
props with onrep much better than multicast rpc for this reason too, they can give an inital state of pawn
eg you can make them look dead upon showing up on screen
because property has inital state of isdead=true you can do that in beginplay
I think it may because he is a placed actor, but not sure.
gamemode will take care of spawning the default selected pawn type for any player joining in
you just put down some playerstarts which the GM will use
use gamemode for spawning, oh i usually level blueprint, thx for help again
level blueprint is not quite for this purpose
@tawny parcel I got part of it fixed. It seems the animation appear faster as well.
Only in dedicated and in one of the clients dedicated unchecked.
So in order for my bullet impact effects and decals to show up exactly for every clients I have to make these events reliable. Is this efficient? Or is there a better way?
multicast rpcs are not comes cheap, a replicated struct may be better. also it's a funny concept your client seems authorative in telling the server what he just hit. usually its the server makes the same bullet path and figure out whether the client was true or lying about a shot. then server will tell everybody about a bullet hole by multicasting or replicating a struct with onrep.
reliable can be a problem tho, it may stack up rpcs since i think reliable actually needs confirmation from clients they received it
@rotund sapphire I run the bullet trace on server then just send the location and rotation to these events in order to spawn the correct emitter at said location and rotation. I thought that multicasts were supposed to be used in one-off events and that onrep's are used for important things like states or things etc.
ServerPlayImpactFX is accept calls from player to execute the event. If you only run this event on server, then remove the replication rule.
@rotund sapphire im sorry again, but when you told me abt ppl joining later, it kinda thrw me and a spiral lmao. this is suppose to be a equip sword system, where it destroys the old one in the destroy on equipped notify( the blueprint says it isnt, but it is), the notify contains a destroy actor. it works with all the clients currently in the game but if a new one joins it stops working https://blueprintue.com/blueprint/tyrnbvow/
You can use multicast rpcs, but answering your question you can optimize by using onreps instead.
BIVZe its going to spawn sword on client, however in networked game you want to only spawn stuff on server then set replicate true, so it will replicate to everybody. there you can attach it once the new actor will arrive.
@rotund sapphire Ok I lied lol I just looked and I run the bullet trace and hit events on the players and then just replicate the impactFX. I guess you're not supposed to do that because of cheaters? But my game is just a simple coop game so if they cheat it don't matter really.
i think its about respecting authority. the server is hosting the game so anything happens should come from server telling what to show. client can make a shot and show some local effects, but server will tell everybody else about his opinion of what exactly just happened.
I get what your saying. I think I was afraid that the listen server would get bombarded with too many bullet traces from all the clients that it would lag everyone.
i dont think that will be an issue
Ok I'll redo it for server and then use onRep if you say it's better than multicast. I just know there will be a lot of impact FX so I wanted it to be as optimized for the network as possible
Like i said you can continue use multicast rpcs, but perhaps a struct will replicate with less effort.
you can remove reliable tho, that's potentially an issue, can be blocking i think
that's a big oof
Hey why would my game be able to find LAN sessions in a non-shipping build, but not able to find them in a shipping build? (When i was still using nonShipping build I set the ini file's Online subsystem to NULL)
Any idea why only multicast plays anim montage but not when I use Run On Server?
unless you are replicating the motnage play another way
the server will play the montage but the clients wont
Also depends on what you are even doing. Not enough info to help.
Could anyone direct me to some form of tutorial that explains how server-side saving works?
@river hazel @thin stratus So I have a horse. I mount the horse by attaching the player to the horse's socket. The player has the controller. Once mounted I send player's MoveForward and MOveRight info to the horse' BP by using interfaces. In the horse BP, I update a variable called movement. Previously I used to use that variable in horse's animBP to play root motion animations. Now I'm switching to PlayAnimMontage and placing them in the horse's BP for network purposes.
What's the best way to (de)serialize data from an archive into another archive? found a viable solution
Just need to make sure, does NetSerialize get called on FFastArraySerializerItem structs?
yeah
Just not on something that has NetDeltaSerialize instead
Look at FFastArraySerializer::FastArrayDeltaSerialize in NetSerialization.h to see where it calls NetSerialize on the items
Is there a special point in implementing FSavedMove_Character::Clear() and resetting all the custom values to the default, in the saved move, in CMC? Won't they have a default value through the header declaration e.g float SavedSomeFloatValue = 0.0f;?
๐ thanks Jam
i am trying to use render custom depth but it only works on the server not on the clients, any ideas?
i have a multicast event
Would this be the best way to add things to a players inventory when they pick something up? The interface is ran on server.
@woeful ferry Is everyone on the server supposed to know that they have this item in their inventory? Or is it just a private matter between the server and the client that picks it up?
@rain coral Well, when they get killed other players should be able to loot their friend's inventory.
That's where I think it would be relevant
@woeful ferry The problem arises when a client joins the server after the client picked it up. The multicast only ran on the clients that were present at the time. If you want new clients to know that this player has this item, a replicated variable is more appropriate. All the replicated info is handed to new players, so it won't matter that they missed a multicast event
That is true! So once the player dies or disconnects, you tell the server what's in my inventory?
Well, the client shouldn't specify to the server what is in their inventory, the server already knows what's there.
The clients might not need to know whether someone else has a certain item in their inventory until they're dead/disconnected, at which point the server can update a replicated variable which exposes their inventory items to other clients.
But the main takeaway is that as long as the server updates a replicated variable with the inventory info, all current players and new players will be notified
Thank you for the clarification. Trying to come up with a way to do this ๐
^^ ๐
So more like this?
@woeful ferry So in this screenshot, all the server is doing is calling a client function, so it gets added to the client's inventory, for that client alone.
Instead the inventory component itself should set Component Replicates to true, if I'm thinking about this correctly.
Then, I imagine the inventory component has an array of SlotStructures? In that case, the array should be marked with Replicated, or RepNotify. Replicated just means that all clients will get this variable when it changes. RepNotify is the same, but makes a function for you so you can do additional things (print a message etc) when the variable is replicated.
I don't know exactly how you've implemented your inventory though. But replication makes some stuff like this pretty simple. Whenever a replicated variable changes on the server, every client gets it
I can show you, hold on!
(but if the client makes a change to a replicated variable, nobody else knows)
This is what it looks like when I add an item
My first go at a inventory system, so please be kind ๐
It's probably fine ๐ So in this case, whenever Inventory (which is replicated) gets stuff added into it or removed from it, Inventory changes, and it will automatically replicate to other clients. Given that this happens on the server, of course, otherwise it won't be replicated to others
If you make it RepNotify, and make a print node in the RepNotify function, you can verify that it works as expected
Do i need to explicitly add android permissions or something in a shipping build.for android to be able to find LAN sessions? Does it use a.different ini file?
Versus the other build types used during development I mean
@woeful ferry Wooo
Now it's just the UI that needs to be refreshed correctly, but the array get its values. But I can try to fix the UI myself ๐ @rain coral
I mean what is the difference in shipping build that could cause that?
Mayne it has nothing to do with android. I am not sure where to look
@woeful ferry You can use the RepNotify to update the UI with the correct info
Looks good btw!
Damn that works wonders, now the UI updates too ๐
Slight delay, but it works
Probably doing thousands of network calls atm ๐ Have to check out the network debugger
@rain coral RepNotify only works in multiplayer right?
@woeful ferry If you change the replicated variable on the server, it runs the RepNotify on itself too, so it happens regardless of any clients being connected or not
Yes, but my game is both singleplayer and multiplayer. Like if I play in editor without simulating as a listen server it won't fire.
Okay it works if I do a setter, then it fires in singleplayer.
Ahaa. With singleplayer, do you mean if you just run it in viewport without any additional clients? I thought the editor always ran as if it was a listen server ๐ค
Yes, with only 1 player it won't fire
Can you see the image?
It just loads for me
Ah okay, so I guess it was on the server, but you had to explicitly set it. Yeah just loads for me too, but I clicked it and could see it then
Yes, I have to set it in singleplayer if I want a notify to fire.
In multiplayer it works without it
But now I guess it will fire twice then?
I see, good to know!
In multiplayer that is
Hmm, the clients will only get one, since they get it only if it changes from its last value. But I'm not sure if it will fire twice on the server, or if Set w/notify is the only way to get it to fire on the server
Yes, if I add a set it'll fire once on server and once on client.
But in singleplayer it doesn't fire unless I set it
Interesting
@rain coral Thank you for the help by the way, really helped me wrap my head around solving problems in the future with replication ๐
@woeful ferry Anytime ๐ I ask a lot of questions here and get a lot of help too, only glad I'm able to give some back
In November 2017 I said my game will be in early access in march 2018 ๐ so I'll be ready for your game in January 2022!
@rain coral Would love to see what you're working on, if you don't mind sharing in like PM.
@woeful ferry I don't mind sharing here, but feel free to PM if you fear it will be too offtopic =)
http://gunandbuckler.com/ (hope this link works? Yesterday someone said it didn't)
Nope it doesn't work ๐ฆ
https://www.deltaquack.com/gun-and-buckler/ Hm weird. This works
Oh shidd, it's this game! Seen this on the subreddit ๐
Aah, right, yeah I post on reddit too! Cool that you've seen it ;D
https://unallocated.itch.io/outpost-glacier This is my game, I also post on the subreddit ^^
Haven't seen it before, but looks gorgeous!
Thank you! ๐
I wanna play your game with my friends and beers
Seems like a laugh fest
Soooon ยฉ๏ธ
cant seem to understand what is the problem here
modifyItems function is inside c++
is it because its being called inside widget ?
yeah I guess it was the reason
can someone link me to a youtube series that they have used for setting up multiplayer? There isnt one in the pinned messages which is surprising with this being a multiplayer help channel.
im trying to set up projectile but they do dmg to the owner as well as others, is there a way to check if the player is the owner of the projectile and and then do dmg
@queen flower https://www.youtube.com/watch?v=09yWANtKmC8
Creating a networked multiplayer game isn't easy, but Unreal Engine's gameplay framework is designed to set you up for success. On this episode of Inside Unreal, Technical Writer Michael Prinke will cover fundamentals such as the server-client model, various features of replic...
dang. so bummed i missed when this went live
pin this? lol it happpened just after I hit the wall of setting this up and took a break.
can someone explain me why i cant connect to my gamelift server if im using steam?
how do we know?
we cant see your game nor your code nor anything..
we are not mind readers
lmao
anyone never used gamelift?
im trying to set up projectile but they do dmg to the owner as well as others, is there a way to check if the player is the owner of the projectile and and then do dmg
i used gamelift b4
it went pretty smoothly for me
if i just join without steam i can join. but with steam no
i nvr tried it with steam so idk
fk my life
when we spawn a replicated actor on server, properties that are equal with default value won't be replicated as initial bunch am I right ?
but they still take CPU performance ?
so how to disable them completely. (things like Instigator,bCanBeDamaged,..) AActor has lots of replicated properties which I don't need at all
there are some macros that you can use to change the conditions or disable replication of inherited properties
check the header where DOREPLIFETIME comes from
can I ignore them by writing my own stuff instead of calling super in GetLifeTimeReplicatedProps?
that also works but then you have to make sure you copy paste the macros for the properties you do want
(and check if it needs updating on every engine upgrade)
I want to spawn 10000 of actors which they are not replicating any movement and ... just need their actor ๐
hope that they are not private ๐
Edit*~~ ue4 online subsystem cross platform compatibility is still non-existent?... ~~ found a link on how to do it
I have a technical question. ๐ why UE4 checks the replicated UProperties for change every time ?
couldn't they just use a boolean variable as state of a property ?
plus some Setter Getter functions maybe
@rose egret If I understand you correctly, you could set an actor to be dormant, so that it never checks for a change, until you call ForceNetUpdate manually, at which point it will replicate in that frame, and then stay dormant.
it's because replication was originally made in a very dumb way, in 4.25 they are adding push model which finally makes it make sense (using explicit dirty lists rather than checking every property all the time for no reason)
So any final guide on how to reliably increase bandwith per player on server?
Seen a lot of things on the internet saying different stuff
@fleet raven do you know where I can find more information about the upcoming push model?
find a header called push model in 4.25 branch
Thanks
Do you if it's planned to be a full release, or just experimental as of 4.25?
Is there an event fired when an actor/component loses net relevancy?
If I setup my project to use Steam multiplayer, is it equivalent to testing in UE4 dedicated server check box on?
So I have a dismemberment system I created that hides the bones you shoot with your weapon. It works but I'm trying to not use Multicast and instead use OnRep to hopefully improve performance. How should I approach this? If I use OnRep would I have to promote the bone info I'm passing along to a variable so the OnRep function could retrieve it? https://i.gyazo.com/0ba834f91a1de9dd8a50ea5e9c83ee3b.png
@cedar finch maybe a onrep replicated array of hidden bone names? in onrep loop through array and check if bone is already hidden, if not then hide it and play effect
@ocean geyser So I did that inside the "MulticastGibZombies" event before. So instead of redoing it, I remove the replication on the MulticastGibZombies event and just made it a normal event. Then I did my dismemberment checks on server, set the bones to a replicated variable, called the gibzombies event, then also set an OnRep variable that also calls the gibzombies event. https://i.gyazo.com/cfb9affda9a5ada025abf6ca2822b29c.png
https://i.gyazo.com/53761c7745f70c48856b519887b451eb.png
It seems to work in-game. You think that's optimized?
@cedar finch I think thats a solid route, good work
Now I'm stuck trying to make my shotgun bullet impact FX play OnRep. I have one linetrace function that I execute 8 times, one for each pellet of the shotgun. I just can't seem to get the impact FX to show up for all clients. Clients only see 1 bullet impact FX instead of 8.
make an onrep for the effects when fired. store the impact points of the hits among other information that the client needs to know
So I have the hit location, rotation, and physical material of what my bullet just hit. I tried setting them to variables and then setting an OnRep variable that would then spawn the FX but still only one. https://i.gyazo.com/f149d60c7a448a76f624c572fd135dbf.png
https://i.gyazo.com/41c15f240764b475016abf353d3abbe9.png
It's like it happens so fast that it doesn't have time to set the impact variables and call the OnRep for clients that fast
make a struct that contains the impact locations/rotations as an array along with the impact material for the effect?
FX should be multicast
you can't use replicated variables to indicate the occurrence of events, you can only use them to carry and transfer important data about "current state". the fact that you can run code when they change does not make them suitable to use to represent the occurrence of events. the server will never send every little quick change to the variable (in your case it is obviously just sending the final change, the last pellet).
@cedar finch
super mega-simple example, if a player gets shot by 3 different bullets that all hit him on the exact same frame, the server will set their health 100 >> 75 >> 50 >> 30 all on the same frame as the bullets hit ... the server had previously replicated the health variable as 100, now it's changed and will be replicated as 30
@fleet raven This push model seems kind of awesome.
would be once they work out the kinks with it ๐
@hoary lark I get what your saying thanks. I previously used a multicast but it only displayed the impact FX when I had it set to 'reliable' but I was told yesterday that could be an issue for the network. I'm not sure what to do. I just want it to be optimized for the network and display for everyone
@meager spade Sorry for the late reply, is it possible to do it in the AnimBP in any way? I've spent a long time setting up all my animations through the AnimBP.
not networked root motion no
Damn.. Do you know much about montages? I have actually heard quite a lot about montages when searching up how to do networked root motion. I can't seem to find anything explaining the functionality of a montage and how I make it work similar to blendspaces and stuff though.
montages are just animations played in game code
not for locomotion that kinda stuff
for things like sword swings, grenade throwing, etc
Yeah, I've heard some examples, like partial reloading for shotguns
I'm not sure how I'd make character movement in any way other than in the Anim BP.
@cedar finch shouldn't be any issues using an unreliable RPC for broadcasting "unimportant" events like a hit impact (that's definitely a preferred sort of use for them) :\
Really? There isn't any way at all to use it? I don't mind any input lag as my setup can be played at 10 fps and feel smooth with a lot of input lag. (That's if there is a way that it can be done but it has input lag)
I like that the character has to put a foot down before stopping. Since my character is a Wolf. It feels a lot like controlling the Wolf, rather than you actually being the wolf. Makes it feel more realistic.
removing clientside prediction is never a solution. never. 
I don't mind cheating. My game is a campaign game that will hopefully have up to 4 people (Invited by host) play. So if they cheat, that's on the host.
I think that's what clientside prediction does? Stop cheating?
Wait, were you talking to me @hoary lark? I'm confused.
yes ๐
ah
no that's not what clientside prediction does, it prevents input lag heh
Ah, well, eitherway. I don't mind cheating, so if that brings up any possibilities?
I got really close to having it work actually. The only issue was that the animations played at a separate speed for the viewer and controller.
I guess I'll have to get to making the same feel with IP animations.
@split nova It's possible to extract the root motion track from an animation and use it to move the character, which would probably replicate fine
But it's not straightforward when you start talking about blendspaces and complex pose processing
Ye. I'm pretty sure it'd be harder and much further out of my league when it comes to knowledge to do that, than to just make it feel kinda the same using the supported motion for multiplayer.
Though, given the right information as to how I could do that. I'd go down that path, I don't think the feel for the walking animation I have would be the same without root motion. The character slows down when the legs aren't really pushing forward, but when they're on the floor and pushing, the character speeds up a tiny bit.
When I kill a zombie should I make the Server set the "isDead" OnRep variable to true, then inside the OnRep function do the simulate physics and play death sounds? https://i.gyazo.com/fdd3dce05bd30aaf9fff047d2baa2c88.png
not really
how about if another player comes relevant never seen that zombie before
he will see the death animation again
or ragdoll start animating
then hear the zombies death sound
... (Continuing) does cross platform not work in shipping builds with NULL online subsystem for LAN?
@meager spade Oh yea. You taught me that a long time ago. Hmmmm this is where I get confused. I want everyone to see the zombie ragdoll when it dies, but I don't want to do it wrong where it's trying to replicate the ragdoll movement on the ground. That would be bad right?
i'm using the "Event AnyDamage" so it's on the server correct? How should I activate the ragdoll so everyone can see it?
I guess I could just ship my game using a non-shipping build if that is the case
But i would really like to know what makes Android unable to see LAN sessions hosted by PC on the same Wifi when it is a shipping build
So that I can still have a shipping build that is cross platform
ragdoll should be multicast
actual being dead (final state after ragdoll, should be set via the rep notify dead bool
So in my case I simply check if health <= 0, if true then simulate physics, disable movement, delay 10sec, then destroy actor.
Well yikes
https://blog.squareys.de/ue4-android-windows-lan-multiplayer/
I think i should just ship with non shipping build then if I have to alter the engine otherwise
Since it was working in non shipping build
Well, I ly if I start the game, then turn the android's Wi-Fi off and back on again. Then it works. But this workaround doesn't work for shipping build. Any ideas why?
Using 4.23
Is advancedsessions plugin something that can solve this problem or is that only for Steam?
Is using a SaveGame BP unreliable for a multiplayer game
Is using a SaveGame BP unreliable for a multiplayer game
@shy kelp Depends on the type of multiplayer game, but in general yes.
@solid echo what would u personally do
@solid echo what would u personally do
@shy kelp Again, depends on the type of multiplayer game. Is is something like Conan Exiles where player inventories and stats need to be saved? Or is it just a FPS with static waypoints like Doom/Quake?
I wouldn't use SaveGame at all. SQLite would be your best bet since there's a really good plugin already out for it that's free.
thx
Anyone know of some good documentation, videos, or other material that covers the network profiler and how to reduce waste? I want to learn how to reduce the amount of times the server considers things for replication. https://i.gyazo.com/600bc3787206602f9ea7e642f108f203.png
A chest or door and other actors shouldn't have 159 checks.
Use RepNotify for chests.
If it's not going to be moving and is something static like a door or a chest, use RepNotify for those, otherwise it's constantly going to be sent over the wire.
Basically use a RepNotify bool if the door is open or closed, the client can handle the animation and everything else.
@solid echo Yea I know. I just watched this video and he said mentioned what I said above and it made me thing: https://youtu.be/KsORRtBOJYc?t=1751
๐ฎ Unreal Engine Replication Series - Part 4: Multicast & RepNotify
Part 4 of our replication series unlocks limitless potential with Mutlicast and RepNotify! In this video, we dive deeper about how Actor Replication really works as well as introduce ourselves to a variable re...
I timestamped it
Yea, basically that.
And if you want to get fancy you can look into Replication Graphs
Should I be setting persistent variables that I want to save on a database so player stats stay when they log off, and get retrieved on game join, in playerstate?
Multicast will send it out to all clients, a RepNotify is essentially the same thing with a callback function when it's replicated.
Should I be setting persistent variables that I want to save on a database so player stats stay when they log off, and get retrieved on game join, in playerstate?
@twin juniper It's one way of doing it. I usually stick things like that in an array and shove it in a DB (I currently use VARest with a php backend but that's because my game requires it due to using multiple nodes as one world.)
You can use their SteamID as their base unique ID in the DB.
Is there away for multiplayer configuration? Meaning, a player would be able to host their own dedicated server and change settings through a config?
Is there away for multiplayer configuration? Meaning, a player would be able to host their own dedicated server and change settings through a config?
@sly arch Short answer? Yes.
How would that be handled?
lol
You can read and write to the engine configs if you wanted to keep it easy
Or use something like a YAML file (i think there's a plugin for it)
Yes! How would they host their own dedicated server though? Since all the players connecting would have to be saved per server.
You give them the dedicated server binary and let them have at it? Everything should be self contained in it.
@solid echo so I have been doing it wrong lol had put loads of vars in my character not playerstate, time to fix everything, though essentially, I could just make a copy of the vars in playerstate, and hook them up to me spawning my character? Or I should port relevant code that is saved to playerstate?
But how would they save every player data?
To answer both of your questions, Just use SQLite (or MSSQL if you're feeling daring enough) and save players stats, states, items, etc in that.
and @twin juniper yea, basically you would spawn the character on the server and replicate all relevant saved info to the client when they load in.
The reason why I suggest SQLite over the internal save system is just ease of portability and management.
Can SQLite be used to create advanced sessions?
SQLite is just a storage mechanism, nothing more.
But each server would have its own yaml file with every player data
and each server's data might be different than another
You could use a master server
That's sorta what i was thinking as well
Or like I'm doing, I have a central DB that all of my nodes connect to store and pull player data when the player travels between nodes.
That makes a sense.
It used VARest to communicate with it, so it's an extra layer of security. You give the person a token, they set it in their config files, and they're allowed to communicate with y our servers through that API
I'm assuming you're using AWS?
You could also throw a salt in the dedicated binary itself.
Nah, I'm all self hosted for now. My lab is uh... bigger than most.
Well I was thinking on making a config file in the binary and they would have the players info in that.
Lol geesh
I'm a senior linux engineer as a dayjob lol, so it's used a ton.
Insane
Thats awesome! I'm / was before the conrovirus a intern at our local city in software development. Thats neat.
But as for the salt, you'll want to throw that into the binary so you don't have someone trying to hack playerdata with just that token.
True
It's not 100% hackproof, but it makes it pretty hard.
I guess im just confused on how to communicate to each server since each server would essentially have its own database
You store only the the transient data on the master server.
so player stats, inventory, etc.
Right, in that case I'll prob just use steam
How do you connect varest to each server though?
The dedicated servers keep a local copy of that and then whatever gameplay data that's relevant to that server
varest is just a REST api.
Is it possible to run a dedicated server + the game on the playerโs machine, essentially having them host the game? Anyone see any big problems doing this?
Right, I've set that up before locally
Is it possible to run a dedicated server + the game on the playerโs machine, essentially having them host the game? Anyone see any big problems doing this?
@coarse meadow Depends on their machine, you could let them locally host instead.
Or even if its not varest, how would I connect it to the databases of the people whom are hosting
They connect to you, not the otherway around.
Their dedicated servers would handle that bridge using an API.
NEVER let them connect directly to the DB, you'll need to store DB credentials in the binary and that's a huge nono
The master DB that is
Which API would I use?
@coarse meadow Depends on their machine, you could let them locally host instead.
@solid echo Do you mean a listen server? Seems when I do that level streaming replicates from host->client, something I canโt have, and itโs apparently hard coded into the engine
mmm lol
You can set it where the client handles the level streaming in world settings.
Will steam API not work with that?
I've never really used Steam API so I'd have to look around.
But you could use Steam API to get the playerd SteamID and use that as your global save ID for that player in your DB
Yeah I've done that
Essentially you'll have a Master DB and a Slave DB.
Dedicated server uses API to connect to Master DB when player connects to it, checks to see if player data is there, if not initialized data on both.
It uses a web or socket API to do that.
The easiest way would be VARest mostly because you can use Python/PHP/Javascript to make your custom API for your master server.
Or you can go the Java route and use websockets.
Mmm, Makes sense
But again, NEVER let players have direct access to the master DB.
Well, yeah of course not lol
Always have an API seperating it.
Youd be surprised how many people do that.
MY DB GOT HACKED.
Did you give them direct access and store the credentials somewhere in the game files?
Well... uhhh.... yea....
And did you give your DB * access?
Uh... yea...
I'm sure. During my internship I've worked with the different databases but not creating my own API, but i'm open to learning so that'll be neat
There's a lot of PHP examples, you can use the login script examples
I've created that. I had a whole website created using php and html
you can use MySQL for the masterDB and SQLITE on the dedicated servers, the SQL is interchangeable for the most part.
That's the primary thing I did
Well then yea, it'll be ezmode.
Yeah, that's prob what I'll do
You can set it where the client handles the level streaming in world settings.
@solid echo Just gave it a quick go. It seems the client's level streaming doesn't replicate (as intended). However, when the listen server player steps on a streaming volume, it replicates to the client still
I'm trying to have each player only stream what is around them, while keeping things like players, AI, etc. on the persistent level
You would probably need to use Replication Graphs then.
I've only been able to manage it with a dedicated server. Does a dedicate server have much more overhead then a listen server?
It doesn't load any graphics so it's not terrible.
But again, it depends on how performant your game is and the persons machine they're running on.
There's people out there that still use Core 2 duos and Athlon 64's lol
Makes sense
But yea I also forgot that that listen servers are basically all multicast
So that's why it's being replicated across.
I need to read up on Replication Graphs. Can they be used in listen server mode?
Not that I'm aware of. Rep Graphs basically split up the level kinda like level streaming does, think of each level as a replication server.
Working on a multiplayer game? Are there many players in-game together? On this livestream, our networking team will demonstrate 4.20's new Replication Graph Plugin and the server optimizations that were implemented for Fortnite Battle Royale.
NEWS
Unreal Engine Drives Mons...
Or rather chunks.
Cheers, watching it now. Btw, know if there's any security implication for running a dedicated server vs a listen server on a user's machine?
Listen servers are more easily hackable on the listen side of things since everything is all in one.
It's basically the authority.
Also when it comes to lag, the listen side will always have the advantage since they're the authority as well.
Since, you know, they're basically at <1ms latency lol
for competitive type games, you'll want a dedicated server. If it's something like minecraft or something that won't suffer from hacking much, a listen server is fine.
no prob
Dedicated servers don't discriminate, they hate everyone equally.
Ha
The project I'm working on is online co-op in a relatively open world, so while competitive advantage due to latency or cheating isn't the main worry, it really helps to wrap my head around it all. The main headache has been getting replication and level streaming to play nice in listen server mode
yea co-ops listen servers are perfect, as for level streaming and it not multicast across on listen server, I'm not sure, I don't use listen servers much.
I'll probably have to take the performance hit of running a dedicated server on whoever is hosting, just adjust my target specs accordingly
You could ask in the BP/C++ channels, they may know a trick or two
True, I'll give it a go (during better hours). Tried the blueprint forums but didn't get any responses unfortunately
Yea, multiplayer help is sorta limited in this discord lol
Something else you could implement (which is sorta hacky) is that since it's a co-op game, whenever someone wants to load into the streaming level you could do a "Player wants to go to x location, join them?" and if they say no then the level doesn't get streamed.
Since it's a co-op game, the players should be together anyways.
relatively at least.
Interesting. Would that require somehow intercepting the listen server telling the client to stream the level, and stopping it from happening?
Just trigger volumes on the edge of the levels and blocking the player.
Then just just check distance between the players when they hit the trigger volume
You could do something like FFXIV does with the blue dots in between zones.
The way I've been envisioning and testing this is that each of the max 4 players can go anywhere in the world, and my main concern is that they each must only load the static meshes around themselves to keep things performant. If I understand your suggestion correctly, I would partition the world like FFXIV to get around this?
Basically, the listen client needs to know where the players are at all times, the sad part is that since it's a player itself, everything gets multicasted
It doesn't know how to separate the players into there own replication bubbles basically.
Makes sense. I think the FFXIV idea may be an interesting alternative as long as I keep the levels big enough
Or, if you want to just do away with it all, just have a hook on the co-op menu that just spins up a dedicated server and call it a day lol
lol leaning towards that yes
Just not used to working with dedicated servers. I know with a listen server the same codebase will work when playing in single player or multiplayer. I wonder if coding for a dedicated server splits the codebase
sorta yes, you can use macros in C++ to separate the code so it doesn't compile, but as for blueprints and general design, it's not much different.
Call an RPC on the Server, Server Multicasts it to clients (or the client that called it), that's about it really.
Then your normal Rep/Repnotify variables and what not.
Keep in mind replicated variables only get replicated Server->Client
So if you change a replicated variable on a client, it WILL NOT update on the server unless you call an RPC to change it.
That was the biggest stickler for me when I first got into UE4 dedicated servers and replication.
You can also set priority as well if it's supposed to be reliable or not.
@sly arch something else you might be interested in: https://docs.unrealengine.com/en-US/Gameplay/Networking/OnlineBeacons/index.html
Overview of the Online Beacon system
Oh neat. I'm reading it now. Thank you
Hey, guys.
I want to make sure that I am using GameState and GameMode the correct way. I am trying to make an event that triggers when player interacts with certain object in game and when the player interacts with all objects of that kind to trigger another event that opens a door in the level.
So my question is where am I supposed to implement those events. Should I use GameMode or GameState?
if the game is multiplayer, there is no game mode on clients
which kidna makes it awkward
but
unless its a very small game you should really use neither of those
as using a GameState to dump all logic of that kind in soon turns into a cluttered nightmare
but if you do insist on GM or GS, use the GS
as it will save you replicating the state of your trigger in each of the affected objects individually - as they can bind to a GS event dispatcher client side (as well as server side) on BeginPlay and react to single replication in GS
Hello, so Iโm working on a game with multiplayer but want players to be able to host there own servers which I have. But I want the player data to save on there servers that player creates anyway?
So every server is different
You want to host the save data on your own servers and have players host the game servers, correct ?
Yes
So if someone wants to download the server download anyone that joins will save into the server file
On that server only
@bitter oriole
There is a big issue with this : how do you ensure a particular server isn't destroying saves, or cheating ?
A good example is Minecraft how they do there servers.
Player runs a .bat command and it starts
Each server will be disconnected from Mine itโs like a completely different itโs up to the owner
Of the server
If that makes sense
So you want the save data to be tied to the hosted server, or not ?
Yes
Letโs say if someone kills someone the stars will only stay on that server
Has a file
Stats*
Then just save on the server when it quits and load a player's data when he connects
Yes so how would u do this
Or trying to convert unreal into java language then I know how
Use to do it all the time in java
Ok
You should consider starting with reading up on Unreals server type and how it's intended to work. That would help you understand where you should be considering implementing certain systems, like saving data.
@pliant ember If you haven't seen it yet, check this out. It'll answer a looot of questions. http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
Iโm also confused on something else
Cause I want to be able to build but others canโt see it
Doesnโt it need to send to the server first?
@pliant ember You mean that you want to spawn buildings, but when you do this, other clients can't see the spawned building?
@pliant ember In general, what you need to do is spawn the buildings on the server. It sounds like you're spawning them on the client. Things spawned on client only ever exist in the client.
Replication only works Server -> Client
So a replicated actor spawned on client, will only be on client, Replicated actor spawned on server will be replicated to everyone.
Like for example how did fortnite do it they place it down
And I thereโs dan see if too
It
You really should read that compendium. Taken an hour an and just read it. It will help put a lot of that stuff in perspective.
maybe an obvious question, but what is the networking layer using under the hood? UDP? TCP? I can't find anything in the docs that's concrete about it.
there's the option for unreliable RPC, so I assume UDP?
Any idea why my "Add to inventory" on server does not fire in multiplayer?
Is it okay to ask questions about FSocket for C++ here or should I go to #cpp ?
@woeful ferry As far as I know you should call replicated events on Actors that exists on both Server and Client. So calling a Server replicated function on a Widget (correct me if that's not on a widget) doesn't fired since UI only exists on Client
@upbeat basin Yea, I just had a discussion with my coworker and we decided that we should move the logic to the inventory component.
Not have it inside the widget
I'm back, so if the owner (which is a storage box) exists on both ends, why will this not work to run on the server?
How do make an object replicate on the user that spawns it ? so that no one can see expect the player that spawns it( c++)
no @woeful ferry
Hey guys, I'm struggling with passing object ref array from server to client.
I am trying to make a lobby and when a client is connected to update his nickname to a text render.
The issue is when I call the update when someone connects only the server updates his text render but not the client. Furthermore, when any other action is made (like choosing a character) everything works like a charm, but the first time the client connects doesn update anything in the text. And I get an error from the client that NONE was accessed trying to read the name from the object that I have passed from the server to the client.
Any idea?
Server RPC can only be called on actor that is owned by an actor which has a Owning Connection (a way to a PlayerController)
regardless if the actor is on client and server, its Owner HAS to be a an actor with a route to Player Controller.
I need to call that event from the playercontroller instead?
@chrome ruin then your accessing it before its replicated
@woeful ferry ideally, yes, that is how i handle all my pickups
the controller handles Adding it to inventory, etc
@meager spade Thanks, I'll look into it and come back with the news ๐
try a slight delay @chrome ruin or use a rep notify/onrep and update it
if thats possible
with a property
isn't that replicated when I call the RPC?
the event is called, but nothing is coming from the Spawned Characters Slots
then the server has empty slots
where does the server call that
and what is Slots?
an actor?
yes
replicated right?
yes
then the client hasnt recieved the actor yet
when the rpc is called.
so it doesnt know about that actor.
it cant resolve what it doesn't know
so why not make SpawnedCharacterSlots on the server a replicated property
and in the OnRep function, do your logic
might be safer, but then again its a race condition
you can't guarentee the Spawned Characters Slots actors are going to be on the client when you try to access them
so, basically I have to use RepNotify, and add the "Update Names" event to be called (or just put the logic there) ?
Holy .... You are the best!!!! It worked!!! Thank you man !
๐
@meager spade It still fires on the client unfortunetely.
you cant do that
you have to call the RPC function ON the controller
oh wait
hmm
that should work..
It fires the event on the client
it shouldn't not via the PlayerController
Never mind, it does fire on the server.. I need a break ๐คฃ
๐
Thank ya! ๐
Hey guys, how do I differentiate between an actor being destroyed due to going out of relevancy versus being explicitly destroyed by the server?
not easy
Yeah I've noticed that.. lol
Actually, there is a Destroyed() method or something
That takes a reason as a parameter
Check that
Yeah i have, the EEndPlayReason only has Destroyed and some irrelevant ones
Ah, that's too bad
There is AActor::PreDestroyFromReplication but I vaguely recall trying that and having it trigger for both cases as well. Might try again just in case I messed something up.
For gameplay programmers writing C++ code.
Test: can anyone see my messages?
yep
no, we can't see them
yeah I didn't check for validity, just thought it was an interesting thread
Oh hang on, I see what OP is saying now
Ok. No response to previous messages then probably means nobody really has an answer for the questions I posted. I'll try my luck on answerhub. Worst case scenario I can just release the game using dev build instead of shipping build
They are saying there is room for supporting larger floats without increasing the data size (not higher precision)
I think the issue is that doing so would possibly decrease the precision for more commonly used values.
Hey! Anyone knows how I can perform movement on a character without possession?
I found the boolean "bRunPhysicsWithNoController" but that's not sufficient, my pawn is not autonomous proxy so it doesn't replicate movement to the server.
I tried to call SetAutonomousProxy(true) on the server but it didn't do the job cause client still "Simulated proxy"
If it's not autonomous then it gets the transform replicated from the Server.
I know but I want to set my client autonomous (without possessing the character)
The fact is I push Input into the InputStack of my controller to control my vehicle.
Not using character movement for vehicles are you?
I'm using it ๐ฆ
I doubt it'll work
Autonomous by design means it's "controlled" by a client.
Either way you can only set the role on the Server, you can try it I guess
I'll try
I'm pretty sure a lot of character movement relies on having a controller though.
But the fact is I know that in some game, you don't need to possess to control vehicle
Ok
Yeah but I doubt most games are using characters for vehicles
Yeah ๐ญ
You might be lucky, so long as the Owner is properly set along with the Role you might be ok
But it sounds like a nasty workaround to me
I didn't want to use VehicleWheel either and I didn't find good documentation about multiplayer ready movement component so I chose to use the CharacterMovementComponent
Well they all work in multiplayer technically, they just don't have automatic prediction and reconcile like character movement
But tbh, most games just don't care
Even fortnite uses client-auth vehicles.
Oh
We use server-auth in HLL because our vehicles aren't pawns and have multiple occupants, but we have input lag because of it. Thankfully the vehicles are so slow you don't really notice...
Not FN, project I work on
Ok
I do what fortnite does in my own game, just client-auth but with basic anti-cheat detection.
e.g, make sure players don't insta-teleport 500 meters etc..
Sure, ok
Couldn't you unpossess the character and switch it over to the vehicle? (if driver?) then if they are just passengers dont possess and just set camera to follow the vehicle?
In any case, I attach pawn to the different seats
What you describe is my first implementation BUT I needed to be able to call RPC from the two entities (That sounds like multiple possess?)
no I mean branch check if driver/passenger, driver possesses put pawn in seat and move camera, passenger just dont possess car but still set the pawn in a seat and move camera
Yes sorry that's what I did
What I do is possess the vehicle but set the owner of the character to the player still, so they can still call RPC's on the character
Yes I tried that and it worked. But now I use the InputStack and I don't even needed to set the owner to send RPC strangly.
@chrome bay Sounds to be the best solution in my case
Except that a third party plugin that I use is not handling it properly ๐ญ
Thanks for your answers in any case ๐
I created most of the main code in the player character (including interacting with widgets), but a majority of the things are the same, but they are not the same between teams, some things like abilities are, though they have some team specific abilities, and this was decided in that code instead of player state. So things won't exactly get too out of control, can I just ask playerstate what is necessary i.e. attributes and replicate it to player character and do similar things on spawn? Does it make sense to not move lots of logic to playerstate this since there are just 2 teams, and many shared attributes/abilities? Instead of moving lots of logic into playerstate such as if it were a MOBA where there things like abilities are character specific where things would spiral out of control much quicker? Am I understanding this correctly?
You want to make an asymetrical game right?
Why did you not spawn different pawn depending the team?
Characters could have a lot of common components but the different abilities should be described as data (DataAsset or DataTable, for instance for each character, the list of GameplayAbility which can ben used)
PlayerState should store any data relevant to show for all players (Team chosen, character chosen if the pawn despawn cause it's too far for instance, Number of kill, ...)
Common attributes like health and resource count should be on the player itself on some components. So any replicated data should be available to a client if it is relevant to him (within its netDistance or any custom condition).
PlayerState should store any data relevant to show for all players
@twin juniper even though some are not all relevant, but thinking of where to put such variables, playercontroller doesnt work since its just controller I know that it shouldnt be used for this, the character doesnt work because it resets to defaults when destroyed, so that leaves player state or is there something else?
We use PlayerController in our game to replicate data for the owning client (like missions or any personal data not useful for others)
Oh but what did you want to persist?
I have a server RPC that I am calling from my PlayerController, however inside of the function the RPC calls the remote role is always Simulated Proxy and not Authority. What would cause this? The client should have ownership over their player controller, which was the only thing I could think of that might cause the problem.
The fact is PlayerState are always relevant (if I'm not wrong)
persist the player stats, into player state, which sends it to GM when spawning player character/switching teams, and when playercharacter does something, it changes values on playerstate even though its not relevent to other people. Since its not relevent to them what would I use then?
Use database?
Player stats means Kill/score for a session?
oh I meant like booleans of what the player has access to in player characters abilities for example has access to something (T) not (F), or how many levels a player has
@frigid bluff You mean that your player controller has not the AutonomousProxy role on the owning client?
Yeah, I call a server RPC on my Controller from the Character. I use a UE_LOG() to display what the remote role is inside of the function that the RPC calls, and it's always 1 (Simulated Proxy) even though I called the RPC from the controller which the client should own.
You call the RPC from the server then?
@twin juniper If we think about MOBAs, level and items are displayed to everyone (and refresh each time, the team has visibility over the enemy character).
I have a check before I call the RPC to see if it's the local controller. So it should be the client calling the RPC.
So it seems to be stored in something like PlayerState. But maybe you could have a specific Actor to do that per client.
@twin juniper so dont bother with playerstate? example I have level here, pressing key adds a level and level point, are you saying that just save all the character variables in a datatable and update it on the DB when certain vars are changed such as when level gained, update on DB? Then when I spawn said character as well, just use the datatable from the DB to give playercharacter said stats?
@twin juniper You could use PlayerState if info should be available continously to everyone
But If you want to hide data sometimes, you should create a similar actor which is relevant with custom condition.
wouldnt i just be able to hook up said shown value from character into something like a scoreboard?
Player state is "Always relevant" and is never destroyed while the player is connected
PlayerState are used as scoreboard basicaly
I mean, what if there is a character specific var shown on scoreboard, but not in playerstate instead of the var being in playerstate
I see, let me think about that
So from some further testing, it looks like the code that is calling the RPC is only on the server
but it should still run on server even if it was called from the server
If you said it logged "Simulated Proxy" it seems that it's executed
Except if this log is printed before
You said that it was inside, so that's called
The code the RPC is calling is on an actor that has no ownership, it's just placed in the level. Which is why I was doing the RPC on the player controller. Should I still SetOwner even if the RPC is being called from the controller?
Also, how would I handle multiple people interacting with the same object if I was setting the owner?
This the function that the RPC calls
You have to do a component on your actor which permit to call an RPC on your client to interact on the server with this specific object
Something like an InteractorComponent and the Object should have an InteractableOne or an interface as you want
I use an interface to determine if an actor is interactable, is that what you mean?
Yes but you need an actor component on your pawn to use RPC Call from your owning client.
This way you can have multiple interactors cause they have all the interactor components
So I wouldn't have to set the owner of the interactable actor then. I would just have a InteractionComponent on my character for example that would call a server RPC , then that RPC calls the interact function on the object? And since every player would have their own component, multiple people could interact with the same object and call the same interact function?
@twin juniper You want something like the final scoreboard of overwatch with stat per role/character? Maybe the simple solution is to store every stats but display only the relevant (or highest ones)
Trying to understand this, new to multiplayer so I'm still trying to wrap my head around all of this
Read the page 60 @frigid bluff http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
It explains really well
On the page 67, it explains with an example : A door which is not own by any clients
We use a Class/Actor, that the Client actually owns. And this is where the PlayerController starts to shine
Alright, thanks
You're welcome
Fortnite has crossplay
@meager spade fixed the issue, had to change some file settings in IOS config and the project, cross play on our dedicated servers works like a charm ๐
I guess I think I will just keep the stats and everything in the character but replicate certain relevant ones to others, and the stats/vars get retrieved from a datatable when character is spawned which also get updated in the table when they are changed. But that begs the question how would these stats persist between levels without player state? When the player switch levels, the stats are the same since they were already updated?
DataTable are read only data
oh then what would I use instead that has ability to modify values?
PlayerState data can be transfered between maps if that's what you want
yes that is, but how would I modify the values?
is there a variation of a datatable that I can modify from the game that updates some player tables in DB?
and all the playerstate data is also still relevant, which not all of it needs to be
Store data into a replicated structure per PlayerState
For the one that you want to keep
What is the point of these data?
Persist until server is closed?
to initialize player stats/what player has access to / replicate certain ones and persist until player leaves
So we don't talk about database data?
For the inititialization at least
but data would be coming from DB?
Yeah I think, use PlayerState to keep trace of data which persist between map.
And just store into an actor (AInfo) non persisting data per player into a TMap<Id, Struct>
Don't sure how to have struct inheritance or if we should use UObject to replicate them. I know that you can replicate UObject but that need a specific setup
Player joins, player requests spawn, GM determines team they picked, server retrieves player specific struct data for that team from DB, returns it into related spawn node with said data.
Player requests variable in struct to be changed, server changes it, makes change on database.
If level changes, it should be okay since those variables are now the player characters default variables?
Something like that?
Once the player has a team, the server should just create an UObject with a specific structure for this team and store it inside an AInfo to replicate it in the current map.
For any data that persist more than one map, you need to have another structure stored in the PlayerState.
If you need real persistance. Use a database is way simpler than that.
You just have to load the data once the character is connected. (or when he travels to another map) And save data of this character with a regular interval
You just have to load the data once the character is connected. And save data of this character with a regular interval
so this would not need player state to persist between levels?
Yes
But it means having a real database server (or at least small local one)
It depends if your game need persistence or not
If that just session based with reset each time, you can try my first solution
so playerstate is more like for singleplayer persistence, in tandem with saving the game progression
No you can using it when player is reconnecting cause he just crashed or when he travels to another map
Cause saving progression in multiplayer is using a database
I meant local progression
like save file
No you can using it when player is reconnecting cause he just crashed or when he travels to another map
but would not be necessary because data would already be retrieved from DB?
Not really cause PlayerState is not saving anything. If you logout and you come back two days later, every progression will be lost cause the server could have clean the object or restart totally
Yes not necessary
If you have a DB
Given UE4 Servers have to be restarted frequently, that is very much the case
In most case, PlayerState is more used for session based (Think about a DeathMatch or a BattleRoyale or a moba)
Given UE4 Servers have to be restarted frequently, that is very much the case
also wouldnt matter if it was a dedicated server?
okay that makes sense
For instance, you could chain multiple games in a row and persist your kills and deaths count between maps until you disconnect
So yeah, mostly for Dedi Servers
@twin juniper Yes Uptime of UE4 is generally not more than 2/3 days without having lot of lag issues. Don't know exactly why
Because of float numbers that can't increase for ever
Oh yeah like the timeSinceStartup ok
Yeah
In most case, PlayerState is more used for session based (Think about a DeathMatch or a BattleRoyale or a moba)
so if player state is not used between levels, when loaded on new map, everything is reset to its default value?
For instance, you could chain multiple games in a row and persist your kills and deaths count between maps until you disconnect or server shutdown and restart
It's used between levels but not between server restart
It's actually pretty straight forward. Despite SaveGames, and such things, nothing presists a ServerRestart.
Or rather a GameRestart
There are a few exceptions, like graphic settings and such things
But they are mostly ini files so more or less a save
I mean just why arent the values persisting without the use of playerstate?
That's actually kinda not true
You can use the PlayerState to persist player related data on the Server, between map changes and also for things like disconnecting and reconnecting (think about traditional disconnect cause of internet etc.)
There are more classes you can utilize
PlayerController
And your own classes if you use C++
But that's only during SeamlessTravel
Any HardTravel kills that. So basically everything despite ServerTravel.
The Disconnect/Reconnect thing is more or less time-based. The Server keeps the PlayerState inactive for a bit, but ultimately also deletes that if the player doesn't come back.
Also I'm pretty sure that only works if you use a subsystem that uniquely identifies the player, like Steam.
You can use the PlayerState to persist player related data on the Server
So if playerstate isnt used, it just uses default values?
The Disconnect/Reconnect thing is more or less time-based. The Server keeps the PlayerState inactive for a bit, but ultimately also deletes that if the player doesn't come back.
Makes sense for things like CSGO reconnecting to comp match
So if playerstate isnt used, it just uses default values?
You use PlayerState either way. it's a Framework Class that you should always utilize. The PlayerState simply offers you to move data between old and new playerState in a seamless travel.
Makes sense for things like CSGO reconnecting to comp match
Yes
Yes, that's definitely not used to persist longterm data like player progression
And yes, if you don't actively make use of moving the data to the new playerstate (functions for that are OnCopyProperties and OnOverrideWith), then even with SeamlessTravel, your data will be reset to default.
And that all only counts for the time the server is up and running with the player connected.
okay that makes sense
These servers are meant for games like Unreal Tournament
thanks
You connect, kill a few peeps, go to the next map, kill a few more peeps, disconnect, go to bed
session based?
Well Session is a whole nother story
Yup, I use it for an MMO but we've lot of stuff around
Sessions are only info to register a match and be able to find and join it.
Like via Server Lists.
You can play without sessions if you connect directly via IP for example
I used the term session based to mean "short game" (Not the class of Unreal ahah )
Sessions also need a MasterServer, so there is a general place to register the session and to ask for a list of them
better to write "game based on short matches" or so
Ok ^^
Either way, any form of overall persisting data, such as player progression or the shitty Battle Pass crap that exists, should be handled in a backup, far away from UE4.
Same as data about characters, .e.g WoW.
(though, MMORPGs shouldn't use DedicatedServers of UE4 anyway)
๐จ
Anyway, good luck, gotta eat some dinner
Thanks ! Have a good night !
Has anyone use unreal.js plugin before?
how do you properly use PreLogin (in AGameModeBase) to prevent players from joining the server? Do you have to call Super, or just set the error message to a non-empty string?
`void AMyGameMode::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueID, FString& ErrorMessage)
{
if (bHasStartedMatch)
{
ErrorMessage = FString("Match already started!");
}
Super::PreLogin(Options, Address, UniqueID, ErrorMessage);
}`
is that correct?
just set the error message to a non-empty string?
I think that's enough. I'll check
actually I think the Super will possibly set the error message so this implementation would not work
I need java to Communicate with unreal engine and back
Java, or Javascript ?
Yes it can override it in your case
JavaScript
oh just saw how ShooterGame implements, it actually just calls Super on else
if (bHasStartedMatch) { ErrorMessage = FString("Match already started!"); } else { Super::PreLogin(Options, Address, UniqueID, ErrorMessage); }
Because I need unreal to find a file
quick question about replication
is it a better practice to say, open a door using repnotify on an "IsOpen" variable, or to use a multicast event?
@median elbow Lemme ask you a question and see if you learn something from it:
Would you say a person who comes to the door some time later (or even joins later) should see it open/close?
ok yeah, that did cross my mind
It's basically both though
You need to divide it into "What happens right now?" and "What state should it keep afterwards?"
the thing is that the variable is there in both cases
actually, if you would mind baring with me for a moment, if i back up to why i had this question in the first place, its because of the replication hierarchy
i have a whole room which is an actor, and a wall as an actor, and the wall has a door which is an actor
i don't understand, but it seems that replication wont' work if i don't replicate ALL of that, and from my understanding, you ideally only want to replicate the higher level objects?
Each Actor needs to replicate on its own
so i've got the "self" in an actor, and the default scene root, and then the component
but if an actor is a child of another actor, doesn't the parent actor need to replicate in order for the child to?
oh man, thats going to make my life easier then, this whole time i thought i had to replicate all the way down to the bottom actor if something needed to be replicated there
No, only the Actor that needs to replicate... needs to replicate
And for your door issue
You need to basically Multicast the action of it opening
But the state of it being open should be a repNotify
Set AFTER the door opened
And in the OnRep you probably want to check if the Client is already opening the door, and then let it open and if not, then fully open the door instantly
interesting, so basically your saying to multicast the event of opening the door, then set the opened variable immediate after that, which has repnotify, and in the repnotify check if the door is already opening/open and if so leave it along, otherwise do the animation of opening the door?
sorry that came out a little wierd
could i just do repnotify only and make it reliable?
its not something that happens constantly in the game, but its important for the people currently in the game to see the door open
Don't do the anim
also, nobody new can join
The OnRep should instantly open/close
where should the animation go? just in the multicast event?
Unless it's in the process of opening
oooh, i see
maybe i'll use an int, 0 is shut, 1 is opening/closing, and 2 is open or something
Na,
alright, so i guess the important thing is that a good approach is to multicast the event, which runs the animation, and right after i send that event, i set the isopened variable with repnotify, and repnotify simply opens/closes the door if its not currently in the process of animating?
non-replicated boolean: IsOpening
non-replicated boolean: IsClosing
These are set to true when the Multicast makes Players in range open or close the door.
And set to false when that is finished.
And then a replicated boolean: IsOpened
When in the OnRep you check if IsOpening or IsClosing is true, let them finish or instantly fully open/close the door
Something like that
ok perfect, that makes sense, thanks!
alright not to keep going though, but how about the replication hierarchy in this case?
i'm pretty sure i know the answer
but if i have a wall, who has a child actor the door, i don't have to replicate the wall right?
Correct
because there's nothing changing in that actor itself
Unless the wall* also does some rpc/replicated stuff
ok perfect! man i dont' knwo why but i thought there was this whole hierarchy thing i had to make sure was connected
ok, that makes perfect sense
and also makes things a lot easier
alright, what about in actors, you have the (selft), the default scene root
is there ever a reason to replicate teh default scene root?
That's Component based then
There can be components you want to replicate
And there can be none
Depends on the situation
ok
Components don't replicate when the actor replicates. They have to be marked as replicate too
but if i just want to replicate variables in the actor, i don't have to replicate the scene root then?
Correct
ok, and about components replicating, are you just talking about their own propreties replicating?
or is there some other kind of thing you would want replicated with components? like themselves or something
Yes, only their own
so this doesn't have to do with adding new components to the scene root or anythign, or does it?
Not really
like if you add a component in bluepritns or c++ during runtime
Well that is something else
oh ok
so i would need to replicate the scene root if i add a component during runtime to it?
And RPCs, yeah
i'm still trying to figure out how far replication goes
i promise, i actually read it a while ago
i might need to refresh though
i'll do it
these last couple questiosn were mostly just out of curiosity for now
alright so last question then, haha, RPC's include events or only repnotify's?
haha, i know that probably sounds like a dumb question at this point
You could just read the doc :P
I'm new to replication.
Trying to make projectile replication.
I'm wonder if anyone has a sample i can learn from?
My problem is:
Atm either i get a duplicate projectile on client side from checking replication box on the projectile.
Or
Sound and emitters (explosion) won't work inside the projectile blueprint.
gods, i hate name stability for networking
i have discovered something that has broken my understanding of what it means to have a name stable for networking
Custom spawned actors apparently don't have a stable name... so how do they replicate?
{
return IsNetStartupActor() || HasAnyFlags( RF_ClassDefaultObject | RF_ArchetypeObject );
}```
if you use like SpawnActor() to create an actor, then it's definitely not a NetStartupActor, and it's not a CDO or Archetype
so this would return false
thus the name isn't stable so how do they replicate????
Quick question: what would be the best way for setting a replicated variable on the client owned character differently from the server version?
Essentially my character has a replicated property and I want to be able to set the property on the client and use that value, before it is sent to the server and replicated back
Right now the character calls a server RPC that updates the variable on the server which gets replicated out from there
Guys,
What's the difference between PostLogin and HandleStratingNewPlayer in GameMode?
I tried to print a simple string to get an idea when are they called and to my surprise they're both called on server and on client. Not quit sure when to use what?
@analog rover Run on Client event maybe?
@forest kettle I was thinking of that, but I was wondering if it would be a bad idea to try to set the value for the replicated property from the client as well
As in, in the client side only code set the value of the property
Not sure what you mean by that! Do you want to set the same variable on the client and on the server but with two different values?
I guess I should be more specific about what I'm trying to do
please
I'm working on making a simple system to allow the player to equip a different tool/weapon
Right now I'm storing the type of weapon/tool as a replicated property in the character
And whenever the local character equips a weapon, they run a server RPC which then updates the weapon/tool type on the server
Which then is replicated back to the client and the local character runs some code to switch the view model, etc.
But I was thinking that there could be some significant delay when equipping an item because the character has to wait for a server response
So I wanted to set the equipped item on the client first and run the equip logic before hearing back from the server
I see...
I'm not a great Multiplayer programmer (I'm still learning from the pros here) but in my couple of years learning curve I noticed that there's no real reason to worry about delay between server and client IF your code doesn't have bad stacks or consumes heavy traffic.
That said, I would always wait to get a confirmation from the server that I'm indeed allowed to equip that item before I do anything in client
With all that said. What you could do is run on client the HUD, camera view logic and whatnot while waiting for server
Event EQUIP (RunOnClient): run your local code then-> Set isEquip -> Call Function RequestEquip (RunOnServer)
Or you can Call Function RequestEquip (RunOnServer), and drag from the pin after you called that function and run your local code
@forest kettle thanks! I appreciate the input!
Hey People, im pretty new to multiplayer and just finished my first experimental game using the steam online subsystem. However i was wondering what online subsystem id have to use if i want to put my game on the epic games store for example. What alternatives are there to the steam online system? I wasnโt able to find a single one on YouTube what really confused me. Thanks for any help!
They are two completely different companies, i dont think you should mix. Put your game on steam, also get a unique steam app id by running thru their system. The demo api id is not meant to be used in released games, but for tests only.
Epic has their own thing but I don't think it's been released to the public yet
you can look at services like playfab
steam has one particular advantage for multiplayer games it suppots p2p online
@gleaming vector i am sure somewhere else it does a check for the NetGuid of the actor
and ignores that call
it has to, but i wonder where
UE4 supports P2P natively. When you use the Steam version of a session, you get access to everything in the Steam SDK. As for EOS, which is the Epic Online Services, it's public, but it's not fully fleshed out yet. There is some functionality that you'd have to create yourself that makes using the Steam or EOS SDK more attractive, as it's far less development time to use what they have, than to create everything yourself.
p2p and listen servers are not mutually exclusive
It technically is p2p for the listen server model, however for online p2p you need services like steam
thats not p2p
pretty sure is. please explain why not :)
p2p networking for video games implies that all connections are peers
there is no authority
in a listen server environment, someone is the authority
^
you are confusing it with network peers, which technically everyone is a peer
they are, and authority is a common issue in p2p games you need to implement a logic to figure out who owns what
that's absolutely not what at least half the people talking about p2p means
in listen server model you get the server to be the authority, thus no confusion
it's still a client/server model
because when THEY say p2p what they mean is nat and hole punching
Roy the issue with listen server model is same as p2p client-client games, which does not differentiate them in this sense
I'm not confusing anything
UE4 is server-client model
just the context of server is different, either Listen Server or Dedicated Server
so lets just slow down
p2p at the transport level is what you are thinking of
unreal is still client/server at the application level
this quickly escalated into an argument of schemantics. sorry about bringing this up.
someone asked about alternatives to steam networking, and p2p as an advantage of steam was mentioned
then you guys decided to make this about listen server vs authority less models
you can have a client/server application running over p2p style networking
because network layers are a thing
but the context was what steam is talking about when they say p2p networking, which is hole punching and nat traversal
kaylen yes steam has this pretty cool advantage which is why i mentioned
and listen server (as a peer) can utilize it pretty well
also you shouldn't be using steam p2p sockets, they are deprecated
via steam sockets which i believe is hooked on any network transmission while dealing with steam listen server games.
guess its the same old sockets but fancy refactor
it's not
hehe
i was contracted by valve to do the UE4 implementation because Epic originally said they weren't going to do it... and then epic went and did it without telling anyone (we found out when it got committed to the UE4 repo)
so that was fun
but, anyway, that socket lib is a misnomer anyway
there is nothing p2p really about them
epic make me laugh, i made a pull request to expose a function to BP (already in the engine), and they marked it as New Feature FFS
they are just a wrapper around udp sockets
i was thinking of webrtc for similar purposes
now its sat in a cue..
the p2p part is that it facilitates making connection between peers on the internet which is harder than you might think
not that it really matters because 'p2p' has no meaning at the transport layer
everything is a peer at that layer
the issue is the connectivity indeed
but only because by saying "at that layer" you are excluding all the ways in which they are not peers
correct, because the idea of peer to peer exists at the application layer
OSI model is not super useful for a practical understanding of how things actually work on the real internet
like, yes, those sockets do nat punchthrough for you
otherwise we wouldn't need things like steam networking
that doesn't make it inherently peer to peer.
you still need nat punchthrough for client/server
or, ignore nat and directly map the IP/port to the application socket
either way, that has nothing to do with a peer to peer application model for a video game
peer to peer from a position of authority and peer to peer from a position of networking are unrelated
that is what i'm saying. peer to peer is meaningless at a networking level because at a networking level everything is a peer
in any network connection one party initiates the connection and is technically the client no matter what you do afterward
when you get disconnected, the error message is "connection reset by peer" for a reason
anyway yes semantics
my guilt bringing this up sorry
does steam networking handle stuff like setting up the windows firewall exclusions?
or does it just do the networking and not the OS environment
some basic software firewall might actually support steam by default but for the rest i think it's managed by the user
i mean, the semantics matter here, because if you say "ue support p2p by default" the naรฏve understanding is that means you can set a value on a client and it's replicated to other clients, which is not true
for comodo i had to press allow when install steam
it's gotten much better
it still asks to open ports every time you launch a game for the first time
there's a relatively simple way you can register your apps connectivity now
i dont think that's something done at the steam level
you would have to do it yourself at engine startup
which epic doesn't do because cross platform stuff
I haven't seen a windows firewall popup for a steam launched game in a long time thats why i was wondering
not much use for a firewall any software can bypass silently
^^
firewalls that promise to protect you against processes on your machine are lying anyway
having some conspiracy theories on this night?
anyway this would be something that's done by the installer, not by the game itself at startup
oh steam installer scripts do have easy to use firewall exception setup
so that'd explain it
Where exactly do you put dedicated server code? Such as connecting to the database (So it goes Client -> Dedicated Server -> Database). Would you put it in the GameMode? Anywhere you want with the #if WITH_SERVER_CODE tag?
id think it would depend on what you are trying to get/store in the database. like persistency id do in the game mode so you can check everything on the post login function, retrieve what you need and give it to the player.
So if I were to update the players inventories with their data according to the database, I would put that code in the GameMode?
And wrap it with the WITH_SERVER_CODE tag or is the GameMode server only in the first place. My goal is to make it so players don't connect to the database to prevent cheating in that kind
the gamemode runs on the server. it still would be smart to make an API to interact with the database though to act as an interface so that the dedicated server is not interacting directly with the database incase someone manages to get their hands on whatever they need to access it
How about this then Client -> Dedicated Server -> Master Server (Webserver?) -> Database
thats how id do it
@nocturne roost I would put it in the GameSession
or a GameInstanceSubsystem that is disabled and compiled out if !UE_SERVER
didnt know you could do that, thank you
for health and stuff, should i be using the player state or is using the player character pawn fine?
alot of people seem to use the player state for stats that you want visible to other players such as kills/deaths and such, personally i make actorcomponents for things like health/stamina and such to keep clutter out of the character. you can override TakeDamage though which is on the character so you may want to keep health on the character or just access the component from inside the TakeDamage function
@ocean geyser is there any problem with putting it in the player tho, cant you just put everything you put in the controller and state in the player character, unfortunately thats what i have been doing lmao
just think how you want stuff replicated. controller is replicated between only you and the server, character variables can be replicated in any way you want. you can put everything in there if you want to
so there isnt a problem?
like performance issues or something
if thats it, i will keep it in mind.
no, just replicate only where you need to. such as stamina doesnt need to be replicated to everyone, just between the server and controlling client. things like health you may want to replicate to all and such. depends on your goal
@gleaming vector So is GameSession and GameInstanceSubsystem both not compiled in client side code? And I'm looking at the docs for AGameSession, are both of these restricted to the server compilation?
they are, but if you use #if !UE_SERVER around your server-only code, it'll be compiled out
ie
So the only thing the clients would see is the fact that they exist?
void UFoo::Bar()
{
SomeCode();
#if UE_SERVER
ServerOnlyCode();
#endif
}```
I'm confused, I thought "!" was for "not" so would that be if it isn't a UE_SERVER?
oops
since their compiled out would it be a safe bet that it can access the database directly from that point? for example if someone reverses the game would any of the compiled out code be left in there or does UE literally just not compile it (if not doing a server build)
i blame the fact my cat was sitting on my arm but it totally wasn't that haha
correct cody
if it's compiled out, then nobody can find your SQL queries
or connection info
they would need your server binaries
so protect those
Ah lol. So in reality you don't necessarily need a master server if it isn't compiled in the code in the first place?
Or is it just common practice to have dedicated servers attached to a master server which accesses the database instead of having ~20 servers all trying to go into the database at a given time
if you plan on distributing your server bins, I recommend having some API-type server that recieves data from servers and validates it
and just make a http call to that api server
i would recommend the web api path anyway
honestly
having a sql server exposed to the internet that dedicated servers can talk to is a recipe for disaster
it gets discovered and you are fucked
I don't plan on having users be able to download their own, my plan is session based with roughly ~25-32 players a server
But there are inventories and items so I want to avoid being able to hack in items at all costs
So you're saying the best route would be Client -> Dedicated Server -> Web Server (HTTPS calls) -> Database
And it would just return what the database says with the http call?
its what i did but it was unrelated to games so i wasnt sure how well it applied. it was fairly easy to actually write the web server portion once it was setup to work with the DB and calling procedures