#multiplayer
1 messages ยท Page 687 of 1
oh i think i have a different issue so nvm, i didn't realize i think my actor for some reason wasnt spawning in for clients
roger thank you!
We have a patcher. My script just runs other commands. It could technically be a .bat.
it does a lot more than just build, building is a small part of it. You still need to be able to provide the user a list of the current branches, change based on the input, generate timed links for each user, prompt them to upload to aws. Thats why i was impressed about powershell.
oh gotcha, so just an automated build too, still cool :)
Yeah
It does a few things for us
1. Syncs from our source control (swaps branches depending on build being ran)
2. Packages the client for our desired platform
3. Packages the server for our desired platform
4. Uploads our debug files to our crash report receiver (we use BugSplat)
5. Removes all debug files from the client build
6. Uploads the client files to our Patcher(you can use Steam, PatchKit, etc here)
7. Uploads our server files to our S3 Bucket
8. Restarts all servers which have code to pull from S3 on start which updates them```
We also have a pipeline setup for updating our servers we host on GameLift too
Ah thats some cool stuff, my team is still developing so we can get away with automated zip file sending and gamelift uploading but thats real cool
for steam, we actually use the upload manifest thing to exclude PDBs
as we also upload an "internal only" build which does include the PDBs
so reliable RPCs always arrive in the same order they were sent right? Does the same apply for unreliable ones?
i.e. if some RPCs get dropped, the ones that make it through are still guaranteed to be in the same order?
Reliable, yes. Though I have a memory that was only for the same Actor. Unreliable, there is no promised order.
Even if the RPC is lost during packet loss and the next RPC arrives before the first RPC arrives?
I think reliable means it's guaranteed to get there eventually
But not necessarily in the right order
Not sure. I've never tested personally. I just remember someone talking about it at one point. Pretty sure it was Jambax.
It's never been a consideration of mine. ๐ I don't think I'd ever rely on RPC order.
Yeah me neither
@winter plover Unreliable means the RPC may never arrive at all
If it's dropped due to high bandwidth
yes i know that
but do the ones that DONT get dropped still arrive in the same order?
I don't think you'll ever be able to guarantee order
so ue4 doesnt buffer them to guarantee order?
Since you'd have to hold up loads of current RPCs to wait on old ones which may never arrive if you did want perfect order
yea i just wanna know for certain
Well say RPC 1 gets sent and then RPC 2 and 3 get sent. 2 and 3 arrive but they have to wait for 1, but 1 fails again. Now you have 3 stale RPCs all being called much later than they should have
so its basically fire and forget, and its up to me to keep track of things?
I don't know for sure but I'm assuming that the engine doesn't wait on older RPCs especially unreliable ones
I think the RPC executes whenever it arrives, would be surprised if that isn't the case
Some more info here: https://forums.unrealengine.com/t/ordering-question-about-rpc-and-replication/140018
Hello, I have a few questions about execution order on RPC and replication, 1, Will RPC receiving order keep the same as sending? example like below Server send RPC1, RPC2 to client ActorA, RPC3, RPC4 to client ActorB, what will be the possible order on the client side? can RPC3 come back earlier than RPC1? 2, With the same set of the replic...
ONLY Reliable RPCโs will garauntee order, and ONLY for the same actor. Connections do not matter. Note that they do not neccesarily arrive in order, but they will be processed in order.
Sounds like reliable RPCs do guarantee order
But not unreliable
They actually do, but as they're unreliable it sort of doesn't matter
Edited my response there ๐
so how is order guaranteed?
does it just drop late packets?
or does it make them wait?
For an unreliable rpc it'd just drop any late packets. For a reliable one it'd have to wait.
aight, that makes alot of sense
How does a replicated variable in actor A of Actor B work? I am just wondering from a performance perspective replicating simple things like strings/int would seem to be more lightweight than a full on actor reference being replicated unless its just replicating an instruction for the client to point to its current reference?
Objects are replicated as a Net GUID, which boils down to an integer.
There's a complex system behind the scenes that handles the tracking and synchronisation of object references between server and clients.
But TL;DR, it's more efficient than any alternative - UE's networking architecture is very mature
that's great to hear ๐ thats what i was assuming thanks
UE also only replicates what has changed. So it's not replicating the entire actor, it only updates the properties that have changed. It does check them all. But that's extremely efficient.
Hey guys, can some one give me an idea about how many players i can fit per instance into 4 core server, which has 6 instances running,
My server cpu is like 6%, and memory is 6% when there is no client in the server, I was doing some tests, but i am not sure where should i can start off.
and what should be the idle cpu and memory for each client.
Our app is a VR multiplayer.
I'm no expert myself, but there's no real means of determining any kind of expectation of number of players for any application for any given hardware as there's too many variables involved, including the coding of your application, the optimizations you've done within it that can allow the engine to manage more players, the potential network traffic and the network that supports it. All you can do is profile, see how well things run with X players, and increase number of players up to a point where performance is still acceptable. If you want to squeeze in more, then you need to either upgrade the hardware or optimize your code more.
Eg. A server handling 20 players that don't do very much and only have 1 input that only allows them to increase a integer value displayed on the screen by 1 each time they push a button, isn't the same thing as a server running 20 full characters that move around an open world with meshes and animations and AIs running around where players can attack things etc.
Hey guys what's up ๐
So I have a rather conceptual question: I'm making a multiplayer parkour game rn and I did the logic for the character building up speed by changing the MaxWalkSpeed on Tick. It starts at X and as you continue running, it increases to Y (max value).
I have the feeling that, in terms of replication, this isn't the most elegant solution, given that:
- The
MaxWalkSpeedparameter isn't even replicated - Doing this kinda means that the client needs to constantly tell the server to update the
MaxWalkSpeed, which apparently is bad for movoement replication and isn't super network efficient.
My question is:
- Are there ways to make this work more elegantly, or other ways of changing the character's speed other than through
MaxWalkSpeed(that can be properly replicated)? ๐ค
I think the best way to do this is to replicate just the movement input of the player (Vector2D) and then the server calculates MaxWalkSpeed from that.
What would be the best way of doing that? ๐ค
If it builds up while you are moving, the best approach would be to deterministically increase the max walk speed during the movement simulation tick, that way it will climb on server and client without any additional networking and be in lockstep with the rest of the sim. Doing it anywhere outside of the simulation tick will break prediction/replay anyway.
This would require a custom CMC ofc
Yeah I already have one ๐
Things is, MaxWalkSpeed starts at 0, and when I try to move on the client, the server keeps correcting the movement to the initial position because the MaxWalkSpeed on the server is 0.
How do I "increase the max walk speed during the movement simulation tick"? ๐
You need to move it inside some function that is called to calculate movement physics such as phys_walking or somesuch
Can anyone tell me if voiptalker will work with quest2?
i'm running dedicated server setup, and would like to use voiptalker on the clients.
Hey guys, a though question here...
Does anyone know what might cause the actors SendingRepState to become invalid short after spawning an actor?
It happens on my dedicated server and I've been dealing with this problem for quite a while now without finding out what causes it. It don't happen everytime only in like 1 out of 100 actor spawns.
(The actor is not being destroyed)
I have simple task that I don't know how to solve. When player click e it cast line trace and then call interface function to object it hits. If that object is loot actor it opens widget. When I click button in that widget it destroys that object.
This far it's working it open widget
But when I call from widget back to object it doesnt destroy it
Curious, why are you doing this on every machine? This all looks like client only right up until the widget button click.
And I try to make dedicated server game where server doesnt play
@kindred widgetI'm beginner but I tried that and it also works I just try everything. Now I changed it back to client only
should widget also have server event when call that interface thing?
Client Only Code:
What I would do, is make your code to open the widget client only. No other machine or the server needs to care about that. When you click the button on the widget, that widget can use it's local controller to pass that object through a generic ServerRPC that passes an Object type pointer through.
Server Only Code:
On the Server version of that client's controller, it can call the interface function on it and pass that controller or that controller's character, which can then add the loot to that controller/character which will replicate back on it's own, and call destroy.
Okay thanks! I try that
question about switching the view on the PC while the VR player is playing... how Can I manage this without changing the view in the HMD?
I tried using a sceneCapture2D and setting the 'SetSpectatorScreenMode' to Texture, but the screen capture makes the VR Player view choppy.
I tried 'SetViewTargetWithBlend' Setting the new camera to the 2nd ingame camera, but it also switches the HMD view to that camera.
Is there a way to allow the PC viewer to switch between cameras while the VR player plays?
@kindred widget "local controller to pass that object through a generic ServerRPC that passes an Object type pointer through" What that actually mean? Possible in blueprints?
In loot chest Bp
In widget which is created in that chest actor
Now problem is that when play on client actor is never destroyed but when play on server everything works
You don't need multicasts. Your only form of networking here should be a ServerRPC called from the pickupbable on the local controller Which means the local controller sends the RPC. Everything else is replicated including destruction.
@rocky kestrel Simple Interface.
PlayerController
PickupActor
Player character controls.
If this works. All you have to do is change the part I commented to spawn a widget instead, and pass in the pawn, then you can do the same calls in the widget.
UserActor in the authoritive version will be the player's Pawn on the server. So you can set inventory stuff that will replicate back as well. Then call destroy and you're done.
Thank you much!
In a multiplayer session, is there any way to prevent additional connections? For example, everyone loaded into a lobby, the game is launched with the people that were connected. Now they're playing but people can still find the session and connect to it.
I'm sure I could have some flag to say the game is started in the gamemode and kick new connections in PostLogin but it would be nicer to not show the session in the first place in session search.
@kindred widgetIt works thank you!
I have a vague memory that there was a connection limit.. Can't remember if it was in Session, or GameMode..
Session, I believe. But lets say I allow for up to 10 players to connect. 5 connect and start the game.. I only want the game to be playable by those 5 people until they return to the lobby. So unless I can dynamically change parameters mid-session .. which may be just the thing I wanna do if I can figure out how
I don't remember where it is, I swear it was GameMode. I could be mistaken, it might not be a default thing. Worst comes to worst, you can just get the server's Session, get it's limit on a player's Login, if GetPlayerState->PlayerArray->Length < Limit, let it go on, else kick. Or some similar event. I think Login would work for that.
Wouldn't help for limiting just those five people. But you could add extra parameters there.
Well, I'm using servertravel to "start" the game and PostLogin doesn't get called for traveling players. So I can just use PostLogin to detect anyone connecting after it's started and kick them. It's OK for the meantime but I would like to find some way to handle this at the session level so when players find sessions they don't try to connect to already-started games
Are rep notifies only meant to be used for changing client only things (widgets, gameinstaces, etc) and everything just be handled by setting it on the server?
If you're using EOS, there's EOS_SessionModification_SetMaxPlayersOptions
I only ask because I am doing a multiplayer car setup and was using repnotifies to show players getting in and out of the seats. Had an issue where the other clients had no idea of the models in the car because i was pointing to reference of the actors and they were hidden.
I would say they're used when you want clients to be able to respond to something that has changed serverside. It guarantees that the replicated value has propagated to the client before the client tries to act on it
If your lobby has a "StartTimer" without a predefined amount of players, you just set maxplayers when the lobby gets started ( like 5seconds countdown ). If you have a max nubmer that's predetermined you can set it right after you create the session
the cooldown timer is so you dont accidentally let people in that joined before your session changes take effect
So you do want the check on PostLogin < Max just in case there's rare stragglers, but otherwise rely on MaxPlayers option
Gotcha thanks!
I'm following a tutorial, because I want to start getting into multiplayer, but can someone tell me what the yellow pin means?
his pin isn't yellow like that and it looks normal
edit: but mine still works the same way as his, and I doubt this is cosmetic
it's an interface
oh nice, I figured out why its different
he has his as the message one
thanks
Can multiple players posses a pawn? In my case a vehicle.
Nope. To do that, you need Pawns as vehicle seats that have input into the vehicle.
My current setup is skeletal meshes on the vehicle pawn, obviously thats not going to work. I heard about socket attachment but the consensus on the forums was to not use it for multiplayer. Is that the only way to do it?
Im having an issue where when i switch weapons on the client side the original weapons stay attached and the new weapon attaches to the same place.server side works perfectly.
Server Client Server Client because its client only issue im thinking it is something that i replicated wrong i can send pics of BP too
Whatโs your setup? Depends on lots of factors
I use an array to store the weapons this is the beginplay Server spawn of the weapons
i figured it could be alot of possibilities ive just been troubleshooting this for about a week . im pretty new to blueprint replication
Any reason your not just swapping the meshes instead of spawning a whole new actor?
thats only the initial spawn afterwards i do this
i use a decrement and increment integer for the swap interaction
Although I wouldnโt recommend it, if you want to spawn new actors youโll need to destroy them also. Make sure itโs being spawned and destroyed on the server.
so this spawns new actors everytime i switch the array
it looks like my weapon is spawning twice on the client side
So youโre spawning new actors every switch but not destroying them?
no i only spawn the weapons at begin play
this what spawns on begin play i dont know why the clients are getting double the weapons
Net Cull Distance Squared - If I want something to stop replicating at more than 5000 unreal units, would I do 25000000?
For weapons, I would recommend a weapon system. Data-based, that handles all your weapon logic
The weapons spawned should just be visual meshes, spawn them when the weapon is switched into
Have the server-side weapon spawned be for 3rd person view, spawn the FPS weapons on a per client basis, local only
I mean that is if you dont have to deal with gameplay features like dropping the weapons in the world, being able to pick them up ( this is assuming you're only doing basic FPS stuff )
Anyone have an opinion on the simplest way to send a chunk (say < 50k) of binary data from server to client? Ideally without needing a web server in between.
yeah i plan on having the ability to drop and swap weapons that are on the ground
thanks for the help @gleaming kite @verbal tendon i figured it out working now
I know PlayerControllers only exist for the client of that PC and the server.. do AI controllers only live on the server?
Answered my own question, yay google "Controllers are non-physical actors that can be attached to a pawn to control its actions. AIControllers manage the artificial intelligence for the pawns they control. In networked games, they only exist on the server." https://docs.unrealengine.com/4.27/en-US/API/Runtime/AIModule/AAIController/
AIController is the base class of controllers for AI-controlled Pawns.
why the player lags/glitches when changing walk speed on multiplayer?
Follow up question .. I'm trying to utilize FindPathToLocationSynchronously to draw potential move paths for the player before they choose to move. I am taking the player's cursor location and drawing a path from the character to the cursor location using this FindPathToLocationSynchronously. But if I can't access it on the client, is there any way to get this information? I really should be able to perform the move calculation locally without having to query the server
nvm, my dumb ass brain realized the server corrects my walk speed because it doesn't replicate
but how do I replicate it to server?
like, do I need to make a new BP class?
which will be a server?
Run an RPC to set the speed. Create a custom event and set it to run on the server, pass the speed as a parameter
and then I need to change the player's speed on server side?
You might have to do both. Some of those values are weird, like max step height. Try just setting it on the server first and see if the built in components replicate that value
But if that doesn't work, have the RPC function call a Multicast function to set the speed.
It's messy but I haven't found any other way around it
Make sure when you call the RPC that it's done in a place the player owns like their character bp
Is "Can Run" something that is handled by the server? If so, yeah that's worth a shot. If it doesn't work you should see a similar stuttering like before
nope
it's not handled by the server
but can run is true by default
Just a heads up, that sounds like something that SHOULD be handled by the server. You don't want clients to be able to make that kind of decision about things they can do. But making sure everything is 100% server authoritative is definitely a rabbit hole
wait, but if I would be doing it without can run variable then is that how it should look like?
Looks OK. I still have a feeling it will look weird though. I think the movespeed isn't something that gets replicated by default
well, I guess not, because the player is still glitching
then how do I replicate it?
From your RunEvent, call another custom event with Multicast. This event will run on all clients and server.
strange, client1 is not glitching when running from client2 perspective
You can probably leave the set "IsRunning" on the server function and then just set the run speed in the multicast
Hm. That is weird, I would have expected the opposite
same
ohh, it's working perfectly now
thanks
I thought replication would be harder
but it's not as hard as it seems
gotta replicate other variables then
It can be simple and it can be complex. Mostly just remember "replication" means it's coming from the server, propagating to clients. If you're going from client to server it's an RPC and needs to be executed in a spot where the client owns the actor. There are several objects that exist on the server and not the client, I always refer to this http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf on page 10, there's a nice diagram showing what exists where
@sullen burrow multiplayer sprinting is harder than you think. Test with latency.
awesome! sorry i couldnt be of much help, but good work
if i change a replicated component thats a child of the replicated pawn on the server, shouldnt that component be automatically changed on all clients? (Changing the mesh of a skeletal mesh component thats a child to a vehicle pawn on the server and it doesn't seem to be propagating to the clients)
i know i could use a multicast but thats just a lazy ducttape solution; a rep notify also doesnt seem right for this, shouldnt it just work?
Somehow when I try to print the Morning Roll Call boolean value after setting it to true, it's true on the server, but when I try to print the values of the struct from the BP_Character, the Morning Roll Call boolean is still at false
I could be missing something but you need to set the struct to replicate otherwise it will only be relevant on the server
But the struct is on the player state, and the player state is share between all clients and server, isn't it replicated by default as it's in the player state ?
According to this image :
It works perfectly, thank you ๐ But I still need an explaination on why it needs to be replicated
Yes, the player state is relevant on all clients and the server but the variables still need to be replicated. If you look at the default player state variables, they are all set to replicate.
Just because a proxy owns a object doesnโt mean all variables are replicated
Also glad it works :) let me know if you need clarification on anything
So that means it's the same behaviour for the PlayerController too, even if on the server a variable has changed on the PlayerController doesn't mean the owner of the PlayerController could get the value of that variable if it's not replicated ๐ค ?
Yep, also gamestates or any shared classes
Thank you so much ๐
Of course glad I could help :)
Could someone confirm to me to always use Rep Notify on variables instead of "Replicated" to be sure if new people join the game they get the infos too ? If this is true, then I don't see any reason to ever use "Replicated", could someone explain to me ?
In the context of a multiplayer game
RepNotify is when you want a function to be called when the value is received
so you use Replicated when you don't need to be informed that the value changed
Replicated and RepNotify do the same exact thing to variables. If the server has a different value than a client, itll make the client update their value, RepNotify just has a function thatll run on the client when it recieves its updates, so both options will update the new players info.
Isn't there more than that ? like people joining the game later not receiving the info in the case of Replicated as they were not present at the moment the value changed and the server sent the info the clients.
it's impossible
when a variable is replicated, it will be replicated, repnotify == replicated but with a function called
its repnotify that may have case where its function will not be called because by default it will check if the client's value is the same as the server's and if that's the case it will not call your OnRep function
So using "Replicated" will also make sure if anyone joining the game later will get the infos ?
But what could the function of Rep Notify do ?
you can do alot of things
for example updating UI
updating visual, etc
like for example you have your repnotify health, when it is updated you can update your UI
but usually the health UI, we use Bindings
not really
bindings will each frame check the value, it's great for cases when your value is changing alot
but ideally you only update your UI elements when needed
oh I see
and OnRep is a great way of doing that in a multiplayer game
Then I have been misinformed about the RepNotify
people told me people joigning later don't get the info if I use "Replicated"
yeah no it's false
maybe they were telling you that with Replicated you can't really know when the value is updated tho ^^
i met someone that told me that too. maybe some popular post out there says that
Then I'm not crazy ๐
Thank you so much, because now it makes me understand the replication system even more as it's the same as a Game (like Roblox) I was coding on where it has the same thing as Unreal
yep, this replication scheme is very common in a lot of games/game engine
@pearl fog Also 2 other questions I need to be sure about :
- Is it possible to create a struct and put a boolean in it and when it's checked it opens a submenu to be able to put values in it like for instance (in blueprint) :
HealthRegeneration? : Boolean
- Amount to regen : Float -- The submenu starts here and only shows if HealthRegeneration? is true
- Instant regen : Boolean
- The Player State is accessible from the Server and the Owning Client, but is it normal that variables you put in the player state don't show the right value on the client but it's the right value on the server without replicating it ? I thought as PlayerState is accessible on the Server and the Client that means the variables in the player state are synced without needing replicating those variables.
yeah using a repnotify it's totally possible
huh ?
and yeah it's normal that's non-replicated variable in the playerstate are not replicated
a non-replicated variable will never be sent to clients
oh I thought you were talking about replicating your boolean, well in C++ it's possible but in BP I don't know ^^
but yeah, Unreal doesn't do any replication if you don't explicitly asks for replication
so even if you're on the PlayerState, GameState or any other default replicated objects, you must mark your variables as replicated/repnotify if you need them to be replicated
PlayerState/GameState/... functions like classic replicated actors
Is it hard to implement in C++ (as I did a bit of C++ but never Unreal C++) ?
Aright thank you
No that's not really hard if you just want to disable/enable your variable based on a condition, but for a menu it's more complex and I personally never have done submenus for properties
What the name of the thing doing that in C++ so maybe I can type that followed by blueprint in google and maybe someone asked the same question on forums or stuff like that ๐
question about switching the view on the PC (desktop) while the VR player is playing... how Can I manage this without changing the view in the HMD?
I am trying to allow the PC player to join, and help the VR player (multiplayer asymmetrical style)
I tried using a sceneCapture2D and setting the 'SetSpectatorScreenMode' to Texture, but the screen capture makes the VR Player view choppy, although the PC player is fine.
I tried 'SetViewTargetWithBlend' Setting the new camera to the 2nd ingame camera, but it also switches the HMD view to that camera.
Is there a way to allow the PC viewer to switch between cameras while the VR player plays?
Anyone knows about this?
Unreal isn't going to do anything automatically - I don't believe there's any code built in to synchronize sequence players. You can set the playback time of sequencer yourself when the player joins, though.
I remember something about a Replicated checkbox on sequencer
Ah, looks like I'm wrong - they did indeed add some sort of replication in 4.22
ALevelSequenceActor::bReplicatePlayback
I have a project setup with Steam Online Subsystem that works fine on PC, but on Mac the client cannot find any servers. Any idea why this might be?
when using seamless travel, can I only allow the game to move from the transition map to the new map after all the network queries have been handled.
for example: after a character is loaded in the world, I execute queries to the backend loading weapons inventory etc.. however it looks ugly when teh character is sitting there naked until the data is loaded
what I want to do is keep the loading screen running on the transition map until all network queries are finished, notify the transition map that they are finished and then finally travel to the new map.
How can I achieve this?
why pause on travel map? engine isn't really made to stop there
you can just do it on destination map, covering with the loading screen
and set everything up before world calls BeginPlay
@gaunt cliff
also, that seems like it could had been loaded before travel even started
setting up everything on the start map, and just persisting it through seamless travel
hummmm
if you have a lobby, with players setting up, they can RPC everything to the server as they do
server stashes the information on the PlayerStates
if you have separate PS classes for lobby and game, they can have a common base carrying the setup information
and just CopyProperties the data when they are created
this is followed by AGameMode::HandleStartingNewPlayer when each player finishes seamless travel
currently we're using on post login
so we should switch to HandleStartingNewPlayer ?
and there you can just reconnect or reinstantiate everything you need, as this is when the PlayerPawn is spawned, and you already have game controller and a game PS, fully populated with data
yes
post login happens after they log in
which is when they first join the server
it does not happen after seamless travel, as there is no reconnecting involved
HandleStartingNewPlayer is called from both PostLogin and from HandleSeamlessTravelPlayer
Travel map is not treated as a normal level, its just there so engine can release the old World before it starts loading new one
Hi, how can i set different settings for the same actor, so everyone would see him in one way, but he himself will see it different?
What i mean. I have a player as listen-server, and i set every client client-side only animation class for skeletal mesh. But when i do it same way for server, it gets replicated and everyone sees mangled client-side mesh. Im doing game where you can equip different weapon, so clients should see weapon on the screen, that's why i do it.
if (IsLocallyControlled())
{
GetMesh()->AnimClass = ClientSideAnimClass;
}
Usually you don't. You just have two different meshes and use OwnerNoSee, OnlyOwnerSee settings on the mesh component.
I need to make a replicating grid inventory.
There are a few ways to handle items and containers for me:
- Make them using UObjects and add replication code, plus force some actor on scene to replicate them on update (pickup, etc.)
- Make them using AActors
Second approach looks easier for me, but i know that actors weight more and having 600-800 extra actors in world is not a healthy way to go.
Are there any other cons of using actors for that solution other then load on server? Maybe anyone has other ideas on how to approach the problem in the first place.
Hi, i'm using the ?listen param when i launch my game to use it as a host, but i would like to know how i can have the same behaviour from the game when i create a session for example ?
This isn't a fun error to see, lol
[2022.01.16-11.58.54:686][398]LogNetPartialBunch: Error: Attempted to send bunch exceeding max allowed size. BunchSize=76945, MaximumSize=65536
:clock2: againstao#0115 was muted for 5 minutes.
So I decided to roll my own networking via some basic Websockets, and I have the WSConnection component living in a GameMode blueprint...
This was working great up until I started trying to debug with 2 clients launched in the editor. Realizing that the gamemode blueprint is shared between both of them, that is problaby not going to make testing easy.
Where do you think it is "safe" to have the WSConnection... I was thinking in the playercontroller? But there might be a better place I'm missing.
GameMode shouldn't be shared between any clients? If you're running two separate standalones, there will be two separate GameModes. If you're running any form of other client, they will not have a GameMode at all.
Hmmm - I was experiencing some super strange behaviour but I'll look into that again.
For example, if I do a print string in the game mode on play, each client's window shows two messages. Is that they are actually just sharing the same output log?
I'm spawning a replicated projectile on the server without lag/latency simulation, the projectile spawns at the right place, but the issue is that the projectile (an actor with projectile movement component) seems to not spawn from the player's hands, but a bit far from the player, is this due to the replication taking time combined with the velocity of the projectile movement component?
It could be that the projectile isn't replicated until after it's first movement is calculated.
hmmm is there a solution to this in case that's the issue?
maybe I could enable the projectile movement after replication ๐ค
What is the best way to handle procedural meshes in multiplayer?
I know I am supposed to basically replicate the instructions to each client, but I dont really know how I should go about doing that. If anyone could push me in the right direction that would be great
im making a multiplayer game that I plan on releasing on steam, should I pay the steam fee now to be able to get an app id or should i wait until my game is finished
is there any benefit in replicating a struct with an array in it
over just replicating the array ?
I think if you can simplify the system such that a procedural mesh can be derived from a series of vectors then all you have to do is replicate that initial series
then allow each client handle generation locally based on that series
I would imagine not since it has to replicate the array anyways when it replicates the struct.
How should I call the event? I would expect it to be on game join but I dont know what is available
Some has a guide to write a good actor movement replication system, and also for component ?
any doc where i can get the idea will be very helpful.
You can always test with 480.
And it's not difficult to update later.
So, I have still have been fighting this issue from close to a month ago. Now I haven't been working on it that entire time, but I have tried off and on. I haven't the faintest idea on what is actually happening. I've tested in PIE, with separate processes, separate instances, and over the net. The issue persists. Server, the orientation is fine, client's, their weapons are rotated to the side. I am setting the WorldRotation in the OnConstruction method. It appears to be getting called twice on the client. I have also tried using PostNetInit - same issue persists.
So I have admitted defeat and have just rotated the mesh to face +Y by default from the Skeletal/Static mesh windows and reimported. @meager spade @chrome bay (Sorry for a fairly delayed ping)
depends on how the procedural mesh is needed
but i'd make the vectors a rep notify and use it as initial only
or just regular rep notify if the mesh can change later
the event would be called from the rep notify function
will repnotify be called on a player's client when they join?
Its called whenever there is a difference between clients and the server
so yes
if the inital state of the array is empty and the server changes that
any clients that join and any that already exist will receive the rep notify
oh that's great news, I didn't realize they worked that automatically
I had already done the repnotify but thought I needed to set more up before testing
sounds like it could work as is
great
how would I make a system similar to Fall guys which will only let a certain amount of players pass through a level when they cross the finish line
not exactly a coder so I was wondering
Has anyone ever had an issue when weren't getting replicated all of a sudden on the server and the client? It appears to only ever happen when I add a specific GAS ability to one of my characters. Although when I make the same ability in the Tranek sample it appears to work fine. So I am thinking that it must be something with the way the multiplayer is set up that is different from mine and his. This is the ability that is causing the issue, this is what the server and client see when that ability is added, and than this is what they see when its removed.
is there a standard way to have the server wait for a graphical event to run on a client? For example:
User enters a teleport ring
Camera fade plays on the client
When the camera fade is complete then the server teleports the actor
should I just create an RPC when the Timeline is finished to complete the teleport or should I run the timeline on the server and simply send the fade amount to the client and carry on with the logic with the timeline is done.
Update: For whatever reason it appears something inside the Wait Target Data Task is causing this issue to happen. When I disconnect it and just have it print something out it appears to work fine, and it also works when I recreate this ability inside the Tranek sample using the same calls and everything.
Personally. I would have the player's HUD set up for this. Pawn can do the interaction, server can start a timer on the pawn's controller. An RPC should be sent back to client to tell it that it's being phased and pass ServerTime + TimerDuration for the timer ending point. Now back on the local controller you can get the player's HUD, and have it put up a full screen widget, maybe hide the normal widgets on screen, and pass that float from the rpc to the widget for end time. The widget itself can interpolate the best it can to match the time the server wanted to teleport. You can use GetGameState->GetServerTime to help widget interpolate. If you time it so that the widget is fully opaque at TeleportTime-0.25 seconds, it should hide the teleport completely. So networking wise, a single Reliable ServerRPC to use the teleporter, and then a single Reliable ClientRPC telling client when it'll teleport.
VR, no widgets on the screen.
Camera fade should be able to manage the same.
We're not particularly concerned about 'cheating' since this isn't really a game we're making, but would it make sense to run the timer on the client's controller if we were? Wouldn't you want the server to control the timer?
Server would control the timer. Server version of the client's controller.
Ah okay. I wasn't sure if that's what you mean or not. Yeah, that's fairly straightforward then.
If you don't care about cheating, then you could just do it all locally for the fade, then call the teleport RPC after fade complete. Just really depends. But the effects should definitely be local. Server should at most send the end time like I mentioned and client can interpolate to it, but sending back constant timer updates from server isn't necessary.
Can anyone tell me how i can make an FUniqueNetId from a string?
Well, strictly speaking you can't really. FUniqueNetId's have different underlying types depending on what OSS you're using.
So it's up to the OSS to "create" one in the correct fashion, then expose it for the rest of the engine to look at.
If the OSS has an implementation of the IOnlineIdentityInterface though, you can use CreateUniquePlayerId() which takes a string argument.
Most of them should have that interface
So actually I guess you can :D, but the OSS is what needs to handle creating it
thanks, this is what i needed
: D
Hi @chrome bay (sry for the ping), i was wondering if u using Single Fire/Semi Auto/Burst Fire all in the same class with HLL or if you have subclasses, actually i'm implementing your "better burst counters" logic to handle semi-auto more easily but got some difficulties to make it match with the original shootergame fire logic
all same class yeah, following same logic for the most part
ShooterGame weapons are not good tbh. Better off writing your own.
apart from anything it's like 3 reliable RPC's at once just to fire a shot
in shooter game, it waits player to release fire input to stop fire state and it f*cked up totally semi auto weapons
shooter game only really has auto weapons, it doesn't do anything else AFAIK
do u have any advice on how can i handle that in just one logic ?
i'm kinda lost with that since my logic is based off shooter game weapons
nothing specific really, for semi-auto you just don't fire the weapon unless the input has been released between shots
We're based on ShooterGame but it's not even remotely reminiscent of it now tbh
Okay, thanks for those precious informations ! ๐
Also, on your blog, the videos aren't working (at the end of the article)
Ah yeah, I never got around to putting them up ๐
Oh i forgot, when do you stop fx for semi auto ?
We don't, they just don't loop
so u play it one time ?
i might do that, the one from shooter game is a looped one ๐
same for fire sounds ?
So you fire, the fire simulation is triggered. For automatic weapons this process re-uses existing particles and audio components, for semi-auto weapons it just uses a single non-looping effect.
okayy i see ๐ค
i was using the AC/MuzzlePSC from automatic weapons ๐ might be why it wasn't working on semi..
thx for ur help jambax ๐
If it was me, I honestly would scrap shooter game altogether and do your own logic from the ground up. The shooter weapons are good to pull ideas from but not a good basis IMO.
The more you modify them to add new logic the more you end up hacking it together
yeah that's what i will end with anyway since im planning to convert my weapon system to GAS later (my whole project is dependent of gas)
yeah exactly lol x)
@chrome bay do you have chargeable weapons in your game?
not in HLL but I do in the tank game!
yeah i am currently working on making my weapons better
i have 4 different "trigger" types
Press, Automatic, Release, PressAndRelease
idea is Press and Release is for chargeable weapons
Press -> Start charge, Release -> Fire
but then again that could be done with just Release..
anyway the main question is, how to handle states
do i go Enum or go Uobject states..
Gameplay Tags ๐
GameplayTags with states is a bit urgh
tbh I'm not too sure I like my weap system in that game yet.. it creates a state object and assigns a tag to it
yeah
especially when using switch, etc
I don't have trigger types as such, I just have press and release events for the trigger, and then to assist with AI the AI has a "rate weapon for release to fire" utility
Since for some weapons they might charge up, or others might be that you have to hold trigger to lock on etc, then release to fire
HLL only has auto and semi-auto really in terms of trigger but they operate pretty much the same way
yeah, i mean i only really have Semi Auto (Press), Automatic, Release (Charge)
although on yet another project I had this setup.. which sounds similar to what you have:
enum class EAbilityUseMode : uint8
{
// Tries to 'Activate' the ability when key is pressed.
AUM_Default UMETA(DisplayName = "Default"),
// Charges the ability while the activate key is pressed. Tries activation on release.
AUM_ChargeAndRelease UMETA(DisplayName = "Charge & Release"),
// Ability is active while the activate key is pressed.
AUM_Hold UMETA(DisplayName = "Hold"),
};```
This was all predating GAS though :/
managed to get a lot of mileage out of that though
i don't do weapon logic in gas
abilities are activated via the weapon code
just for the actual "Firing" data (hitscan/spawning projectile)
yeah makes sense
Hello i've got few question about dedicated server programming, first, how to host a map on server side but not on client (avoid reverse engineering the map) and how to split client / server code for avoid client to create dedicated server
what is that ?
like snipers ?
Can't
Well "can't" and "the engine does it already"
A) You can't - the client needs the map too, you can't stop users decrypting PAK files so there's no point trying.
B) You can wrap code that should only exist in server builds by wrapping it with UE_SERVER, and then you just don't distribute your server binaries.
'kay
To clarify on (B) it's really not worth the effort to do that, it's a pretty pointless exercise imo. Unless you are embedding some sort of passwords in your code, and then I would say. Those clear text passwords shouldn't be living in your codebase in the first place, but rather a config file that's loaded, and that file would only exist on the server.
You can do if you're paranoid that someone will disassemble it and figure out how you've implemented it. I wouldn't bother personally.
You're planning on hosting your own dedicated servers and not allowing 3rd party hosting?
As I mentioned in my message above. I do not believe anything should be guarded by the UE_Server macro for security reasons. If you think you have to do that you need to go back to the drawing board.
In other words security through obscurity sucks
i use it for compiling out code i don't want clients to see
like my anti cheat stuff
(server side checks)
Yes but that's you - it's not something that should be on a newcomer's mind ๐
By the time someone's at a point where they're comfortably writing server side security checks for their competitive PvP game. They wouldn't be asking the questions that they have
Wrapping a server RPC with it won't really achieve anything. Clients calling RPC's and the server not verifying what the client is asking at any given time is the root of most cheats.
Anytime a server RPC executes something, just validate what the client is asking of it
Yeah that is true
E.g, you want to sprint - you don't check stamina client side and tell the server "start sprinting"
You check it at both ends
Only if it's a competitive game. Otherwise, just don't bother
Depends
what happens when you want to add competitive later?
It's not just for competitive purposes, it's also about validation - e.g, what the if the client is asking the server to get into a state that shouldn't even be possible.
even on non competitve games, you need some kind of way for the server to say, yes that's valid (else they can be desyncs)
That's very likely, even in non-competitive
I mean yes you have some sort of checks for gamestate validity that are normal
My point being that there shouldn't be an abundance of checks in the name of security that someone less experienced ( and paranoid about this potential issue ) may add
But yeah generally how hard you go in the paint for anti-cheat depends on the target audience of the game
(and UE_SERVER probs won't help there much generally)
UE_SERVER is literally for hiding sensitive code client should not see
like i wrap it for the verification of client shots
http://thegames.dev/snaps/rider64_O2vmmyU7Tj.png for example (hidden the crucial stuff)
yeah same here really
also compiling out cosmetic stuff etc..
not super important tho
if i use the steam online subsystem, will people need to forward the port in order to host?
if yes how can i make it so they don't have to?
if you use Steam then steam handles nat punch through
so forwarding should not need to be done
ok bc on the tutorial i follow it asks to forward the ports
do you mind if i send you the video?
https://discord.gg/W5g6pZXfjh
: ATTENTION!!!!!!!!!!: At 1:06 we need to also change DefaultPlatformService=NULL to DefaultPlatformService=Steam at line 43 in our DefaultEngine.ini.
In this video we alter our code a bit and change our .ini settings in order to use the steam subsystem. Once we get it setup we then test the game on 2 separate comp...
im following this one
it's from 2020
so it's not that old
do you know any other good steam c++ tutorial?
did you look at the video i sent
ofc not
it asks you to port forward?
Chill. It's an assumption. When you ask things on Discord, we never have all of the context that you do. Therefore any answer makes reasonable general assumptions based on the information that you have and haven't provided
And you as the person asking the question aren't the only target audience, but anyone else reading the question as well as the answer is too, and those people might not even participate in chat. So that's also something that I keep in mind when helping out, because those people make their own assumptions based on the information that they see.
Could anyone link a good set of videos or articles explaining how multiplayer works with unreal engine? Specifically looking for how gamemode, gameinstance, etc. work in the engine for multiplayer and how you would setup rules for multiplayer games. Just @ me please. Thanks
@chilly arrow Look at pins in this channel
is SteamWorks and steam online subsystem the same thing?
Steam online subsystem is part of UE ( Epic ). SteamWorks is the SDK provided by Steam ( Valve )
They are not the same thing. Steamworks deals with all kind of things around Steam. The online subsystem allows your UE game to play MP together through Steam
Ok so if I want to make a lobby through steam how would I do it
though that's still a poor explanation of OSS
online subsystems abstract multiple online services through a common set of interfaces, underneath the steam OSS wraps the steamworks SDK - just look at the source
so an xbox, playstation, or mobile version can use the same API just targeting a different underlying service
when loading a new map, the ground is shown for a second before the pawn is spawned, where in the lifecycle can I intercept that and show a loading screen before it happens ?
Usually you put up loading screens before map load. Then stuff like HUD beginplay removes them.
i believe i was wrong in that video, steam should handle nat punchtrhough for you
Hey, ive got a health bar which when either client or server takes damage the health bar updates for both of them, but its just the health bar not the actual health, how can i replicate it so the health bar shows correct values for each player?
This is the healthbar's bp
This is damage in the character bp
How do you add a Blueprint Component to one person in Multiplayer?
Kind of like a pickup ability. Usually this just crashes the client for me, but the Host can do it.
Also how do u handle situations like fire rate of the semi auto weapon is 0.2s and the muzzle duration is 1s, if you full spraying it will keep showing the muzzle flash without interruption, is there a solution to avoid that ? ๐ค
I've tried this a few time but failed. Not exactly sure how to get the server to create the component.
@twin juniper your muzzle flashes should be timed such that they dont cause issues like that
seems like a VFX issue
Yeah but if I want a weapon with 0.2 of fire rate I canโt have my muzzle duration be less than that or it will just looks weird on screen ๐
What is the common duration of a muzzle flash ?
๐ค
mine are about .1 to .3
And so you have no weapons under/equal .3 fire rate
my rifles are about .15 in durations
for the flash
in real life muzzle flash is pretty quick
like blink, you miss it
.15 of muzzle duration or fire rate ?
the MF duration
So u got different MF per weapon
Wait, can we set duration of a particle at runtime ?? ๐ค (Iโve 0 knowledge with the VFX side of UE)
So I can adjust it with weapon fire rate
Sps ??
Shots per second
think thats RPM?
Muzzle flashes are purely visual, there's no reason to have that handled on the server. That logic can all be on the client
Thatโs the case actually ?
Is there any way to minimize or compress the strings that i need to replicate , because i have huge strings that i need to replicate.
For what reasons are y replicating a string tho ๐ค๐ค
Then it's probably not a #multiplayer issue ๐
And the time between shots is > .15 ?
Yeah but itโs never under the muzzle duration ?
@twin juniper information related to Actors... actors descriptions bunch of stuff, these strings contains necessary information to construct a Actor.
i have SPS, so in my datatable i have like 6.5
So 6 shots per seconds ?
nah, just design choice
on the user front end, i can display how many shots per second the gun is
with the damage, etc
Also how do you handle sniper reload ?
And I guess it also applies to shotgun reload
Between shot
I have an actor A that spawns an actor B on the server. Actor B is set to replicate, has a reference to A and calls a multicast rpc that tells A to play a montage. The montage is not replicating. Any ideas? For this specific actor A, I did switch out it's skeletal mesh and anim instance class with a multicast rpc (which is working).
Did u check that the rpc was called from the server ?
I'd really appreciate some help with this. I've been sitting on this issue for a few months now. Even a link to a form post would help me immensely. I've looked up stuff on my own, and have had people try and help me, but I've only been told the solution and not shown how to do it.
yeah I have an authority check before it
More info - if i move the play anim call to actor A but call it on actor B, it does replicate. so maybe the problem is that my actor B is somehow not replicating despite replicates being checked?
the solution was that the actor B was not net relevant(probably because I spawn it at 0,0,0 due to not needing its position to be valid). I resolved it by making the object Always Relevant. I'm going to try using Net Use Owner Relevancy because I don't like the Always Relevant solution.
This is what GAS (Gameplay Ability System) allows you to do
Otherwise, are you not able to construct object from class, and then attach the component to the actor?
This seems to be what I was looking for. Thank you for giving me a lead to follow up on.
Look in the pinned messages in #gameplay-ability-system GAS Shooter by Dan is a very impressive open source example
Can anyone recommend the best way to debug / profile what appears to be client/server networking issues? Just in general where I should be looking / checking.
Depends on your issues! Give us some more detail.
Profile if you're having frequent packet drops or you're suspicious the bandwidth is too high (Unreal Networking Insights tool is good for this).
Otherwise, just the usual debug stuff: logging, breakpoints, disable run in process, etc
It's just a looping particle system, so it doesn't really matter how long each shot lasts, you just time it to be synced to the fire rate.
Is it possible to predictively add items to an array that replicates? Doing so currently would result in an inconsistency between the server and client if the client goes through with the add but the server rejects it, at least until the next replication update. I'm trying to figure out a way to force a replication of the array (even though that array hasn't changed) when then client adds an item predictively, but the server doesn't. I tried using Fast TArray replication inspired by this earlier message: #multiplayer message, but calling DirtyArray from the server after the server rejected an item add doesn't result in the removal of that element added predictively client side. Any help would be amazing and appreciated.
Certainly possible, but you have to handle the reconciliation yourself. I.E, the client needs to track what it has predicted, and remove it if the server didn't add it for whatever reason.
I see, that makes sense
Also, the server would have to know the client predicted something, so that it could notify it if the prediction was incorrect.
Unless somehow the client is able to work that out for itself.
Can look at how prediction works in GAS
Yeah that sounds a lot like GAS prediction or movement prediction stuff
Ok thank you very much!
There's a huge comment in GameplayPrediction.h that explains how Epic approach it
A clients' relevancy position comes from their view target usually.
Which by default is their own pawn
What the server is looking at shouldn't matter
Try debugging APlayerController::GetPlayerViewPoint() to see what each clients relevancy position actually is
Yeah I know but for semi auto you using a non looped one ?
yeah
So what if semi auto TimeBetweenShots is like 0.2s and the muzzle duration 0.5
If Iโm spamming the fire input the muzzle will have no time to disappear between shot
I know itโs not a problem on auto weapons but on semi auto it just looks weird
you just spawn a new particle each time, or have a pool of them to reuse
or drive it through events so you can keep the same component and just create new particles
Yeah but sometimes the old one doesnโt had time to disappear that a new one has spawned (if Iโm firing very fast)
This is really more of a FX question really, you just make it fade away quicker if it's too much
and limit the maximum possible fire rate if you have to
Well it depends, theres flashes, residual smoke etc.
Yeah true
It can be as long as it likes, you just spawn a new one each time
Iโll try to adjust that when Iโm on my computer then
Also for sniper/shotgun how do you handle the reload per shot
Itโs not a ยซย reloadย ยป but idk the proper name lol
Like with a Kar98
there's an additional "bolt cycle" state
With a timer etc ?
Is this something there is in UT ?
So I can maybe look at it to have a ยซย goodย ยป example
Most UT weapons don't even have reload
let alone any complex interaction
I don't know of any examples tbh
๐ฉ
Yeah Iโll do that alone then
UT is a very one-dimensional project too
Good source of inspiration for some things but not much IMO
It was good in itโs time yeah
Itโs outdated now (same for ShooterGame)
The projectile prediction is wacky, weapons and characters are closely coupled together. Just don't like the approach much, but their only goal was to "make UT", rather than a template or base project, so it's understandable.
Yeah I guess they didnโt even achieved that (make ut) since the repo hasnโt got updates since years
But anyway thanks for ur help again !
Imagine UT5 with GAS
(Never gonna happen)
Still I wonder if a gas sample is planned
We are in #multiplayer obviously Iโm talking about a MP sample
And with good concepts
The ones in action rpg are very poorly done. (Like the way of giving startup abilities etc.)
Epic said there will be a new sample with UE5
with GAS and multiplayer (i already have seen some of the stuff, looks interesting)
Looks promising ??
yes
Is this oriented shooter or rpg ? ๐ค
shooter
So it takes some concepts from fortnite I guess ๐ค
maybe... ๐คท
I read about prediction in multiplayer and it seems like very hard topic, especially for projectiles. In theory how hard would it be to make prediction system for PvE game (multiplayer for coop), so it doesnt need to be very high quality prediction, client actions should have high priority (for hits and for dodge enemies abilities), something like in diablo 3?
So goals are:
- all players can see enemies actions (dont need to be accurately synchronized)
- other players can see your actions (accurate sync is also not important)
- you can see your own actions and its effects instantly (for example projectiles that deal damage to enemies, you should instantly see projectile, hit and damage)
- if you dodge enemies abilities on your screen, it should be considered as dodge, even if its different on server and other players screen
- should be protected from easy cheating (still need to validate players actions somehow)
- easy to make/good optimization (i guess the better synchronization the more heavy it will be for server?)
So would this system be much easier to make, instead of system with good synchronization across all players, or its still will be similar?
https://www.youtube.com/watch?v=h47zZrqjgLc @grave notch
In this 2011 GDC session, Bungie's David Aldridge discusses the programming that drove Halo: Reach's online networking.
Register for GDC: http://ubm.io/2gk5KTU
Join the GDC mailing list: http://www.gdconf.com/subscribe
Follow GDC on Twitter: https://twitter.com/Official_GDC
GDC talks cover a range of developmental topics including game des...
you'll probably find the format more digestable
What exactly happens when pointer is sent from server to client as a parameter in rpc function?
it gets converted into NetGUID
if client has that actor in its NetGUID mappings (actor is net addressable) it can resolve it into a pointer to its own instance of that Actor
doesn't have to be Actor, net addressable UObject
Lets say I have a DataAsset that the server sends to many clients. Do each client then point into their local instance and they can do whatever to that instance without affecting others?
they can, and should not
is player state preserved in a seamless travel?
not in the case of DataAssets
yes and no
Or if server sends it to same client many times then that one client always addresses the same dataasset with each call?
it is preserved, but is likely to be reinstantiated, especially if lobby/game class is not the same
thats what CopyProperties function is for
first time server sends an asset reference, its sent as the assets path, but is also assigned a NetGUID at that time
any repeat sending of that asset reference will be just the much lighter NetGUID
data assets should not be changed at runtime though
what I see is the game trying to add the same playerstate to the new world's gamestate after a seamless travel, same mem address same name
HandleSeamlessTravelPlayer
will reinstantiate PC and PS if needed
in the GameMode
so you can put a breakpoint in there and follow the execution
Okey. Thanks a lot ๐
Has science advanced far enough to simulate seamless travel in editor?
no
I don't think it ever will ๐ซ
It has. But it doesn't make nukes, so screw spending money on it.
I'm trying to get a Component to be added to a Player Actor to replicate, but this doesn't work. Anything I'm doing wrong?
A bit of a vague question, but does anyone know if Control Rig is properly replicated?
I've been looking through the documentation but I'm not seeing anything about this.
Pretty sure you don't replicate control rig but just the variables that drive it
Same as with the normal anim bp
Hey got a question I got a projectile which is colliding against a wall the second it gets spawned. But Only when playing "AS Client" if I try "Standalone" it works or if I play as "Listen as Server"
any idea why is it happening?
look at the video, you'll see when I play as client, the print screen shows up inmediatly
You're crossing execution paths. The "T" key press would only ever happen on the client, so your return value from your component addition wouldn't exist on the client like that as that bit of code never executed on the client.
Is there a different way to test adding a component using something that isn't a button press
It's not specifically about the button press. You marked the component as replicated so that component should then exist on the client so you can try and reference it by doing something like "Get Component of Class". That being said, you also shouldn't need a client to tell the server to initialize it. The server should be able to do that itself without any input from the client.
It's a test for down the line adding a Component at Runtime that allows you to change into a diffent Actor. But not everyone gets the ability. I want all players to stay on the same base character BP, but add mechanics to a select few people.
My guess would be that the server instance that the editor is launching is running for a long enough period before your client instance is joining that it appears to collide already when the client joins. Try moving the orb spawn point further away and see what happens.
If there is a more practical way of doing this, I'd love to research it, but from my understanding, components can add stuff like this.
This wouldn't happen on standalone or listenserver as the client is technically the server.
Then how would I do it? That's the part I'm caught up in.
I've done replicated a lot beforehand, but this is just a bit different to me.
@sinful tree if I move the projectile back it collides half the way from reaching the wall
So again - you've already added the component to the actor, so it does exist. The problem you're having is that you're taking the return value of something done on the server and trying to use that return value on the client which won't work as that code never executed on the client. You can use Get Component of Class to find that reference, both on the client and on the server afterwards.
You shouldn't need to pass through a reference to the component from the client to the server as the server can get the component itself. At most, you'd want your client maybe doing an RPC to request the addition, but it shouldn't need to pass any of these values as the server already:
- Can find the appropriate component using "Get Component of Class"
- Can get the reference to the character in question as "Self" also exists on server.
- Can get the appropriate player controller from of the character by using "Get Controller" which can then be cast to player controller.
- Can get the reference to the camera boom as it also exists on the server.
Ok, but your collision message, does it appear as soon as the client joins?
Thank you. I will take a look at this and see what I can get working
Hello, Iโm trying to make a game similar to Mario / pummel party . I have a lobby set up to host a game and a few levels but how to introduce a point system that is consistent when they go into a level and come back to the lobby? I am thinking to use gameinstance but wondering if there is any other methods thatโs better?
Game Instance would be the place.
This is the code of the BPC. Would any of this need to be changed replication wise to work for everyone to see?
Actually, it looks like it's working. I added a call event to the end of Initialize for Transform, and it seemed to put it all together.
That actually fixed all my issues. I understand what the problem was now and got the rest working. Thank you for helping me understand this. You've saved my sanity lol.
So, I've been spending some time simplifying my camera control and got to a point where I really like how everything works together. However I'm running into one small issue. The rotation of my character isn't being replicated to the other clients. If I hold middle mouse button I can rotate the camera without rotating the character, this is good and by design. However, when I hold right click I want it to rotate the character and the camera, this is also working, but the other clients do not see this rotation happen. Any ideas on how to fix this?
Control rotation is not replicated by default as it's something handled on the player controller itself which is something that only exists on the owning client and the server, not other clients. This means you'd need to replicate the rotation of your character yourself.
Target Rotation in the below example is set as a rep notify variable (not sure if that's the best way to do it, but it works!)
I'll give this a try! Was about to say maybe I could make a custom event and make that run on the server and call it during the action on the client. Though, I believe movement is tick based already so, maybe a tick based event would work well here too. Thanks for the info! Trying it now.
Is set w/ notify it's own variable you've set as a rotator? Additionally, how did you get target rotation x y z ?
Oh figured it out ๐
Hello. I'm trying to figure out multiplayer so I can add it to my project, but my wall jumping code isn't working. It should lunch the character in the opposite direction of the wall, and while it does so for the server, the client gets rubberbanded back to the wall. I have disabled the lag in the .ini so that's not a factor at the moment (although I will need to account for it later) Does anyone know how to fix this?
(The first pic runs off event tick)
This does work, however now my character is rotating on both middle click and right click. Trying to see if I can correct this, but if you think of something I wouldn't say no ๐
With the 1st On Rep Target Rotation screenshot, the character and camera rotates with both middle mouse button and right mouse button (which middle mouse button should not rotate the character at all), but also does not replicate to clients.
With the 2nd On Rep Target Rotation screenshot, it does the same as the first, but it is replicated.
Without the On Rep Target Rotation, it does the same as stated originally, middle mouse button rotates the camera (which is correct) and right mouse button rotates character and camera (which is correct) but doesn't replicate.
Does anyone know of an example in the source code that adds items to fast tarrays predictively? I see that client prediction is mentioned in some of the fast tarray code itself so I assume that there would be.
To work with your logic of having a key controlling it, you'd want the client to be able to send RPCs to Start and End when the rotation should be getting set on the server so it replicates to everyone.
Eg.
Ohhh I could kiss you Datura. This works perfectly! Pretty easy to tie into my existing flow as well. Thank you!!!
I'm using a RepNotify to change a skin to something random on spawn. It runs every time the actor respawns. Is this done poorly / could cause overload?
Is there a value somewhere that can be read to determine how many clients are expected in a PIE session? In other words, I would like to know the expected number of players prior to them connecting and being added to the PlayerArray.
No. How would the server know how many people are going to connect until they connect?
If you're asking about a matchmaking service that spins up a server and sends a group of players to it, that's on you to build and not something unreal would provide.
There's an option for a maximum number of players (AGameSession::MaxPlayers) in case that's what you're asking about.
I mean specifically in PIE. Some way of accessing the # of players the editor is going to create. It's so I can fabricate some fake test data that would otherwise be passed from the lobby. I did find FGameInstancePIEParameters which seems promising. There might be a way to access it...
Ah I missed the PIE part.
Do they not connect on the first tick?
If there isn't a simple number you can grab from somewhere, you can probably count the number of PIE world contexts.
int32 PIECount;
for (const FWorldContext& WorldCtx : GEngine->GetWorldContexts())
{
if (WorldCtx.WorldType == EWorldType::PIE)
{
++PIECount;
}
}
Ah, good tip. Let me try that. Thanks
Note that what I posted would include a dedicated server PIE instance in the count if one is running. You can check WorldCtx.RunAsDedicated if you want to filter that out.
It would at least seem that by the time AGameModeBase::BeginPlay is called, they do not all have PlayerStates yet (although that might be different from actually being connected, I'm not sure about that distinction).
Anecdotally, it seems like as long as I schedule my code for the next tick after BeginPlay, this works and PIECount is correct. Thanks.
Does checking the player list work on the next tick too? Probably easier to use that if it does.
No, one tick after it is still 1 (PlayerArray.Num()) while PIECount is 4. (In this case listen server + 3 clients). I suppose I could just up the delay a bit for PIE if I really wanted to use the player states or # of controllers
I guess PIE still does whatever network negotiation it does across a real network so it takes a few ticks.
Yea, the PIECount seems to hold up if I turn up the network emulation latency. Seems like a decent solution for this. Thanks
Wondering if I could get some help with this;
I'm trying to setup an interaction so that when the user is hovering over an interactable object, the player won't swing their weapon. As the interact button is left click as well as the swing weapon is bound to left click.
On the first screenshot, this is the event graph of my door, where I've set it up to open 120 degrees from 0. This works fine, however it only works for the single person. It doesn't show for any other, even if the server opens the door, the clients do not see it open.
On the second screenshot, I'm trying to set it so that on the branch, if "is interacting" is true, then it won't call the start attacking.
You'll see in the first screenshot I've set it so that if the user is hovering over the door, it should mark the player as "is interacting".
I've tested the on begin cursor over and end cursor over with a material swap, and it does indeed swap, but per client and server doesn't change it for client either. I'm guessing my is interacting variable isn't carrying over.
Okay, I fixed the attack issue, but still trying to figure out the replication. I just needed to cast to thirdpersoncharacter and grab the isinteracting variable from there.
Hopefully this is an effective way of doing it. lmao
Fixed server side replication, now if the server opens the door, it opens for clients, but still having issues with client side opening the door and replicating to other client.
does anyone have a alternative to ?listen
im making a mod for a game that does not support ?listen and idk how to get around it
If a game doesn't support listen servers it's likely because it was built in the client configuration. Running a server from that config is impossible.
Does RepNotify call when a client initially joins a server and the variable is replicated to them?
I think so, but if you want to know on the client that you are now receiving data from the server the first time, you can override AActor::OnActorChannelOpen If you on the server want to know if you send data the first time to an actor on a client you can use AActor::OnSerializeNewActor
You just need to trigger the server door code from the client. Clients don't talk to other clients, only the server
Server opens door -> everyone sees door open
Client requests door open -> server opens door -> everyone sees door open
RepNotify will call any time that a value arrives on the client from replication for any reason.
But only if the value is different from the current client value, if you want it to always be called whenever the var is received, you an add REPNOTIFY_Always to the property in C++
Hey guys , I got a little question , I am trying to understand a replication , and what i read on all the posts online , they say never trust the client, never make client to do something , do it on server and replicate , OKEY i got this , but then i opened tutorial on replication "Sprinting" and all of them doing this (Image).and as you can see before they change MaxWalkSpeed on server , they change MaxWalkSpeed on Client , and that value on client isnt comming from Server , isnt this Everyone saying "UNSAFE" way to do replication
However if you dont do this way , it starts lagging
it doesn't start lagging it starts jittering
client movement is predicted, meaning client moves itself and RPCs movement to server
then just corrects when the server confirms this
if you were to set speed on server first, it would make the client move at lower speed then the server until its set client side too
and that causes corrections/jitter
Should I put multiplayer events (Run on Server/Multicast) for actions in my game in the player controller or the player state?
hey guys, how do I properly set up a UPROPERTY'd actor for replication? this actor represents the weapon of the character, and I wish to have it fire off a net multicast to trigger projectiles/melee swings etc, however, the multicast event is not being transmitted. here is the setup:
{
const UWeaponDeveloperSettings* DevSettings = GetDefault<UWeaponDeveloperSettings>();
bReplicates = true;
SetCanBeDamaged(false);
SetReplicateMovement(false);
WeaponCharacteristics = DevSettings->DefaultWeaponCharacteristics;
WeaponAlignment = FWeaponAlignment(DevSettings->DefaultWeaponHandling);
return;
}``` ctor
i do not need to replicate everything on the actor, just the netmulticast stuff
For example I have houses in my game, each house has a player that owns it. Do I put "Claim House" in player controller or player state?
virtual bool Server_SpawnProjectile_Validate(FVector2D Direction) override;
virtual void Server_SpawnProjectile_Implementation(FVector2D Direction) override;
virtual void NMC_SpawnProjectile_Implementation(FVector2D Direction) override;``` here is function declaration
```void AInfantryProjectileWeapon::PrimaryInteract()
{
FVector Location(GetActorLocation() + GetActorQuat().RotateVector(WeaponCharacteristics.BarrelAxisOffset));
FVector Direction((GetActorQuat() * FRotator(0.0f, 90.0f, 0.0f).Quaternion()).Vector());
ProjectileSpawnerComponent->SpawnProjectile(Location, Direction);
Super::Server_SpawnProjectile(Direction.UnitCartesianToSpherical());
return;
}
bool AInfantryProjectileWeapon::Server_SpawnProjectile_Validate(FVector2D Direction)
{
return true;
}
void AInfantryProjectileWeapon::Server_SpawnProjectile_Implementation(FVector2D Direction)
{
NMC_SpawnProjectile(Direction);
return;
}
void AInfantryProjectileWeapon::NMC_SpawnProjectile_Implementation(FVector2D Direction)
{
FVector Location(GetActorLocation() + GetActorQuat().RotateVector(WeaponCharacteristics.BarrelAxisOffset));
FVector CartesianDirection = Direction.SphericalToUnitCartesian();
ProjectileSpawnerComponent->SpawnProjectile(Location, CartesianDirection);
GEngine->AddOnScreenDebugMessage(0, 1.0f, FColor::Red, TEXT("NMC Test!"));
}```
A rule of thumb. If you want to send RPCs from your client To the server, you need to be the owner of this actor. You are the owner of your character and you player controller. I'm actually not sure how to set this up properly but I bet google will give some results or check how the PlayerController is setup.
nevermind.. i figured out why. I called the Super implementation which was not configured correctly.
hehe, goot catch then^^
Hey guys. Is there anything like "IsListenServer"? Cause we have UKismetSystemLibrary::IsServer but I dont see anything about ListenServer
Nvm, I found an answer in this thread
Is splitting weapon into UObject based states common as I think or is it a bad idea for multiplayer?
Our initial prototype with shooter game based weapons were nice but we implemented some other mechanics and code is pure sphagetti now
Like charged weapons, bolt cycle state etc
I would put that in the PlayerController or Pawn
Depends on if the player owns the house or the pawn does (maybe ai can own houses, etc?)
Anyone have any idea why its returning a different pawn here?
https://gyazo.com/0f38b369cdeaf91b16ae2391bf789d11
It depends on what is set in Character Ref on Server and on the Client. Everything else is appearing as it should based on this code.
Omg i love you ty
I just realized i didnt have that on an event
Im having a weird issue though where the server player cannot move
Oh god, I hate replicating... I am trying to replicate doors to other clients, but seems like the server doesn't really want to replicate it to others
https://gyazo.com/b5aa35222357286261a792eb8c25c4a8 In this video the clients can move, but when i try to move the server pawn he cannot move
I am pretty sure you have that all wrong- set it up like this:
When I am doing it like this then nothing happens. The door doesn't open
like, it stops here. It doesn't even print Test1
What event is calling open door
this
and the function is getting called from the player
You have multiple problems
That trace event is not replicated
And your open doors is executing a timeline on the server
The server needs to multicast an event thats running the code
oh right
That timeline should probably be on the multicast event
Hello, i need some help if someone could help me i will be really greatfull !
It is possible to call a function from a Multicast (so, the Authority) but only on the target client ?
For example, when my IA attacks a local player, i call โApply Damageโ, and then, i use "Launch Character " on the damaged actor with โOnTakeDamageโ, and it works less and less as the ping goes up.
For example :
โข Get damaged by an AI on Client with 0ms โ Launched, smooth, perfect
โข Get damaged by an AI on Client with 100ms โ Got teleported in air, not smooth at all
โข Get damaged by an AI on Client with 200-300 ms โ Not moving at all
I know what is happening with 200-300ms, its because on the server, the client already jumped from the TakeDamage function and has already landed.
So, how can i do ? And it is only possible in the in-built prediction system ?
Thanks a lot !!
Does anyone know why this is always returning the server pawn?
On listen server it will return server pawn
On dedicated I guess it will return clients
Use GetController instead
You need to cast to pawn from actor first
Thank you! I will try that
how do you tell a dedicated server to create multiple sessions?
so what i normally do in case of hosting a level as a server
i create a session and then open the level with listen?
but in case of dedicated server, i believe i shouldn't open the level?
cause i could make 2 level and run at same time
and when i search for session i see the level created
though, what map is loaded!!?
cause i never passed any variable about the map when i was creating the session
do i still need to open level? but then when i do that how dedicated server knows for which session it should open the level?
though i just noticed when i try to make the second session, it fails
hello, can you please help me with that:
i have a function that leads to an event: (pic 1)
how should i replicate that event so both clients could see that animation? (pic 2)
if i do understand that correct, 1 dedicated server instance can handle one level
one session with one level i mean
Client calls a Run on Server event. Server calls a Multicast event that plays the animation.
that doesn't work for some reason
Your client must be the owner for the Run on Server event to work.
if i just multicast - client 1 sees that (if he's holding bow)
if i add server, noone sees
hmmm
wow! then I need to have multiple dedicated server to be able to have more than 1 session? and each should have unique IP?
probably i should call that event from character then, not from bow bp?
unique port that is
or you can have some kind of connection handler so it will redirect your client to the dedicated server that is, for example, empty, i believe, but that is devops stuff, i'm not so good at it ๐
oh, hmm... when i created a dedicated server i did register a port in my hub, does that means i need to make list of ports in my hub? and wouldn't ports clash?
so it was 7777
in the common way user can enter port after ip like - IP:PORT
but you need those to be opened and forwarded through NAT
yeah, i do have that
i did register dns name as well to reduce the hardcoding ip address
i think you can assign session id to the port somehow and send user to that port from hub
yeah and make the same to every port you use
or create batch file for that
but i dont recommend that basically. ๐
i've done so for my server and someone started ddos on that port after two weeks
if thats your home network and you have some kind of default routers
Hi, may i askโฆ ๐ i need to set view target with blend in multiplayer. I try to get the controller but if itโs triggered all player cameras get movedโฆ its a simple Listen Server Session
at least don't keep that session listening all the time and for long periods so it wouldb't be noticeable in the network
hmm.... but how can i manage them? this is very confusing
yeah, that's just my home network
hi, is it possible to add any protection against players using the command demospeed in an MP game? currently have that issue where players can bypass cooldowns by doing that
manage opened ports?
most of the routers have some kind if API
so probably you can call it from your session using custom fuction
yeah, i can handle that in GameMode in case game end after certain time kill the session, but wow didn't know dedicated only run once
per port i mean
you mean i can manage my router ports from UE?
yeah, but you gonna need to run custom scripts if you are using blueprints
haven't think of it that far ๐
aaren't you multicastong that?
OR you can just go with nat punch / steam and ignore the 1990 port bullshit
yeah, but need to see if my router has any API library can be access in UE
Nope i didnโt replicated it. Should i?
Its meant to be for one player only
None of that is useful if you use Steam or implement nat punch
Its just a death screen camera
yeah, if i want to put the game on steam right?
i guess you should try run on owning client
steamworks sdk right?
Oh ok i try this. Will it works for the host to?
Or if you implement nat punch yourself
Ports are just not a thing people do
okay, what is nat punch?
i think so, but i'm not good enough in that replicating stuff yet ๐
Google it, there are libraries to implement it
Or just use Steam and it'll just work, but hey
I give it a shot tomorrow, will let you know if it worked then. @thorny fog
okay, let me look that up, see what it's about
@bitter oriole yeah that makes sense, though that means I need to have another server with another internet provider to be able to have a master server
So I am trying to get into the server setup stuff for a multiplayer game and I am trying to get a handle on where to start, but for like a server browser, how does the game find all the available servers? As in if its trying to get the IPs and info for the servers that are running the game how does it actually get that information, is that where the subsystems come in?
If you decide to use a subsystem I believe it does STUN and routing for you. I remember using Steam's OSS a while back and pretty much you'd tell it if you want to host or join then it would handle NAT traversal for you and return a list of hosted listen servers that a player could connect to.
Alright, cause I was trying to do some research but could not for the life of me figure out how the game is supposed to know all the ips and address's of the other instances of the game. So using steam it can do that searching for you.
is there a way to make RPC interface function call?
for example I want to call a run on server event on my controller from some locally spawned actor.
can I do that without casting
You can just pass the interface through to your controller and your controller can do the RPC from the interface call.
Is there a good way to spawn a particle system as a collision effect between two actors? I want to show some sparks when two items collide.
I've set up OnComponentHit for the actors and it triggers as expected. The problem is that OnComponentHit only seems to run on the server, so the effect does not show up on the clients.
I could do a multicast RPC from the server, but it seems wasteful in the case of a lot of collisions. This is not important information, it's just visual. The clients should be able to figure out that there's a collision on their own and spawn it locally.
Does anyone know of a solid way for me to implement the second screenshot into my first screenshot? Was testing out some multiplayer attack stuff and I really like how I have my blueprint running now. However the only thing I don't like is this sphereoverlapactors. It just places the sphere overtop of your actor and there isn't really a solid way to place that sphere in front of the player, at least from what I can see.
I'm trying to replace it with the multiSphereTraceByChannel, this lets me create a cylinder in front of my character and detect hits if it collides. Though it only gives me Out Hits, and I need this to be Out Actors.
Maybe I'm approaching this the wrong way, but I'm trying to get best of both worlds here.
Third screenshot is the entire blueprint for attack.
You can break the out hits and get the hit actors from them.
How do you break it out? I'm not getting that option when right clicking it
You can do it like this, or just use the current loop and use the actor reference from the hit result directly.
Hmm, not getting the hit actor option when dragging out from the second for each loop or addunique, what exactly is all this doing? Maybe I can figure it out
Create an array variable
'
What is happening is your trace is returning an array of hit results - hit results are a collection of data relating to the hit that was made with the trace you've done. When you "Break" the hit result, you're able to access the data that it has.
Since it's an array of hit results, you need to loop through the array to get the individual hit results so that you can get the hit actors from each hit result and add them to an array, or as I said, you could even use that first loop to just do what you want to do with the actors directly from the hit result rather than creating another array to store the actors in as then you'd have to loop through that array to do things with those actors.
Both of these essentially do the same thing. The first one saves looping through the array of actors (which could potentially be a bit of performance savings if there's enough actors in the array)
Can't seem to get it working, doesn't detect the hit of the actor at all.
Move the "Return Value" branch you have further head to before the first loop.
Also, your radius of your sphere trace is 0. It might be that it isn't hitting anything.
Check your collision settings too - it doesn't work quite as easily as you're looking for things that respond to the trace channel defined rather than just responding to specific object types.
Yeah, so it's colliding now, but not with the actors, so I will have to figure that out. I forget how to enable that, done it before though.
Additionally yeah, it would be better for it to respond to specific object types. Is there a more streamlined way of doing what I'm trying to achieve here?
Trace for objects
hey ther can someone explain please what is UObject::GetLifetimeReplicatedProps() and why we need DROPLIFETIME()
HรLP! I try to Blend the Camera to a closet for hiding. In Multiplayer it works on if the Host does it, but if the Client (Listen Server) enters the Closet all cameras from everybody go in the closet and are ejected for from there characters.
I tired to replicate the event with run on owning client.. but the client still creates all cameras of all players to do it
I'm not sure but it may be because of the GetPlayerController 0
If you put actor on the map (Not spawn at run time) , and set it to replicate & AlwaysRelevant = true ,who will own this actor in this case ?
Anything you place using the editor is owned by the server.
Okey ,Thanks
mh i make a simple horror game where player just hide in closets... cant be so complicated
any idea how to make it right? ๐
i'm not quit sure but can't you set the player who's using the closet into a variable, and then, set view only for him ?
maybe you can try to "A BP Player" -> "GetController" -> cast to "PlayerController" and then plug it
i saw a lot of people saying that "get player controller 0" is not recommended at all in multiplayer games, but maybe it is not the case here ๐
ok let me try
@karmic geode mh the blend node only allow a player controlle rnode to plug in, get controller is not accepted
Yes, try to cast the Get Controller into a Player Controller and it should work
this reversed it, so now the server changes the viewport of the client, but not the client from server @karmic geode
Are you calling a function from the server to multicast ? i dont understand quite what's the problem, the client dont see himself into the closet ? @rocky night
Well its simple , player goes to bp closet, presses F and i set the body invisible and change the camera from the player with that node on the end.
the problem is, that the camera changes not just for the Player who is hiding
with this setting now, the client camera is not changing but from the server player it does
OH
When the non server client press F, are you calling the server function ? then multicast it to everyone ?
oh nice ! ๐
I've got this that runs on Begin Player on my FirstPersonCharacter
I've got a replicated structure (playerinfo) which contains player name and profile picture (both gotten from steam and saved on startup)
I'm trying to make nametags work
PlayerInfo is set to RepNotify, which runs this function on Notify:
The Server can see nametags:
However all clients cannot:
I thought that if the variable is replicated it should be sent to clients? And therefore the OnRep function should run, updating their nametags
I think I cracked it
Not sure if there's a better way to do it, but it's working for me ๐
hey , can someone please say , why we need component replication on actors ? i got an actor where is just cube SM inside of it , i have changed its size , added impulse ,changed its color to some random value . and everything works just fine . my actor set to replicate but Static mesh component not , and its working absolutely fine . So i am wondering in which situations we need to replicate components ?
when a component need to do basic position replication, has replicated variables or sends any RPCs that are not multicasts
also, if you want attachments to replicate
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/Components/
https://www.reddit.com/r/unrealengine/comments/6hnclt/component_replication_when_should_i_use_it/
@oak oracle
Is this the same as IsLocallyControlled?
Rly not
IsLocallyControlled checks Remote Role, Net Mode and Local Role
best to avoid GetPlayerController[Index] completely
even in supposedly safe scenarios, indexes can still get shuffled around during seamless travel
resulting in 0 being a client controller on listen server, for example
not to mention a multitude of different misuses people do with it
if you have any c++ make a static function cpp UFUNCTION(BlueprintPure, Meta = (WorldContext = "WorldContextObject", CompactNodeTitle = "LocalPlayerController"), Category = "Local Player") static APlayerController* GetLocalPlayerController(const UObject* WorldContextObject) { UGameInstance* GI = UGameplayStatics::GetGameInstance(WorldContextObject); return GI ? GI->GetFirstLocalPlayerController() : nullptr; } @twin juniper
and use that, saves a lot of headache
Hey! Is there a known issue with the online steam subsystem in 4.27? moved
oof didn't see it, thanks!
hi, got a question
I wanna make a soulslike game and I wanna handle melee with two state machines in an animation blueprint, one that's always active that handles movement when not attacking, and another that gets switched depending on which weapon the player has equipped, done using animation blueprint linking
Would it be possible to sync the state of both of these state machines in multiplayer? if not, what other possible options are there to achieve the same result?
How would I go about using my own signaling server to broadcast listen server hosts
Would I just make a UDP request to the signaling server?
And there's also the issue of dealing with clients behind the same NAT
This question gets asked a lot ๐
Two issues, the first is concept of 'master server' if you want to google it. Servers register their address with master server so other clients can find it. It can also provide the "introduction" of the client with the server to establish NAT connection.
As you seem to know robust NAT negotiation is quite a challenge and there's a couple of open source libraries out there you could try and use, or use a platform like Steam which handles the master server and NAT stuff for you.
Yah I wanted to avoid steam and try to use my own
The master server in this case is public and any client would be able to access it
yes
But yah NAt negotiation is the problem especially when dealing with same NATS or ipv6 vs ipv4
Can you point me to some open source libraries?
there's a bunch easily googleable, but I can't remember ever working on this stuff directly so I can't really recommend any
"nat c++ library" is a good start ๐
Cool so on my first question how does the server register their address with the master server? IS there a protocol to follow or could it just be a simple UDP request?
yeah could be UDP, TCP, WebService, whatever
Correct,
I was thinking
If there was a propper way to do it
Or did it not matter
How I've done it previously is the client just sends a 1 byte udp packet to the server and the server then grabs the public IP And Port then sends it back to any other clients.
But this was outside of Unreal Engine
Ah okay
Is there a reason a RepNotify is only running on clients and not the server?
Don't forget you want the servers to register, but also clients able to perform searches based on some criteria (num players, gamemode, ping, etc) so your master server needs to accept more complex messages. Might as well use the same kind of protocal for server and client registrations.
If it was me I'd probably do a webservice
Yah like a generic packet structure
or JSON payload ๐
Where's the fun in that?! ๐
I guess it's just better to see how it's done properly.
Than constantly running into pitfalls
Ship? What is.. 'ship' ?
Release
Distribute
sorry I was being disingenuous
it is of course entirely the right thing to do
unless your goal is to learn how to make a master server
A bit of both.
Aren't impulses in CMC totally driven by server? I'm getting a stuttering on client when applied any impulse or force on server
It's a simulated proxy (AI character)
Say you have a struct that also contains another struct that holds 6 int32s
If I was to set only one of those ints on the client and then send that struct to the server via an RPC, is the client paying the full bandwidth cost of all 6 ints?
Or will UE only send modified from default values, therefore only sending 4 bytes instead of 24 bytes?
hey, I have a few functions on my player character that are defined in an interface
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/ReplicatingFunctions/
this tutorial explains how to define whether a function should run on the server or on the owning client
however, when I click the functions on my player character, they have absolutely no settings in the details tab, and the required settings are missing when looking at the functions in the interface blueprint
how can I set these parameters?
right now they're running on the client, but if I use switch has authority to check whether or not I have authority, the answer is always no, resulting in no control over the character, and if I don't, I can move my character around but he keeps getting teleported back where he spawned
multiplayer works fine on a fresh 3rd person template project, the only difference with mine as far as I can tell is the fact that I control my player character blueprint through a player controller, using that interface
But why?
cause that made more sense to me
also means I can have an AIController control the player blueprint instead
anyway, solved it using IsLocallyControlled instead of Has Autority
You don't need to control a pawn to EnableInput on it. You definitely don't need to use interface functions for control inputs. Just bind that actor's InputComponent to the local player controller's input stack.
Then you can just put normal input bindings in it or anything else you want to control and just enable input on it.
the interface also allows me to do stuff like control any pawn that implements it, which would be useful to test like, enemies that don't have AI yet
You don't have to have a controller to accept input though. You can have fifty thousand actors enable their input components into the local controller and just not consume the input and one press of W, makes them all run that binding.
Sorry, I'm just super allergic to interfaces. ๐ I spend too much time in the Blueprint channel.
If it works, it works.
yeah but if blueprints rely directly on inputactions then how could they be controlled by AI
also turns out I didn't solve my problem, IsLocallyControlled is true and yet when I move I still get teleported back
They're not mutually exclusive? It's no different than the interfaces. Input binding calls a local action on the AI, or player controller calls interface event on the AI. Same difference.
If it works, go for it. For me it just looks like double coding. You not only have to put the events in the AI, but then you also have to go back to the controller and route the controller's controls to send to the AI, where as binding the local controller's input stack is a one time call, and then you just put input actions directly in the class.
I really don't get it
like, can the AI somehow directly triggers inputactions?
Wait, are you talking about AI controller calling interface calls on the AI?
I was under the impression from your last message above that you were sending interface calls from your player controller.
the point of the interface is that any player or AI controller would be able to control any pawn that implements it, without extra code per pawn on the player/AI side
the controller, the interface, and the actual player pawn
anyway that's what it looks like when I try to move right now
works on standalone tho
AI input should come from a base class. AI controller or BTs can access pawn actions through that base class that it needs. PlayerController can just bind the InputComponent. Then there's no need for controls in the PlayerController. Also your AI controller and Player inputs will be fighting each other anyhow. Usually better just to trade possession and put the AI controller back when player leaves the pawn. Instant networking capability that way too.
I don't want both player and AI to control the same pawn at the same time, the idea was just to not have to implement both player and AI control stuff directly in each pawn
Well, most of that can be handled by using a base class. Single place to put them all and then reuse.
not sure what you mean by "bind the inputcomponent" too
Calling EnableInput on the pawn. Though if you're not going to let AI and Controller control at the same time, I'd strongly advise possession switch instead. As that will allow the player to own the pawn, and directly RPC controls through the CMC.
okay
now the inputs are in the player character blueprint, still got that rollback issue tho
oddly enough, character rotation syncs just fine and doesn't get rolled back but movement does
@azure cape you're talking about both the AIController and PlayerController talking to the pawn with the exact same events/interface, right?