#multiplayer
1 messages · Page 469 of 1
as for child actors, i am not sure how they fit into all this
you can reference the ChildActorComponent that holds them
i don't no @winged badger
well, that class either doesn't inherit from UObject and it should, or its missing an include in the header that lets the compiler know that it does
i never attempted to source build 4.21 so can't be more help then that
@opaque flicker both your server and client do know how to get to the door locally
so I have to add Uobject
so if that logic were to be in a WallActor, instead of the DoorActor
it will work just fine
@hasty orbit if you are not a programmer, then good luck 😄
I use unreal engine for a 1/2 years
it's the first time I'm doing a dedicated server
but visual studio almost never use
@winged badger thank you man for the reply, but the weird thing this problem doesnt happen while running the game in editor (With dedicated server up), but this only happens in the game dedicated server build
that kind of thing happens often enough that it is no longer weird 😦
yes
it compiled @hasty orbit ?
yes
😃
it displays ready
nn not the build
😩
bottom right of the screen it reads ready
what is the difference between building and rebuilding
@winged badger
I want to try to rebuild but I'm afraid to make mistakes
Something I don't get. I want to MUTE a player (W4lly63), instead what happens is:
- They get muted.
- They get unmuted.
- I can hear them in game.
This is the code I'm using:
Printed on screen I see MUTED: _SCAR -now muted: true.
I'm seeing this in the logs:
[2019.06.09-11.44.02:968][893]LogOnlineVoice: OSS: Muting remote talker (W4lly63 [0x2A57C100])
[2019.06.09-11.44.02:968][893]LogBlueprintUserMessages: [None] MUTED: W4lly63 -now muted: true
[2019.06.09-11.44.03:037][904]LogOnlineVoice: OSS: Unmuting remote talker (W4lly63 [0x2A578AA0])
What am I doing wrong?
Can someone point me in the right direction, I've been at it for months now...
Hi, anyone got some guidelines on how to bitpack my data so when sending data across network with RPC or replicated? I know C++ have bitfield but not sure if it is directly supported in ue4 or do I have to declare usigned ints and write to it using bit operators. All help is appreciated 😄
if you're doing it so that the payload is a struct, just implement a custom NetSerialize
recommend taking a look at EngineTypes / FHitResult::NetSerialize for an example
if you want to send a uint8 or some such instead, then its just a matter of using some bitwise calculations
it doesn't have anything to do with UE supporting it or not, as you send a unit8 packing up to 8 flags and its your own logic that packs and unpacks them
thanks for your tip, do you recommend manually packing or using the NetSerialize?
unless you're using it for other stuff and not just the RPC
i'd go for struct with custom NEtSerialize
i have a variable for example, uin8, that is holding flags for every way my character can get incapacitated
and then its already there, so its easy to just send it if i have to
this clears things up a bit, thanks alot man 😄
i hope doing this with delta compression and using a sane relevancy logic will save some bandwidth
Hello everyone,
Currently i am having issues with server events that need to be called by the client.
When the server calls it, all the clients get repnotified but the client cannot seem to call that same event. (run on server event)
i'm bad at explaining, if i could screenshare my situation with anyone for a minute, i would be eternally grateful!
https://gyazo.com/c328ec556aca0c30436a4d1e88c4e0fd hi everyone I'm playing around with the advance session pluggin and when I package the game I got this
Advanced Sessions Plugin
Message to users 09/08/2017
I'd like to note that the original intent of this plugin was to shore up blueprint support for sessions
this it?
@ember needle Hey Roberto I think it's close but not exactly the issue I'm having, I can actually package the game but when I run it, I get this pop up, I installed the plugging like this https://gyazo.com/d993cc80b0852fdc587b80d2a70eee3f but it was packaging before and I was able to run it
@ember needle as soon as I changed this I got the issue I think https://gyazo.com/bb316c607d87d052c2ab84776ea8785a check the top right I'm using a different parent class than the default instance I had in the beginning
Why can't the client call this?
when the server calls it, the traffic light turns on. when the client calls it. nothing happens
the int = int is to pair the switch with the traffic light
because client doesn't own a switch
you can only use server and client RPCs inside of actors that are owned by the PlayerController
and their Components
nvm i get what you mean
and the output log prints "no owning connection for..." in yellow
also, don't get all actors of class then iterate over all of them, use a SphereOverlap
and the RPCs can have inputs, so you can send a reference to the trafficlight, or its ID through the RPC instead of looking for it again, with allactorsofclass, on the server
but the RPC itself needs to be in PC, Pawn, PS, or something that is owned by any of those
thanks! ill look into it. its quite confusing but i'll probably manage
I have a weird issue:
Multiplayer, third person, on the client the character mesh (standard character class) jitters as if its movement wasn't replicating properly.
This doesn't happen on server or for the client mesh on server or for the server mesh on client.
Movement of the actor itself is smooth. Only the mesh jitters.
Also, the jitter only happens when the fps of the client is high. If I limit it to 30 for example it works ok.
I tried adjusting replication settings of the actor and optimization settings of the mesh, but it didn't help.
Any suggestions?
turn off replicated for all scene components that are part of the class defaults and have no replicated variables/RPCs in them
they do not need to be replicated, but can cause problems when they are
(as in, there is no benefit whatsoever in replicating them, they get created client side just fine, and they can be referenced over network even when not replicated)
I will try that. I vaguely remember having to enable that for some reason 😃
also, even for those that should stay replicated, turn off replicate movement unless they need to move independently of the character and its skeletalmesh/animation
@winged badger thx. that fixed it. Honestly I don't even know what I was replicating it. Seems obvious not to do that.
Quick question : on a remote player, what's the owner of another player's pawn ?
Owner is replicated, but the player controller isn't - would it be nullptr ?
controller will always be null on other clients
server and owning client have access to the controller
Yeah I'm aware
so yeah would be nullptr on other clients
So GetOwner() would return nullptr on a remote player
if the owner is a player controller yes
Thanks !
How can I replicate a player's inventory component (custom component I built) only to that specific player client? If I replicate it as a normal variable, that could allow potential hackers to see other players inventories correct? To combat this I want to only replicate inventories to the owning player
@lucid vault you can use conditional replication
Detailed information about how to conditionally replicate Actor properties.
@copper mango Thanks for the info. That would definitely work for only sending the data to the player. However, after doing some more thinking, I realized that there are times in which the player inventory should replicate to others; such as when the player is killed and someone attempts to loot them. The system that I am thinking of is essentially have "authorized" players for each inventory system. These authorized players are the players that the inventory will replicate to. For instance, a chest with an inventory system component will not replicate it's inventory to any actor that i s not authorized to view it's contents. In order to authorize yourself to view it's contents, you must 'interact' with it first.
This is the system that I am laying out for creation
Now here is my question: how can I replicate only to owners of specific player controllers that I specify (and can change at run time of course).
I didn't see an option for that in the link that you sent
You can use a custom condition
I think?
If it’s an Actor there’s also an IsNetRelevantFor function you can override
Which gets a player controller who you’re checking against
I'l take a look at those options
Somebody said quote "By default, the COND_CUSTOM is not per connection. It just allow you to send or not the replicated data based on custom algorythim but not to choose the connection on which the data will be replicated."
So it seems that won't work for specifying clients
Well
I'l look at IsNetRelevantFor
It’s just the condition can’t change per client
So for example if your condition is “owner is in this tarray”
That’s fine
Oh
That's confusing. When he says "not choose the connection on which the data will be sent" I assumed that meant that it will be replicated to everybody
No, it’ll only replicate to whoever passes your custom condition
They just mean you can’t do different conditions based on whether the remote is autonomous or not
It has to be a simple Boolean expression basically
I think
If you want to do something more complicated then IsNetRelevantFor would be the way to go
I will probably just test if the player is in a tarray of authorized players
Hi all, I'm trying to get player meshes to appear for other players in my FPS, so I put in the third person mannequin mesh into my character bp and checked the Owner No See bool. That works fine, players can see each other walk around and whatnot, but how would shooting work?
My assumption is players still shoot out of the FPS gun but wouldn't the FPS gun and the gun on the third person model be in different locations?
@copper mango I'm having trouble finding an example of COND_Custom. It's says SetCustomIsActiveOverride is used for the on/off (replicate/not replicate I assume), but where does this function come from?
Maybe I feed in a custom function as a parameter in the DOREPLIFETIME
@granite peak check out Shooter Game
it does exactly what you would need
FPS shooter networked
is that in the market place?
aye thanks for pointing me to it tho i appreciate it
i understand C++, but i'm farrrr more used to blueprints lmao
at least ue4 c++ is scary to me
but in a nutshell, the player fires from the FPS gun
the thirdperson gun is attached to the thirdperson mesh, and just plays visuals to other clients
so its like a dummy weapon
noice that's what i assumed ty man
@lucid vault I believe the way you do it is once you've marked the condition custom, then in your Actor PreReplication function you use DOREPLIFETIME_ACTIVE_OVERRIDE( ActorType, VariableName, Condition)
oh wait, I read it some more and maybe you can't use it for what you want
so you might need to use IsNetRelevantFor then
Hello everyone I am having trouble telling the server to do something from a player controller. Any help is appreciated I can give more details as needed.
@twin juniper you didn't give any of those... details i mean
Basically what I have is a few functions that control the terrain generation in a procedural world inside my player controller. One updates which "chunk" the player is in the other two add the chunnk the player is in and removes it when the player is not in it to save performance. The problem is in multiplayer the clients do not tell the server to add the chunk despite me using the execute on server for replication. Not sure what to do as I have been trying to fix this for a while. @winged badger
you're pushing a reference to the chunk thru the RPC?
I can send screenshots through dm if it would help
can just do it here, its not busy
you do know that Tick runs on Server and Client?
I forgot to remove the server one
That wasn't there before
That was from testing earlier
also nothing that is RPCed on Tick should ever be reliable
i suspect you are trying to jury rig streaming levels by hand there
This is a screenshot of in game Server left client right. The client should tell the server to add a chunk where he is but doesn't
both server and client know where the client is
so there is no need to send any network requests
I know but the server isn't adding the chunk which is the problem
yet the client doesn't seem to be falling
Hes on a platform that isn't part of the world
how do you add/remove chunks?
Spawning an actor that I have created
is that Actor replicated?
Yes
and Destroy for removing it?
Yes
even if I remove the remove chunk function it still does not add the chunk in the first place to the server
well, your logic should be simplified by
client doesn't need to tell the server where it is
server knows that at all times
so server can spawn chunks on its own just fine
How would I get all of the different client positions and use them to spawn the chunks>
chunks?*
you should test with something simpler, as i have no idea what replicates and what doesn't inside that voxel chunk
Ok thanks
are rpc's synchronous?
for example if i have
void test(){
serverRPC();
// rest of the code
}
will the test method wait for the rpc method to finish?
before going on to the "rest of the code"
no, and it will never get the information that it did finish
alright, thank you
for that you'd need to send a server RPC, which does its thing, and sends a client RPC acknowledgement
then implement a callback to that
that's what im currently trying to do, but i want to pass an a pointer to an actor to the server rpc
but for some reason the pointer ends up being null by the time it reaches the server rpc
its a normal pointer, its not a TScriptInterface or some other wrapper that can silently fail?
yes
is the actor pre-placed on map, or replicated and spawned by the server?
spawned on the client side, and then i pass it to a server rpc
then it doesn't exist on the server
yea that makes sense
and NetGUID will never be assigned to it
im trying to spawn something client side to make up for the latency
so that when it does spawn server side, i can destroy the actor spawned on the one client
i see
client still needs to detect when the server-spawned Actor appeared to get rid of the simulated copy
then im not sure how to destroy the actor on the client side, since a lot of these actors can be spawned fairly quickly
i guess i can call a client rpc from the server rpc
but then it's gonna be annoying to figure out which actor to destroy in the client rpc
i would never engage in a simulation of that particular kind
but
you could have a replicated int32 or some such in it, ID
and have the client send it thru the RPC, server sets that ID after spawning an Actor, and it will be available by the time BeginPlay is called on a replicated Actor client side
would u happen to know if fortnite does any client side prediction for their building?
better solution is to have them pre-spawned by the server and pooled somewhere
hmmm that's probs better
spawn actor is problematic because its expensive
and you're currently doing it 2x on client
alright, i appreciate the insight, thank you so much for your help!
im having strange problem, apply damage doesn't work when i'm running 2 instances on dedicated server
any damage is not recived
how is this possible?
Well, key presses happen on clients
How are you pressing 'Z' on a dedicated server?
Damage happens on server
ninja'd
😛
Yes
It's one way
what is the other way?
You can also use functions
if I'm not mistaken
(Never used Blueprint for multiplayer)
okay, thnx
Events only unfortunately
functions are not replicated in bp, only events
Okay, didn't know about that. In C++ you replicate functions
almost nothing works exactly the same in BP @bitter oriole
OnReps are called locally, for one
Yeah I knew about that one
even if the client sets a variable locally, it fires
I have a NetMuticast function in GS. which send the information of teams.
I call it when the last player joins . (In GameMode::PostLogin )
but all the clients receive that function except the last one . why?
if you call it on post login the client might not have the game state yet but i could be wrong
the best way to handle something like that is with an OnRep
that way anyone connected after its set will still receive the data and run the function
multicasts should generally only be used for things that should run right now are irrelevant if ran later
like the effects of a gun firing
or a chat message
yep. Use variable replication for states
You can't guarantee when an actor will be relevant or even exist on a given connection
spectator paw is spawned on local client only ?
Is there an event called when a player disconnect from a server with a reason? Similar to QuitGame()
Does anyone know why animations may be stuttering on listening server? You can see here the other person's animation is not fluent. BTW the other player sees me with no issues at all, and if the other player hosts - no issues for anyone.
the listen server only ticks the character pose when it receives a move from the client
it's desired behavior from an engine point of view, but not necessarily for players
I don't think there are any settings for it
double-ah! apparently i recall badly i remember an option for ticking animations on the character
i will search for it
thanks
basically if you didn't do this you would only have 2 options:
- the animation runs ahead of what the server knows about the inputs from this player, like a prediction, very complicated
- the animation runs behind of what the server knows about the inputs, like interpolation, very bad as it will delay actions of the player on the server
but why does the other player see everything ok
when looking at me
isn’t that the same issue?
also when he hosts everything is fine
i’m not talking about location btw
really about fluidity (so yeah, animation tick)
because he's just viewing an interpolated copy of your player
whether everything is correctly in sync doesn't matter on remote clients
if you are not using root motion, and no gameplay features depend on the character animation (such as notifies, or maybe weapons attached to a socket) it will be fine
yes i have notifies
that do change gameplay (bombs being thrown on animnotify)
and weapons attached to sockets.. wth
🤪
Hello community! How realistic is it to attempt to do a client/dedicated server multiplayer project in UE4 currently with the expectation of not writing C++ code? Are the majority of the networking functions exposed to blueprints, or not yet? @golden stirrup
You have a lot of accesses in BP but I'm not sure if you have access to everything.
I think the less available part in BP is all the lobby name/etc.
@hexed wasp not even close
I find networking done in BP to be extremely awkward
It is possible tho, but you wont have access toany low level optimizations
Eerm, guys, doesn't the PlayerState get replicated to every client?
Like PlayerState A will be available for access to players B C and D + server yes?
I'm asking because I'm having trouble accessing player score on other clients. I'm getting it from inside the HUD class, but it stays as None.
Player States are replicated to all clients yeah.
You will have to access them from the Player Array in the Game State.
oic, can't go direct from player controller id ye?
@hexed wasp To even ship a dedicated Server build you need to use a source engine build, so technically speaking it's not possible.
No
Because the player controllers don't exist on other clients
omg ur right lol 😄
So GetPlayerController 1, 2, 3 etc. won't return anything
ye ye
Same for GetPlayerPawn 1,2,3 and so on
np's
one thing tho
why would you store score in playerstate
if u gotta go thru gamestate anyway
So that all players can access it
could say the same bout game state
You could, but it's probably not a great design to do it that way. PlayerState is as the name suggests, information about a "players" state
i see, i was thinkin the same thing
but always thought that was more for things like health etc
Well IMO health should belong to a pawn
stuff like kdr
Player State is more for persistent player stats. Kills, Deaths, Score, Team etc.
aight what about inventory then
Depends on the game
Persistent inventory I would say player state too, or player controller if other players never need to know anything about it (probably still best in the state though)
For an inventory that belongs to a specific character, having that in the pawn seems best to me
interesting, was always split on where to put inv
Zlo told me of a very neat way of transfering inventory data without gameinstance
but thats a good place to store it post transfer
thanks 😃
well i was just asking for a general opinion
obviously for single player only game it don't matter much 😛
That's what I mean. My example, I have a game with Characters and Vehicles which have their own weapons - so weapons / inventory is stored on the character/vehicle. If they respawn in a new vehicle, I don't want them getting the old weapons, and if they leave a vehicle and hop into a new one, I don't want them taking the vehicles inventory with them.
If I was making an RPG and I wanted to keep exactly the same inventory when my pawn/avatar dies, I'd keep it in the player state.
do u have loadouts that u gotta feed from each player or is it all preset depending on vehicle/char
cuz a loadout preset would technically count as a 3rd separate inventory
Vehicles/Character classes specify their default weapons
But that's just a class, new weapons are spawned with the object from that list when the vehicle/char is spawned
ez stuff, but yeah depends on the game really so it's hard to say a one-size-fits-all solution
eh i was just curious if there was an established "right way" 😃
at any rate, thanks for the tip, I can't believe I forgot bout the PC situation lol
np's
@winged badger , @hollow nexus thank you for your answers, that proves my assumptions. I felt so too since the early phases of experimentation.
@hexed wasp i’m not done yet but my whole mp project uses 99.9% bp.
i think what @chrome bay is saying is that to build a dedicated server you will need to do a little c++, however your project can be bp.
Sure, the dedicated server build is not a problem to compile using Visual Studio. That is trivial.
@ember needle you mean you have developed a client/dedicated server project will full UE4 networking done in blueprints?
i’ve done a full mp game in bp, however no dedicated server compiled (yet), so i partially answer your question.
Interesting. That seems to reverse my assumptions then 😃
well i don’t know. everyone says to not do bp multiplayer, so i’ll tell you if i hit a wall
hopefully, not 🙃
@ember needle sent a friend request, maybe we can keep in touch on the subject.
sure thing
Much appreciated and godspeed in everyday work 😉
Can somebody explain to me why an object with Authority can't get a GameMode, whereas an RPC on the server can?
I mean the execution path switches to the server side, I don't understand why you can't run server owned functions that way and instead have to rpc
@copper mango bool AActor::IsNetRelevantFor(const AActor* RealViewer, const AActor* ViewTarget, const FVector& SrcLocation). RealViewer is the player correct? Which means I need to return true if RealViewer is within the array of authorized users and false if not?
@west rapids not sure i understand your question, but if i do, clients do not have GameMode instances
@ember needle yeah I know, i was asking why Switch Has Authority, when using Authority pin, returns None when accessing the GameMode, whereas calling an rpc on the server, returns it
nevermind, it works on both, I'm just blind, sorry
@lucid vault yeah RealViewer should be the player controller that you're checking relevancy for
@copper mango So here is an issue. When the player interacts with a pickup, it get's added to the inventory on the server. Then, a function is called from the server to the client that updates the inventory widget. The problem is that when the function is called on the client, the inventory hasn't yet replicated down
So the inventory doesn't get the updated item
I guess I will have to set up some kind of listener onchange for the inventory replicated variable
Instead of calling a func
you could do a ReplicatedUsing function which will then get called on the local player when the variable is updated via replication
Will the get player controller node set to index 0 always return the local playing client?
Looking to do some clientside event that's based on an overlap event and have to verify it has been triggered only by the local owning client (be it the listen server host or a regular client)
generelly, yes, but be careful not to use this on the dedicated server
@grizzled stirrup ^
I'd suggest using IsLocallyControlled to figure that out
That actually returns true for AI on the listen server which can mess things up unfortunately
could use IsLocalPlayerController on the controller, then
good idea! thanks
IsLocallyControlled returns true for AI?
i have never seen that :/
can't say i really use that tbh 😄
does max player count include spectators?
i have a lobby level that players goes into when they join a session, the second they go inside they should get widget to select a character so they will be spawned inside the lobby i created a custom event inside the game instance and i try to call it from the level blue print in the begin play event and i run it on dedicated server, my problem is :
when the host creates the session and gets into the lobby he gets the character select widget and every thing goes fine , but when some one joins the session they get the widget for less than what second then it goes off without selecting anyone and leaving the player spectating and i don't know why
the level begin play is likely to get called on the server before the player's even joined, so you can't rely on that
then what can i use ? player controller ?
the game mode has a PostLogin function that's the first point where the server knows about the player controller
i am new to the networking thing
well, where it's valid for you to call an RPC on the PlayerController
so you could make a Client RPC on the PlayerController that creates/shows whatever UI you want, and then in the game mode you make it so the player doesn't actually start until they make their selection (so you could set it so when they first join they're forced in spectator mode)
and then once they make their selection and tell the server, it can restart the player with their selections
if you're doing stuff in Blueprint, there's an OnPostLogin event you can use in the GameMode blueprint
so the RPC i should use it would be inside the playercontroller and i would be calling it from inside the gamemode on the OnPostLogin right ?
right
so when the player joins you tell them to show the UI, and the server can also setup whatever options or whatever through that RPC potentially
the other thing might be if your server is just immediately starting the game before any players are ready
because by default the game mode will start the match once the first player connects
or joins rather
but you can override that also
to be honest, I don't know how much you can do via blueprints
@elfin creek dedicated servers do not mix well with either use of GI, and especially LevelBP
you picked up 2 objects that you can't even hack to support network, out of total of 2
yeah i thought as much when i saw the casting failing every time 😂
how much is the blueprint far from the coding ?
does anyone have experience with aws lambda and ue4?
I honestly don't recommend trying to make a networked game in Unreal if you can only do Blueprints, but I guess it's possible
skill wise or implementation wise?
it is possible, its just... awkward
trying to play basketball without using your dominant hand would be a good analaogy for it
i can code it but i find that blue print is a bit easier on me so i wanted to know the difference ,beside unreal coding is quite different from what i used to do normally with c++
in BP, everything is verbose, difficult to track or read
and some of its implementations are just plain awkward, like OnRep being called even if client sets the variable locally
plus you don't have any access to any of the low level networking
if you want to see what changed in replicated array in BP, you'd need to store backup, then compare the arrays and/or elements with the backup
aha i see , maybe because i don't understand networking right that makes things a bit blurry to me , ia m building my game to learn more or less
so in a multiplayer game it's not good to use the game instance and level blueprint because they cause problems
they can't ever support network
generally, i think using level BP for other then showing MainMenu widget from ManuMenuLevel BeginPlay is also a mistake
then what is game instance used for exactly ?
its an object with a lifetime from start to end of application's runtime
it holds an array of local players
which hold the viewport
it doesn't get changed when you load a new level
i mostly use it to handle the menus, which don't really fit well in a HUD
okay , i tried the way @copper mango said , the Widget is being displayed now for both players but it's not functioning for the player who joins , only the host picks up and spawned but with the joining ones nothing happens when the buttons are pressed
you can't send RPCs thru widgets
now this is confusing
so i can't do that ?
i know this looks sucks , but it was the only idea i had 😂
would be nice if the engine told you when an rpc you made makes no sense
made an rpc on the game mode? nope
made a multicast on the player controller? nope
it gets worse @fleet raven , some wrappers for pointers replicate just fine, like TWeakObjectPtr, while others silently fail, like TScriptInterface

