#multiplayer
1 messages ยท Page 642 of 1
and this is the last task
So you are executing the code above on everyone
You need to limit the Axis stuff to the LocallyControlled player.
And then use a non-reliable ServerRPC to tell the Server to move.
If you have the boolean checked for rep movement, it should happen automatically.
But that has no smoothing and no prediction. So higher pings will make this really bad
Do you mean the bReplicatedMovement? I've got a squiggle for that, so i used bStaticMeshReplicateMovement
void ASpaceMayhemPawn::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
if (IsLocallyControlled())
{
// Find movement direction
const float ForwardValue = GetInputAxisValue(MoveForwardBinding);
const float RightValue = GetInputAxisValue(MoveRightBinding);
// Clamp max size so that (X=1, Y=1) doesn't cause faster movement in diagonal directions
const FVector MoveDirection = FVector(ForwardValue, RightValue, 0.f).GetClampedToMaxSize(1.0f);
// Calculate movement
const FVector Movement = MoveDirection * MoveSpeed * DeltaSeconds;
const FRotator NewRotation = Movement.Rotation();
if (Movement.SizeSquared() > 0.0f)
{
ServerMoveActor(GetActorLocation() + Movement, NewRotation);
}
}
}
void ASpaceMayhemPawn::ServerMoveActor_Implementation(const FVector& Location, const FRotator& Rotation)
{
SetActorLocation(Location);
SetActorRotation(Rotation);
}
bool ASpaceMayhemPawn::ServerMoveActor_Validate()
{
return true;
}
Something like that maybe
But that's mainly pseudo code of course
Or send Movement as a vector and use your root stuff
Never used that before though
Thank you very much! I will try to modify it to see what happens ๐
The boolean is squiggled cause it's private
read the errors please...
You can use SetReplicatedMovement(true) iirc
@thin stratus I'm getting these errors
D:\GAME DEVELOPMENT\PROJECTS\BIG MOXI GAMES - TEST\Task 2\Source\SpaceMayhem\Source\SpaceMayhem\SpaceMayhemPawn.h(53): error C4596: 'ServerMoveActor_Implementation': illegal qualified name in member declaration
1>D:\GAME DEVELOPMENT\PROJECTS\BIG MOXI GAMES - TEST\Task 2\Source\SpaceMayhem\Source\SpaceMayhem\SpaceMayhemPawn.h(55): error C4596: 'ServerMoveActor_Validate': illegal qualified name in member declaration
I tried to remove the _implementation from the .h, but then I've got this
Show me the header part where you declare the function
You aren't declaring it as a server RPC
UFUNCTION(Server, WithValidation, Unreliable)
put that above it
(above the server function)
the ServerMoveActor_Validate must be declared too?
in the .h?
Now im getting 1>D:/GAME DEVELOPMENT/PROJECTS/BIG MOXI GAMES - TEST/Task 2/Source/SpaceMayhem/Source/SpaceMayhem/SpaceMayhemPawn.h(54): error : Bad event definition
when i use the UFUNCTION
No you only need to define the name
Without _Validate
And without _Implementation
The UFUNCTION() macro does the rest
When you call the function you use the normal name of it
When implementing it you implement only the _ versions
Thanks for your reply! I was reading https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/Actors/RPCs/ and tried to modify it
Designating function replication across the network
then
I put UFUNCTION(Server, WithValidation, Unreliable) void ASpaceMayhemPawn::ServerRPCMoveActor(const FVector& Location, const FRotator& Rotation); in the .h and
_Validate is probably const
And you are missing the _Implementation behind the main part of the function
And your header shouldn't have the ASpace... in front of the function name
Wtf i didnt see that
I keep getting the same BS., the bad event definition thing. It sucks, because the page tells nothing. Const or not, the result its the same =S
The error is inside the _Validate
But const or not, wtf I don't get and the page says nothing
IF I remove the Validate from the .h, the compiler tells me that the class has no member _Validate
I removed the namespace that I forgot in the validate line
what even happened here
the actual UFUNCTION definition needs a function signature that doesn't end in _Implementation, a declaration for the _Implementation function will be created if not defined
Thanks for your reply! But If I remove the _Implementation from the RPC signature, I vot this
in the cpp this
read the error
also the tooltip placement doesn't help
well that part is clear, the screenshot I posted is what I would expect from someone who has no idea what is front of them
are you following a tutorial?
also changes not saved
also you wouldn't call Implementation directly unless you know what you're doing
I'm following the Epic page https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/Actors/RPCs/
Designating function replication across the network
then you didn't follow it correctly
And
void SomeRPCFunction( int32 AddHealth );```
this is what an actual RPC declaration looks like, you do not create an implementation for this function yourself
this poorly formatted 5 year old blog is not something I would follow
it doesn't help that the error is not shown in the screenshot
I will post it
also the Validate function would need the same arguments as the actual RPC
Ah, ok this must be the reason then
No
Well. it compiled, but i had to match the parameter list of the validate with the list of the implementation. the fact that it was empty was causing the error
@thin stratus @chrome bay @lost inlet Thank you very much ๐
Right sorry, I am too used to having Resharper create me this stuff
No worries, you three helped me a lot today
thank you
๐
And now I have a better understanding of RPC in UE4
Now let see if is going to work XD
Loading the editor here
Haha the Pawn movement apparently is sync, but when I change from one viewport/PIE window to another, the controller is not working correctly, lsomething relatd to the GetInputAxisValue i guess after moving from window to another,
Almost always I use SetLifespan(2.0f) just in case. In this case it's more that the projectile explodes instantly if firing point blank into a wall, so the explode FX can in theory play before the projectile is inited on the client if bExploded reps before the init repnotify property which is a UDataAsset*. I'll try and delay about 200ms before showing FX if the init property hasn't repped yet, should do the trick. Thanks!
If it didn't explode instantly it would appear to either fly through the wall or would hang in space until the property reps
Hey, I'm having this issue where client characters are falling through the level because they spawn before the client finishes streaming in the level. The dedicated server places the characters where they need to be. You can see here in one of the clients, we see the other client standing on the landscape, but the other clients show they're falling. I can push the character to send another movement replication update and the client fixes itself
Any tips on how I can force the client to finish streaming the level before enabling physcis/etc? I'm trying the Flush Level Streaming node, but I guess that's not doing the trick
I'm pretty sure this is related to World Partition not forcing the cell from loading before the player starts. I have a non-WP version of this map and it seems to work fine
Thanks!
@grizzled stirrup issue is easy to kinda solve
if the OnRep is set before the projectile is replicated to client
the bool will be true on the client in BeginPlay
so just do the same path
explode it.
@meager spadeDamn true that!
Another example of calling the code twice to make sure it runs
Thanks
Would be great if beginplay was guaranteed to run before OnReps do
on clients
To prevent these messy double calls
I need help for an issue with multiplayer in blueprints , free or paid.
okay
i have asked the same question 2 times already
so i prefer ask for personal help
or you will strike me for spam
Given the names of both GameState And PlayerState I can assume that PlayerState Is player specific and only replicates data from the owning pawn
If that's the case GameState would primarily be used to to replicate information that is non player specific but important such as things like Total Team Scores, Total Game Time, Etc?
The uses for GameState and PlayerState is a little foggy to me
That's generally correct, except that PlayerState is owned by a controller, not a pawn.
Oh I see, So then Both the server and the owning controller can make changes to it's player state?
However only the Server can Update The GameState?
I suggest reading the network compendium: https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
Clients cannot replicate changes to any replicated variables (they can make a change locally, but they won't replicate it to the server). Owning PlayerState just means they can call an RPC on them.
Thanks
I'm looking for people who has not already tried to fix my issue:
I call the server who call a multicast using "set master pose" on clients , the operation fails
The same function set the master pose correctly in singleplayer mode.
everything but the set master pose works
These images are inside the character BP
The cast fails , the clients does not know the child actors
Why
Is there a way to use replication conditions to replicate values to specific clients (on a team) and not replicate them elsewhere? It, in theory, could be done with an actor which lives on the server and uses client RPCs to specific clients, but that sounds hard on bandwidth.
Which function/ID are you referring to?
i mean you can test the player id ( is like a client id) to accept the brodcast or not
For which broadcast? I'm not very familiar with property replication conditions.
Oh you are talking about property replication sorry , ithought you were asking for event replication
No worries! Sorry for the confusion.
After google searchs , it appears that child actor components are never replicated ,so i'll not use them
in a first of third person template, when I move the camera with my mouse when the game is running, is the rotation of my camera replicated from the client to the server every frame?
Dont think so and that sounds very unnecessary to replicate something only the client needs to know? ๐ค
Network data isn't sent out at the client framerate, that'd be incredibly inefficient. Data is bundled up over a short period of time and sent out all at once.
Anyway, I don't believe either of those templates replicate anything about the camera. At most they replicate the horizontal control rotation axis. iirc you need to replicate the vertical axis yourself if you care about that.
I see, I was asking because in my game I have several features that require the game to know which direction my camera is facing (such as wallrunning) and so far I have been calculating such values in the client and storing them in two variables called CameraRightVector and CameraForwardVector and then calling a server RPC to set those variables on my server too from the MoveForward and MoveRight input-axes-bound functions...
But maybe there's a better way to do this?
I would have 2 boleans for "Running on wall left" and "Running on wall right" and just send when the state starts and when it ends
well the way I've been getting the camera rotation is through the controller like:
const FRotator Rotation = Controller->GetControlRotation();
which is inside my My_Character::MoveForward(float AxisValue) function
so the controller rotation is replicated?
it's more like I need the direction of the camera to determine which type of wallrunning the character will perform, I have 3 types of wallrunning for the left side and 3 for the right side
I would still just do 6 "states" like if the camera is in this angle then its state 3 that started and then just send when its ended or changed state
I see, is determining things like which wallruning type should be performed only on the client safe? I'm not very familiar with what things are safe to let the client determine yet.
Couldn't someone use a hack to fake a collision with a wall in a client and then the client might say "hey it's time to vertically wallrun" and the server would do it even though there is no wall there?
I would run states on the animation and all fancy stuff and then the position is checked by the server,
But im not a pro at this
right, do you know if collisions are server authoritative? like if the player puts a fake wall introduced by a hack on the client, will the client run through it as if it wasnt there because the server will not see it? or what happens?
the client will get blocked then glitch inward
i think character movement component will stop there however
i see but someone should not be able to put a wall in a client through a to wallrun upwards vertically right? the client will glitch but they wont be able to suddenly start floating in the air on the server side since the server will autocorrect teh position?
try it ๐ , setup an input bind that spawns a wall only on that client and have client 2 view what happens
how would I spawn a cube in C++ for the client only?
i would make an input bind for the pawn that would just spawn a cube when i hit V or somethinf
input in graph editor not project settings, all input is clientside only
can also make a umg widget that has buttons to spawn diff walls and stuff
Does anyone know how to make like an account system were you create your account, and when your in-game it shows your name you chose when you signed up, something like battle net or epic games
(Multiplayer) ^
oh i see, thanks looks like from the 2nd client it my first client jsut goes through the spawned cubes as if they were not there. Is Spawn Actor from Class what you normally use to spawn something like a cube or any other actors? this is what I ended up doing
I think maybe that's a question for #epic-online-services
this is exactly it
Is it normal when i launch the game in multiplayer , there is only 2 players and their Player ID are 478 and 479 ?
Hi guys! I have been working on a street fighter like game but even though i made a spawn and possess system in the default game mode, i still cant have my other controller to possess the second character even though my keyboard possesses the first character here is my blueprint for the multiple characters so can anyone tell me how can i fix it so that my second controller would possess the second character and make it playable?
You can do things like that if you use replication graph. Then you can create team actor that would be only replicated to the team members.
Shouldn't it be enough to override IsNetRelevantFor?
ReplicationGraph sounds like overkill for this
Well if your started it with 2 players, then yes? Idk what you expected. The PlayerIds are also reassgined when players join. It's not the unique id that they would get if they use steam
Yes. I also agree that ReplicationGraph might be overkill for this thing alone
Yeah unless you're dealing with high numbers of actors or connections rep graph probably is a bit much.
Do you use child actor components?
HI Guys, i have a npc that loses blood when running.. but i dont see it on clientside. so ho can i replicate this decal?
the state where i call it is flee, and it is replicated.. but just no that dang thing there:D
turn on the repnotify
and spawn decals from onrep
or start/stop timer that spawns them, i assume they fade out after a bit
yes i have them with a timer and fade. where can i call the repnotify? it is all called in a npc bp
just swap from replicated to repnotify
and onrep funvction will appear
note: onrep will also run on server
the thing is i cant set nowhere in the character bp something on details. xcept i make a custom event out of it
Guys i am having slight problem.I have two clients in my game and i also set use mouse for touch controls as true.I am having a left virtual joystick but when i drag that joystick it is controlling other client rather than my client but WASD keys are working fine for my client.Plz help me.Thank you
It is also happening for default third person character as well.Joystick is controlling other client rather than this client
anyone any experience with 'allow client side navigation' i'm using it to control 'click to move' player characters in multiplayer, anyone know if it can cause issues with cheating?
Now i got an interesting issue, When i spawn an Actor its correct for the server but for the client the spawned actors inherited components are split (like 100-200XYZ transform) from the rest? ๐ ๐
Hi guys, im working on game, where players can switch characters. How would i make possession? I can't get it to work, because in my case only server triggers possession event, client is ignoring
Is it done through RPC? or how?
I have done multiplayer possession with a multicast RPC
Logically, as i got it, i get GameState and call Server RPC function on it, that checks if everything is okay and then it gets PlayerController and calls Client RPC on it to possess
But something somewhere is not working
Like clients don't even get to Server RPC function
Even though GameState presents on all sides
If I'm right
Just to make sure we are on the same page:
Yeah GameState is present in all clients;
You need to make a call from Clients with a SERVER RPC;
Then the server RPC should make a call to a MULTICAST RPC;
When you call a Client RPC its supposed to be called from the Server to be executed on the client
Did I understood your implementation?
I call Client RPC method from Server RPC method function, is that right?
I just dont get RPCs
But you got it right
I will get to my code in few minutes
why in the world would you multicast a possession?
all the code that needs to run to make it happen is server side
have you done it?
if you need to notify other clients, there is such a thing as PlayerState and OnRep_Pawn
in my case the clients dont change possession until they do it locally
other clients don't even have an instance of the possessing controller
Here's my implementation, i got my code
First of all, there is custom GameState class
There is 2 of them, but i will look at first one
This function is getting called from UMG
UMG gets GameState, casts it and executes this function
2nd signature is wrong
Oh ok, two different players swap between two characters
unless you have split screen
Why is it wrong?
unless you have 2 players playing on the same machine
Server doesn't know about other player controllers?
you will never have 2 different valid PlayerController references on a client
ohhh, i got it
So if i call first function from different client, will it pass invalid controller?
you only have one controller to pass
use PlayerStates
those are replicated, so all clients have them
and server can resolve their controller just by doing Cast<APlayerController>(PlayerState->GetOwner())
It's hard to understand as i only started to work with networking...
Doesn't server replicate all APlayerControllers?
no
it replicates only 1 controller to each client (their own)
but each controller has a PlayerState
and those are replicated
server has all PCs
so it can grab a PC from the PS reference, as PC is the PS' owner
like PCs, PlayerStates are also 1 per player, 1:1 relationship with the PC
Okay, got it
but actually, when i call GameState Server RPC method, it doesn't even get called from client
you can only send server/client RPCs through actors client owns
GameState is not one of them
oh damn! I got it
PC, PS, Pawn, theiir components, anything owned by them
Damn, i just got wrong all the concept of RPCs...
Is this channel the proper channel for setting up steam for my game ?
yes
Can i use GameState to possess PC? Possession is not RPC method as i guess, and server knows about all PCs
sorrry for my stupidity again...
I mean i got that clients do not own GameState, so they won't be able to call RPC function to them
But can GameState make SomePlayerController->Possess(SomePawn)
in not RPC function ofc
Actually i can write down what im really planning to do
Can someone help me fix a problem with my 2nd controller system in ue4?
Ive already posted my problem here but some help would be appreciated
Like we have 4 characters in game. And some players (1 to 4) can connect to server, so they will be able to switch through these characters, because some of them can do something better. Some characters can die and you can get more characters to your team. I need to somehow make UMG that will have buttons to switch characters, so i need player to press on character button and it's player controller will possess pawn
That's in short
.
I just don't understand much, though i watched some YT videos and readed some guides
Its not server or internet related but my second controller is not possessing the 2nd character in my project
Would I need to port forward or something to setup a dedicated server?
Hey, i have a question related to replication.
I have a 2 functions that i use to move around my objects with my mouse.
(see blueprint below)
Do i need to set the 4 variables to "replicated" or "repnotify" so the listen Servers knows this variables?
does anyone have idea to controlling projectile in multiplayer with third person shooter?
since players camera rotation doesnt sync with server so..
basically i did this as simple but thats exploitable somehow.
guess what valo uses method to send players view angle? anyone knows?
thats so fun lol. if anyone wanna brainstorm with me about that valorant uses method to send server player view rotation(angle), mention me please. Thank you.
@bronze arch That looks very cool !
yeah at the experimental because its wasnt finished and unstable, need some idea for make it well
you could just replicate the rotation
but how do you think to send to server for player's rotation ? afaik replication is only work on server to all clients, not client to server.
@ancient badge I'm not sure what you are trying to achieve exactly, isn't setting your object as replicated shares it's location automatically?
@bronze arch check how the controller is replicating the client rotation to the server
its only replicating X and Y vector, somehow it doesnt send Z rotation
thats why i cant control it up or down
IIRC Controller->GetControlRotation should work server-side
thats what im talking, it doesnt work. its only work on character mesh rotation, not the actual camera, also Z rotation wont change, so i cant go down nor up on server.
well as expected because character wont change Z rotation tho...
with quick settings (nvm the async task its just sample)
its look so different tho 
guess the one way is go with rpc 
works great for me in my quick test
yes btw you can see the R= is Zero, thats for rotating up down

Is there such a thing as an RPC call limit or bandwidth limit for RPC?
I have a Server RPC function which I was calling inside a function that pretty much ran on Tick. Even when I completely comment out the contents of the server RPC function, just the act of calling it seems to create position net corrections when I run:
this is just running in the editor btw
oh damnit me, you right, my rotation wasnt work because of using smoothsync, not the CMC replication 
well i tried with CMC its work but im using custom movement replication to avoid high send rate and bandwidth for 10v10 players in match 
for 10vs10 you are most likely fine with the default CMC replication
per instance
and what is that Do Async Task node btw?
its something like event tick
similar but asynced ticking for performance gain purpose
if that is running on a separate thread then it is not safe to use it like that.
You shouldn't read/modify resources from another thread if they are not thread-safe
yes if i do use CMC replication it works, but not for custom movement replication
its game threaded btw, i also tried just CMC without change
if those task are running on a game thread then there is no performance gain from that ๐ค
well thats why its async, not too much performance gain but small.
it just ticks intermittently with the game frame instead of many ticks in one frame
does game instance exist on client?
yes but locally.
i mean on dedicated server
i'm running dedicated server on playfab
does game instance on that dedicated server works?
everyone has game instance on locally, you just cant RPC'ed or replication something on there
i'm getting a variable from game instance and using inside game mode
but it's value is false
i mean the value looks like false from server
in client side the value is true
dude
thats what i mean its LOCAL not in the NETWORK
so you cant read a client variable instance from server
its special for game like
uhhh
@bronze arch
the value is false
for dedicated server, where should i store a variable like persistent variable?
i need a network variable

thanks, i already have this book, will read for sure, can you please tell me a solution?
player controller or state, or pawn
i want to get variable in game mode and store in somewhere
like what i did earlier i saved in game instance, which was incorrect
so where should i store variable?
so it works in dedicated server as well
state means player state or game state?
@bronze arch i think the best solution is to store value in state ( so game state or player state )?
Well, If you don't find out yourself, there's nothing I can do. because we don't even share the same project/mind. Also, it won't help you in the future when you alone.
That's why most of the time I research and do it myself.
just saying tips.
try player state
does variable needs to be mark as replicated as well?
if you set it from server yes, if not you only way to send that variable via RPC to server
i'm just setting like normal method, get player state -> cast to my player state -> set bool to false or true
does it works on dedicated server?
if you know of to get playerstate from your locally controlled character, yes. if no, google it. Also add send to server rpc event on playerstate. Hope that's enough tips for you, im gotta go
i need to set variable inside widget
i mean i want to get player state inside widget
does it works?
well, it looks like i can't able to get player state inside widget
what is solution to this?
@bronze arch
i only see game state inside widget
does game state exist on server? so does it works?
does unreal support ipv6? I'm trying to replication right now and its working for local games using ipv4 address, but I can connect with my friend thru ipv6. am i missing something?
I don't know for sure with ue4 supports connection using ipv6 or not, but it is needed that your host need to be able to reached via a real IP address.
Ie. when I local host a listen server, I need to setup my port forwarding first so my friend can connect with my public IP address.
So if you are doing some prototyping locally with your own computer, try to make the Nat layers as less as possible.(sometimes need to talk with your ISP)
My setup is modemโrouterโpc
I just talk with my ISP so the modem is in bridge mode so it doesn't operate it's own Nat layer
so it my code working then?
also when I put in my public ipv6 address it returns me to the default map not the designated map I chose. is this normal?
I assume if there were any problems it'd be here
stock AStaticMeshActor is not network replicated right?
so I need to make an empty BP actor with a staticmeshcomponent to be able to set replication on them?
my current issue is using AStaticMeshActor the client doesn't see them, only the server instance can see them
So apparently ipv6 and ipv4 work the same way and doesnโt matter? Hmmm
How we that be done in blue print?
@languid igloo the component will replicate with the actor, its on CDO
you can just do SetReplicates(true) at runtime
depending on what you're up to
on the stock actor? the actor that gets created when you drag a static mesh onto the editor
non replicated Actors spawned on runtime won't propagate to clients, but you can turn the replication on per instance
then its part of the package
client should see them fine
where do you set replication on it?
bNetLoadOnClient = true
you don't need it
unless you need it to replicate its own members/subobjects
no it's just a non movable static mesh actor
weird that it's not showing up in client
if its saved with the level
it does, it's placed in the editor
and has bNetLoadOnClient checked (default true)
it should not only be visible, it should also be net addressable, meaning pointer to it can be resolved over network
its no different then your floor mesh in that regard
weird,
it definitely doesn't need to be replicated
I ended up just created a new actor with a static mesh component with replication checked
and they worked
you really don't want to be replicating actors that don't need to be replicated
net broadcast tick time is a thing
and its not cheap
whats the best way to do line traces for replication?
Anyone get advanced sessions to work in ue5 XD
I have not tried with UE5
ALS seems to be working well
just checking, if a server calls a c++ replicated on server event, is ue4 smart enough to bypass the replication? Are there any downsides performance wise? It's easy to do it the other way but it's much cleaner just to have one function that gets called from client or server im thinking
It's just a function call, not RPC. So yeah you can call it manually without any network involvement.
i dont mean if you call the _implementation, i mean if you call the base function which acts like an rpc
might be the same answer just trying to clarify
You are not replicating it AT ALL
Read the Network Compendium that is pinned to this channel.
Second pin from the top
@twin juniper
Hey, I have a problem need someone to help . How can i stop character mesh follow control rotation? It follows contol rotation when my character moving.
The mesh doesn't follow control rotation, the character capsule does
The mesh is attached to that capsule and inherits it
The character movement system moves and rotates the mesh independently for smoothing, so you should avoid moving it yourself for anims etc. Use a bone if you want to do that.
Hey,
Is steam matchmaker able to launch a dedicated server instance on demand and send ip/data to clients in the queue?
no, spooling up server instances is something you have to setup with whatever service is hosting them
Steams matchmaking is just about querying for suitable servers as a group, that's about it.
Process is described here: https://partner.steamgames.com/doc/features/multiplayer/matchmaking#2
I have an issue that I haven't figured out what could be a problem.
Basically I have a Inventory System that I create items hidden at the beginning of the game and I call the item information from spawned item (like it's image, transform, uid, variables etc.)
But the problem is, when I create items at the beginning, Server has no issue but when client spawn items, they only valid for client. I saw the spawned items on Server, I check replication status and they are fine, when I try to take items from ground by Server has no issue, but if I spawn 8 items by client sometimes 3 sometimes 4 of them return as Valid for Client. When I check isValid status of item from client-side, i have no issue and it returns true, but when I call isValid status on replicated on server event, they return invalid. (As I said, I also test replication status and has no issue)
https://blueprintue.com/blueprint/fuf5v3po/
This is where I create items (Create Item event is Replicated on Server + Reliable)
https://blueprintue.com/blueprint/984ambfk/
Here is Create Item Event (TempItem is replicated variable)
Honestly I am not looking direct solution my issue, but if you give me some idea about what could be a problem I could work on it.
Thank you! :)
The problem solved!!!! Thx so so so so much!!!! ๐ ๐ ๐
@gentle depotWhat exactly is that function intended to do? It's named Sort, but it's creating things?
This is just for developer mode, sort is for sorting inventory for players. It's called at construct event of widget. It spawns the items depends on the items he chose before starting game (I haven't sent that part because I only use developer part to make tests) and the sort inventory function spawn items and then sort the inventory by getting information from spawned items.
Basically;
- Player chose the items at the items widget of lobby.
- Then inventory system called at game start.
- Server and Client spawn items invisible at the place they start game.
- Inventory System get the information of items (like Image to Show inventory Block, Amount of the item, Name of the Item etc.)
- Sort the inventory depends on the choice of the Player.
And the result;
But the problem is When I click 1-2-3-4-5-6-7-8 (inventory buttons) for server he has no issue to equip. But when I try it on Client, sometimes 1st 2nd 3rd items works fine but others not, sometimes 1st 3rd 5th works fine, but others not
I don't know if this is bad wording, but it's wrong. Clients never spawn anything.
- Server and Client spawn items invisible at the place they start game.
I know, client send the item list to server to spawn
Ah, noted.
That function you posted, is it ran just on the server, or is it ran on clients too?
Problem is your inventory items will be arriving on the Client at all different times. There's no guarantee they will have all arrived when you create the widget. You should use OnRep callbacks to tell the UI to update based on the inventories current state.
Yes both run the sort inventory function at the beginning, Create Item event is replicated on server
Yes but if inventory has the issue to collect item information, it doesn't get item image too.
Because item images also variable on item.
Yes
So use OnRep callbacks, and when the inventory changes, broadcast an event that the UI has subscribed to so that it can rebuild itself
You can't ever guarantee that the UI will be created at the perfect time, networking is inherently latent and subject to race conditions.
I also check the item information in inventory system and items created and saved greatly on Client-side inventory. This is why I thought it's replication issue but replications seems fine when I test it on server-side
If you simulate that with latency, it will probably not work at all
Okay I can try replication callbacks too :) Thank you, I can inform again with latest results
- Server spawns the inventory
- Client has an 'OnRep', which pushes an event when TArray<MyInventory> changes.
- The UI panel binds to this event, then rebuilds itself based on the current state of the inventory - and also when it's first created.```
or better yet, a fastarray that can broadcast just per item changes
I think this is all BP @winged badger from what I gathered
slightly more complicated, but not by far
assumed it was code ๐ฆ
BP = Multiplayer: hard mode
its doable as long as you have <= 4 players and a small game
i think, was never actually crazy enough to try networking in BP
do you have to keep the array of items synced in order between client and server?
@lusty sky Normal Array will do that by default. At least as far as it can. Usually best not to allow clients to mess with the Array and only handle copies if you need sorting or stuff.
If you ask me, no, I only sync them when the item equipped or drop the ground, because I need to replicated dropped item to see everyone. Other than that status, they always stay still as Hidden at the place they used last.
Hmm If the player moves some items in his inventory and then sends an rpc to stack an item, it will look wierd if you received updated array if its not synced in the same order i guess
For sync I have no issue honestly, when the item returns valid, drop and equip works fine, but honestly I don't understand what the issue totally. Because theoretically everything works fine, and doesn't work same time :)) Half of the items works fine, half not. But I guess maybe spawning items quickly causes that issue, maybe I can create custom for which have a delay on every tick if this is the issue :)
Hmm, what actually happens to the player's possessed pawn when they exit the game/disconnect from the server. It seems to be removed, is that right?
i belive it gets GC'd if its not longer referenced xD
LOL obviously its getting destroyed did you expect something else?
Expectations are dangerous ๐
You can change that behaviour
But yeah by default, the server kills the players' pawn when they logout
Yeah, overriding the function ๐
Curious how the event isn't in blueprint
Gotta expose it
Meh see above RE Blueprint and Multiplayer ๐
Heh, yes
The further along I get, the closer I get to understanding the whole "multiplayer needs C++ mantra"
I'm making a lobby and using BeginPlay in PlayerState to notify join or leave for players, but on the host screen player name property for all clients is empty in BeginPlay but on client screen all names are there! why on host it is not ok?
client name on host screen is empty, but all names on client screen are there
in BeginPlay everything should be replicated, right?
No, no garauntee of that at all
is it a coincidence that it's working correctly on clients?
It works with 2+ clients?
yes when a third client joins, the second item gets a name but the third is empty
I guess it's a delayed replication? but why and all clients get the correct data
Begin Play is called by the GameState when that replicates, so depending on whichever order things replicate in, BeginPlay may be called at different times
To see if it's delay with begin play just add like a 5 second delay timer
And then have the server run that
All clients should be loaded in by then
can't garauntee it though
and it won't work for join-in-progress
using delays to get around race conditions is a quick way to end up with a very unstable MP game
You just need to make the code more resilient to that kind of thing
I meant it for test purpose, certainly not a good thing to keep
yeah for sure
yea actually I'm currently trying to get rid of all timers, so I thought begin play is the way to go
The way to work around initialisation ordering issues is to use OnRep callbacks mostly
But a lot of actor properties don't have those exposed to Blueprint
In fact I don't think any of them are for base properties
I'm in C++ so it's fine, but I want to make like a lobbying system so that when a player joins everyone else is notified
and in case I have many properties, I'll have to depend on OnRep for all ?
this is interesting piece of info that I rely on, it doesnt matter what the order is, I just want to get player state properties in begin play
You should be able to get any of the PlayerState's own properties in it's BeginPlay without issue - but only for that actor.
What you can't do is use say, the GameState begin play, and assume that all other player states will have replicated by then.
ok cool, but I'm using PlayerState's BeginPlay
But the order very much matters - because you could receive another players player state before your local UI is even available.
oh okay, hmmm but my own player state will BeginPlay after my UI is available, right?
and the idea I wanted to implement is to listen to changes in PlayerArray but I cant find a way to!
since it gets filled locally
it get filled via AGameState::AddPlayerState
So you could add an event - but you will also need your UI to wait until the GameState is available too, before you can bind to it
so there is no way to do it without using timer delay ?
you need to replicate it
The way I do it is have a global event that the gamestate calls when it's available. I use a subsystem for that, since I know the subsystem will always be initialised before anything else.
set it to replicate and use RepNotify in BP to update UI , and it will be updated automatically on all clients
you mean I can just broadcast that event from AGameState::AddPlayerState !
there the name is still empty
you should change the value on server in order to replicate, you can read more about replication first
to run that on server you have to make that call from an actor that's owned by the client
use player controller
Character is owned by the controller that possesses it by default and should be fine to make RPCs.
why is it only for that actor? ,,, because on clients they can get all names without problems!
Hello everyone! I am curious to know if anyone has found a proper solution for multiplayer observer cameras after dying. (ie to spectate other players once you are dead and out of a match). I have tried several approaches but they have all suffered from jittery movement on the character being observed. So far using SetViewTargetWithBlend and providing a reference to the players private pawn as the target as opposed to the camera or controller is the only solution I've found that follows the camera's pitch as well, without additional networked data retrieval (though it does not include things such as FoV changes on the observed character when aiming and such) but it still suffers from the same jittery movement issue on the player being watched as the others.
If anyone has found a way to do a proper observer camera that views from the target players point of view (ie shows what they are seeing/ sees what they are aiming at etc, not just following their character), and does not suffer jittery movement issues, and would share the solution (I would be willing to pay for the solution too if can show it working properly in an actual networked setting similar to a real game and not just a couple pawns in an empty scene), it would be extremely appreciated! Thanks.
cmc = character movement component? if youre asking what the observed characters are / how they move, they are character based actors and yes use character movement component
ive tried various targets for the setviewtargetwith blend, ie the characters controller, the pawn etc, so far the private pawn as target gives best results as its the only target object that also lets you see the observed characters camera pitch too
ah does it @meager spade ? ok I will set a proejct up with that and take a look at what they are doing
problem is the capsule is teleporting
and the camera you are observing is likely attached to the capsule
ah ok thats a good point
so your seeing a jump everytime the server sends new capsule location in
camera needs to be on the mesh
so maybe attaching the camera to the skeletal mesh would fix that
as that is what is interpolated client side
ok now i see
I will try that right away
and yes now that you mention it my springarm is attached to the capsule itself, thats probably the culprit!
100percent the issue
Im trying to update the weapon mesh of a component in my actor. I first line trace to find an actor and then get the data from that actor, then set that as a variable which is a struct. That variable is rep notify and in the notify event i call a function called update weapon mesh which just takes the data from earlier and sets the new mesh. However, when the client does this the server does not see the new mesh, but when the server does it the client can see the new weapon. Anyone know what Im doing wrong?
awesome I will make that change and see how it goes, thanks guys ๐
are you making sure the repnotify var is being set by a function running as server? I use similar setup for char customization mesh changes and it works well
and the repnotify ensures that even clients out of relevancy range or who join the game after the change still see it correctly
awesome
Because you're spawning it on beginplay once for each character.
So if you have two players, you'll have four widgets total, two on each player's screen.
That is more of a complicated question than it seems. Realistically this should be called on owning client only through some virtually overridden functions in the possession line. If you're blueprint only, a simple and easy, and fairly performant hack is to just check the local controller's pawn on tick in the HUD class and call functions based on whether that changes.
Anyone know why GetNetConnection() is returning Null on the server?
I've tried grabbing one from the PlayerController, Game State, and other replicated actors. What am I missing? Everything seems to be replicating fine so I'm very confused
Testing in editor on 4.25 as a listen server
All I really need is a UPackageMap though
@lament cloak probably have to interrogate ClientConnections in a different way
I don't know the other way
dig around
is there any way to calculate the delay between a client and a server
like say you have a timer
if I can calculate that delay then cant i just offset the local timer by that delay
ping / 2
as ping is both ways
so ping / 2
is one way
actually I just solved the issue
I was dividing ping by 1000 instead of 10
so if the delay is 2
then I subtract 0.2 from the length of the timer
and end up with synced timers on the client and server
Thanks tho @eternal canyon
F
it does not work noww
wait what
what is ping measured in ?
ms
ping is milleseconds but is represented as an Whole number when shown in UI usually
this is basically what im trying to do
the function is called On_Rep so I expect delay
Well what you wanna do is replicate the servers GameTimeSeconds and figure out the delta to get a synced time that is shared.
So each world (clients, server) will have whatever (based on uptime) but they have another one that is synced.
but im stuck on trying to compensate for that delay
Any business logic on clients uses ActualServerGameTimeSeconds
oh wait
I can just pass the game time as a client event
OnRep of that, you need to factor in the ping/2 (at the time the server starts replicating the timestamp)
you do that once on join
then any time value the server sends should be approximately the same on clients
you can resync the time periodically
Im gonna need time to comprehend this
Hrm
I see what you're doing though and that could work to have the timer be close
it's difficult to perfectly sync things
but you could also send down an event to run a function at a particular time
The standard timer stuff can't do that though
RunEventAtGameTime is nice because if a client happens to be ahead it can immediately fire (or ignore it, if too much time has elapsed)
Im sorry to ask but would it be possible for you to summarise your solution above ?
tell clients what time it is for the server when they join. Store the offset or actual time
use that
Timer Manager doesn't use that and can't be made to use that easily
Hi everyone, I'm using the Advanced Sessions Plugin in 4.26.2 to get dedicated and listen server functionality working. However, while I have dedicated servers working great, I'm completely stumped as to why my Steam listen servers don't show up in the Steam browser, or when using "Find Advanced Sessions". To test, I have a very simple setup. When I hit comma, it starts a session and listen server:
https://gyazo.com/a4039ba44501957b6b569ca1210810de
It appears to create the session successfully and I travel just fine, but when I then check in the Steam server browser, or run a search for advanced sessions within the game, the server doesn't show up. If I run a dedicated server it works fine and shows up. Am I missing something here? All the tutorials say the above is correct...
I am running from a source build of the engine, and I have added the global definitions to both my Target and ServerTarget build files, as well as added the necessary bits to DefaultEngine.ini. I am testing by simply launching the game from the uproject file
Hello guys, I just opened a new project and made almost no changes to it, I followed a multiplayer tutorial and here are my multiplayer settings https://gyazo.com/9cd83fe8216a5004fc03f209d412b817
the problem is the movement replicates on the server side but when I move in the client side the pawn does not move in the server screen
@stone dust which pawn class are you using?
thank you
I did it using the game time from game state in the end
its not perfect but stays close even at 200 ms delay
Just wanted to let you know, the actual ping is that ping value * 4, and you need to convert it out of the byte value as it can only hold up to 255.
that could have saved me a lot of mental damage
oh well
it is what it is
at least it works
What I'm trying to do is use a FNetBitWriter to send some data to all clients. But it's from a manager actor. No client actually owns that actor, so I guess that's why GetNetConnection() on it isn't working
I'm ultimately trying to do something like this, except their example works because they're doing the opposite, sending from a client to server
https://forums.unrealengine.com/t/serialize-a-uobject-so-it-can-be-sent-via-an-rpc-over-the-network/86954/9
In-Case anyone wants it this was the final solution
the pin above the subtraction is connected to the length the timer is supposed to be
so from what I understand, GameInstance is the correct class to use to persist variables across maps
however, I'm having trouble replicating variables from server to client
is it supposed to work?
I'm replicating an array of structs
You can't replicate through game instance. Each copy of the game has its own game instance which only the local copy can access.
You can still store it in game instance, you just can't replicate from it.
for my use case im trying to store a character selection, and in the next map, spawn the actor, but i call the method from the server
which I believe is correct for spawning actors in MP
So the server should call to the appropriate player controller when something is needed. The player controller can then read its game instance, then send back the data to the server on the player controller.
interesting
the thing is, for my game, the player controller is kind of separate from the actors it controls
its a multi unit game
I was thinking of storing netId on the units
so it determines what you can select and control
so youre saying
on one map, let each player make their character selection, store it in each player's game instance, then load the next map, the server side player controller will attempt to spawn the unit based on the previous selection
so call a server only function that takes an argument for what to spawn
and call it from each client
fetching the data from the local game instance?
so its kind of like how input is handled then
ok that worked lol
The player controller should be thought of as strictly the "essence", "brain" or "mind" of the player. Even if the controller is not strictly possessing any specific unit, the "mind" still exists and can exhibit control over what you allow it to.
Ideally you wouldn't allow your player clients to store their selection as that means they can attempt to manipulate the value locally in their memory --- as an example, let's say you had a multiplayer game where each character could only be selected once under normal conditions but someone keen on cheating could manipulate the value they have stored and then allow them to spawn as something they shouldn't be allowed to spawn as since someone else already selected it.
That being said, yes, you can store the value on the game instance and then have the server request from the clients for their selection.
yeah, I get that
for my game its probably okay, considering its a co-op game
but I can see how that would be an issue in a competitive mp game
whats the right way to do it?
If you're doing a lobby-like game where players can't drop in, then I believe you can use seamless travel which can make the player controllers and player states to persist. So then you have your players connect to the server - make their character selections, then all of them move to the new map. So your server can store it on the server copies of the player states of those players.
ah
yeah I remember having some issue with seamless travel
Ill have to look into it
good to know though, thanks
which class is the appropriate class to use as a container for game wide replicated variables?
is it game mode?
not cross map, just in general
Game State would be best
ok
Game Mode is not replicated to clients.
only game state?
Well I mean... You could use an actor placed into the level and replicate from that, but Game State is already available and meant to be used as a means to replicate stuff that is common to all players.
makes sense
ie. Team* Scores
was mostly curious if that was the only one which was replicated, amongst game mode, game state, and game instance
yes out of those, only game state is something that is replicated and can be accessed by all clients.
Game Instance is like the "game" copy itself - accessible only locally, and even clients have it.
Game Mode is only available on server in multiplayer. It doesn't exist at all on clients.
Game State exists on all, and is common between all connected clients.
So anything replicated on Game State will exist on the client versions.
kind of random but have you ever had issues setting a custom game state?
I set it in my project settings and in my game mode (also a child class)
and its always returning game state base when I call get game state
is it per map or something?
If you used game mode base for your game mode, you need to use game state base.
if you used just game mode, then game state should be used as the parent class.
got it, thanks
HI, how can i replicate this?
Client -> Run on server -> Multicast -> Spawn Decal At Location
I believe this is known as RPC cast
can i call it in th e npc bp or only in the World bp?'
You can call it in the AI's blueprint if that's what you mean
That said you can skip the RPC cast and just multicast it if it's called by an AI
i got what you mean, but this node dont offers to change it to multicast from itself. thats why i struggle here a bit
alr im confused as hell, is unreal "replication" and "listen client servers" only local, like LAN over wifi? How do you make a true online game then without using steam or dedicated servers?
I'm assuming you're using beginplay or event tick
In which case you'll need to create a new custom event that calls multicast, and then point to it
listen servers aren't local only
Anyone has any guide or article about how push model works
Hello everyone.I have a gun skeletal mesh actor and it is not replicated.the socket transform of that skeletal mesh is not same in both server and client.But the skeletal mesh transform and actor transform is same in both server and client.I am using that socket to attach my camera during scope action.I am problem with it.Thank you
how do i know if they are working online or not?
i have had many successful attempts or wifi but never across multiple network connections
Hello guys.I am currently developing a game in ue4 dedicated server method.But I am having some problems with socket positions.Is there any way to visualize the server pawns like how they look and their state.Thank you.
skeletons are disabled from ticking on dedi by default iirc
https://streamable.com/0n5gr2 Is this about the same? I think we have a similar issue. Somehow it only updates after recompile at runtime and after that it keeps running and updating the socket just fine
Incase you still need a possible fix like the issue I had above ^ try this under optimization in the skeletalmeshcomponent (I had issues with sockets syncing due to that)
@twin juniper you need to make sure the mesh is set to "always tick pose and refresh bones" in the "optimization" section. By default meshes are set to only refresh bones when rendered ("always tick pose") but since dedicated servers have no renderer then the mesh is in a permanent t-pose
You can change it at runtime as well if you want to only enable it for a period of time (e.g. during an attack animation)
Unless you need socket positions to always be updated on the server then enabling/disabling it when needed is a good way to avoid too much overhead on the server
right now we do an if iOS{DynamicallyLoadedModuleNames.Add("OnlineSubsystemIOS");} else if android{DynamicallyLoadedModuleNames.Add("OnlineSubsystemGooglePlay");} in the build.cs. on a kindle without the google play framework installed we get a startup error message stating that google play is not supported on the device. is there documentation on where and how to check the available subsystem before the error message pops up to change the subsystem to null to avoid the error message?
It throws an error message so i think there should be an exception that gets handled via showing the error and changing the subsystem or disabling its features. i just dont know how to find the code responsible for that and i hope i dont have to edit engine source.
"[Game Name] won't run without Google Play services, which are not supported by your device"
Hello, i am using the advanced sessions plugin for game sessions on steam, and some players are reporting that after a while they are disconnected from the session.
Does anyone know any possible cause for this?
Do you use the 'Create Advanced Session' node/method or 'Create Advanced Session Dedicated'?
In our case the Dedicated one works perfect and the other one we haven't got to work (still have to look into that one). So yeah not exactly the same issue as yours but maybe it can help ๐
oh, I use the first one, Create Advanced Session
I think I found out what is causing me such a huge headache. Inside editor it works, outside it doesn't. What suddenly becomes active outside of editor -> SteamParty.
This could cause 2 OnlineBeaconHost implementations to become active. I don't know this but maybe that is a bad idea ๐
If I may ask? What settings do you use for Create Advanced Session? It has quite a bit of options
Create Advanced Session Dedicated has a lot less options. So I would definitely try it out for your dedicated servers ๐
@thin stratus so yeah I'm not there yet. The TestBeacons you found are pretty similar to the PingBeacons I found. But it was while I was looking at the TestBeaconHost I noticed it inherits from OnlineBeaconHostObject.
Talk about being confusing. Then I noticed pretty much nobody inherts OnlineBeaconHost. It's this that got me thinking maybe the problem lies there
But alas not there yet :/. It simply refuses to work outside of editor still.
hey, i have this funtion that is hooked up with a event tick.
https://blueprintue.com/blueprint/r_qd_f55/
For some reason the "Last Card location" isn't replicated to the Listen Server. So the Actor i'm moving in my Second Player isn't moving on the fist player( the listen server)
I'm using blueprint to do, here is the node
Do root motion montages work with "Run on server" type multiplayer? the animations arent playing on the client side.
Can someone point me in the right direction for dedicated server hosting that works well with unreal engine games
Nice okay
I'd try the dedicated node if I was you. Of course only for your dedicated servers :)
Is there a discord for advanced sessions plugin
For some rason I thought there was but I cant find it ๐
So using a dedicated server host...isn't each 'game instance' require its very own VM
I have two players in a local multiplayer game using controllers, and for some reason, the second controller does not get input
When I use a keyboard and a controller, they both work as intended
What could be the cause of this?
This function is how I find out what player answers first
Small heads-up for everyone actively reading this channel right now: We are splitting the Online Subsystem, Session and Beacon topics from #multiplayer .
The new place to discuss these will be in #online-subsystems
Please re-direct users if you see them not finding the right channel (: And do so kindly!
Yes
Yes advanced sessions is built upon online subsystem
#multiplayer should now "only" handle general Local and Online Multiplayer. Which mostly boils down to replication and the network gameplay coding.
I am trying to modify the spine bones to correspond to where the player is looking. I found a tutorial online but it doesn't really work for multiplayer. So I tried making a replicated rotator in the character bp and and tried to reference it in the animation bp but it says its not in scope. Is there a proper way to do this or does somebody know a tutorial that works for multiplayer? I havnt found one.
I think if you want to use variables in the AnimBP states, you need to have member variables and fill those from the Character
So you can't use your Character reference and get the rotator inside an anim state
You need to grab it in the EventGraph and save it to a variable in the AnimBP
But either way, the look rotation should be available via GetBaseAimRotation @wispy path
it has replicated pitch
Ah that was incredibly simple. Thank you
When using either subsystem(right now the default one), and opening two separate instances of the game in any mode (PIE, standalone, packaged, etc...), why can I control the character in only one of the instances, and not both?
My setup goes like this:
A gamemode blueprint, a gamestate blueprint, a gameinstance blueprint, and a player character blueprint. The player character is controlled via the Enhanced Input System and takes the player controller ID from the gamemode, which itself uses OnPostLogin to add the new player to an array and then cast that index to a newly spawned player character. I have player spawns with tags from 0 to 3 and I'm trying to use them via the FindPlayerStart node.
Here's the blueprints:
Sorry if the english is a little broken, I'm just very tired.
Your PlayerIndex that you feed into the PlayerController and PlayerCharacter nodes is wrong
The Index on those nodes is for Local Games
You should use 0 as index
And that is also kinda wrong
I used 0 as well and it gave the same result
If you are inside of a Character, you can use GetController to get the relative controller of that
And that also only works on Server and owning Client, cause GetController returns null on other clients
And then BeginPlay is too early to get the Controller, that's what the Possessed Event (server only) is for
It's triggered by OnPostLogin
I would also check if you have the same issue without the ALS system
Well, no you have code in BeginPlay of the Character
And why is it even trying to get the PlayerPawn
You are inside of the Character
Like, just use "this"
or "self" in BP
That is as redundant as it can get haha :D
Also, ALS isn't in the project
I honestly tried every combination of nodes and just left it out at this
PlayerIndex used wrong. Then getting the ID from the Controller, which is the PlayerIndex, and then getting the Pawn, that you are already in
I suggest stepping back from that BP and using a simple Character that has basic Movement Inputs
The entire thing is a mess but I'm just trying to get all the players moving lol
And then getting back to it once that works
In addition you should make yourself familiar with the Functions you can override in the GameMode
There are a lot of functions you can use to just spawn a Character
The way you currently spawn it you can just leave the DefaultPawn as that class
And not spawn manually at all
Ah well you have custom spawn points
You can override the FindPlayerStart or ChoosePlayerStart functions for that
and ShouldSpawnAtStartSpot, or the first 2 won't work ๐
Oh.
Yep, seems like the player controls work just fine in a LAN listen session with two instances open of a default third person project
Thank you guys for helping
I'll get learning :)
I've been having troubles changing a value on a clients PlayerController through BP..
I'm basically spawning a player using a UMG widget based on which team they select. I set the PlayerController's TeamID before I pass it to my spawn function, but once inside the spawn function it's showing TeamID as the default -1 that's set in the constructor and not the value we passed in. It seems to work for the server player but not the client
TeamID is replicated. I've even gone so far as to declare a BlueprintCallable function that sets the TeamID within the PlayerController itself but I still only get -1 when spawning as a client
Am I just approaching this the wrong way?
@fierce elbowYou're setting the value from input. Input is on the client. Spawning is done on the server. Server has no idea or care what the client's value is. You have to set the ID on the player controller on the server.
Replication is one way, Server to Client. The one and only way a client can ever talk to anything else is through a ServerRPC through an Actor that the server has set that client's playercontroller as the owner of. Clients cannot do anything else. Anything done on them will be ignored by the server, or overwritten from the server onrep if that value is ever set on the server.
Ahh yea, I'm still pretty new to C++ in general and I just assumed because I was passing the controller to the function afterwards that the changes would be reflected, but I guess it's still going to grab the server's version of that controller and not the clients version.
I added a team parameter to the function and set the teamID on the server in the spawn function and it works now.
Thanks for your help (:
Can someone tell me if a player reaches a certain ping limit he is disconnected from the server?
I did not do it myself but I think we have it set to 300ms. Maybe it is through advanced sessions and the default is even lower?
Do you know where I can set this?
If I am running a function on the client, and I need to send the output to the server, what replication type is that? Client RPC?
@regal sand The type is always the destination. So in this case if your client wants to send something to the server, you need a ServerRPC.
Ok cool. thank you
Can I write that function in the gamemode, can call it from the client, using it in blueprints
No. It was the lead programmer who told me about the limit. I can ask him on monday ;)
I would be very grateful if you could ask him
on the server all player states have a Net Mode = NM_Client , right?
no
server will have NM_ListenServer or NM_DedicatedServer
what made you come to that conclusion?
because there's the HasAuthority() I thought it should be different!
I mean when to use the Role and when to use the net mode, there's no difference then, right?
there is a lot of difference
an Actor will have ROLE_Authority on whatever spawns it
so a client can have ROLE_Authority actors.
when connected to a multiplayer game, you can always rely on GetNetMode to return NM_Client if its a client, or < NM_Client for any type of server.
but roles are also crucial
ie, if an actor is LocalRole ROLE_Authority and RemoteRole is ROLE_AutonomousProxy, then we know that actor is the server version of a clients locally controlled actor.
if LocalRole is ROLE_Authority and RemoteRole is ROLE_SimulatedProxy, then we know this is the servers version of a replicated actor that simulated proxies see.
like a player controller yea, but on the server the player states of all other clients would have NM_ListenServer or NM_DedicatedServer!
You can't have different net modes per actor
that is not possible
netmode represents the local program's mode of operation
it doesn't say anything about the actor
the server will always have NM_ListenServer or NM_DedicatedServer
GetNetMode is based on the NetDriver
not the actor.
Single player, non network game, will be NM_Standalone
so yes, the server will have NM_ListenServer or NM_DedicatedServer for the playerstates as you said
it will also be ROLE_Authority
on the actor.
yea okee, so I'm iterating over PlayerArray and I wanted to know which player state is the host's one
you cant do that ๐
tho granted host is normally the first one
but i would not trust that
yea because it doesn't replicate same order everytime
ah yea it gets filled locally, I meant like when the GS does
when a playerstate replicates, the PS tells the GS to add it to the PlayerArray
but why cant I check for the net mode here?
anyway to find the host, you need to cache who the host is
cause it does not work like that.
btw listenserver is always the host
if your dedicated server, you have no host.
so not sure what the problem is?
yea I don't have a dedicated server
you mean you want clients to access the host player?
that sounds like a bad design choice, unless its for a widget
the thing is: I wanna make a lobby when the host can have a kick button on all other players but not his own item in UI xd
then like i said, you want to flag the listen servers playerstate with some bool.
We use steam, and i have a function that the UI asks steam who the lobby owner is, and sends in the users steam id, this returns true if that is lobby owner
so i can show the kick buttons, etc
hmm nice xd, I use steam too, but idk, I didn't want to put subsystem code in UI
wrapper functions ๐
you could cheat a bit
if GameMode is valid
you are host
if not, you are not host
job done, hacky af, but it will work.
haha koool
works ok for listen servers
another thing you can do
use the IsServer bool
if that is true, show kick buttons
else, dont show them
a non-hacky solution
that bool is in steam right?
no
right click any BP
and type IsServer
if that is true, show kick buttons, else don't
in c++ it is in gameplay statics?
or just do GetNetMode() != NM_Client
in the widget
bool bShowKickButtons = GetNetMode() != NM_Client;
oh that's why I started to ask here cause I used that but it just hides them all
that will not hide them for the listen server
listenserver netmode is always < NM_Client
unless you never join into the game
and this is pure lobby
if you are not connected to the host, via open <steamid>
then you need to mark the playerstate of the lobby owner
and check that.
yea true, though I get the net mode of the player state from PlayerArray
thank youuu, I will try these solutions and see
heya, I've been researching this the past couple of weeks and I'm wondering whether there is a best practice for this.
In the multiplayer combat action adventure we are making the attacks move you forward similar to how it is in Dark Souls or Fable. You can chain your attacks, which means you can interrupt your first attack after a point and start a 2nd attack.
The problem I'm having is that if I use animation root motion then there's gonna be a desync as the client interrupts it's own ability, that the server receives later, so root motions do not end at the same time, hence why the desync.
Am I doing something wrong with the animation root motion cancelling or is this a scenario where they are not as useful for network replication?
Anyone know why calling "DestroyComponent()" from a server function isnt replicating down to clients? Trying to destroy a sphere collision thats being used to test overlap for picking up items, goal is to prevent equipped items from being picked up. Currently the comp gets destroyed on the server but still exists on the clients allowing other clients to yoink the item from the players hands/body/etc
I'm totally not sure but afaik components are not replicated like actors on spawn/destroy
Actually that makes sense since components are initialized on actor spawn, Epic might never needed to replicate it
So you might need to use a multicast
@peak sentinel hmm interesting, I will keep messing around with multicasts and see if I can get that to work. thanks!
Dont forget to check if the component is valid or not on multicast
Only attempt to destroy component is valid
Good luck
disabling collision via rpc or a bIsEnabled repnotify might be quicker then creating/destroying a component during gameplay
@half jewel yeah I think any of these solutions would be fine, just having issues getting anything I do to this component to replicate to clients, whether from server function or net multicast
Hello, i am receiving a warning on output log saying that there's no owning connection for actor and a function won't be executed. Anyone know how can I solve this?
That message usually has to do with RPCs on actors that are not locally owned. eg. A server spawned copy of an actor that is trying to call to owning client.
https://drive.google.com/file/d/1wR-JgeCyb3qaftfpxvXJIqTvkkgtQv9d/view?usp=sharing I have an AI using a standard Behavior Tree node (MoveTo) but it looks like it's rubberbanding, the AI is just inheriting from ACharacter so I don't know why it's behaving like this, first time I have to deal with this
Just filter the overlap. Put the larger overlap area on the character. I use a different collision profile for equipped and in-world items so they don't even show up
So I'm at the point in my game where I'm ready to start setting up a dedicated server to host game sessions for players. I've taken a couple of courses and did some minor research here and there with the overall functionality of unreal's built in multiplayer features. However, I haven't really found any clear examples of how to set up a server / client model that allows multiple connections over internet or just over LAN. Are there any built-in unreal engine functions or BP nodes to allow you to send and receive objects or other data to another separate unreal project? Closest I found was a plugin called Object Deliverer, but haven't been able to get it to work over a LAN connection to my server running the other unreal "game"
If you're just setting up a dedicated server, why are you trying to communicate with a separate project?
Let me get this right. A benefit of a dedicated server is that it doesn't have to render the game, only crunch the logic and replicate data to clients. In theory, does this increase performance of the logic then?
It means the process has to do less overall. That may increase performance (if the game is gpu-bound), but it also means the hardware requirements for the server are lower (no GPU required, more servers can fit on a single VM/machine or you need a smaller VM size/lesser hardware).
Anything related to visuals (that doesn't affect gameplay) can also be turned off which means the server has to do even less.
I need to hire someone or a team even to do networking ugh
Listen server stuff is simple enough I can do most of it..but when it comes to managing a dedicated server I just ...idek where to begin
Im at a part where I am just seriously overwhelmed. I've done everything myself and now I feel lost and have no idea how I am going to do networking
Hi Guys, does anyone have any links where i could learn how to expose some functions from the steam API to blueprints , i have no experience with C++, So far i have learned how to expose a function to blueprints, but to use the steam sdk and expose its functions looks very complicated to me, any help would be much appreciated !
I never developed someting for a dedicated server but it should be simple as
if(GetOwner()->GetNetMode() != NM_DedicatedServer) // if nm is dedicated server dont run
{
// something related with rendering, particles, decals etc.
}
Check out Advanced Steam Sessions
It should be exposing them to BP
Man i was doing that just now haha, I'm overwhelmed with all this information man... I will graduate next year, i've learned java and i thought i would be able to learn the different aspects that C++ has, but honestly man... I feel like i can't call myself a programmer, C++ is SO different from java there is so much stuff that i never heard of, i'm feeling really sad today, this is the first time i feel like i have lost all hope๐ข
Never worked with Java, but from what I've heard its just very similar to C#, UE's C++ workflow should be easy to understand after a while
Check out Cherno's youtube channel, he explains core structures of C++ very well
you dont really need to do much special gameplay code wise for a dedi though, is there anything in particular you are stuck on?
It's really just trying to find a host and how all that works. I have no idea how to manage running a game on a vm
it feels so daunting
Ah yeah, that can be annoying. It's often easier to just grab a spare computer and throw your dedi on that especially at first
or running it in the background on your dev machine can work too if you only need the server up now and then
@round star don't be discouraged - it's not as difficult as your mind might make it out to be ๐
you don't have to do pre-hosted cloud servers like AAA games do... self-hosted dedicated servers (used to
) exist too FYI ๐
sounds like you're trying to wrap your head around building your dedicated server package and also renting a VPS or something to run it
@edgy valve @peak sentinel Try to use and redirect to #online-subsystems for this in the future please (:
Okay eXi, thanks ๐
Hello, can anyone tell me why my "Print String" is giving me the right numbers for the "host" player but only 0 on XYZ for the "Connected" Player?
This is inside of the "Player Controller BP"
Trigger Event is a RPC with "Run on Server"
The server wouldn't know about where the mouse position is on a client's screen. You'd have to replicate the position (and direction) through your RPC.
@sinful tree So, make them to a Variable and set them to "replicate"?
Setting a variable to replicate means that the server when setting a value on a variable will set the same value on the client. You're trying to get a value from a client to the server. Add vector inputs on your "Execute on Server" event node.
Then you can pass the values from the client:
Then you'd have to add those inputs on to your function as well:
@sinful tree Thank you very much! i checked all my variables but never even thought about this two.
@twin juniper You're welcome! Good luck!
Thank you
What is the default region (the one you set in the downloads tab) when you create a session on steam server browser?
and where can I change it
is there a special way I should be passing actor references to a net multicast function that gets called from a server function? The server function spawns an actor to the world, and tries to pass a reference to the net multicast function, but the reference is invalid for all clients but is valid for the server
^ still not totally sure what the problem here was but I fixed it by calling the server function from the actor itself rather than the character/actor that owned it
I'd be careful I don't think there's any guarantee the new actor will be replicated before the RPC is sent. It will probably break in weird and wonderful ways.
Better to decouple it. Create the replicated actor on server, and in BeginPlay on clients have it register with some system that needs to know about it.
Or store pointer to the new actor in a replicated var and it will eventually resolve on clients it is relevant for.
Hello, in this current ,,system" my server is able to do everything as planned (dig up a chest), and the client sees everything. My client can dig up that chest aswell, but the server does not see it happening. How could I let the server see the change aswell or just always let the change happen on the server?
@hollow flicker You shouldn't be calling server RPCs and then doing the same thing on the client. Not without a thorough understanding of prediction methods. Keep things simple. Handling controls like this in the overlapped actor can work, but you also need to handle how your RPC to server. For instance here, with your exact setup, if your client walks over this actor, even your server can press Y, cause you're enabling it on that client and the player0 on the server.
Also here, if your client overlaps and presses Y. What is happening and why the server doesn't see it, is that you're pressing Y, calling a server RPC, then doing the logic locally. The issue is that the RPC is never going through. That client does not own this actor, and therefore cannot send RPCs through it. So the RPC never actually happens.
@twin juniperPart of your issue is calling RPCs shortly after spawning. RPCs are sent and forgotten. If the RPC arrives on the client before the actor replicates to it, the pointer won't be valid.
Come to think of it, I suddenly remember he told EasyAntiCheat does this. Do you use an anti cheat system?
I now disconnected the event calls from doing the logic locally, but now the client obviously cant do the logic anymore. How could I make the client do the logic now?
It would be weird if advanced sessions disconnected players by default for high ping
@hollow flickerThe client would need to own the actor to call RPCs from it. You can set this on the server from the overlap, or you can reroute the RPC through some more generalized function in your client's controller or character.
I'm having a similar issue to Bruce. My client cant see the server attacking, but everything else seems to work fine. Here is mine to add to the picture. This is all in the Character Blueprint.
How would I set the client as a owner after the overlap?
Can more than one Client use that Actor, Bruce?
You could make an assumption that if it's overlapping on the client, it'll overlap on the server. Can be safe for handplaced things. You just set the owner as the overlapping character's controller. But this will lead to issues with the last or first character always having control.
Like, can 2 stand in the Overlap and interact with it?
Generally, there is little need to set an Owner on overlap, unless it's an Actor that is picked up and only belongs to one player for that duration.
The better idea is to have a place in your Controller, or a Component on that, through which you route RPCs
And to already RPC in the Character when starting your interaction.
E.g. Press E -> RPC -> LineTrace
or Press E -> RPC -> Interact with current overlapped Actor
The RPCs shouldn't need to happen in the Actor you overlap
And it will become problematic if you have an Actor that needs to be interacted with from more than one Client at a time
Because only one can own it at any given time.
It's safer to just not use the SetOwner function then, and RPC in the Character/Component/Controller/whatever fits your system
@thin stratus Two players could stand there and interact with it, yeah. I didnt know there could only be one owner at a time, just setting the owner probably wouldnt be a good solution then. How would I go about routing RPCs through my Character?
I'm having some trouble debugging an issue here
I'm working with Logic Pro, and on a state, I am choosing a waypoint to move to, and then traveling towards it
Here is the logic for choosing the waypoint
The problem is, that the point chosen in the Chose Next Patrol Point function, and the returned value in the state are often different
As said, when the Player presses the key to interact, you can instantly RPC to the Server in the Character and then do the rest
where in the code does the client send the request to join the server?
i want to change the login URL that the client sends
You mean when you call JoinSession?
is that what its called?
Idk what you are doing so
How are you connecting to a server to begin with
open ip:7777
Then you can just pass stuff along there
open ip?Key1=Value1?Key2=Value2
But you need C++ to retrieve that in PreLogin and Login in the GameMode
There are other ways to do that
You could just override how the PlayerName is returned
i'd prefer not to
Why is not sending the computer name important?
When I now press the key in the character, it calls the event in the actor blueprint. Is that what you meant?
my playtesters dont like it
Well yeah, but instead of calling it directly in the Actor, you RPC in the Character and then call it on the Actor
Hmm, are you using their computer name as a "player tag/ID" in game?
im using PlayerName from PlayerState
the client seems to send the computer name as part of game mode login
For test builds that are not implementing a specific / finished subsystem, I usually just assign random names and store them
The online subsystem eventually takes care of that (steam/aws/etc)
i might end up using the null subsystem
or whatever is it whenever you dont use one
and just join by IP
are the unreal docs down?
their websites have been rocky this past week, a lot of 404's
eugh
Either way, I'd just assign them a random name on join and use that instead
until you have a production-valid user name assigning method, their names don't matter
im just curious like, where in the code
Best thing would be just override the part that forwards the PC name
yes exactly
that's what i want to do
where in the code does it send the computer name as part of the connection URL?
on the client side?
i found where it receives it on the server side but i cant find the code where it sends it on the client side
I would check the LocalPlayer class
That, and/or you might be able to find it by searching the declaration of the open IP command , then follow that line of instructions
open ip is a bit overdoing it
Becaues that's really hard to follow
Just check the ClientTravel function and go from there
Sits in the PlayerController