#multiplayer
1 messages ยท Page 164 of 1
Changing them is like changing a TextureAsset (the actual asset itself)
It doesn't magically replicate
They are Objects, so you can alter them, but you are still altering them as an asset
And this doesn't replicate
oh yeah, indeed! you can change it at runtime, i wasn't talking about the multiplayer
Yeah but you are using it in a Multiplayer set up
The change your client does to that file won't replicate
Not even if you RPC them to the Server etc
there is probably useful cases where you want that behaviour
hmmm yeah that's true, so i guess i should pull it from everyone's GI and then notify it to the others, but the replicated pawns should not pull from the GI right?
And that was to ensure that all Chests were using the same chance calculation and that getting an item from it changes the chance for the others
And even that should potentially not be done via the DataAsset
DataAsset is supposed to be ReadOnly
You need to have some sort of Structure that holds all changes in a format that can replicate
And then in e.g. OnControlledChangedEvent -> IsLocallyControlled in your Character, you get the GI, RPC the Struct to the Server and the Server sets it on a RepNotify variable
And then you apply the changes in the OnRep
in what cases DTs are good ?
because for me its just a more anoying version of DAs
specially because it goes through all rows to get the one you want
dude thank you really much! โค๏ธ
DataTables are more like a Spreadsheet
Eh, there are some, but I can't name any atm
Some stuff in the Engine needs them
I often use DataAssets, or with the power of C++, turn my normal BPs into "DataAssets" and similar
I used one for the character selection and another one for some options such as force feedback and gore, it can be quicker for some stuff to access them and the cool thing is that changing them at run time you don't need to update anything else
the only downside is that you have to save their state once you close the game and set it back when you start it again otherwise they get reset to their initial state
It's mostly if you really want Spreadsheet like Data for something
Aka mostly 1 depth deep stuff like some meta data about an item or so
But in almost all cases you could also use DataAssets fwiw
๐ค are we talking about the primdata right?
i'm sorry if i get messy, i have no background in programming ๐
DataTable - Asset you create from a Struct where you add Rows to
DataAsset - Asset you create from, e.g., a PrimaryDataAsset Class
One DataAsset Asset is usually the same as one Row of a DataTable
While the Struct defines what data is in each Row for the DataTable, the selected DataAssetClass defines what the DataAsset has in terms of properties.
They are pretty similar, and again I would say that one can do most of the DataTable stuff with DataAssets.
But there are still use-cases for DataTables fwiw
I think there are also things where you can combine multiple Tables into one or so
I'm more a friend of DataAssets and the AssetManager, but iirc that needs a bit of C++
I like to just ask the AssetManager for all DataAssets of Type XYZ.
Also allows for SoftReferences and what not.
whos gameinstance? The server or clients?
thanks for the explaination dude!
i should pull it from clients gameinstance
Then it needs to be sent over through a run on server event
I already wrote that
yeah @thin stratus gave me some insights ๐ thank you dude!
DataTables are cool, but their editor is subliminal
Not being able to edit multiple column/rows at the same time, in any way is horrible
not being able to just edit a single cell without opening the row,
is terrible
yes
@twin juniper Maybe I misunderstood, but why not use an AnimNotify/AnimNotifyState to sync your hitbox timing with the montage?
Do you have that message bound to a hotkey or something
The one you just posted because you posted something incredibly similar last night
@lost inlet Why is it bad to use AnimNotifies for gameplay in multiplayer? I would like to know as I rely on them quite a bit.
I worked on an FPS. We saved the animation timings offline so we didn't have to run the animation blueprint on the server
But there can be timing differences, especially if you run animations at a reduced rate on the server
Because you probably don't need high fidelity animation on the server
Just to clarify, are you referring to latency or skipping notify ticks due to server tickrate?
On the dedicated server the character animation update rate was about 5Hz, and the first person animations didn't run at all
Hm, I see. Thanks.
And reload timings were based on first person animations
So since they didn't run, they just used presaved timings. The animation sequences didn't even need to be loaded
I'm using AnimNotifies for a continuous hitbox (swords basically), but the server only really needs to know a socket location from the skeletal mesh during montages. Haven't had any issues yet.
The timing is consistent, but of course latency will have it's own effect on top.
@twin juniper What server model are you using? Not sure why pausing would be an issue for an online game, unless it's a listen server and window focus somehow affects the timers/animations.
I don't really know though, just asking. Feel free to ignore ๐
Unreal has a way to "run" montages as pure notify data - no animation calculations. If you don't need any animation calculations on the server whatsoever you can just use that.
EVisibilityBasedAnimTickOption::OnlyTickMontagesWhenNotRendered will fire off notifies as normal but not tick animation otherwise on the server (since the server never renders).
It can still be a bit more expensive than caching notify timings outside a montage (just because you have a bit more overhead for using the animation system at all, and it still ticks rather than doing something like scheduling with a timer), but it shouldn't be much.
though I forget if that's the only thing you have to do. There may be some other options necessary to prevent any other calculation of animation data.
Looks like for a melee system you'd need the transform data of whatever point you're reading at the notify in the animation
I mean if you need it you need it
Well the melee system that was described
if you need accurate hit detection and are blending anims all over the place then there's no way around it really
Yeah but having it super accurate seems like a whole can of worms in a multiplayer context
I would expect something that is doing super accurate stuff to be somewhat using CSHD
What's that?
ah clientside hit detection
yeah that'd probably be the source of the hit, but you still want consistency and to be able to sanity check things
Hi,
If a game team is shipping multiplayer-only, dedicated-server-only, then they have the opportunity to keep the server code completely out of the hands of the players, by making separate builds for dedi and client, and by using preprocessor directives.
I.e. do not support listen server at all, not even for dev.
Is this common? Your dev team would need to use dedicated servers for all testing, rather than listen servers.
But it the most secure approach.
If you are building a dedicated server game, why would you test it with listen servers???
That just makes no sense
So of course you would need to test with dedicated servers...
Yes
Know of any teams who have done this?
Yes
Most AAA teams I know support a listen server for dev. But that may not be the best choice in these circumstances.
You can even bundle dedi+client somehow to make it easy for team to use
Basically if you are not supporting single-player, nor player-hosting, you should consider this option.
if i wanted to send location under cursor do i do that on client and send vector as rpc to server?
Yes. The cursor is something that only exists locally so it would be required for a client to get its cursor position and send it through an RPC to the server if you want the server to know about it.
and is that normally done? i keep reading tick is bad for rpc
How computationally heavy is "get all actors of class"?
I'm trying to build a "line of sight" check, using a line trace for object. I need an array of actors to ignore; otherwise my sight check will fail if another pawn steps in front of the trace line.
For my use case, I want the trace to only be blocked by a specific object type.
Question: Is there another method of trace that I can use, otherwise is it okay to use get all actors of class every time a player attacks on the server; say 30-40 players @ 30 attacks per min?
Sure it is. Is it necessary to send the RPC continually on tick? Can you maybe get away with a lower rate?
the mouse controls a paddle (ping pong), so i think continiously is best, i optimised it where it doesn't do rpc when mouse and actor loc is same
So that would be a good use case for using full-on tick considering it would be a player input which is usually something you would send on tick - even the character movement component does this.
Perhaps you could save some network bandwidth by checking if they actually moved it (position is same as last sent position) and not send the RPC if they didn't move it.
thanks, didn't think about storing and comparing previous
Hi guys, do some one know how to simulate different weak net envir in editor on two clients? Unreal seems only can simulate same weak envir on all clients. ๐ฆ I want to apply different net settings per client in editor.
Question. For developers creating only dedicated servers and clients (i.e. no listen server, no single player), how do you separate your client and server code?
Do you just litter each module with the appropriate preprocessor defines?
Or do you create separate class instances for server and client (and conditionally compile)?
former
was it a conscious choice?
yes, it is the "unreal way"
you should specify that you want different net settings per client
Guess I can try both ways and see which is less painful
Yes thank you.
Actually I guess there are 3 cases: server only, client only, shared.
Ok it seems the console command has support that. ๐
what is an equivalent for GetFirstLocalPlayerController in BP?
Don't think there is one exposed. "Get Player Controller" with index 0 is closest, but that doesn't really take local into account when dealing with the server/host.
I will expose it then.. thanks
When dealing with UMG or input, is it /in certain cases/ safe to use on client getplayercontroller(0)? I had to use it few times, everything seems to be working okay, but...
Not really, the only exception would be if you are working exclusively with dedicated servers
UMG Widgets have an owning player so it should be easy to access through that.
for inputs where i want some hold before doing X
should i calculate the cooldown in client, and only call the final result event on server ?
since calling on server each tick might be to much for nothing
If it's just about a different input method and doesn't matter for gameplay, just do it client side
well it will matter in gameplay
for example
user has to hold a key for 2 seconds then I call "Use item" on server
i dont see an issue if i run the check and add "elapsed time" on server side
Timers over network are not pinpoint accurate so you might occasionally fail in the "real" world.
thats the thing, if user has a bit of ping, 2 seconds might become 4s
for the client
If it's just for input, it doesn't really matter. If there are gameplay reasons (i.e. it's a firing delay or something), then really it doesn't belong in the input domain
okay
i'll stay with server then
i'll maybe to a timer by event instead of adding delta seconds each frame
Well you certaintly don't want to be sending an RPC with elapsed time every frame
If you must do timing on server, send a "start" and "end" RPC and allow some tolerance to account for network error
You can just use timestamps
how would i add some "tolerance" ?
You check the length of time on when the client "End"s pressing, and checks it's near to the time you expect them to hold the button for plus some small tolerance for error
The point is that in the real world, those RPC's will not arrive with a perfect 2 second delay
i see, ty
psuedo-code
void Started()
{
LastStartTime = GetWorld()->TimeSeconds();
}
void Stopped()
{
float TimePressed = GetWorld->TimeSeconds() - LastStartTime;
if (TimePressed.IsNearlyEqual(2.f, 0.5f)
{
DoThing();
}
}```
also, i found that that you can use replication conditions
for the elapsed time float var, i should do this in owner only right ?
because other clients doesnt care about "how far he his"
Client should just track it locally
Replication will be way too latent to be of any use
Plus it's wasteful
You should test this with packet emulation to see how quickly it falls apart under real world conditions.
the server is running the timer
Just run one client side too
Doesn't have to do anything
Your 'ElapsedTime' property will not update regularly enough to be of any use
hello goodmorning guys ..please i am trying to make a static mesh movement replicate form client to server
It will in editor, but not IRL
Replication is always Server->Client
If you want the client to move it, you have to tell the server to move it via RPC
What does the log say. You need to be the Network Owner of the actor to call a Server RPC
Clients are not allowed (for obvious reasons) to just move any actor they please
earlier you said that if its gameplay-related it should be on server
The Server should just validate things for gameplay, that doesn't mean for UI for instance you need to replicate that back to the client
yes but the rpc is set to run on server so the client sends it
Who owns the actor you want to move? If it's just placed in the level, they won't be able to call the RPC and the log will tell you that
this the code
Well that's definitely not going to work
You're getting the Mouse Location from a Multicast, that's going to give you the mouse location on the local machine
so
- (client) runs the timer
- (client) if the elapsed time meets the conditions call event on server
- (server) gameplay stuff
?
The Client calling the RPC needs to send the location to the Server with the RPC. The Server should then set the ball to that location, and the ball should have "Replicated Movement" enabled so that other client see it. You don't need or want a multicast here
IMO yes. Server simply validates the client calls to start and end the timer are within a tolerance, but only IF the timer is critical to gameplay functioning properly
ill do that, thanks for discussing this with me
rightttt
sorry not rili used to bp thanks for the clarity...
I have a question for anyone familiar with the C++ side of UE multiplayer.
Here's my timeline:
- Start a game in PiE, 1 client
- Map includes one 'NetStartup' actor with a replicated property (in this case a material color)
- I change that color during play, see it change onscreen
- I connect a second client (via the experimental 'Allow Late Joining' option)
- Second client gets the RepNotify for the NetStartup actor's changed material
- Second client gets BeginPlay called on the NetStartup actor, as a side-effect of the GameState RepNotify
- Play starts on second client with all actors in correct states
This is all good, but here's my question - where in the code does it guarantee - if it guarantees it at all - that the net startup actor will get fully replicated to a joining client before the game state? Is there any guarantee that the in-world actor states are all replicated to a new client before they get BeginGame called on them?
well, since the actor is not owned by the client i cant really call the validation on server
If you're asking about "for inputs where i want some hold before doing X", just count it on the client then send the RPC. On the server, do extra validation
thats what i am trying to do
the thing is that the client cant call the event on server because he is not the owned actor
You can always do validation on the server. You can use a different actor if you need
Does destroy session only works for host(listen server)? and if i wanna leave a session as a client i should just open a new map?? instead of using destroy session??
this will be dropped
You need to route it
Well, I don't know anything about what that is, what it's called on, or why you rely on it.
wdym
Through a client owned actor
Isnt there a leave option?
basically have the rpc on a player owned actor like a player controller or character and call it there
But yeah clients cant destroy sessions
leave option???
let me give some context
- (player character, client) input event
- (acbp on player, client) call interface on item (actor)
- (item actor, client) call event on acbp
- (acbp on item, client) run timer
- (acbp on item, client) when conditions meet callback to server <- where i am stuck
who owns the item is it the player who pressed input?
or no one?
the item is spawned by client, and is replicated
so the client is the owner
It still exists on the server. You can still call RPCs on it
so the rpc should work if the client is the owner right?
only thing that isnt owned by client is the actor component attached to the item actor
but its weird since the owner of the item actor is the client
Just sounds like you need a [Server] RPC
so how to make a client leave?? i saw few forums and videos they all said destroy sessions
apparently you should call destory on clients aswell, according to forum post from 2016
im calling but its not working
do you have a valid session?
yes
its working when i call it from host
1- (item actor) on client
2- (item acbp) on client
3- (item acbp) on client, not calling on server
are you testing this in-editor ?
wouldnt you do local prediction, and only replicate a bool from the server for when its avaliable again ?
that what i am doing
this doesnt look like that
yes
do you get any warnings when the rpc is called?
and with play as standalone checked
I wouldnt trust the result in-editor , as they can differ from actual clients by a fair amount
that means the item is not owned by the client who called the rpc
so the tiem actor isnt owned by client
are you using a session plugin?
i saw a video, it says to open a level, but i read in the docs u cant join a session unless u destroy the preivous one so if i open a level will it destroy the session??
advanced sessions plugin yes
well are you blocking client logic from executing ?
wdym
the start use
is it explicitly called on server, or on client aswell?
i suspsect client calls it
i just resume to breakpoint to breakpoint
so, it runs oin clinet
the IBP event ?
the interface event yes
The "no owning connection" thing looks like a massive red flag to me. That implies something is wrong with how that object is being created, or that it's not designed to be replicated at all
yeah seems like the server spawns a usable item for a client, who has no ownership iover the item
which would be strange, imo
the actor is spawned from server
it isnt automatic ?
and server dont know which client to rpc to (as it has no client owner)
ownership is explicit, always
Now you have to change the owner eveytime a different player tries to do that xD
We dont really know if this is an item spawned from an inventory, ment to only be used by a single player
right
it will always be the correct client owner
so single owner is fine
if the item is going to be used by different players
oh all good then
and so destroeyd when unselected
Its only used by one player, as it is their hotbar item ^^
ty for wondering
verified that the node is excecuted on the client ?
i found a node called end session in advanced sessions plugin
its working
There's also a function in GI (not BP exposed) that safely returns you to main menu
Ah cool ,alright
thanks
@thin stratus
Hi ! ๐
Found that old post and was wondering if - with all the experience you gathered - you would come up with a cleaner solution ^^
https://forums.unrealengine.com/t/rpc-client-server-not-working-owner-problem/32590/12
There's not much choise beyond routing it through a client owned actor
That or edit the engine
"If your team consistently implements the extra steps for creating multiplayer, the process of building gameplay will not consume much more time compared to a single-player game". Ive recently finished my first (multi) unreal game. And this line from unreal manual makes me feel like an idiot. Because ive struggled hard to get things working compared to single player. Do you with year(s) of exp agree with unreal devs?
If you at both starting points would have the knowledge to use the framework as intended, i would kinda agree (altho I dont have years of MP experience myself)
I feel like MP forces you to work with the framework, while singleplayer gives you tons of leeway to almost do as you like
(Which doesnt speak to the quality or 'correctness' of the code, but if it works per your frame budgets and target performance, it can be considered acceptable)
If your game fits entirely within the framework that exists out of the box and doesn't require any extra logic than marking things "Replicated" and maybe occasionally checking for authority then sure, but objectively speaking no it's not true
Biggest caveat being related to prediction / lag and compensation of it
i've added multi when game was like 50% finished, thinking that checking 'replicate' will make multiplayer. And result was like someone hit my face with a brick
Brick hitting your face is indeed the intended behavior ๐
Yeah, its not just flipping a switch, thats for sure
Its often rewriting tons of code to even get the events in the correct sequence etc
Yes thats what I did... Can you recommend any unreal sample to learn multi? Although Ive finished the game I feel 50% of stuff I coded badly. I did everhing in blueprints, is it big no-no when doing multi?
It certainly constrain you heavily compared to the fine-grained control you get in c++ when it comes to replicating properties and whatnot
Dont really have much learning material beyond stuff pinned in this channel already
Not enough apparently ๐
fix on fix on fix on fix
AI?
jones in the fast lane
good times playing on single pc with friends
can GetActorEyesViewPoint be used on a client?
Of course
I need private multiplayer tutoring. I'm not fully grasping things and I need just one hour of someone's time to help answer any questions I have. Any takers?
paid?
I mean, do you know your stuff? @dark parcel
If it's paid, I expect you to have some proof you know your stuff haha
@indigo brook not much but I can route you to #freelance-jobs
I know my stuff, but yours is unknown
That's good man, I'm making single player games right now, I want to transition to multiplayer, you can check my profile
I know you cant replicate a tmap in a traditional sense but is it fine to serialize and send a version of a map over rpc inside of a struct payload
you can do it yeah
I'm having an issue, when 2 player connecting to the same dedicated server using open level + ipAddress of AWS ec2 instance, the one of the player controller sometimes stucked
The issue is when 2 player connect in the same moment
It happens in aws, also happen in my dedicatec server in my local laptop using PIE 2 player
Check out your Game mode. PostLogin is called after a player joins. Maybe you overriden something there already and broke it for anyone other than the first player
If you can't figure it out, try it out with an empty level or different game mode.
Game Mode is responsible for handling the player connecting to the server. E.g. how to spawn their pawn/character and such
Hello, I started to learn multiplayer programming in UE using these articles:
https://docs.unrealengine.com/5.3/en-US/multiplayer-programming-quick-start-for-unreal-engine/
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/HowTo/RespawnPlayer/
and I'm trying to make RespawnPlayer replicated, so I added:
UPROPERTY(ReplicatedUsing = OnRep_bIsDead)
bool bIsDead;
UFUNCTION()
void OnRep_bIsDead();
void OnDeath();
void AMultiplayer3PTestCharacter::OnRep_bIsDead()
{
OnDeath();
}
void AMultiplayer3PTestCharacter::OnDeath()
{
CallRestartPlayer();
}
void AMultiplayer3PTestCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMultiplayer3PTestCharacter, CurrentHealth);
}
to the Character class
Also modified the SetCurrentHealth to call OnDeath
if (GetLocalRole() == ROLE_Authority)
{
CurrentHealth = FMath::Clamp(HealthValue, 0.0f, MaxHealth);
OnHealthUpdate();
if (CurrentHealth <= 0)
{
bIsDead = true;
OnDeath();
}
}
but I never added bIsDead to the GetLifetimeReplicatedProps
And it still works as I expect:
- server calls
OnDeath()then it callsCallRestartPlayer()which callsDestroy()and then it calls gamemode'sRestartPlayerfor specified controller
My question is how the clients know that the character is dead if GetLifetimeReplicatedProps doesn't have bIsDead variable?
Hi, I migrated lyra's locomotion for our project and I only use it with the AI character's. Currently it works but only on server, on the client everything is wrong. I did assume that we don't need to replicate stuff for the AI as all the calculation's are done on the animation blueprint, which happens on both server and client. Any idea if I also need to replicate something like they did on Lyra's movement component, even though we use it only for AI? Thanks for any help
greetins i have a problem with my project, i used the online subsystem for to connect my Oculus quest 2 device to my PC, my device as client and the PC as a serve, before works! but now idk why it doesnยดt work. may some body can help me
@jolly nymph Are you testing with localhost? Does FindSessions trigger OnSuccess or OnFailure?
put a breakpoint on your OnDeath function and see where its called from.
To have a helper on your VS watch, use this:
https://x.com/joatski/status/1645471151097802752?s=20
Also! The client shouldnt call "RestartPlayer", only the server, as its a server authorative action.
Noob Question again. I'm getting stuck trying to get a property from player state and replicating it properly. Made a video showing the issue if someone could help point me down the right path that would be much appreciated!!
that whole loop thing is goofy
Text Renders don't replicate, so yea, you don't need to mark it as replicated.
Part of the problem is that you're using the player controller to replicate the name you want to use. PlayerControllers only exist on the server or the owning client, so the server would have both the local player controller and the client's player controller, but the client would only have the client's player controler - this means they wouldn't receive the new name value for the other player.
yea thats why i paused I tried so many things my brain is pretty tired lol.
It should be as simple as:
WhateverTheServersideOnPossessIs -> shove the right playerstate's name variable into the pawns text render
I think OnPossess is serverside
er wait a sec
yeah you want a clientside onpossess, sec
or on possession changed
so perhaps better to run this logic on the gamemode?
no
the pawn has enough info
If Pawn is possessed by a player, returns its Player State.
That's your getter
now you just need a WHEN
Test, use a timer or delay loop on beginplay, just in the pawn:
GetPlayerState -> cast to YourPlayerStateClass -> pipe the name into the text render
make sure that works
then solve the WHEN problem
okeey okeey i'll give that a go.
The way to approach these problems is to sort of start from the fundamentals.
At any given time, does a pawn on any machine have enough info to know what name to put in its TextRender?
Since pawn can get the corrosponding PlayerState, and those are replicated, and name is replicated within it, then pawn should already have enough info on any machine. No need for any additional networking. You just need to find the right trigger event.
I think that was sort of where i started but then probably started chasing a red herring when it didnt immediately work
okee I have it working now. Thanks a bunch!
Yeah I'm also curious something is broken within the game mode. I'll have a look around. Thanks.
Question: How do you isolate your game instance and get information out of it to apply to a specific client?
In multiplayer this is crazy
You can only access the game instance of the particular instance that is currently executing whatever event.
@sinful tree Maaannnn I tell you, I tried this that and the other thing and for some reason when I try to load that info into my client, it just dosn't happen. I'll get screenshots. I've been stuck on this for a freaking week and pulling my hair out haha
L_Lobby_Multi
-Game mode casts to player controller to spawn third person character
-Player controller spawns third person character
-Server has his clothes
-Client does not
L_Persistent
-When I change clothes in the persistent level, it looks fine in game and replicates...but it does not save
-When I go back to main menu, it's the default save clothing choices
I fixed the save issue for the server, I missed the connection here
Easy mistake, yet, my client still arives naked haha
Net next step is to get the freaking clients charcter info loaded up, having trouble
Any tips based on what you seen in the bp's
Hello, I was trying to search for someone that could achieve a p2p connection, what are you using exactly to manage p2p? are you truly using a solution without a server? are you keeping the way that networking works in unreal?
Well I'm trying to create a p2p solution, I thought there was no way in doing that while keeping the unreal's networking system.
A partner of mine create a web socket solution with a kind of json format to replicate basic stuff such as locations.
But is there a native implementation to create a connection without a server? I'm still not sure if EOS p2p is just to handle services like invitations and matchmaking.
@placid flame There is no such thing as Peer 2 Peer in unreal in the context of what you want.
Unreal has a Server Authoritative architecture.
There is always a Server
Whether thats a headless (dedicated) or a Player operating as a Host (Listen)
oh okay, then why is a lot of people talking about p2p? I saw that someone explained that it is a misunderstand
Because people throw terms around without understanding their meaning or provide context to what they are actually talking about
yeah thank you, that was what I was trying to clarify
EOS does use P2P messaging, but it has nothing to do with the overall server architecture of Unreal
okay, well we could achieve a p2p solution, but is pretty much recreating the server's code with web sockets, I'd love to see if someone else has any improvements, but I only find people confusing terms
Honestly in my opinion, unless you have specialist engineers and a lot of money, its not worth even trying to introduce P2P as you understand it, into Unreal.
Its gameplay framework is just not designed for it.
oh is a metaverse, we just need to replicate locations and basic events with no more than one parameter
Seriously though, your best bet for something that simple will be to just get some sort of communications endpoint in the game and run as standalone on all machines
the game process doesn't know it's "networked", just theres data coming in from somewhere which affects game state. None of the Unreal networking is in play.
yeah we are doing that, is a standalone solution, and web sockets to send data
exactly!
Yup that shouldn't be too hard, depending on what you're actually doing.
I love it cuz it avoids server and client crashes
You doing something liek Dark Souls soapstones or what?
not sure what is that
but well I'm the master in unreal, not in web sockets and backend, I wanted to get some help in order to do it by myself
they are little messages you can leave on the ground and other people can see them
and vote on them
I hope so
"Fort
night"
"Is this a dog?"
"Try finger
but hole"
etc
If I want to handle assigning teams, for example, allowing players to select their team in a lobby, where is the best place to actually represent what team the players are on? Right now I'm basically using boolean values that I track within the game instance so that it's maintained when the players move from the lobby to the game level, and then in the game level gamemode blueprint I use the boolean to determine what team the players should be on
but something about that seems extremely flimsy and not the way I should be doing it, even if it technically works
Team is a part of the state of a player
I'd put it on PlayerState
I can put it on playerstate, I just hold it in the game instance for moving levels
but is there a best way to actually represent the teams themselves other than booleans?
I have no idea what best practice is
Enum, int, tag
Enum sounds pretty good
hey all, with these nodes , do either of them account for players that are still server traveling? or are they just counting the loaded the players?
trying to check for all players to be loaded before starting play.
Only Local Player Controllers can be assigned to widgets. BP_PC_C_1 is not a Local Player Controller.
Im getting this error everytime im doing this
can anyone help me whats wrong
but when i do this the error gets resolved, i just randomly did this but i wanna understand how it got solved
update it was not resolved, but i resolved it now and understood why its giving the error
@obsidian halo the begin play will run on every single actor and every single machine
So if u have 5 of your player character instance in your world, you do be running it 5 times on each machine
yes and it will get called on both server and client
So u r adding the widget as many times as there are number of instance in the world
yea
It will run on every single machine
So what u have to do here is
Only create widget on the actor that is controlled by the local player
Exactly
That will do the trick
yea thanks for the explanation!
By doing that, if the character is not owned by the local player, it will just go to the false node, so the widget only created once this way
yes
Ok I have a problem and have no idea what's wrong. When my bool is changing OnRep function is not being called. I know that it is called when it is changed on the server but I checked it and var is changed in server and client so it should be called but it's not.
.h:
UPROPERTY(ReplicatedUsing = OnRep_IsFullySubmerged, BlueprintReadOnly, Category = "Base Player|Movement|Swim")
bool bIsFullySubmerged = false;```
.cpp:
```cpp
if (fWaterLevel >= fFullySubmergedLevel)
{
if (GetLocalRole() == ROLE_Authority)
{
UE_LOG(LogTemp, Warning, TEXT("Server"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Client"));
}
bIsFullySubmerged = true;
}```
OnRep:
```cpp
void ABasePlayer::OnRep_IsFullySubmerged()
{
GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Purple, TEXT("Submerged state changed"));
if (!bIsFullySubmerged)
{
// Here will be it fired once?
GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Purple, TEXT("Player is no longer submerged, we can play particles effects!"));
OnEmergesFromWater(GetVelocity(), GetActorLocation());
}
else
OnFullySubmerged(GetVelocity(), GetActorLocation());
}
Edit: I have bReplicates = true; and GetLifetimeReplicatedProps implemented
Ok, had to change this value via Server RPC
should I every variable change via serverrpc if I want to be replicated or only when I want to use OnRep function?
Hey, I have issues with replication:
I defined a value like this:
FWeaponData WeaponData;```
and set GetLifetimeReplicatedProps:
```void AAriseRangedWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AAriseRangedWeapon, WeaponData);
}```
But the value of my structure is always equal to its default value on the client, any idea ?
AAriseRangedWeapon also needs to be replicated
Also, what does the FWeaponData definition look like?
Can someone help me with this. Why is this setting greyed-out?? I really want to open a client viewport much bigger than these settings.
Now I need to rescale with every play
i realize this process will be much more complex than the answer i receive (possibly) but how can i make it so that in a muliplayer open world like game, quests take them to a different instance of that world, so that they are no longer inside the same game world as other players? so that they can complete quests that might trigger thing in world that i don't need/want other players to experience
You'd need to send them to a completely different server
Not really much different to a "Hub" style server system where the hub server spools up another game server on your backend, then sends all/required players to it when it's ready.
what kind of extra coding would this require? other than the stuff that would be simply needed for that partiuclar world ? would this also be a different gammode?
Hi All! Some help needed with dedicated server. All works just fine, but after some time if no one is playing he game, server hibernates. Players can't connect, unless I press 'Space' button within the server console. Any ideas how to keep server running?
Hey just a general question regarding voice chat, is there a specific way you're meant to do it, since the documentation for it is horrible and the tutorials are basically non-existent and don't work
I have no idea, depends on your game. The backend/server architecture is hard enough
hmmm, well maybe i can get away w not doing any of that and having certain things be not showing for other clients in the world
or maybe have them have like a transparent mask around them when they are in a quest and an enemy ai that pertains to it isn't interactable by the other clients
or maybe even having places that are only access when on the quest. i suppose there are other methods to solve the problem
Can putting certain information on the player state open your game up for cheating? Like for example if you had your inventory on your player state and now that all clients have a copy of your player state they can "see" in your inventory?
Assume that any data you send to a client can be read by that client somehow, even if you don't put a mechanism in game for them to see it.
Inventory on a Player State seems like an odd choice to me but obviously depends on the game
Remember that you can make your inventory replicate under owner only condition, that way other players don't necessarily see other players' inventories (or they can see a part of it, depends on what you want)
Ah ok
I was thinking for persistence since player state handles seamless travel and would keep state between level chanes and disconnections.
i personally find the idea of putting an inventory on the player state appealing, because that way the inventory naturally persists across deaths as pawns come and go, giving you control over what to do with the inventory should a player respawn. there is also the 'outfit' part of the inventory (which arguably should be a part of the inventory) which other players should be able to see (if your game has outfits), so the pawn can be an external observer and react to changes in the owner's player state
yeah very much depends on the game really
I want to aim for a game that kind of combines EFT with Day Z
So I think having that inventory state during the entire game session would make the player state a good candidate?
how does multiplayer works with anim graph
some states arent the same between client and other clients
anim graph has no networking
you mean by default, or not supported ?
not supported, nothing in an animation is network relevant
because you can see the player running and stuff, and its replicated
Anim graph just read values
so states are replicated
They are driven from data that comes from other systems
so each client gets from server the data ?
the graph just read w/e the value from the owner
the anim graph just read from it's owner, period
on what side ?
client or server
Both, independently
i think there's a bit of misconception when you say that
server has no idea about clients animation, client has no idea about servers' animation. They are completely independent
it just care about it's owner in it's machine
because on debug, the animgraph exist on server and client
That's because there are two of them, one on the server machine, the other on the client machine
everyone have their own version in their own world
Assuming you had one player ofc
okay
the only thing that isnt sync between clients is this aim offset
and i cant find out why
U don't just expect things to be in sync
that's your responsibility to check what should be in sync and how to sync them
if you need something to be sync, then it can be a replicated variable (Not the variable inside the anim graph ofc, but the value from the anim graph owner , eg your player character)
the aim yaw and the aim pitch vars are set in the anim BP, using the character location and rotation
that doesn't say much about networking
if you need something to be sync, well then sync it
by reading a replicated variable for example
isnt the character the same on clients ?
i'll try moving the logic of the vars to player pawn and read from that
not sure what logic and what you mean by that
could be doing something wrong but I can't tell
for something like aim offset, pretty sure there's a replicated value that you can use from the player controller
doing some math
but don't ask me, I don't do FPS
well it works on the owning client
from other client, you are the default aim center pose
debug
find out why the client's pitch and yaw is not updated
you probably didn't tell the server to update the var
this worked
but again, for something like aim offset, im pretty sure there is an existing variable you can use
from the officials UE docs they do that, so i assume there isnt
๐คทโโ๏ธ , ask someone that knows. iirc there is something like that
these are the only default made vars
Unreal is kinda made for FPS game
i mean the engine it self
it would have somehting like that handled
same deal then
maybe because of unreal tournament
idk if UE was used for something else before
it's used for all types sort of game
but the CMC it self is made for competetive shooter is my guess
cathered to it
They have a default node for yaw or pitch (can't remember which is responsible for looking up and down), which is automatically replicated. However, for sideways aiming, you would have to replicate your own logic from the pawn or similar.
i mean, when you are a studio and are building games, you either make you own engine or use another one
epic games made their own, and before fortnite i think UT is the real entry point (because it had a level editor really similar to UE4)
maybe it wasnt "epic games", prob another group name, but you see the point
is this a bit to much ?
should i replace this by "get world delta seconds" ?
Anyone know if there's an event on the client that gets triggered when they're disconnected from a server that's crashed? Want to add a timeout message and then boot players back to lobby in that case...
NetworkError and TravelError in Game Instance
A whole crap ton of games. Splinter Cell, Mass Effect, Gears of War, Batman - Arkham trilogy, BioShock, Borderlands, Army of Two, Astroneer...really, all kinds of games.
(Of course Epic's games as well)
i meant before unreal tournament
what games epic made that required to start making their own engine
before it became a public engine like nowdays
UE was made for UT, yes. Beforehand though, Tim made things like ZZT and Jill of the Jungle
Hi there..
I'm currently struggling with a Problem targeting a SceneCapture2D in my PlayerCharacters.
The Screenshot shows the BeginPlay Setup of the Capturing..
The Select choses one of two RenderTarget textures, depending on the Playr Index of the Session (2-Player Coop.. so 0 or 1).
The Problem is...:
I can't get it to work to have both Players have their own Animated, rendered Texture in their Inventory.. Only Player 1 has it fully working.. bot not the joined Client...
Can one pass me a Hint?
Player 2 simply has a white RTT...
@hexed star check if the controller is valid?
It indeed is..
Calling that from Event Possessed
event possesed run on server
u want to check if everything is set in the client machine
No link with your question sorry, but what plugin do you use to make your wire like this ? (Im not talking about the flat nodes)
Node Graph Assistant
Ty
looks like windows 11
Kmg.. i totally forgot about setzing the right RPC.. thanks
And Flat Nodes for the Node Style
Yeah i guessed that
Didnt knew that node graph assistant had an option to change style
Noob question, if I replicate a variable with OnRep and also handle the server side update of the variable. Can I assume that the value in the details view should be correct for clients and server?
To update a var on server and make it replicated to clients. You have to set it on server side
OnRep will always be called, when the variable changes on server side, only.
And it will call the moment, the variable got updated on the client.
Yes. So I should expect e.g. count to represent the correct value for each client when inspecting that value in the editor details section.
Why in asking is because i see different outcomes from the UI of a client compared with the value in the details view for that client
did you update the UI on rep_notify?
try to print the value as well in the rep notify function
see if the client actually gets an update
Yeah, if I press a button I can get the value to decrement correctly in the UI for both client and server, I must have done something else wrong
Thanks โค๏ธ
any feedback ?
and is the "delta seconds" returned by the event tick the same as "get world delta seconds" ?
also, when setting a var replication to "owner only", does it propagate to actor components ?
similar
as for this, there's no context at all
context isnt, really required, i just need the delta seconds almost each frame
event tick -> Get delta seconds
okay
afaik get world delta seconds give an almost same number
ill make it owner only
down to the small decimals
okay ty
Hi guys!
my animations on the client are jittery. Only for the client character, doesn't happen with the host character. Both the client and the server can see the same thing, I will send two example videos (in the last seconds of the first video you can see it well). Does anyone know possible elements that I can check or study to try to find a solution?
More info:
- I'm connecting via Steam
- I'm only using blueprints
- Both PCs and internet connections are good (the problem happens always with the client)
- I used a default thirdperson character controller as a base, but I changed the
mesh and SK, and created my own ABP - Using an animation blend for movement
- It only causes problems in the build, the same doesn't happen in the editor
Editor infos:
@pallid mesa Thanks, really helpful "VS watch", I also had to change the configuration from "Development Editor" to "DebugGame Editor" because debugger was ignoring a few breakpoints when I used the "Development Editor" configuration
Server executes:
Character#OnDeath()
Character#CallRestartPlayer()
Character#Destroy()
Character#Destroyed()
GameMode->GetOnPlayerDied().Broadcast(this);
AController* CharacterController = Character->GetController(); // returns NULL in the GameMode for some reason
GameMode->RestartPlayer(ControllerRef); // calls Super::RestartPlayer(NewPlayer); // NewPlayer is not NULL
Client1 executes:
Character#Destroyed()
Client2 executes:
Character#Destroyed()
Now I see that technically the clients don't see that the character is dead they just react on the server's Destroy()/Destroyed() call ( automatically replicated by the UE's code I think ). Also I'm not sure if it's bad that GameMode's RestartPlayer() runs on the server before each client runs Destroyed() function. Looks like the GamMode's RestartPlayer() is also automatically replicated, because I run the dedicated server with 2 clients and on the both clients I see new Character spawned.
Will check GetController()'s implementation to see why it returns NULL for the character's reference in the GameMode's function
@primal trellis It doesn't look like a latency issue, but rather a discrepancy between what the client is trying to do, and what the server is telling it to do.
That's probably why it does not affect the host. Essentially, the client is in disagreement with the server, and the server is constantly trying to correct it.
A typical case for this type of jitter is setting walk speed on the server, but not on the client, or rotation rate on the server, but not the client.
To remove jitter, you have to set whatever you intend to replicate (e.g. walk speed float) on the server and locally to make them synchronize.
Thanks for answering!
I just didn't quite understand the ending: "to remove jitter, you have to set whatever you intend to replicate (e.g. walk speed float) on the server and locally to make them synchronize."
What I understood is that the server should take care of everything and then replicate the information to the clients
But in your example, so I have to make everyone, e.g. take care of their own speed and then I make them synchronize it?
What would be an example of how I could set this walk speed correctly?
(sorry for the possible doubts beginners, it's my first multiplayer)
Basically, if walk speed is not synchronized, you can fix that by setting the walk speed on the client, and on the server.
The server has authority of course, and should handle all gameplay events, but we can help it by settings things locally. As long as the server agrees with what we set, there should be no discrepancies.
If I've got an actor that's out of relevance, and teleport in to relevance, is there a way to not play an audio component attached to it from the start, and instead pick it up where it would be for folks who were in-range the entire time?
Okay, I'll try to do it this way. Thanks for the help!!
Can someone summarize multiplayer for me? Like the different aspects of it and how it works on a technical level? Just so I have a better understanding of multiplayer as a whole and how it functions in a game
Hmm @shadow aurora. I don't have experience with that, but what about saving a timestamp of when the audio started playing, and once it comes into relevance, we check how long ago it played?
hey everyone, how do you deal with primary data assets in multiplayer
i have a player who selects a building which sets a data asset variable to the one theyve selected, then i want to replicate which one is selected on another client. should i just replicate the variable or the asset id or something else
hello
data assets cant be replicated (well, technically yes, but you have to do some c++ stuff and its not that easy)
i also ran into this issue, what ive did is made a struct using some info that the data asset holds, and use that struct to be replicated
that seems incredibly wasteful if its static data no?
example
i was considering just sending one key bit of info so i can search through all the assets to find the right one
well, DAs are UObjects
and UObjects arent replicated
UObjects are replicated as anything else
i aslo thought about that, depending on the amount of DAs and your system, maybe saving a struct var is beter
no, because replication goes through actor channel
that only actors and actors component have
more info here
https://jambax.co.uk/replicating-uobjects/
//~UObject interface
virtual bool ReplicateSubobjects(class UActorChannel* Channel, class FOutBunch* Bunch, FReplicationFlags* RepFlags) override;
//~End of UObject interface
do your homework man ๐
would replicating primary asset id work?
idk, test
i didnt specified it wasnt possible, UObjects arent replicated by default
as i said earlier, you can make it replicated
there is even plugins to do that automatically
I have a variable in the GameState set to array replicated, and when trying to print its content by the host of the game it has the right content, however when I try to print its content by the client it doesn't have the same content, why is that ? I print that in the Player Controller like this
i just stayed with struct to be more clean
show how you add stuff to array
seems like you're using up bandwidth for no reason though
less than if i was replicating a DA
my inventories are small so i can allow this
but you dont need to replicate data assets? everyone has the same data assets on their systems
because my inventory only needs some part of info, so i can control what i give him
sure he does not do that.. you're absolutely correct
you asked to replicated data assets ?
no, replicate which data asset the first client is pointing to
You're incorrect here - assets are replicated just fine. Their data isn't sent over the wire, a reference to their path (and sometimes a guid, depends on the situation) is.
Anything with a "stable" name (so... any asset on disk) can be replicated this way.
didnt know that
the ref is still null if i remeber correctly
so i can just replicate it and itll work? i assumed itd have to be loaded or something
thats the issue i had
im new using data assets so
In general, replicating a pointer to something isn't replicating the data inside that pointer. It's replicating a reference to that object (which would need to exist on both sides already). This is super important for assets.
exactly.. as I said before, @lament flax please do your homework. your advices could be quite misleading
interesting, thanks for the info siliex
this in particular i didnt know
i may be wrong, but i think arrays only replicate when you set them rather than add items
source ?
i believe this is something i ran into before a couple of times
i ended up doing a rep notify with single variables and then on the notify i added it to the array
arrays are replicated as any other variable.. just be careful that out of the box, whole array will be replicated which could be a real deal for a bandwidth
so if you have a bigger array(or array which tends to be bigger in the future), you could think about FastArraySerializer(c++ only)
so how to fix my issue then please ?
Are you printing array at begin play?
No by pressing the "P" key
hard to say. Your snippets are not quite verbosive. That picture with a begin play is ment to be run on what? On server? On client?
What does the output look like ?
I think gamestate runs both on client and server each having their own instance ? The goal of it is to retrieve the data from the GameInstance and copy it in the GameState as the GameInstance isn't replicatable
sure but you have to do that on server, not on client.. so you have to check Role e.g. HasAuthority
This is the print in the Lobby (that's where the host enables / disables roles to set up the game) and it prints the same on the client and on the server
And here (still in the lobby) I disabled all the roles for examples except 2 then start the game
On the left side it still printing all of them because I'm still getting the GameInstance values which is not where I save when I enable / disable roles as I save that in the game state (in the next level being where people would play)
man I mean NETWORK Role ๐
Now I'm in the next level (so no the lobby anymore) and press P and it prints only the 2 enabled roles, so that's all good on the host side
However on client side it's still printing all the roles
I'm not sure to understand what you mean ? ๐ค
and this is a practical usage in BP
https://wizardcell.com/unreal/multiplayer-tips-and-tricks/#51-filter-by-netrole
But in this case it's the gamestate, so I don't really know who owns that actor but I guess the client has its own version of it and the server too
Server owns it
And as I'm printing that in the Player Controller, it's owned by the owning client if I'm not mistaking
Ok then doing this fixes the issue
that's correct(sort of.. PC is autonomous proxy, but for a sake of a simplification yes, client "owns" controller).. Server owns gamestate which is replicated to all clients.. but only server should do changes in there.. means when you want to replicate something to all clients, so you have to check HasAuthority() and make changes only when you really has an authority otherwise there is a solid chance that server replicates your variables correctly but you erase them by local version
so you're fine now right?
Oh it makes sense, thank you so much ๐
Yeah thank you ๐ ๐
Another question : How would you test something like in my game where I need to distribute all the roles in the game (there are 16 roles so 1 per person) without having to open 16 clients window ? ๐
from server print ?
i would rather open a couple of time the 16 windows to be sure each clients know what they are
I'm not sure to understand
what is a purpose of that test? what do you want to achieve?
Just to be sure that every role is distributed properly (and then later when I will implement the mechanics of each role) being able to test those because my game will have alot of intricated things with other roles)
so it means your game always need to be played by 16 players right
No
you can play with how many players you want (I need to set up a minimum still) and the max is 16 players. So depending on the amount of players and the amount of enabled roles, the game will distribute those roles so everyone has role and if there aren't enough roles to give to everyone because the amount of enabled roles are lower than the number of players in game I will either fill that by giving simple roles like Simple Villager and Simple Werewolves or I will give certain roles multiple times.
I will create a setting for that to let the host choose which one he prefers.
so you answered your question by yourself or?
No because that was not the question ๐
I will give you an example : There will be a role that will make the name of someone being killed being displayed to only certain roles and other roles will see that name being blurred / censored. So I have to make sure that every role I wanted to see the name being able to see that name while others must not see the name, so that's a reason why I need to test it with alot of players to see all the roles and if my programming skill succeed doing that.
Get a couple computers, have each of them open the game a few times, have them all connect
if you just open the game and not the editor you can have quite a few no problem
I could say you something about
https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/GameFramework/AActor/IsNetRelevantFor/
or implementing a rule in your ReplicationGraph(filter certain connections)
but I think that for your own sanity just replicate kills on all clients through GameState and filter it on client's UI.. I know it could be hacked, but you can tweak this later
Checks to see if this actor is relevant for a specific network connection
e.g you will replicate to each client that player with role A gets killed.. and on all clients you will do some check if (KilledRole == MyLocalPlayerRole) do this.. else do nothing..
But it doesn't answer my question ๐ Like here I'm referring to a need of having a lot of game instances opened to do games alone by testing different combinations of stuff and see if my code breaks or not, and if I'm not mistaking Unreal only allows 4 window instances and it's already burning my computer in terms of performance ๐
ok, soo.. you wanted to test combinations of roles.. so hows about Excel?
why you need to test it in a game.. it is not a network related problem. it is a design
Because there's a big differnce between theory and in practice, so that's why I need to test in game
sorry, dont get it.. well good luck man ๐
๐
Just test with the minimum amount of players needed, and test combinations for all roles. If it works with four clients, it should be scalable and work with more.
If you need to test with a lot of players, test with LAN using multiple packaged instances to reduce performance load, maybe with two computers.
Make friends help you.
Alright thanks I will try that (tho I don't have multiple computers :D)
friends ? What's that ? ๐
I have heard you can make them ๐
those are rumors only ... ๐
Cant you spawn a bunch of pawns and test your logic on those in a non replicated scene ?
If you're worried your distribution of roles is incorrect. Test it in a minimal environement.
No replication, just a bunch of Actors
Can test 10 roles , 15 pawns and vise versa (dont need no real friends for that. Can use fake friends. Fake friends are nice)
@vagrant grail
Noob in need of some help with replication and ownership in the context of simple tutorial task.
The task is to make a simple button press animation and have it be replicated to all clients(ultra small demo task, not worried about net cull or any distance gate, consider all of that well past my current level of understanding and demo requirements)
I have so far: Made the button press BP, added static mesh, collider box, added logic for collider component overlap, added simple timeline and anim logic for button as well as getting player input and allowing the button to be pressed by "E".. all of this is contained in my BP_Button - How should i go about sending an RPC to the server that the button press has taken place? I have tried creating a variable bool and passing this to server and an OnRep function without success(probably incorrecly mind you)
This all takes place on BP_Button - I tried to add in server logic and RPC here but failed. It feels like maybe I have not understood the problem well enough or making a basic mistake i think
I really wanted to have the client just toggle a bool and then have the server replicate the animation entirely too all clients
Did you try a rep notify using that bool variable?
It helps with visual things that are changed by the server but the clients need to see
Instead of just replicated you do rep notify and handle the animation in the function that it creates
Have the client call an rpc
rpc toggles bool
bool onrep plays animation
If it's a pawn and a button actor, it'd have to be like this:
Pawn:
Input -> RPC
RPC -> get button -> toggle bool
Button:
OnRep_bool -> call event OnBoolChanged
OnBoolChange -> branch on bool -> enter timeline
you can't directly have a timeline inside an onrep, that's why you need event OnBoolChanged
I am too embarassed to post the photo of my blueprint
๐ฅฒ
So lets try this like a computer might, line by line.. Kaziie, I will attempt now to create a rep notify using the bool Is A
Start with the bool in the button.
Set up your button so that
Begin play -> branch on authority -> bool = !bool -> 3s delay -> loop back
put a print string on the onrep for the bool. print it, make sure everyone agrees its flip flopping
then just directly set relative location in the onrep
then add an event so you can use the timeline instead of instantly snapping
I appreciate this super detailed and fast reply Adriel!!
I think i got to about here before I cannot follow
So far i am clear on lets try to make Is_A a var, then set this variable to a RepNotify replication type. However further steps are unclear
not at all
ignore input for now
remove all inputs from the button
you need ownership to call RPCs through an actor so putting inputs on the button isn't a great idea.
what are you setting IsA to on begin play?
you should set it to be NOT(IsA)
and also loop that delay back into the set
so it keeps flip flopping
I dont know how to do the test loop youve specified but the OnRep print string is working
that doesn't check if A is true or false
Hmm? im not sure i follow
Why dont we just remove the test loop and focus on the onrep?
because you have nothing driving the onrep
get the test loop going
i literally just handed you it
OnRep appears to be working
ok show what you got right now
Looks like more functionality on the same test. ButtonPressed or "True" or "False"
i dont really get the difference
false means Button unpressed
the main issue i think is i dont understand how u mean to loop back over that delay
just drag the execution so it loops forever, flipping the IsA from true to false to true to false to true to false forever
Yes false would mean state of the button is depressed((like me working to learn netcode))
false is button NOT pressed
I wouldn't call it Is A though, call it ButtonIsPressed or whatever
IsA doesn't mean anything
Once you understand this, change the onrep to move the button to a different spot DEPENDING ON THE BOOL
I see what you mean on the looping delay! ugly as sin but works like this right? :
Onrep -> if bool -> true -> button position should be down
-> false -> button positon should be up
yeah it's just a quick and dirty loop, you could use a timer but this will work
Better than the branch is to use select though
yup that's perfect
dirty but gets the job done
so now you got a flipflopping bool, now make it do something visible rather than print a string
Man why is visual scripting so obtuse ๐ฅฒ !! I want to write the word "for" so badly it hurts right now
there is a for loop but that wouldn't help you here lol
yes it's server side, and gets replicated to clients
and the onrep fires when it changes
Understanding this flow has been so tricky w/ docs alone - i will attempt to use custom events to call the button animation now with onrep?
Now just snap it to position
do animation later
onrep -> set local position (select position based on bool)
select node is what you want. it'll pick one of the vector inputs based on the bool
you can also select on enums too, it's templated for all sorts of stuff
In my image above for the loop - we are setting Is_A = False, i have yet to get that flip flopping like you had wanted to achieve
hmm
isA -> NOT -> Set isA
I dont follow this last instruction
How do you access the logic gate functionality?
I am not seeing any NOT or logic gates familie to select from
OK! Makes sense line for line in pseudo style : Get Is_A, Invert its state with the NOT, then use that state to Set (With OnRep)
The Pick_A var into the select vector is something new may take a few minutes - set rel location i see you've chosen to simplify inplace of the timeline , for testing i assume?
yes, crawl before running
since timelines can't run in a function then you'll need a new event and also need to handle trickier situations like what to do when you release button before timeline is done etc
After, this, the final timeline version will probably look like this:
and that'll be it
button done
now you need to handle the path between the clients input and the bool being changed
but get button done first
For this you mention the client input, at that point we may be adding to our character BP?
Heh but first let me get caught up a bit more! so far we've got the server's rep notify loop working and this is being replicated correctly to all clients connected
(In case any other new people wish to follow along)
AHHH so even better yet i see you've used the Is_A var to select a home , or displaced vector in the Select Vect function! very clever wow . i kept asking myself why cant we just use timeline in our OnRep Functions!
Yeah the best way to think about multiplayer is "What is the least amount of state or events that need to replicate to make the end result the same?"
In this case, it's just a single bool
After using the Select Vector test to confirm the behavior is replicating, i see you have extended out to a custom event driven from this bool to get that timeline node back
Hello
Some context about my issue :
when i equip a weapon i change in the anim BP the pose (this pose is replicated to all clients)
i am shooting a line trace from server, the linetrace start is using the world location of a actor (that is attached to a player mesh socket)
when i debug the linetrace, i looks like that for the server, my actor is next to between my player legs (instead of his arms)
how can I debug this to find the issue ?
the pose is replicated between clients, so my server should have it to
the actor is spawned and attached for all clients, so the server should know it to
Hello everyone, I have a system for turning the brake lights on and off. If the client connects to the game later and the brake light is on at this time, the client does not see it. I used RepNotify for this and it works. When the client connects late to the game, it sees the Brake lamp without any problems, but I don't understand what should I choose in the Replication Condition, can someone please inform me?
The replication conditions are there for special cases where you may want to limit the replication. In this case, you probably just want to use "None".
I understand, thank you very much.
Old docs but maybe helpful for giving you an idea of the this function in older engine ver
An example: Let's say you have your brake lights being client predicted (you're setting the bool true/false locally on the client first before sending to the server) and in that case you could use the "Skip Owner" option to then not override what you've already done on the client that owns the actor that has the bool.
Yes, I understand it much better now, it makes sense, thank you for the example.
Thanks for the source, I'll look into that.
As predicted there is no way for the client to access the bool but this is where I was able to get the button task Adriel! Thank you very much for the kind explanation
Yes because a timeline cannot exist inside a function
The part in the button looks fine
now all you need to do is change the button on the server at behest of a client
Simplified, it'd be like this
In Pawn:
Input -> run on server event //call it Interact or whatever
Interact -> determine what button to talk to (line trace, get actor of class, sphere trace, whatever) -> change its bool
Done
The simplest setup would be this. This is literally ALL you'd need.
in pawn:
Input -> run on server event
run on server event -> get actor of class Button -> swap its bool
Do that for now.
I have been stuck there a bit >.<
Even just your delay loop is a great bit of logic that gives me a lot of cool ideas
you could animate a wind mill, use net cull to keep the distance player relevant and voila , really cool server side animation replicated to all clients
Any mechanical structure could be effectively done i think this way
for level design etc, its more than a test loop ๐
in PIE with "Play as Client" selected, i notice that calling ServerTravel() from my GameModeBase doesn't bring the connected client with it?
Have you enabled Seamless Travel?
no
Well thats your problem
ok thanks, will give it a shot
How do you replicate an array of plain UObject in C++ ?
I thought it was the opposite, that seamless travel didn't work in PIE?
Assuming you've set up the Uobjects to replicate, the array should be able to be marked as replicated and have references to the replicated objects.
would this not need a ReplicateSubobjects in the owning actor for every element of the array ?
I'm talking about replicating plain UObjects by overriding IsSupportedForNetworking
Try this one Fishy https://forums.unrealengine.com/t/projectile-start-location-on-dedicated-server-not-the-same-as-client/261064
UPDATE 12-06-2021 Problem Solved To fix: On your skeletal mesh component of your character, set Anim based visibility option to Always Tick Pose and refresh bones Special thanks to KaosSpectrum#0001 on Discord for figuring it out, and thanks to everyone else who tried. Hi, โข My game uses a dedicated server. โข My player character spawns a ...
That ones a bugger ;p
Im working everyday day a few hours so yeah bugs are regularly happening :)
Its nice that people are willing to help others
Wish i had more time to sink into it lol. Kids change everything , atleast the first decade
Make them learn UE 
To smol yet
So weird - if I use the default 'player start' actor in my game I get 'ghost' units spawning on the server corresponding to player starts that players don't use - if I change to use a customplayerstart actor that I created the problem goes away
this fixed my issue, ty
Sweet
Is using PendingData num for Buffer size safe?
i am creating a dynamic material instance and saving it in a replicated var on server
then later on, on server side i am trying to access this var to update a vector param
i get no errors, but the material didnt change on client
did i do something wrong, or materials cant be replicated on server ?
Is the variable/parameter being updated on the clients?
is this true ?
no
i think dynamic material instance are unique per client (and cant be shared ?)
1 - on server
2 - on server
3- to all clients
4- clients
on 4, the var is null (on server its not null)
I don't think it is an issue with material instances, but obviously your client needs to get the data from the server somehow, so all clients can set their material locally and match it to the server state.
well thats what i show in my screenshots
Sorry I'm too lazy to try to solve the specifics of it xD
no pb
You're saying the index returns 0 on clients?
the material dynamic instance is null on clients when setting it on server
Oh. So when you set MaterialDynamicInstance with RepNotify on the server, clients get a null reference?
on rep of the material var its called once on server
not clients
thats why its null
Got it, just confirming. That's kinda interesting though.
How about... instead of setting the MaterialInstance with a notify, just use a boolean notify, which triggers an event on the client outside the notify?
And that sets the material instance locally.
We only care about getting the index from the server afterwards.
Good to know!
i see, on the onrep of the bool i tell to each client to set its DMI
or i can do a mutlitcast
Indeed. I'm sure it could be optimized more, maybe you can call the client side event using the Status RepNotify variable. Of course, you will need some logic in order to select the correct material.
Hmm, possibly. I think it might be safer to stick with a notify, as materials are a state related thing usually.
But if it works, it works. Just make sure clients who come into relevance, or join later are updated.
What about this? Cleanest solution I can think of. Not sure if it would work, but worth a try I suppose.
thanks for helping
Np!
the issue with that is that i will create a bunch of materia instances
i did this :
I don't mean replicate the MaterialInstance variable, just set it once for each client.
yes
but i am chaning this var when i shoot
so with your setup i will create a new DMI at each shoot
with mine i create a new DMI at begin shoot, and use it until the end
Ah, then it makes more sense.
I'm not sure to understand how to do that ๐ค
Is there a way to know when all players were teleported from the lobby to the main level ? I need to be sure that everyone is there before giving roles as I need to know the amount of players in the game
Cant you just hand out along the way?
Doesnt make much difference
Can players join after the round starts?
Right now yes, but maybe later it will if I need to give a certain amount of roles left depending on the amount of players in the game (like the distribution between the amount of werewolves compared to simple villager roles)
Yes but they will be in spectator mode until next round
So no
Logically you do the same wether you know or font know the amount of players
If roles remain, give role
Else handle according to server rules
it's so stupid if Epic didn't put like an event "OnEveryoneJoined" or something like that
Who is everybody
i made a goal count, at each connection i add 1 until i meet the goal count
how do you get the goal then ?
well in your case you just have to get the nb of ppl conneced to lobby
and how do you transfer that value from the lobby to the game level ?
using game state (or instance i dont remenber which persist between levels)
well its depends of other stuff aswell
for eg if you have a matchmaking
right now I don't have matchmaking, it will be people inviting their friends to play with only
I want to make prophunt mechanics but I couldn't find how to replicate the set skeletal mesh. because my English is not very good and because I'm a beginner on unreal engine, I would appreciate it if you explain step by step and in detail as if you were explaining it to an idiot.
Beginner on unreal and doing multiplayer game ? ๐
I assigned set skeletal mesh to be triggered with beginplay event but replication is not working
I know it's absurd, but it's not impossible, is it?
not impossible but it's a high risk of failure. It's like someone brand new to architecture / building and saying that he's gonna build a castle ๐ฌ
I don't care much about making mistakes, after all, I am developing a project for learning purposes rather than a commercial business.
So, can you help me with the above problem? ๐
Start with a solo game first to learn because you will need those basics to do a multiplayer game (for learning or commerical purpose it doesn't matter)
Been trying to setup a listen server and just wanted to make sure I understand correctly. If the host is on the server does this mean they replicate independantly without needing further replication? By and large do I need 2 separate lines of code for host and client?
do you mean like islocalcontroller?
Can you show the beginning of the blueprint that chains to this piece of code?
I simply connected it to event beginplay
How do i check if the owning player is the server on a widget?
Wasted 10 hours because I didn't know 'sets and maps cannot be replicated'
Questioning my understanding of the basics thinking I was missing something incredibly obvious
Will the order of player states in the default 'playerarray' in gamestate be consistent, no matter what client i access the gamestate from?
I'm hoping so
I dont think so
Its locally maintained iirc
The playerstates are replicated, but the playerarray in gamestate is not
@formal solar
ok ty
You can assign id's to the playerstate itself tho, so you can find the correct order if you wanted to
Cheers for tip, stressed myself out today but at least I figured out what the problem was, going to restart tomorrow
for some reason, the var seems not replicated
the route is :
1 - set the var on server
1 - call event on owning client
2 - call another event on owning client
3 - get back the var (buts its null ?)
i am in the player state
Can someone confirm an assumption I am running with in regards to using print strings when debugging multiplayer? I assume we want to add a print string for every set of functionality that has some effect on the other clients/server right?
This way when looking at things like crash logs, we would have more oversight on the different steps a client has/has not gone through
whoa setting the CMC's tick rate low, the character mesh absolute and then lerping between position updates seems to work fine network wise... i wonder if theres any hidden consequences
well lower tick rate is usually choppier movement
and less accurate velocity/physics calculations and stuff
Server Side probably before. Client side you can't know. Replication can cause a race condition
yeah it turns out its before
If I recall correctly, the PC creates it in like PostInitComponents or something like that
Indeed
How does Among Us create games with a code that people can share to their friends to play with ?
What do you mean share code?
You mean mods?
No
I mean this
Sessions?
?
Does among us make it like warframe? So one player become a host, and rest can join for the game?
Yes
So, you create listen server
There is a plugin to make it even better called Advanced sessions
Its free
Already using that but my question is more related to how to do this code system where people have to enter that code in a input box to join that sesssion and making sure that code isn't a duplicate of another session
My quess would be to make some centralised server, e.g. in Node.JS, that talks to Unreal via Websockets. Now, when you host session, you send the reqest to the central server, and then it puts your code into the dictionary [key, host ip]. Now, when you enter the code, it talks to central server, it gets the ip associated to the code, and return value with ip
That would be without steam sessions. With steam sessions, idk, never worked with it. Maybe it has some built in api
I guess the Node.js and Websockets parts are done through C++ ?
No
You can actually use any Websocket server
C++, Rust(my favorite), Javascript etc.
Node.JS is just the easiest one imo
Websocket is a network protocol
But, Unreal has a built in web socket client api
So its shouldn't be very hard to do
No like I'm talking in Unreal, can I do the link between that central server using Blueprint or must it be done in C++ ?
I've done this several times
You can use blueprints:
https://www.unrealengine.com/marketplace/en-US/product/blueprint-websockets
Thank you ๐
But I'm more of a C++ guy
Good to know that you're a guy (as somehow I thought you were a girl) ๐
You might want to take a look at Socket.IO, that is wrapper around websockets to make them even easier to use
lol
Socket.IO client plugin for the Unreal Engine. Contribute to getnamo/SocketIOClient-Unreal development by creating an account on GitHub.
Some people even called me a femboy for some reason(but not on this server). Idk what's with people feminizing me
Because of your name ๐
HiveMind just makes me think of some alien swarm
Correct
Hi, has anyone encountered a similar problem?
In ABP I set the AimRotation value depending on whether the player is locally controlled or not. Then in the CalculateSpineYaw function I take the player's transform and invert the Yaw. The problem is that on the client the Yaw value is set correctly, but on the server and simulated proxy it is equal to zero. As I understand it, the problem is that on the server and on the simulated proxy I get a zero transform. Does anyone know what the problem is and how it can be fixed?
how would I use repnotify to play an animation?
@obtuse field Did Sockets end up helping you reach a better solution to your chunk streaming?
or just HTTP which also has things like VaRest for BP
no need for WS at all for that
and Node.js never dies huh
Still working on it
Needed to make some research on serialization etc.
Sending data trough TCP is working, not just to do things with the data
Btw. is there a way to make serialization with templates?
Can I somehow promise unreal, that << will be valid, or make it to check by template provided type at compile time?
Something like that
template <typename T> void SendBytes(T& Data, APlayerController* Destination)
{
TArray<uint8> Bytes;
FMemoryWriter MemoryWriter(Bytes);
uint32 NumBytes = 16;
MemoryWriter << NumBytes;
MemoryWriter << Data; //problem
MemoryWriter.Seek(0);
NumBytes = Bytes.Num();
MemoryWriter << NumBytes;
int32 BytesSend = 0;
if(!Connections[Destination].Socket->Send(Bytes.GetData(), MemoryWriter.TotalSize(), BytesSend))
{
UKismetSystemLibrary::PrintString(GetWorld(), "SEND ERROR");
}
}
Ok, so I tested it a little further, and its possible
Idk why it didn't work earlier
You said you were using unreal and advanced sessions, Websockets seems more appropriate, but you could accomplish the same thing using the "extra settings" option that Advanced session comes with.
When creating a session add an extra string setting which contains, the code you want, and then when searching for sessions, search for that particular setting, and then join it if found
But there isbstill the issue of duplicates I need to handle through websockets I guess
It's the same thing, you could search through the current sessions and see if any are already using it, because of that I'd try to make the code atleast 10 characters to minimize the chance of duplicates
It really shouldn't be a problem unless you're game gets massive unexpectedly
But I did say from the start It's not the best method, but a quick one
In Blueprint, I have a Rep Notify on Begin play to get the Steam ID of players based on the Player State. I send a RPC to the Server and have the server Call Rep Notify. In my case, it's working for players who are already connected, as they can see the names of people who join, but for people just connecting, it doesn't set any of the names of people who are already there.
Get Unique Net ID from Player State is Retuning Invalid. What should I do to fix this?
I think I got it working. I just had the Server do a Validity Timer check on the Player State Unique Net ID until it was Valid, then had the Server update the Rep Notify with the Name Result.
how does one have a rep notify on begin play?
Sorry, I meant I was changing the Rep Notify Variable on Begin Play
I have a Controller validity check if local, then after that, it calls the Server, which checks the Player State ID, and if that's valid, it sets the String Variable which is rep notify.
That seems to work
Has anyone had a crash because of this i keep getting crashes (AWorldSettings* ULevel::GetWorldSettings(bool bChecked) const { if (bChecked) { checkf( WorldSettings != nullptr, TEXT("%s"), *GetPathName() ); } return WorldSettings; }) Call stack was showing stuff about HLOD's and LOD's im only getting this problem after setting up world partition.
"While we can predict GameplayEffect application, we cannot predict GameplayEffect removal. One way that we can work around this limitation is to predict the inverse effect when we want to remove a GameplayEffect. Say we predict a movement speed slow of 40%. We can predictively remove it by applying a movement speed buff of 40%. Then remove both GameplayEffects at the same time. This is not appropriate for every scenario and support for predicting GameplayEffect removal is still needed. Dave Ratti from Epic has expressed desire to add it to a future iteration of GAS."
Is this still true?
I'm trying to create a slow GE, and it is predicted correctly one apply GE_Slow
but when It is removed the character rubberbands back
or as Dave Ratti has left epic i'm out of luck?
Hi Matt. Have you found a good way to do this?
Seems like I can go with smth like
FCustomStruct.NetSerialize(Ar, Map, bOutSuccessLocal) + forLoop iterating array
But maybe you found a better way of doing it?
FInstancedStruct has a NetSerialize function. Just call that on all elements of your array. Also, if you look at towards the end of the NetSerialization header, there are a couple of helper functions for exactly this scenario.