@elfin creek make a panel, OnConstruct for 0...7 create and add a custom Widget that has a button and ExposedOnSpawn integer Index variable, feeding the current element index into button index
in the ButtonWidget, add an EventDispatcher with Integer payload, and when its clicked call that dispatcher plugging the index into its integer parameter
when you create and add the button widgets, also BindEventToYourCustomButtonWidgetClicked
result: you end up with a single event in outer widget BP that fires when one of its child ButtonWidgets its clicked and its aware of the button's Index
then forward that to your PlayerController, which you can get as long as you connected Owner pins when creating widgets, with GetOwningPlayer
and have it send the RPC
replicated struct properties always arrive in a consistent state, right?
so if I change one of its properties, it replicates, I change another property, it replicates again, it will send a delta with both of those changes since the client hasn't yet acked the first one and it's possible it never gets it?
Does anyone know what NetworkSimulatedSmoothLocationTime exactly does ("How long to take to smoothly interpolate from the old pawn position on the client to the corrected one sent by the server")? If I want to "smooth" animations should I increase it or decrease it?
on unreal http request, windows, android support multi thread. but FApplePlatformHttp not support threaded request. do anybody know why?
@winged badger i guess i am way too novice to understand most of those things you said forgive me, what i understood so far was i have to create another widget that contains a button and an integer variable which has the ExposedOnSpawn property and then in the all characters widget i add button from that widget i made with the same number of characters i have giving each button of them an integer value that corresponds to a character , is that right so far ?
basically instead of adding buttons directly, you add a panel, then in a for loop (or a foreach loop - for each of your possible character selections) you add those custom buttons into that panel
buttons have to be aware what index (and possibly, classname, or charactername - for display) they correspond with
when clicked they call their event dispatcher, which the parent widget binds an event to at the time it creates the buttons and adds them to the panel
so yes, that was good so far
my only problem is i don't really know eventDispatchers and how they work , the event i bind to the event dispatcher what should it do exactly ?
its basically an object that maintains a list of functions it should invoke when called
you add an event dispatcher below your variables
you name it
you select it and add it integer input in the details panel, just like you would for an event/functionj
afterwards, anything with a reference to an object containing the event dispatcher can get BindTo<YoutDispatcherName> from the reference context
that creates a node with the red square bottom left
and when you drag from the red square, and type in "Custom event"
it will create an event matching the dispatcher signature connected to it
its most commonly used (not in no way exclusively) for situations like A has reference to B, A needs to react to something happening in B, but you do not want to reference A from B
then B uses an event dispatcher, A binds to it, and when A needs to react, B just calls the dispatcher
(at least most commonly used in UI that way)
so when you connect this, in a widget holding the panel with buttons that event fires whenever any of the buttons are pressed, and it has an integer parameter telling you which button
@elfin creek
hello I want to know if according to this doc :
https://wiki.unrealengine.com/Dedicated_Server_Guide_(Windows_%26_Linux)
we can make the server dedicate with the version of unreal engine 4.21 because I did it but in part 5 the build does not work so I start from 0
@worn nymph
Can I have a UFUNCTION(Client, Reliable) that I can override in BPs? 🤔
in theory
if you slap blueprintnativeevent to it as well
it just might override the _Implementation
or crash
i'd say 20/80 for those 2 options
seems like it should work but 🤷 never tried
Yeah I would assume one of the two doesn't like the others _Implementation
I will try it later
i mean the safe way would be the client rpc implementation calls a BPNativeEvent
which would work, just means a extra funciton and extra bit of code
hey guys the cable component is replicating but not in the right spot also the object does not replicate when dragged by the cable
I figure out that if I want to replicate the position of the object I just need to enable "static mesh replicate movement"
or replicate the stuff you need to simulate the cable component
and do it that way
Hm, where exactly does one apply impulse to another pawn when hitting them?
I thought using the HandleImpact function from the MovementComponent might work out, but that seems to 1. call more than once per frame (cause of substepping I guess) and 2. for simulated proxies :x
I would assume I want this to call for the local player and the server
And only really once per frame or, if multiple times per frame, not adding impulse onto impulse
I guess I can always filter via GetOwnerRole, just not sure about it calling more than once per frame.
CMC doesn't seem to filter it
ok so it seems like it's working for both players now although the issues is that the client doesn't see the exact location of the rope in the beginning https://gyazo.com/4b382db7a222eec471611f1c1e8a16dc
Hey anyone has already needed to replicate a FMatrix ?
It seems that in some case the matrix is not replicated correctly.
It's the rotation of my character to his current ground (all the logic of wall switching is proceed on the server side)
Base case : (Matrix zero)
Wall case (with correct replication) - The server and the client have the same matrix
And the case which doesn't replicate correctly is this one (a wall which is rotate by 30° for instance)
FTransform has replication support, FMatrix doesn't
Still a bulky struct for replicating the relative orientation though. Just a rotation and location is probably enough
That's true !
Oh I used the matrix to get easily all the axes forward, up and right
I will try the transform first
That's works ! Thanks you !
As it's a student project which don't need to be used online, I don't care about bandwidth optimization at this point. But I will check that later if needed.
Guys what type of lag compensation techniques for rpc you use in your games?
what you mean?
I mean, like for example technique like this https://medium.com/@invicticide/accurately-syncing-unreals-network-clock-87a3f9262594
When implementing real-time network multiplayer in a game, one very important tool is a reliable network clock.
to delay rpc by half of the rtt in order to call it simultaneously
both on client and server
@thin stratus I've tried several different methods of applying physics to a Pawn with a movement component, and as far as I can tell, it's incompatible with the physics system if you want to maintain control.
You'll have to simulate custom physics on that, at least that's what I had to do. You can use the regular input function to create a fake "impulse". Use ConsumeInputVector to prevent "impulse" stacking. My approach anyway.
@humble comet check the character cpp, there's some pretty neat tricks when it comes to prediction there.
@west rapids Na, no custom physics. It's just an impulse added to the velocity of the movement comp
I would never touch multiplayer and actual physics haha
I can understand that
I'm suffering through that right now 😄
was just an idea anyway
Ok is there any reason why this DOESN"T execute on the server?
https://gyazo.com/cf0a7a11828d227c1a0d99666680cc02
Like the same setup works for prints, yet not even a breakpoint is triggered on this
If "BeachBall" isn't owned by the client executing the rpc, then yeah, there is a reason
@thin stratus Receive Input doesn't count as ownership then?
No
i see
just wanted to have a quick test
but i aint about to possess and unposess 😛 thanx
you don't need to possess the beach ball to own it though
is there some other way to transfer ownership? (excluding spawning and children) @wary willow
calling "SetOwner" on an actor, but that has to happen on the Server
Is there anyone here who's got a good idea of building something that keeps track of who has vision of what?
When a unit is in vision of someone, the entire team is informed about that unit and their details (health, location, items, etc.) through minimap and info tab
I have been struggling to come up with a good way to keep track of this across the entire team
It's simple enough when it's just one player that tracks its own units
But when you get interaction between a whole group....
I tried doing something with the PCIterator to inform the different players, but that didn't work well
@thin stratus omg, thanks man
@tropic fjord wouldn't a box trace work?
store the info in player state and then get it on other cleints
or better yet have an enum and just send a byte to the clients and they read stats locally
unless they aint preset
I'm doing a trace to get an array of all the visible enemies, so that works fine
The thing is... For instance
A unit gets into my vision
it gets added to this array
I inform the others that I can see it
now my teammate does the same
oic
what happens?
this seems pretty heavyy
His overrides mine?
His doesn't do anything?
Can't do either
Cuz if one of us walks away and the other stays
still needs to give vision to entire team
🙀
well, what you can do is keep track of every player in the game state
and then just use a bool to trigger visibility on minimap
for other players
dunno how heavy that would be tho
Well, I don't have just players
I also have around 100 AI on the map at any point in time
😓
But you mean that I should do it in reserve @west rapids ?
Keep track of the vision on the unit that is getting seen
instead of keeping track on the units that see
if that makes sens
You don't really want every single AI to have a PlayerState
cuz ull be tracking only once
Hi everyone,
I have the following issue: I am trying to setup a Weapon class for a FPS game with a 1st Person mesh (which has Only Owner See flag) and a 3rd Person mesh (which has Owner No See flag). My problem is that the other clients don't see the 3rd Person Weapon Mesh, any thoughts on that?
eXi, you got an idea about my issue? It's pretty much an MMO/MOBA minimap system.
Just keep one Array of visible units for either player or whatever sort of "group" you want
If a unit sees something, add it unique to it
And maybe increase the viewcount on it
So that you know how many units see it
Where would you store that array
Depends on how should know about it
I mean, teammate AI can give vision
teammate players can
yourself can
teammate AI can turn into enemies
the other way around
etc
So I'm pretty sure everyone should know
Make your own custom TeamState?
Set it up similar to how the PlayerState works
Spawn it in the GameMode
Keep an Array of teams in the GameState
Save the units in their
Assign a teamstate to each PlayerState
tada everyone has access to their team
I'm not seeing it yet.
How are we going to keep track of the count of each unit we see, though?
set up ur teams in GS then distribute across
I'm actually going to take out pen 'n paper cuz my brain can't do this
a lazy way would be just to track position in GS and reveal based on bool from ur trace, update every second or two.
@copper mango I'm using ReplicatedUsing and there is an issue that I'm trying to understand. Basically, each player has his own inventory widget and when the inventory of that player get's changed, ReplicatedUsing will call a function to update the player's inventory widget. The problem is that this seems to be calling on all clients because each client has a reference to each player, therefore overlapping huds on top of each other.
depending on ur visibility logic (fog of war or not) then ud pretty much get away with a toggle
It's a bit more complex than that
well if u can swap gear at run time
then yeah
but even then you can just update ur actor stats when they update their inventory and sync in slowly
Not quite figured it out yet, but thanks for the help 'n the ideas
look
get it working dirty first, you can refactor and make it pretty later
try the custom state, probably a better idea, i dunno
Hello poeple I want to set the relative location of a component from an character that the player is controlling. It works good for the player possesing that character , but it doesn't for others. How does replication for set relative location work and how can I fix it? (for background: I'm trying to make a custom crouch and set the player's mesh up as he is crouching , otherwise it will go underneath the level)
@wheat eagle set ur location serverside
Has anyone here had any success getting Oculus sessions working?
I've tried that , it doesn't work
does it work on a listen server?
for the server?
im not sure if u have to multicast it
or use a bool with repnotify, that would probably be cleaner
Hi everyone,
I have the following issue: I am trying to setup a Weapon class for a FPS game with a 1st Person mesh (which has Only Owner See flag) and a 3rd Person mesh (which has Owner No See flag). My problem is that the other clients don't see the 3rd Person Weapon Mesh, any thoughts on that?
I've tried with both only server and with multicast. Tested on listen server and still it only works for the client possesing the character.
let me try with the bool with repnotify
@fiery geyser so they see the 1st person then? or nothing at all?
Well, they would see the 1st Person if I would untick (Only Owner See flag)
Are you setting the Owner properly when spawning the Weapon?
oh so they dont see a thing then
Yes, eXi, I do that when I equip it, I set the new owner.
ur 3rd person mesh is a child of 1st person
if u cant see 1st person then u proly wont see 3rd too
I really think I should go for the reverse mechanic. Thoughts on this? @thin stratus @west rapids?
- By default, keep track of everyone, but have stuff "Hidden".
- Every xx, do a check of who can see "this unit"
- Keep track of those people in an array. This doesn't involve any networking yet.
- Do a check of those unit's teams. Have 3 booleans (3 teams). VisionByRed, VisionByBlue, VisionByWhite. These booleans are replicated.
- When boolean is set to true or false, hide/unhide UI (minimap, tab info) for all players on those teams.
so I assume u gonna keep track in game mode or some server only thing then?
cuz I'm not sure if u tracking these things in GS that it won't eat up bandwidth like pacman
unless u setup rules for replication
like only replicate if visible
At any rate, I gotta go soon, but I think its a good approach cuz u can scale that to more teams quite easily, can't tell you about how optimal it would be even if you make it sqeaky clean
- you can do all sorts of fancy things with a map tracker that always has the info available
Yeah, dunno either, but I don't know if my brain can come up with that perfect solution :/
As you said, it it functions how it should, then I'm alrdy pretty happy
well another option would be event dispatchers
cuz previously it wasn't correctly updating when I was doing it from the side of those who " see'
like an "enemy spotted" event
and then request replication for others from the array
@lucid vault well one way might be to set the replication condition of the variable to COND_OwnerOnly, then it'll only replicate to the owning player
dunno
I did something like enemy spotted first, but it got really messy
i think repnotify would be your best bet for a clean sync
@copper mango True, but this inventory system will also apply to chests, which means it will need to replicate to more than just the owner
@copper mango I want to replicate to everybody in an array
and you're using IsNetRelevantFor?
anyway i g2g, good luck
Thanks, Ken
Yeah I think that will work, right now my question is more of how to prevent widgets from other players from showing on your screen (since the other player instances are also in your game)
There is probably a function for it that I can't think of
wherever you create the widget, only make it if it's a locally controlled player controller
IsLocalPlayerController
Hmm. So maybe my issue is also that I have been using the player character for all of my logic as opposed to the controller
well you could still get the controller from the player character and test it there
but one advantage of using player controller is that the non-local players do not have a PC on your client
so like if you have two clients, each with one PC, they don't have access to each other's PC
Oh. So that means if I created the widget in the PC I wouldn't even need condition checking?
yeah, so for example could make a Client function in the PlayerController and then the server tells the player when to create their Inventory
or for example when the player opens the chest, the server could send a Client RPC to the PlayerController telling them to show the chest view or whatever
depends what you're trying to do, but I guess you shouldn't make your widget in the Player Character
I see, that makes sense
so basically for PlayerControllers, only the Server and the owner of the PlayerController has access to it
PlayerState is replicated to all, though
@fiery geyser Check the NetRelevant status of your meshes.
Make sure your class has the Replication section properly checked and that your component is set to replicate
@glass plaza everything is properly checked. Still got no idea yet what could cause it.
@fiery geyser why is your 3P mesh in hierarchy under the 1P mesh?
and weapon mesh components don't need to replicate, they are default subobjects of a replicated actor
@winged badger in theory, if a game works in multiplayer, it should run with only 1 player as well yes? (aside from missing controllers)
no i mean if there is a multiplayer game designed for 10 people, and you launch it in editor with only 1 player, no dedi servo, it should still run the same, right?
if its made for dedicated servers it might break in listen server mode
yeah, they usually do
rpcs wll function like regular calls right?
yes
aight that narrows down my problem by a large margin 😄 thanks
they do that in network as well, calling a server RPC from server is just a normal function
i wonder
this would technically be heavier then right?
i mean ud be calling an extra function for every time ud need 1
if any of your game critical code depends on it actually being run on dedicated server
it will still break
i see
i was always curious about that
thats why im askin 😄
since WoW
launched lol 😄
always wondered why i couldnt play by mahself locally
i know they had their own engine and all, but architecture was prolly the same
oh so if i had WoW as a project on my pc it would run huh
good to know 😃
thanks man, resolved a decade old curiosity here 😄
there used to be pirate wow servers when it first came out
@copper mango Any way to use IsNetRelevantFor on a UActorComponent?
Components have bReplicates as a variable though
So, is there no way to decide which clients a component will replicate to?
I am trying to replicate an inventory component's ItemData TArray to specific clients
the bReplicates for the component just means that should the component replicate if its owning actor replicates
but the relevancy of a component is based on its owning actor's relevancy
well, you could set a replication condition for the component pointer in the DoRepLifetime etc
but it won't let him do what he wants, since custom conditions can't be connection-specific
Basically I only want the player's inventory replicating to other players if they have first gained access to it (such as if the player ha died and they interacted on their body). This would prevent cheaters from viewing inventories that they shouldn't be able to view
But as of right now the inventory component replicates to everybody
As opposed to only those in the authorized array of players
so why don't you just spawn an actor, transfer the dead man's inventory into it
and replicate it to everyone
Well I am trying to make the system modular so it can be used elsewhere. In a chest, for instance
I want players to have to interact on the chest first before being able to view it's contents
So I am trying to make the system modular for inventories
The player should be able to gain access to any inventory, no matter if it is a player or chest inventory. Once they gain access and are added to the array of authorized users for that inventory component, it should replicate it's data to that user
option 2
any inventory container when interacted with adds a replicated component onto an interacting pawn at runtime
and destroys it when interaction is stopped/completed
you could probably add that component onto the PlayerController instead of the pawn, yeah?
bonus: you can move the logic for picking up and stashing stuff into that component, and it can also handle the interaction UI
yeah, doesn't really matter
or the PlayerState, works too
just thinking if you put it on the PC it's a bit easier since it wouldn't replicate to non-owning clients since they don't have access to the other player's PCs
So if a player accesses a chest, the chest would add a replicated component to the player controller?
Then this component added has access to the chests inventory
I'm trying to think of how to set that up modularly
then you shouldn't need to maintain that list of authorized players
I'm trying to figure out how the newly added component should transfer the data to the player
Maybe it keeps a reference of the inventory that created it?
And then it uses that reference to view/add/remove items
And it replicates that reference's inventory
if you're using c++, just have the inventory as structs
Yeah I'm using c++
and copy the entire array into a component
Basically I have an inventory component that contains an array of struct data
For the items
yeah, copy that
well, you'd still have to keep the inventory in sync somehow
My question is how I go about replicating the data from point a (the chest's inventory) to point b (the newly created one on the player)
Yeah
but replicating an array of structs from another actor isn't going to work
so as long as you have a reliable operator== on the inventory struct
you can just copy the array and when something is taken, you remove whatever == the item from the Actor that actually holds the inventory
So probably when the chest creates the inventory component for attachment to the player, I should pass in the reference of the chest so that the newly created component can retrieve the struct data
its instance on the server also has to keep the chest in sync with player actions
so it has to have a reference to the chest
the reference doesn't have to be replicated
as i don't see why the player would send a ServerRPC referencing the chest directly
inside the scope of a Server function on that component, it has to have a valid reference to the chest
i am assuming an interface or a common base actually exists
already
not talking about interacting with another class, but the networking involved
oic sry didnt read the whole thing
Yeah I already have an interaction interface
the add a replicated component approach is a pretty much the only solution when you have lots of specific interactions without much in common
like say, a crafting bench, vendor, alchemy bench... etc
reducing that to common interface would be.... challenging to say the least
and putting all that networking logic inside one of your game framework classes would be a clutter clusterfuck
i was under the impression this was needed for looting dead bodies and chests 😛
My idea of reducing it was to have any inventory be able to hold any item unless you specify item restrictions on specific slots (ie. slot one can only hold wood)
well, for looting just needs a single component class to work for any inventory container
So you think that for every item (chest, vending machine, furnace) they each need their own custom component that will be spawned onto the player?
if the Actor in questionj
has specific networking logic, requiring specific UI
yes
otherwise, no
True, I didn't think about the UI. I can use that component to display it to the player
u got a loot table ye?
and you can use the component to react to the UI and send the required RPCs
without any of that ending up in your PC or Pawn
True. I'm going to try and implement this in code and see how it goes. Thanks for all the help!
Okay, I have a component called ChestAccessor. When the user interacts with the chest, the chest adds a ChestAccessor to the player (passing in itself as a reference). The ChestAccessor then adds a widget to the player's screen and handles input. The ChestAccessor can RPC to the server and modify the chest using the chest reference.
How should the chest notify the ChestAccessor when it's inventory has changed?
If two players have the chest open, one may modify it's contents. In which case, the chest needs to notify the ChestAccessor to update the client's widget with the new data.
just replicate the array of inventory with a notify and on client side make the call to the accessor thing to update the ui
That won't work for what I'm trying to do
@winged badger I think I will send the event to all of the stored Accessors when an item is added/removed. Should work
if that happens frequently with anything more then small arrays
you should consider FFastArraySerializer
its capable of per-item callback client side for add/remove/change
Question for the player as a listen server is there a reason why 3+ players spawn properly and possess on each client but for 2 players It does not?
anim montage is not player on other clients, only on my
what i'm missing?
i have tried with repNotify also
still, anim is not played
hey everyone!
I am getting an error Warning: CanServerTravel: Seamless travel currently NOT supported in single process PIE. but I explicitly deselected the use singleprocess in general settings. Any clue?
Guys, Is there a setting to set network timeout? For example my server crashed or client has lost connection. I need to open up a screen to return to main menu.
@scenic raven You need to start the game as Standalone (e.g. Rightclick Uproject File -> Launch Game). Everything inside the Editor doesn't support SeamlessTravel.
@wary wyvern You mean a delay before it automatically kicks you back to the mainmenu?
@thin stratus A delay before NetworkError inside GameInstance gets called
Don't think there is
That's a pretty direct call to it
UnrealEngine.cpp Line 11175
UnrealEngine.cpp Line 11047
You can follow that further up the chain if you are interested
@thin stratus Maybe here it is https://answers.unrealengine.com/questions/532815/where-to-set-connectiontimeout-value.html
Yeah but don't you kinda need to know when you timeout?
The value when just means that it waits longer for the Connection resume
you can confiigure timeouts, somewhere
but actual errors, a deletage gets broadcast, and thats the end of it
Well, for example my server crashes and i have this timeout before client decides what to do.
@real yacht Multicast or a Replicated property witha struct
What happens with an RPC that has a UObject* parameter, where the actual instance in that variable is an AActor (replicated)?
Does that just work?
yeah should do!
I have a few places I think where I have replicated UObject ptrs which point to actors sometimes, components other times etc.
not even that, by default it has to be loaded from a package to be referenced over network
and unreal will give you no warnings
replicating UObject* is fine, as a variable
for a RPC payload its loaded from package, replicated, or after making sure it has exact same name on all machines, making it net addressable
Oh yeah, I assumed we are talking about stuff which can knowingly be referenced on the network already
As opposed to just arbitrary objects etc.
usually the simpler way it to send a pointer to its Outer
example, you don't do
UFUNCTION(Server, Reliable, WithValidation) void ServerPlayAnimMontage(UAnimInstance* InAnimInstance, UMontageAsset* InMontage):
instead you can do
UFUNCTION(Server, Reliable, WithValidation) void ServerPlayAnimMontage(USkeletalMesh* InSkeletalMesh, UMontageAsset* InMoontage);
then in its body grab InSkeletalMesh->GetAnimInstance()
option #1 here will just silently fail, or crash, depending on how rigirous your null checks are
learnt that first hand :D
AnimInstance is not net name stable
well not network addressable
dose multicast or client RPC use Actor Relevancy like replication?
@winged badger are u sure ?
both reliable and unreliable ?
client is directed at one specific instance on one machine
there is no sense to get relevancy involved in that
and if it can receive client RPC, it would return true for relevancy anywyas
since it will look into owners relevancy as well
for reliable multicasts, not 100%, they are handled quite differently then unreliable ones
I want to send a int to all clients. since there are lots of clients. I needed to make sure muticast uses relevancy.
is it for a replicated actor?
yea
just set the int on it server side
have it replicated
(set it in the same frame its spawned)
and clients will have the int ready on beginplay
the problem is my variable is adjusted multiple time with the same value.
not quite sure what you mean by that
I mean my variable is changed to a different value every frame.
on the client side I want to get the same number of OnRep_
You can't
You're never garaunteed to receive all the changes to a variable
Only it's latest state
Not to be ThatGuy but this sounds like bad design
what are you trying to achieve exactly?
I want send some kind of event to tell the clients that a player is immune for a period of time.
Surely all you need then is a bIsImmune flag or something similar?
A replicated "is immune" bool looks like it would be fine
🤔
I am gonna go try it.
technically, it already exists. bCanBeDamaged in AActor is replicated by default.
if bCanBeDamaged is false, they're immune. If it's true, they aren't.
🤔
hi guys, i have an issue with replication : if i create a blank c++ actor and make it replicates with bReplicates = true, and then spawn this actor with a blueprint node "spawn actor from class" on server side, it won't spawn
but if i create a blueprint class child of my c++ class, and then spawn this blueprint on the server, it spawns for other peers
am i missing something ?
That'll be why then - you need a root component or the server won't be able to determine network relevancy
blueprint will create 'DefaultSceneComponent' if one doesn't exist, but C++ won't
np's
https://wiki.unrealengine.com/Replication it's sad the documention doesnt' mention this
In my experience it will just crash usually, as without a root component you're actor technically has no location
Usually your actor has a component so it's probably not worth mentioning
yeah it's right
https://gyazo.com/2b7626d1594d0fc926e4a9a4947d2e9e how can one replicated the pitch input for the client
that's pitch
For characters, it's normally replicated already via character movement.
you will need to make changes to the FPP template to show the pitch in third person.
if i call TearOff() or disable replication for an actor immediately after sending a reliable RPC, and the packet is dropped, will it still be resent even after disabling replication?
Has anyone ever played around with high velocity physics replication?
for example launching something like a spear with a massive impulse
or a golf ball
basically any physx object that travels at high speeds
Hi @thin stratus I know this is an old topic, but were you able to fix your PS persistence issue?
copying properties around
just because I ended up having the same issue because I did fail to override "OverrideWith"
in case you didn't try that yet
worked for me 👌
I had issues with additional actors surviving cause they were referenced in GM and GS while these are reset after the SeamlessTravel
And yeah I fixed that by just getting all actors of class at the start to catch the actors
ahhh, aight, I thought it was exclusively an issue with your PS :)
since client rpcs can't have an authority check (well they do but they're remote) , they should only be used for non game-breaking stuff or are they safe because they are called on the server but executed on the client, im puzzled : D
The logic in a client RPC is kind of non game breaking by nature since it would only happen on that one client and not affect the state of the game as far as the server is concerned
hmm what's the advantage of client over non-replicated if the server isn't messed up with
Not sure what you mean. Server to client RPCs are used to get data from the server to the client for the client to use somehow, maybe it’s info thats needed for a widget to display properly or something, whatever
The server is still the one that has the “correct” version of the world, and a server to client RPC doesn’t affect the world at all so there’s no need for validation
Validation on a client -> server RPC is needed to prevent the client from giving the server bad/false data. There’s no point in validating a server -> client RPC since the servers data is assumed to be correct
If ur looking for advantage, running on client allows you to do things that the server doesn't care about
like if ur throwing a smoke grenade, the server only cares where its located at, particle can be handled client side
RPC = Remote Procedure Call. Basically like your TV Remote telling your TV to Turn off/on.
It's a way to tell something else what to do.
That exists as Server, Client and Multicast.
ServerRPC (if the Actor is owned by the calling client) ask the Server to do something (Server = TV, Client = TV-Remote)
ClientRPC (if the Actor has a Client/ListenServer as owner) asks the Client to do something (Client = TV, Server = TV-Remote)
MulticastRPC tells everyone to do something (Everyone = TV, Server = TV-Remote)
Something like that
What they fiddle with is totally up to you
A ClientRPC always targets one client (the owner of the Actor), so you can't really destroy anything by that
so a clientrpc would execute on the single client with the data of the server?
It just tells logic to run on the owning client. You can pass data in as input parameters but it’s not required.
It’s a good way to get data to the client that has yet to be replicated, if you need that data immediately
Order etc is still not given
So you could also just utilize an OnRep
Not much difference I guess (if only targeting one client)
OnRep would still not fire until the replication occurs though right? I’ve found that sometimes I need to get data from server to client faster than the replication occurs and I’ve been able to work around it by passing that data through an RPC.
Maybe not best practice though
actually
now that I think about it, why can't u grab stuff from GM and send it through client rpc?
i mean ur refing it from the server, so it should return u something.
but ive tried this before, and it don't work
Cause the GameMode doesn't exist on clients
Because the game mode doesn’t exist at all on the client
There is literally nothing to execute the RPC on
You can picture replicated actors like copies that are linked by an ID.
You would have to run the RPC on something like the player controller and pass in data from the game mode
Before you send it
my point is
Function A calls on server Funciont B calls things on owning client and sends through some float stored in game mode
like if I'm calling from the server side onto a client, I don't understand why i cant access GM from the server and dump info onto the client with the rpc
It depends what class you are calling the RPC from. If the RPC is in the game mode it is always going to fail because there is no game mode on the client to receive the RPC
on other actor ofc
Like I said you would have to, on the server, send an RPC through a replicated class like the player controller. Then you would be able to grab a float value from the GM and pass it in as an input parameter
You can totally do:
Inside PlayerController -> CallServerRPC -> GetGameMode->GetFloat -> CallClientRPC(Float)
Where both RPCs are in the PC.
However that's rarely ever needed
You should already replicate everything the client needs through the GameState/PlayerState/etc.
It's also highly recommended by me, if you do something more complex in Multiplayer, to use C++.
UE4 has tons of stuff not exposed to BPs
^ I realized that very quickly when I started doing multiplayer
Starts with something simple like the "InitGameState" function in the GameMode:
void AHLGameMode::InitGameState()
{
Super::InitGameState();
HLGameState = Cast<AHLGameState>(GameState);
if (HLGameState != NULL)
{
HLGameState->SetMatchTime(MatchTime);
HLGameState->SetMatchStartTime(MatchStartTime);
HLGameState->SetRespawnWaitTime(RespawnWaitTime);
HLGameState->SetForceRespawnTime(ForceRespawnTime);
HLGameState->SetTeamBased(bTeamBased);
HLGameState->SetRequireFull(bRequireFull);
HLGameState->SetAllowSwitchingTeams(bAllowSwitchingTeams);
HLGameState->SetAllowSwitchToSpectator(bAllowSwitchToSpectator);
HLGameState->SetTeamStates(TeamStates);
HLGameState->SetForceRespawn(bForceRespawn);
HLGameState->SetWaitBeforeRespawn(bWaitBeforeRespawn);
HLGameState->SetCanRespawnByHand(bCanRespawnByHand);
HLGameState->SetWarmupForced(bForceWarmup);
HLGameState->SetTeamDamageEnabled(bTeamDamageEnabled);
HLGameState->SetReplicatedMapInfoClass(ReplicatedMapInfoClass);
HLGameState->SetGameModeName(GameModeName);
HLGameState->SetBotDifficultyLevel(BotDifficultyLevel);
}
}
Allowing you to pass all your settings that players need access to to the GameState
Where they can get replicated
Just one of many useful functions that don't exist in BPs (whyever)
I think I get it, im testing a client rpc with launch character and it can't break the server state of the character, and a non-replicated actor variable changes only locally, still kind of bothers me that I get the same result with a not-replicated rpc 🤔 I'm still a noob so I can't use my imagination, as mentioned before, I guess the function could have inputs and since the server is the one that calls it, the inputs would be the server's version of the data
oh yeah c++ if u wana do serious stuff, but bp is fun to play around with
Here's what I mean
the Multicast works fine
sends the string to all
run on client always fails
why? Isn't run on client the same as a multicast but for only 1 client?
BeginPlay calls on everyone
So you would already go ahead and filter that properly
Cause currently a lot more than the owning client try to call that rpc
Despite that, it should work I guess
yeah but the output of printstring tells you what's printing, client n or server
was just ez to setup quick
needed somethin to fire
but yeah, the client rpc doesn't work
That’s probably an ownership problem
The multicast will fire for everybody regardless of ownership
tha pawn is just in an empty lvl
Yeah then it's def an ownership problem
Yeah if it’s just a pawn in a level it isn’t going to work
always forget bout ownership
Because the client doesn’t own it
apf yea it does run
Your BeginPlay, as already said, is tricking you
It calls on the Server and all Clients
well then I was wrong, it is possible to send GM info into a client
So the ServerRPC is dropped on all clients
And the Server executes it as a normal event
You'd have noticed if you properly limited it to the owning client
yeah withh 5 clients I get 6 calls but still
I just noticed that if Client and Server set a boolean to true
but anyway, thats one more thing cleared up for meh lol
you mean if they do it at the same time it doesn't notify?
Yeah the Client does it earlier of course
And then the Server does it and the OnRep doesn't call
Cause the Replication of a boolean
If it's the same state
doesn't do shit
Maaaaan
that's supposed to be a good thing lol 😄