#multiplayer
1 messages Β· Page 668 of 1
I followed this one a long time ago to get started.
https://couchlearn.com/multiplayer-sessions-in-your-unreal-engine-4-game/
ty
oh, worth saying that if you use Steam for development you don't need to Release it for others to play it. You can generate keys for your friends to give them access to it.
Hey together, for my UMG windows I have a window manager (for interaction between windows etc) which is currently owned by the PlayerController. Since I only need that window manager on clients and not on server, is there a better default Unreal class available which is only present on clients?
What about the HUD?
Ok
I just need to save 100$ then I will get it
Hm, neat idea, though this is owned by the PlayerController, too. So it would be only meaningful, if it is only existent on the client (didn't checked it yet). I also thought about using ULocalPlayerSubsystem but have no experience with that either.
HUD only exists on client
but do you want these windows to persist between game sessions/maps etc?
Yes, some of them.
Y cool, thanks for your thoughts. Will play around with subsystems, ULocalPlayer also says that is is persistent across maps. π
Local Player probs makes sense for widgets, they do persist
UMG doesn't really behave very well when widgets transition levels though tbh
Have to be cautious with it
is it possible to track changes to array built with FFastArraySerializerItem ?
I have an array of ~300 elements replicating with FFastArraySerializerItem to make use delta serializer
but i need to somehow respond on "onrep" for each element
USTRUCT()
struct FDataComponent : public FFastArraySerializerItem
{
GENERATED_BODY()
// fields and needed stuff
}
USTRUCT()
struct FDataComponentArray : public FFastArraySerializer
{
GENERATED_BODY()
UPROPERTY(NotReplicated)
AActor* Owner;
UPROPERTY()
TArray<FDataComponent> Items;
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms);
// utility methods
}
template<>
struct TStructOpsTypeTraits<FDataComponentArray> : public TStructOpsTypeTraitsBase2<FDataComponentArray>
{
enum
{
WithNetDeltaSerializer = true,
};
};
class AMyActor : AActor
{
UPROPERTY(Replicated)
FDataComponentArray DataArray;
// actor boilerplate
}
but how to try listen to array item changes?
OnRep also works for fastarrayserializer:
UPROPERTY(ReplicatedUsing=OnRep_DataArray) FDataComponentArray DataArray;
but you need to know which has changed?
just found this, checking
/**
* Called after updating all existing elements with new data and after the elements themselves are notified. The indices are valid for this function call only!
*
* NOTE: intentionally not virtual; invoked via templated code, @see FExampleItemEntry
*/
FORCEINLINE void PostReplicatedChange(const TArrayView<int32>& ChangedIndices, int32 FinalSize) { }
void FDataComponentArray::PostReplicatedChange(const TArrayView<int32>& ChangedIndices, int32 FinalSize)
{
if (Owner)
{
for (int32 Index : ChangedIndices)
{
Owner->OnDataItemChange(Index, Items[Index]);
}
}
}
π
bad thing, that it does not preserve the order because uses RemoveAtSwap inside
yes that is the problem with FastArray's
If you don't delete items I think the order seems to be preserved, although the docs say there's no guarantee of this
Hmm.. ok. Thanks for the response
guys is there any way to posses another actor from the client
Is it safe to handle custom net dirty bool in NetSerialize()? I would like to serialize struct only if its bNetDirty bool is set to true and then set it to false as soon as NetSerialize() ends, however I am not sure if engine is not calling NetSerialize() multiple times therefore setting bNetDirty to false on first call would break the system.
I wonder what happens if packet gets lost and bNetDirty is now false. Will it try to resend (call NetSerialize again) the variable but fail because of bNetDirty being now false?
Hmm... is running a line trace in front of the player to get interactables the best method for a pickup system? I tried having on overlap begin/exit collision on pickups, and it works, but kinda sucks if there are multiple pickups that are close to each other. I dont like the idea of being forced to stand in front of an item to pick it up.
Hey guys, I am trying to replicate a chest where a player takes items out it and it will be empty, but each player sees the original amount in the chest. any ideas?
how is it possible that variable replication is reliable? What system is there to ensure that it is reliable? I am interested especially in case when only single var modification happens and the packet gets lost.
I would expect server won't send it again because value did not change
So i have an array of weather types. Once in a while I randomly pick a weather type then change the weather. I have a blueprint with event overlaps. Let's say I have placed 3 of them. If one of the player goes to BP #1, it will randomize a weather type then show the weather only to the player within the bound/
Sounds like the inventory isn't replicated or you're giving the player the items locally, not on the server.
So catch 22 I am currently trying to think of a solution for. I am wanting to eventually include multiplayer capabilities in my game. Right now I have all the relevant values that need to persist across multiple play sessions being saved and stored in the game instance on each players local machine. (Game instance, serializes and writes that data out to a file).
I thought this would be a great way to do this, especially since game instances are local to each machine. However upon looking more into multiplayer I'm wondering if this isn't a good solution in that it essentially relies on clients not mess about with their save files. Might open the door for cheaters. How could I reduce the likelihood that clients modify theses files? I'm probably overthinking this but wanted opinions before continuing development on the game instance.
Don't bother. If you're trusting the client on anything related to their save then there's nothing you can do to prevent someone who really wants to modify it. The only way to truly prevent someone from modifying their save is to have an always-online game (which is a bad experience if the game doesn't have a good reason to be always online). Something harder to modify would be to not have their save locally at all but to save data on your servers even when the game runs locally (still a bad experience if the game doesn't have a good reason to be always online, and still possible to modify the data in-transit or while it's still on the client).
Validating that the client's save makes sense when they connect to a server is a good idea, on the other hand.
Okay, makes sense. What would be an example of validating if a cilents save makes sense? Just checking if the normal items have their normal values?
Yeah. For example, if you are making an RPG with a skill tree, making sure that the player's level and the number of skill points allocated to the tree are correct.
Or, if you have randomized stats on weapons that the stats are within the expected range for whatever the weapon is.
Obviously someone can still edit things to be the maximum you allow, but at least they can't outright break your design beyond skipping the time necessary to get to that point.
Yeah and they would have to be the server in order to do so, presuming I am doing the checking on the server right?
Assuming all saves are kept locally (and transferred to the server) they can edit things however they want. The server would check that these values are correct and reject them if they aren't.
If you're doing listen servers then the player acting as the server can, of course, find workarounds for this by modifying the game, but again this is something you shouldn't really bother with - dedicated servers are the only way to be absolutely sure no one can do this.
Gotcha, alright well thank you very much!
Does anyone know how I would have someone attack with a sword on their screen that lines up with the server weapon tracing whilst allowing realtime tracer manipulation from the client without having to send that info to the server before registering that change on the client whilst still having the server handle and verify all the hit detection?
without putting everything on a delay
that offsets by the latency
I understand the delay offset would line up with the server as for inputs but not for realtime manipulation of that tracer on the client
Why might it be that i can connect to my dedicated server hosted in the cloud on some pcs but not others using the same exe
guys i have a problem with spawning.
The first client spawns in fine but the second one just stands there and moves the first one.
does anyone know how I can retrieve the ping variable?
Not a multiplayer question but I prefer to have an overlap sphere or do a sphere trace and select by distance or angle
Separate sentences please. It sounds like what you're asking for is clientside hit detection with the server confirming?
I have a replicated event (like spawning an attachment). This works fine for the server and the client of the current session. But if a new client joins the existing session, the event (or attachement mesh) doesnβt get carried over. Any tips how to fix that?
I tried reliable and also tried force net update
@chrome bay could u explain a tiny bit more? And thanks for the reply
I should mention that it is a blueprint only project
Ping is a variable within the PlayerState for the owning controller
@young thunder When you run a replicated event, it only happens for connected clients. If you instead make a replicated property, then each new client that joins will have this property replicated to them and they can run OnRep functions.
So in your case, you have an attachment. I assume this is for a weapon or something. You should have a datatable of these. Gameplaytags are best, but even something like integers can work. If you make a variable and replicate it with OnRep, you can set it on the server.
So you want a silencer attached. That might be Gameplaytag WeaponAttachments.Silencers.Basic or something, however you want to lay it out. Or if you want to do it with just integers, Item ID 31675. You set this on server on the weapon. The onrep runs on server when it's set and then on clients when they receive it. OnRep looks up which attachment this is via the Tag or ID, and sets it up on the weapon locally.
@kindred widget thanks mate. I guess I was almost there. I have an ID system derived from the save file that can be decoded into integers to get the right attachment from the data table. BUT I didnβt use OnRep notifies, but normal replication for variables and then used custom events
Hey guys, I am trying to replicate a chest where a player takes items out it and it will be empty, but each player sees the original amount in the chest. any ideas?
Thanks for the reply. The reason why I ask is because I thought there was a better way since things are handled by a server. Guess I'll just make sure to keep chests/pickups a good distance away from each other to avoid bad stuff happening.
How is the event being called for when the player takes the item ? Is it being replicated ? You also need to handle the logic for removing the item properly to start with.
And other than some basic stuff, I'm still super new to multiplayer replication so if I'm out of line or wrong with any of my statements / questions. Anyone; feel free to correct me
When you say "replicate a chest" you are really talking about replicating the contents of the chest.
Anyone have the issue on a listen server where the Frame Rate drops over time and eventually goes to a crawl?
Guys how do i add a hud to a specific player
the hud spawns but it overlaps with the other players
What do you mean by overlapping
widgets should only be on the clients
what is it you are trying to do?
im just spawning and possus diffrent characters and it works but as soon i possus it and switcb to the other client it shows the hud there too
@tight glen
I'm noob at this. So, can you explain how can I do that?
I want to make a game, in that users makes own dedicated servers and so on.
Like ARK: Survivled Evolved.
Not sure if you are continuing a previous post but.... There's not really a straight up answer for your question... I recommend the tutorial links you can find in the pinned messages here
Thanks.
got a very vague question. when running my game in standalone (where a client connects to a dedicated server), none of my actors other than my player are replicating. stuff like target dummies, capture points, etc. they are set to replicate, and they do replicate in the normal editor flow if i play as client etc.
really i'm just looking for a starting point here for debugging
What part of your actors are not replicating that you're expecting to replicate?
basically everything, which makes me think it's a high-level problem
for example, i have a target dummy in the map which paces back and forth. in the standalone game he's just floating there in midair, which is just where he's placed on the map initially. i printed his location on the server and he is moving there, just not replicating to the client. for capture points it's all info that comes from server--capture progress etc.
and again, all this stuff works in the editor, but not standalone
are you actually connecting to your server?
yeah
everything works minus these actors replicating. i can run around, use abilities, etc
Does anyone know how to get the outgoing ping from the server?
Get the ping from the player state on client
if you need to expose it to blueprints it's called ExactPing in PlayerState C++
I have no experience in c++, how would I go about doing that? @weak fog
Consider not doing it, it's not like ping is crucial stuff
π¦
It's not like Blueprint-only multiplayer is a common thing - MP is hard and usually ends up requiring some engineering work
FWIW the Advanced Sessions plugin might have the ping in Blueprint
yes MP is very tough...one thing you'll need to do often is expose stuff to blueprint. this is probably as simple an example as any
what you need to do is make your own subclass of PlayerState. there are lots of resources out there for this that'll go into better depth than me. once you've got that tho, this is how i expose ping:
.h
UFUNCTION(BlueprintPure, BlueprintCallable, DisplayName = "GetPing")
float BP_GetPing();
.cpp
float AAFPlayerState_C::BP_GetPing()
{
return ExactPing;
}
very very small and straightforward example to get your feet wet
is this, in conjunction with the ui stuff to actually fire the events, what I'd need just to get started with a listen server, or am I oversimplifying it massively?
I did what the cedric pdf said, but I'm not sure what more I would need to do just to make it function at a base level
Has anyone ever improved the interpolation of Clients on ListenServers?
I know this problem exists for ages. They did some Smoothing stuff for this, but it's by far not as smooth as Clients see other Clients/Server.
I tried the change with the TickPose, which I think made it a bit better, but still far from optimal. NetSpeed in the ini files is also increased already.
Althouuugh
I just changed the interp variables to the same as the client ones and it seeeems to be better
Question is though if I still need the tickpose change. TESTING IT IS
Okay yeah, that is still needed.
Still open for any ping about this, if someone has some info on improving that even more.
Feels more like hacking it together
Does anyone have a good reference for implementing client side prediction for projectiles?
I want to learn it
Pls someone help
Thank you
What event is happening first. Not obvious from screen shot. Highlight in colors what should/shouldnβt be there on hud.
Quick question: In multiplayer, can clients access data from data assets?
fast question, i found that is possible to replicate animation during networking replicating variables that drives them..
is it possible to do that with live link animation too?
i wrote this too in animation, i think it's a question for both topics
Data assets are essentially game data in your pak file so yeah
Well they're in the executable, but you get the idea
I found the problem, i was multicasting the hud. the only problem now is that the player controller is not being fed into the player
@tight glen
is there a way to simulate lag on a shipping build?
what happens if I have a client RPC and the player has a packet loss of that RPC?
So if packet loss can cause the client to not receive client RPCs, how about a replicated variable that is set on the server? would the variable replicate or is the replication also lost because of packet loss?
Depends if the rpc is reliable
A reliable rpc will always eventually arrive
If it doesn't the connection is dropped completely
Actor replication is always reliable. Eventually an actors replication will get through but it can take many many ms under packet loss for it to arrive. You also can not guarantee the order.
If its an unreliable rpc. Then if it doesn't make it, it doesn't make it.
ππΌππΌππΌ
if I'm using the "open [IPADDRESS]" command, can I test that in the editor? My server player is able to open fine, but I'm not sure what to input if it's on the same machine
So the left is the listen server and the right is the client. This is after 3-4 minutes of a client joining. As can be seen the Frame, Game, Draw, and GPU are all crazy slow. Trying to figure out what is the best way of debugging this or what could cause this on the client and not the server. I have a hunch maybe my widget is always being drawn (checking now) but is there another way to debug this besides using the profiler? Trying to see if it is a networking issue or a dumb logic error issue.
Is there a way to know if a connection has received an OnRep? Kinda like TCP with a handshake? I don't want reliable traffic, I just want to know on the server once the traffic actually reaches
Think I found my bug. Must be somehow re-drawing umg constantly. Apparently I was always drawing a empty screen over and over somehow T T. Back to 120 FPS XD
thanks, I didn't know reliable RPCs always arrived
how does one go about making a random character system like among us with an enemy character and player characters?
Not gonna lie.. I didn't know what to think when I saw your profile picture π It looked so wrong
Anyhow:
I am overriding and using the Restart() function to initialize the PlayerState.
Does this sound like a bad practice ?
Everything seems to work fine
when i add this code to my header file
i get a million compiler errors
if i remove it everything works
but i need it
what's your implementation look like
you probably implemented ServerFire instead of ServerFire_Implementation
well to start, you're missing the validation function
which you probably mistyped as "Replication"
it's validate, not validation
did you also fix "Implmentation"?
yes
It's _Validate() and _Implementation()
Spelling/Capitalisation matters
Also if ServerFire_Validate() just returns true, you can skip it and remove WithValidation
Saves on some boiletplate
Hi guys, got a quick question, we are building pvp vr games. wondering what's the best voice chat tool for unreal engine?
Vivox is also relatively easy to integrate, however it isnt free.
we using Vivox now, but got a bit issues on integrate with game on llinux, and just realize they owned by unity lol
guys any good resource to learn rep graph besides shootergame? π
That's the only official one
Bear in mind it's not worth it though unless you have lots of connections + actors
Good, and from the theoretical point of view just the 2018 streaming?
It's not worth definitely for my use case, but I want to learn the tech haha
just hobbying around
Yeah that's all I know of, I've used it on 2 projects now though so have some reasonable understanding of it. Does have some "gotchas" that you run into eventually
UE5 seems to have improved on some of it too
They got rid of the weird actor lists thing which is a welcome change
buggers, need a ShooterGame UE5 version teehehehe
tbh it's mostly the same, just some of the stranger parts are gone
Concept is similar though
what parts
The thing I didn't like was the "RepList" thing they had going on, and you had to preallocate some "lists" of arbitrary sizes but it never really explained why they were the sizes they were etc etc.
Cool
Like this wierdness:
PreAllocateRepList(3, 12);
PreAllocateRepList(6, 12);
PreAllocateRepList(128, 64);
PreAllocateRepList(512, 16);```
no other explanation
so assume that's gone also in 4.27? or just UE5?
will take a look! π
@chrome bay
hehehe
shootergame 4.27 carried these changes
this is super convenient. Pinging you also @bitter oriole in case you are interested
Ahh good, makes sense actually if 4.27 is compatible with UE5_EA
it isn't but 4.27 released after UE5.0 UE5.0 EA so it goes like... (edit)
4.26 -> 5.0 EA -> 4.27
to an extent
so I bet that some of the non-breaking features made it onto 4.27
yeah meant EA, sorry!
hello all can i make a multiplayer game using only BP(Blue Prints) only with AWS?
Depends on the game
Depends on your marketing budget
i need pubg like graphics
What about the gameplay, though ?
Assuming PUBG you need 100 players on each map and you probably need 10 servers for different regions and to avoid 20min matchmaking times, so say 1000 online players, you need about 100k sales
Got a publisher ?
bro
we have a team of 50 and ya we got publisher and we want to make a battle royale game
Answer is no tbh
same like as it is like pubg
You'll have to learn C++
Then yeah, your 50 person team should likely start with say 10 engineers
You'll need to move a lot of systems to C++ to ever get 100 players, and you'll need some anti-cheat work anyway
The main issue BR games face is the marketing anyway
Also how do you get a 50 person team and a publisher not knowing this already
These are the questions I need answers to
Kinda skeptical too that BR games in 2021 is the thing you want to bet millions on but hey
It's not my money
tbh, didn't see the word money anywhere xD
I kinda explained that I think
100 players in game = need at least 1000 online = need like 100k sales
Speaking from personal experience... if you get big numbers in marketing, you can get free server deals. I was more like on the side of paying the staff
Getting 100k sales is the costly part
Not the servers
Servers for games with 100 players are likely not the worst expense in the world
unless it's F2P with MX in mind, which is the actual model pushed by big pubs
but yeah, not very feasible
Then you literally need millions of players
And monthly events
And a good store with lots of content
But sure
given that you expect income per say... maybe it's just for portfolio consolidation. That can happen
No it cannot
well it happened to me
You got thousands playing your portfolio project ?
yes
At the same time ?
not concurrently tho haha
My point exactly
I think max was 4 servers full (64 player per server). Quite humble, but the release was a disaster
The only thing I'm saying here is that BR games specifically only function at a huge scale that imply a huge ability to get players - that shouldn't be a very controversial opinion
But OP has a publisher and large team so maybe it'll go well
if marketing is great, sure
you can look-it-up my case, the infamous Galaxy In Turmoil.
There's a reason I'll never do more than 4-5 players cooperative
Can't beat a good PVE horde mode
Epic don't get nearly enough credit for kicking off that format IMO
right
Not that PVE didn't exist before ofc
But then of course.. you have to do AI too
as if MP wasn't hard enough π
well in this game I mentioned above, I was forced to do AI because the servers were getting emptied pretty fast
it was a crunch fest, and someone as me that didn't touch AI at all, It was all pretty rough
glad I'm not touching that project again xD
althought this seems more of a #lounge conversation
nothing?
Hey guys! I have a RPC with Client replication, and whenever I call it, both Client and Server reads it, even when the actor is owned only by client. It should'nt be readed just by Client? I'm using 4.26.
Were you originally the networking programmer?
not initially no, I worked on the project mainly to fix things and implement new features
Iβve actually seen this game. Congrats it looked really cool.
@viscid escarp Need to see what you're actually calling on what to understand why it would do that.
It is a pretty simple call. Here both client and server are creating the widget when 1 BP_BasePlayer spawns.
I suppose that only the owning player should create the widget
actor component can have NetMulticast RPCs in them?
The owning actor is set to be replicating
The component is set to be replicating
but neither OnReps nor Multicasts do not trigger on client (multicast only on server)
they can yeah, same features as actors
Don't even have to be replicated to call RPC's if they are default sub objects
if actor won't be replicated won't it fail to broadcast (as there will be no relevant actor on client) ?
@viscid escarpI am not sure what your BasePlayer is, whether it's a PlayerController or Character. But either way, it's usually best to avoid networking when it comes to UI displaying. Your AHUD should handle adding stuff to screen and creating important widgets. Your networking should just be basic values for the most part that are sent to client.
The rare time that I'd say networking should display UI directly is in the case of like a network wide message.
it is a bit weird, for some reason can't make actor replicate component properties (even simple one)
actor bReplicates = true, component set to be replicated by default = true, modifying replicated var on server = no change in details on client (does change on server)
actor is placed on level with netload on client = true
thanks i'll try to use HUD
nvm, someone unticked replicated on component in blueprint class hierarchy chain.
π€¦ββοΈ
thank you, not very proud of how the chain of events occoured π
Hey, i have a problem with Destroy Session. Destroy session doesn't work for me. Server is still on (listen server) and when server quits a game (changes map), all players are moved with him to menu level instead of just staying there (they should stay offline on map, without server)
Any ideas what i need to config?
you need to seamless travel
i have it on, but there is no problem with travel
the problem is that destroy session doesnt work
it doesnt destroy a server
it still works
im using advanced session to create server
why are you destroying session ?
when server is gone all clients handle disconnect and return to menu (default map)
you can try change it in HandleDisconnect
Are you spawning the building on the server?
What is the correct way to make an ALS character face a direction and have it replicated over the network?
when an actors net relevancy changes, is it spawned and destroyed on the client? like, would beginplay and endplay work for it
are you using ALS-Refectored? or old one?
i think setting focus point would do that or rotatetofacebbentry
check out https://github.com/Sixze/ALS-Refactored/
still spaghetti in places but works better
Yes
neat. thx
Spaghett! Also thanks
Sigh, it doesn't compile in UE5.0EA despite claiming to:
unresolved external symbol "public: virtual void __cdecl UAnimGraphNode_BlendListBase::GetOutputLinkAttributes(class TArray<class FName,class TInlineAllocator<4,class TSizedDefaultAllocator<32> > > &)const " (?GetOutputLinkAttributes@UAnimGraphNode_BlendListBase@@UEBAXAEAV?$TArray@VFName@@V?$TInlineAllocator@$03V?$TSizedDefaultAllocator@$0CA@@@@@@@@Z)```
may need to fix, worked only on 426 with it so far
:triangular_flag_on_post: Alaa (Alex)#4397 received strike 1. As a result, they were muted for 10 minutes.
Can someone explain for Replication graph what these do:
PreAllocateRepList(6, 12);
PreAllocateRepList(128, 64);
PreAllocateRepList(512, 16);```
Trying to figure out what the first number has to do with the second.
Does this have anything to do with the spatialization?
Apparently these were completely removed in subsequent versions.
They arent really clear why they are needed to be declared like this. Its one of those things thats just "do it cause its needed for some reason"
Hmm, 4.27? I'm using 4.26. Just don't call it? It's definitely throwing some message when I have a lot of units on the map, could be density could be total units I'm not sure, where it requires over 512 allocation for something.
Yeah 4.27 it was removed.
Ah, Ok thanks. I should update, wanted to get the oodle network stuff too.
The lists are only used if necessary
If 512 isnt enough, declare another large list.
yeah, wanted to understand the numbers I was throwing at it, particularly what that second number meant
We dropped our support for RepGraph as it turned out we didnt quite need it. So its been a while since ive played with it.
Ah ok. Wonder how much rep graph helps now vs. just push model since they seem to try to do similar things, and I'm actually not even using the spatial portion of rep graph since you can see most of the map all the time.
Push Model is different to RepGraph.
RepGraph is useful if you have a large world with many replicating actors and connections.
Push Model simply requires Programmers to explicitly mark properties when they need to replicate.
This helps save on performance as the Engine doesnt bother doing automatic value comparisons in order to determine if a property has changed and therefore needs to be sent to clients.
Essentially passing the responsibility to the Programmers.
On a per property opt in basis.
Ok. Rep graph sorts it out for the connection relevancy, and push is the ability to skip the checks for properties of actors
Basically.
Hello , is it possible to bypass the Map Loading at startup and connect the game directly to a server adress at game start?
Because the game loads all the map 2 times
The game starts offline because i'm in standalone mode , after its loaded i have to click a button to "open 127.0.0.1" and its loads the server map
two map loadings
Or maybe have i to run as client?
Solved , i simply had to run as client with separate server
Hey guys, i added a build feature to my game, for some reason only the main character is setting builds for everyone to see but when the other players try to build nothing places in the game, only for them. I don't know what is wrong with my replication, all the code is in my player character
It sounds like your clients are creating the actors, instead of telling the server to create actors for everyone
@warm sequoia
Could someone tell me exactly which nodes I need to create a listen server and then join it from the client?
I know apex destruction is technically deprecated but has anyone had success getting destructible mesh components to fracture on clients after creating the comp and applying damage via netmulticast? Currently I can create the comp for all clients but the damage never seems to be applied so it never fractures
FWIW my setup works perfectly running as a client and connecting to a local server within the editor, however if I package the project and connect a client to a dedicated server, the destruct comp gets created but damage never applies
Or alternatively, since apex is deprecated should I be trying to use chaos? Last time I tried using chaos it was extremely unstable and would cause crashes consistently. Are there any other options for networked destruction?
I've created a basic teleport ability integrated with SavedMoves and NetworkMoveData, but for some reason I am still seeing net corrections. Any idea why that might be the case? Is it normal to see net corrections even with custom moves integrated into saved moves?
this is 100ms lag on each machine, 20ms variance, and 3% packet loss, so if this amount of corrections is normal for that quality of connection, let me know
SO in my component, if I want to toggle a variable, what's the efficient way to replicate it.
So far using server and multicast works.
Unless I should move that to char bp
Small question. When a repnotify bool's value is set to say false when it's already false, does this still trigger a repnotify or does the repnotify only trigger when the value actually changes?
@void nest By default (and blueprint) - the rep notify only fires when the received value is different from the local value.
Yeah seemed logical, thanks! π
You can force them to always be called when the value is received, but a Server still won't send a value unless it thinks the client has a different one.
If you want the RepNotify to always be called, you can do this:
DOREPLIFETIME_CONDITION_NOTIFY(AHT_CommandData, NetRequestSyncHandle, COND_None, REPNOTIFY_Always);
Are PreReplicatedRemove and PostReplicatedAdd also called on the server for FFastArraySerializer ?
I have a reaaaally strange issue. The Mesh of Clients jitters on the ListenServer.
And I know that stuff like this is known, but here comes the weird thing: If I open the AnimBP and save it, it stops, until I reload the BP or the Project.
Changing the AnimBP to something new and empty also works SOMETIMES.
I disconnected everything in the actual AnimBP, being anim graph and event graph, saved -> Fixed, restarted -> Jitters.
I'm not sure why. I tried with and without the TickPose changes (so native code and with the more aggressive fix), no difference.
It's also only on the ListenServer, but I don#t get why saving the AnimBP fixes it temporary
It's so bad that the capsule moves smoother than the mesh....
I'm still debugging to get more infos, but right now I don't even know what it could be
Do ListenServer and Client use the same Smoothing code? are there any general differences? Some variables that are changed for ListenServer despite the Interp Time (which I set to the same for both)?
@thin stratus u derived from ACharacter ?
Yeah
I know about the TickPose stuff, as written above. I applied and reverted the change for ticking it manually instead of via RPC updates, but no effect
Maybe I did it wrong though
by default the default mesh is interpolated for smooth simulation not capsule .
maybe you have your own mesh as child of capsule ?
No it's the Mesh itself
π€
I know only the Mesh and ChildComps of that are smoothed
It feels like the Mesh position is fighting with an new and an old location
But if it was code driven why would it resolve by just saving the animBP
And if it's the ANimBP, why only the server
Freaking annoying issue
Hmmm
So I added a Sphere/Cube to the Mesh and the Capsule, to see the smoothing in action. The Client actually doesn't smooth the Server o.o
Sphere and Cube remain fully inside each other. For the Server seeing clients you can actually see how the sphere (mesh child) gets smoothed and follows the cube (capsule child) delayed
@thin stratus host sees the client jitter?
there is this thing with listen servers where the CMC update from client actually Ticks the Skeleton
if the client has low framerate, i don't think the problem is solveable
Yeah I know about that
You can comment out hte TickPose call in the MoveAutonomous function
And then set the boolean for not ticking the pose for autonomous to false in your character
That way it should work normally. it also looks fine if I save the animBP
this is obviously in editor test
have you looked at what callbacks anim BP throws when its saved?
Say I wanted to make a platformer for 2 players, but my moving platforms are very stuttery on client. Do I use some kind of prediction for that, like building something similar to UCharacterMovementComponent but for boxes?
No, haven't gotten that far yet
Okay so it stops doing it if I disable the listen server smoothing
which makes me think it has to do with that
I'm confused as to why the Clients don't smooth other clients in this project
Kinda yeah
It's way too much for a simple platform
But you would indeed try to interpolate the visuals over time
I see, at first I thought it should be quite easy, but now that i think about it, its not. I'm nowhere near that level of expertise to even try writing something similar to charactermovement. Kinda bummer because that makes me think I'll be severely limited in terms of what i can do in my multiplayer project.
Again it shouldn't be anything close to that
If it's a moving platform that is not controled directly by the player, then the CMC is too much
And even if controlled indirectrly if might not be needed
It would be enough to take the new location/rotation and interpolate from old to new
That's a fraction of the code that the CMC has
and if its movement is entirely predictable
you just need to sync it for one frame
and let the clients take over
Yeah you could just sync it every now and then and let the client move it by hand
Now i feel encouraged, Ill definetely look into this, I missed the fact that the movement is predictable.
trying around with the different debug modes the CMC has, I still can't figure out why the Client sees the Server so perfectly. The Mesh is barely if at all behind the capsule.
Other way round, it's sometimes a full capsule radius behind
Is the update rate just lower from client to server?
Although that shouldn't change anything about how far it lags behind. Feels more like the server uses different interpolation values, while I made sure the two that are avaiable are the same as the clients have
Server isn't using SimulateMovement for the Client, which makes sense, maybe there is the diff
is that still uptodate? ...
Although that's for forward prediction only
Hi all, I'm trying to work my head around when to serialize variables.
I understand that when you mark a property as "UPROPERTY(Replicated)" it will replicate itself over the network using it's owner's replication settings (NetFrequency, etc). However, what I don't understand is where does serialization come in? When would I want to "serialize" a variable?
Sorry if this sounds dumb, serialization is quite new to me so I'm just trying to understand it/trying to find ways to utilize serialization, as I've dug through some of Epic's code and seen it a fair bit. Thanks. π
Serialize essentially just means "turn this into a stream of binary data"
Not that it isn't already.. sort of. You don't really have to do anything special. The only time you might want to do custom serialisation is when you want to compress values, or force things to replicate atomically etc. Usually for bandwidth/cpu optimisation reasons
else if (NetMode == NM_ListenServer)
{
// Linear smoothing works on listen servers, but makes a lot less sense under the typical high update rate.
if (NetworkSmoothingMode == ENetworkSmoothingMode::Linear)
{
NetworkSmoothingMode = ENetworkSmoothingMode::Exponential;
}
}
Okay..
Ah interesting, thanks!
Quick question please. You know how physics isn't deterministic at the moment.
I want to know if the LaunchCharacter or AddForce functions in a character are deterministic over a network? i.e. do they use the physics engine or is it calculated movement?
Character Movement is all internal simulation
But things like AddForce/Launch aren't part of the predicted/replayed sim
Ah, so non-deterministic?
Well determinism is different to prediction/replay
It's deterministic in that if you provide the same input conditions, you get the same output - but so is physics really.
But networking in Unreals style really makes determinism impossible, because every factor has to be deterministic
Oh, okay. I see what you mean.
Let me provide some context. I'm trying to simulate pendulum motion in a character without using physics constraints (which use the physics engine and physics is a no no for me on multiplayer). Using GAS for the system, would I get the same forces on the character on both client and server?
Not really no, you have to build the custom movement completely into the characters movement component
Right. So using one of those compressed flags and saved moves e.t.c I can get something reasonable
Anything other than jumping, crouching and changing max speed basically isn't supported out of the box
At least, not properly
You can maybe get it to work
That only counts for Client initiated movement though
If your movement is server initiated, you can't do much about corrections
yeah
Hmmm. I understand.
But that's really an unsolvable problem
Character can't forward predict stuff it doesn't know is gonna happen
So I'll just have to roll with it and hope for the bestπ
And it can't be both forward and replaying at the same time
We basically have the same issue atm, where we launch an enemy that is hit by the player and you just can't predict it. We gave up and accepted the delay on higher pings now
Yeah there's not really a solution to that IMO
Outside of switching to a lockstep simulation
But then you get input lag anyway so meh
But to be honest, have two players with different pings walk into each other and watch the universe divide by zero
I don't mind prediction just that the motion is consistent on both ends. Unless that is prediction.....
If you want to avoid corrections, both client and server should do it, in lockstep with the character movement sim
If something is initiated by the server, that can be near impossible to achieve completely seamlessly.
But since GAS does prediction (but doesn't directly interop with CMC), it might be a little better
I wouldn't know how to implement that. Any resources please?
None I know of
You can look at UT source code, and see how Epic integrated different movement styles with it
like sliding/wall dodge
I'd probably do it in a similar fashion to my wallrunning code. And use set actor location. The calculation should be consistent I imagine. GAS can then handle prediction
Not sure about performance though
SetActorLocation will immediately break unless the server also changes it's location (assuming you're doing it client-side)
If you call SetActorLocation server-side, you'll just get a correction
It works fine for the vaulting where I am doing it on tick using an ability task
With simulated lag.
In any case. Thanks for the insight. Both of you. I'll try different things and choose the most consistent method.
I hope I don't regret any decisions.
Vaulting is something you usually do via a Montage
And RootMotionMontages are handled by the CMC
So that could be why you see it properly
Hi all, im having an issue with a Line Trace, i have a system where I have objects that can be interacted with lit up to show it can be interacted with which i have running on my characters base BP, i need this working properly for both server and client but i can still see the line trace as a client if the server player looks at one of the objects, i thought i'd get around that by making the event that calls the line trace function to run on owning client and then calling that event on tick, but that hasn't fixed the issue, and its somehow relating to a crash im having when a client joins the server through steam, has anyone got any idea's how i'd go about getting a line trace thats ran on tick in the characters base class to work properly for both client and server?
Here is the log from the Client, which gives a different error but no mention of the event that isn't working
Here is the log from Server hosting the session, you can see where i join then get kicked as well as the warning log for this event that isn't working properly
hey guys! How can I test my game with some friends on steam without publishing the game? any advice?
check the ue4 youtube channel, they have a whole playlist on setting up steam lobby
Not sure what you actually need here
basically they need ue4 and the project too
it's enough to use the 480 appid
But you can also use your own
You don't need to publish the game for it
You just need to give your friends some keys that you can generate
It's enough for them to have the key , cause that allows the mto download the package via steam
So they don't need the project at all if it's just for gaming
That is not possible for 480 though
There you'd need to send the packaged game over to them by hand
But again, no need for them to have ue4 or the project
i never done it, do they accept wip projects?(steam)
They don't care about your project
You pay the $100 and then you are fine
Given you supplied all the tax shit they need, cause 'MERICA
money solves all the problems as usual
Yeah, but if $100 stop you from deving your multiplayer project, then you might dev the wrong project :P
Or just use 480 in the meantime
But EGS needs to accept you or?
I guess EOS without any proper Auth method works too
Sorry, EOS, not EGS
--
Okay so these values, if set to the same, are resulting in different visuals on server and client:
Client sees other simulated clients very close with their mesh to their capsule (location wise).
ListenServer sees autonomous Clients quite far behind (location wise).
And quite far being +- the radius of the capsule as distance
That's with no simulated lag
I just noticed that if you run against a Player as a Client, that the Server extrapolates the Mesh backwards, even though nothing is moving
It's a combination. I have only a few vaulting montages so to get it to look right and work properly, I force root lock on the montage and move the capsule with code using set actor location. So the montage is essentially just a regular animation without root motion.
It's done in a local predicted ability so..... Maybe that's why it works properly
https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/GameFramework/FRootMotionSource/ this is awesome for multiplayer vaulting
Generalized source of Root Motion to a CharacterMovementComponent.
I mean it works fine but thanks. I'm taking a look.
I have an actor with a replicated boolean. On the server on BeginPlay, it is set to true. Then a client connects - the replicated boolean is still false initially (on BeginPlay) despite it being set on the server prior. Is there any way to force variables to be Net Updated before begin play?
If I have a gun, and the player pressed the button to fire it, is the typical approach to issue an RPC to the server (SV_FireWeapon) or is there another way that is more correct?
You could do something based on a rep notify, delay the BeginPlay setup until the notify happens...
Yeah, was hoping to not use rep notify because then I gotta rework a bunch of logic
There's also that option to load replicated objects on the map on the client before receiving replication
Is this a placed actor?
Placed in the map, yeah
Yeah, I'd try turning off Net Load on Client. That way the actor won't exist (no BeginPlay) until the server sends the data
My guess is that would do it
You could also just add a delay loop in the BeginPlay based on a replicated boolean that gets set to true on the server's Beginplay
Trying it now, so far seems ok. Issue isn't reliable reproducible. I don't like relying on delays, just feels like a messy solution
Oh, delay loop.. yeah but the variable isn't always set
So I have no exit condition
Hello guys how can i make the advanced session joinable from anywhere without Steam ? ..
Im using Playfab to register and transfer session data and IP
Yeah, you'd add a second variable server has begunplay
or something
and that's the one your delay loop would be based upon
so it would always be set to true on the server, and would only become true on the client after replication
ahhhhh yeah. I think I'd rather just disable net load on client, seems cleaner
Yep, if you can do it that way I agree
looks like it's working, thanks!
The downside to that is if the actor isn't relevant yet it won't exist until it enters relevancy
I've always seen that but never thought about the implication
Hmm, shouldn't be a problem I don't think...
Cool π
Oh no worries. I'll just repost it
Q: If I have a gun, and the player pressed the button to fire it, is the typical approach to issue an RPC to the server (SV_FireWeapon) or is there another way that is more correct? If using an RPC for this, should it be set to reliable?
RPC to the server, there is no other way to inform server about that fact. The RPC should be reliable.
Depending on the ROF of the gun, unreliable might be better or you risk flooding the bandwidth with requests. Depends if you're pedantic with hitreg @crimson valve
Reliables fine unless it's like 50 rounds a second
If it's a shooter you don't want shots missing or never firing
We've got 100 players firing 1200RPM weapons in HLL, and that's up to 2 reliables per shot
Never been an issue
Yeah I meant something like this. Miniguns and the like. Just something he should be aware of I guess?
If it's something that crazy then probably want to do something like UT where they tie it into character movement.
Or preferably, shoot the designer and ask them to get real
π
we send 1 RPC per shot
no issues
projectile guns are 2 RPC's per shot, (snipers, rocket launchers, etc)
How come you need 2 RPCβs for projectiles?
I take back my earlier statement then. Misconception.
cause proejctiles activate the ability, this is one RPC, then 1 rpc for target data + end ability call
hitscan, does it one rpc, as its done the same frame
Yeah this is basically what I was wondering about. If packing it into the player's move data was the normal way, or if RPC is.
Sounds like RPCs are fine
I was kind of afraid of sending too much, but it seems like I don't really need to be if that's how yall are doing it
One of the cases was player footsteps. Easiest way to do it would be a RPC per footstep trigger. Harder was is to infer the footsteps based on movement on the client.
I also had it suggested to me to just use anim notifies on the client, but since my character is a VR character with no legs nor a run animation, that won't really work π
footsteps as RPC's?
those are normally done via the animation and a notify on the footstep
as this is ran on all clients anyway?
you can just fake it tho
even with VR
Even something as simple as a constant distance check from the last footstep sound on the client would be better than RPCing that.
So If I have a custom component added to my character. in that component. Is that server and all clients or diff than pawn?
hello, i have lobby map with a weapon loadout section. once the player finishes picking the loadout it can press a button to server travel to the game map and the player's character should use that loadout. what is the best approach to do that? i assume it's either storing just that player's loadout on the game instance or in disk of the client and when the character spawns the client gets that information and tells the server what to spawn?
@cosmic yoke how complicated of an answer do you want?
as best as you can do π
well, first and foremost you should never trust the client with any type of data. They could easily cheat and give themselves weapons they haven't unlocked/earned yet.
There's a few ways to approach a loadouts option.
You could have a lobby server the client connects to and just have the server display what they can/can't use, then connect to another server from there.
The best way i've personally found is to store that loadout data in a database that the server and read/write
when a client joins, the server fetches data about the client from the backend, in this case loadouts, then sends that data to the client, showing them which loadouts they can use
if you don't want to go the lobby server route, it gets more complicated
I would still recommend using a backend to store the data
whether that be a database, dynamoDB, w/e
but you'll need to run checks on your API server that's writing to the database, you should never write to a database directly, to ensure the player can actually use the loadout they've built.
Which becomes an annoying mess to maintain.
does that answer your question?
I would use their uniquenetid
that's generated by unreal?
steam OSS will get the steam ID there
The uniquenetid be the same each time you log into that specific online subsystem.
but generally, you want the loadout struct of some sort
along with a function that can fully equip the player taking that struct in
and you also want all loadout data thats static stuffed into data assets/tables
so that your loadout struct just refers to data rows/entries
that way its much easier on the network
Yup. You should still store all that stuff in a database though.
Personally I've just converted it to JSON data and sent it to my rest api
in case you're using seamless travel, which you should be doing
then the server can just stuff the loadout data into playerstates that will persist through seamless travel, or at least long enough to call copyproperties
Yeah once the server actually has the data, it's just a matter of attaching it to the playerstate and persisting it between levels
and the loadout data arrives on the game level before the characters need to be spawned
without any writing to disk shenannigans
When I have a player join a session, it sends them back to the main menu. Is there a reason for this??
there is, and its probably your handling of the callback when client joins a session
I would check the logs
Ah alright, ty
"LogWindows: Failed to load 'aqProf.dll' (GetLastError=126)
LogWindows: File 'aqProf.dll' does not exist
LogWindows: Failed to load 'VtuneApi.dll' (GetLastError=126)
LogWindows: File 'VtuneApi.dll' does not exist
LogWindows: Failed to load 'VtuneApi32e.dll' (GetLastError=126)
LogWindows: File 'VtuneApi32e.dll' does not exist"
What should I do with this information
with that? nothing, its unrelated
well, you want the bit starting with joining a session
and ending with loading main menu
alrighty
I have a combo counter for my attacks to determine the montage selection of attacks. The combo counter works fine for the client to server replication but always retrieves an INT of 0 upon every execution of the multicast. Does anyone know why this may be happening?
do i have to physically pass through the integer through the replicated function?
Greetings, how would one approach creating a local health bar UI in multiplayer that runs independently on client and server. Client labelled RPC and βreplicatedusing= β have already been tested and it only replicates the servers health. Please help, there are no resources anywhere about this!
CreateSession and JoinSession not working in LAN with OnlineSubsystemNull. Tracing through the code shows that no GameNetDriver is initilized. Why this may not be working
I have one in Blueprint if you wanna see some screenshots of it
You can't replicate properties from client to server, only from server to client. If you want the client to be able to modify a value on the server, you need to make a Server RPC.
the best way I think to do it is to have your server apply the damage in the first place, just server rpc the "apply damage" node and then it should be used to update your Health variable, which is onrep. Your onrep Health then runs either a BPI or custom event to update the bar to the new value
I don't know many C++ functions btw but you can probably translate it to that from BP easily
so the highlighted nodes should work for my basic usage, right?
I don't necessarily feel like packaging to test in MP and then having it not function past the menu
Is there a way to have the client possess a character?
if i have some eents in the mp character bp and get player controller. Will this coutn online for al players or just the client who is playing his cahracter?
Get player controller references the player with index 0
You would need to assign your players an index to reference them correctly via get player controller
Otherwise you always reference the player that has joined first so to say
I think there was a little miscommunication yesterday.
The problem: I have a P2P game (using advanced session to create server), and when the host leaves a game, all players (clients) are automatically send to main menu level.
Needs: I dont want that. I want them to stay on that map, without a server, just local game. I want to show them a UI saying "The host left, now click this button to back to menu". Because if they just change the level, the know nothing. It looks like a bug for them.
Problem again: Destroy Session doesnt work - when i call it in editor (or steam), the server still works, the clients are connected and all things are replicated. I want to shutdown the server before host leaves a Main Map to make sure that clients will not travel with host to Main Menu.
So first you don't have P2P, you have a listen server
Second, you can do that but not easily or without engine changes
Third, sessions do nothing in editor
Debug with -game or right-click uproject / launch to run without editor
As to the main thing here, clients don't follow the host to main menu - the engine just puts you back to the entry level whenever you disconnect. You can easily edit the engine source to make it pick say, the last level, but you're still going to have a hard level reload with loading screen and gameplay reset
And you cannot control the timing of that since the host may simply have had its power cut or the network went offline
So you have three paths here - dedicated servers, ignoring the issue, and undergoing engine changes to implement some sort of host transfer
Ah understand also in a Listen Server Match?
Index 0 for listen server will be the Hosting Client
But right now im not 100% sure whether running get player controller with index 0 on client only will give you a reference to the listen server or the client running it
Havent used it for a while, as I tend to use "get controller" when possible or just have an index stored for each connected player
yes i also struggle here, in local the playercontroller will be added p 1pc 2 pc 3 ect.. but in online its always 0 as i know---- thats whast make it now hard π
that is not always true
while seamless travel is in progress, it might not be
use GetGameInstance()->GetFirstLocalPlayerController() instead
imo, the only good practical use of GetPlayerController[Index] is when iterating over all controllers from blueprint
every other use has a cleaner, safer, or faster approach
*there might be some cases where it is practical during a split-screen MP, with multiple local PCs
So I'm still wondering why the interpolation time for ListenServer and Clients on Smoothing, when being the same value, is super different in terms of the result :(
Epic does a poor job here on actually explaining what the difference is.
/**
* Similar setting as NetworkSimulatedSmoothLocationTime but only used on Listen servers.
*/
It's similar, yeah, but the value is not doing the same. Setting them both to 1 second, the Server has a huge delay, which nicely shows the smoothing and the client still nearly sticks the mesh to the capsule
well, at least its not ```
/**
- TODO: document
*/```
just as useful tho
:/
I also just have a DebugGame Editor build that still doesn't give me all debug info.
Lovely
thats odd. whats missing?
const bool bIsListenServer = (ClientMovement.GetNetMode() == NM_ListenServer);
I just can't get that boolean value
I know it's true based on following lines by now. But still, why is that optimized away
you can probably grab it from outer scope and put into watch
Either Epic didn't implement the smoothing correctly, or the Time variables are totally not "similar"
I can literally run around my mesh as the capsule when setting the time to 1. It's like a 2-3 second ghost that follows me
I might have this all wrong, but Iβm having a discussion with someone on notifies/multicast.
My take is that a reliable multicast is bad for updating UI due to you never know when the data arrives to the client, and a repnotify would be a safer choice.
While the other guy says you should just use a multicast because itβs just a matter of small ms differences.
Iβm eager to learn more if Iβm wrong
RepNotify is always a better choice than a reliable multicast
Yes, that was my thought
But broadcasting events to update the UI only is a bad design anyway
UI should update itself locally
Based on the current status of the game
Yea, but I guess Iβm not gonna argue then. Doesnβt seem like he has grasped it even after all my explanation π
Yeah if you already have the data being replicated, use a rep notify. Apart from a reliable multicast being expensive, there's no garauntee whether the property or the multicast will arrive first, and it's wasteful if a repnotify is already there
RepNotify is entirely client-side, they have zero bandwidth cost
Yea, that was my point all along. But still gives me the argument its just a matter of ms. Iβm giving up on this π
If someone is telling you to use reliable multicasts to update a players' UI, they have it all wrong π
How can I replicate Client Rotation on the Server? I'm changing in specific function a Capsule Component World Rotation. But I have a problem that this rotation does not replicate on the server-side.
We just update the rotation from client to server on an unreliable RPC.
How to do that?
I'm a noob, so, resource about this.
Or.
Explanation. Will appreciate.
Hold on
Roger that.
This is in BP though
Anyone know what this error is? this is from the clients log when losing connection to the host for some reason
check server logs for the reason
Hello again. Did I do all correctly?
Why do you want to change rotation of the capsule component?
it's already replicated by default with replicating movement afaik.
Do you speak about Capsule Component? Right?
If yes.
It doesn't work.
Rotation changes on Client-side.
But not Server-side.
I manually change rotation with SetWorldRotation.
Rotation of the player is already replicated
Then why, when I change the pawn rotation on the client-side, this pawn's rotation is not replicated on the server-side.
What's the problem?
Character.
Then you're not supposed to do anything with world rotation/actor rotation
It's all done internally within the character
All you have to do client-side is call "Add Movement Input" and "Add Controller Pitch/Yaw" etc.
Character Movement handles everything else
Okay, thanks, now I need to figure out what I did wrong.
@woeful ferry @chrome bay
Thanks.
So, how can I do rotation via Character Movement?
You use control rotation
Which is automatically sent to the server via character movement as part of the networked movement code
Even the FPP character sample will work in MP out of the box, Epic have done everything for it
So, I have a logic, that I'm clicking with mouse left button.
And my character rotates.
To the mouse's impact point.
With Character Movement -> Control Rotation?
No
Player controller
GetController->SetControlRotation()
yea
The ControlRotation caught me offguard a few years ago too, when trying to rotate players to face spawnpoint rotation >.>
For some stupid reason, 'ControlRotation' is a property of controllers. The character has an option to align itself with control rotation which is handled by character movement
I think it's a legacy thing that's just stuck
But it's an irritating part of the framework IMO
It's useful for characters that have that upper body rotation I guess
Should just be AddLinearInput and AddAngularInput IMO
Yeah
Even then they could just separate aim vs actor rotation at the pawn level.. but yolo
So UT shit :D
yeah
I tried opening a new project to test AddForce.
I applied force to an object through Server and observed how far the object flew.
Then I did the same thing, only now I had 9 additional clients.
This time, despite only running once on server, the object flew WAY further. I am positive that the add force is somehow multiplied by the number of clients - despite only running it on server.
Does anyone know about this issue?
For the viewtarget stuff you'd need the controller rotation anyway
What Object are we talking about
And what Force
Thanks, guys, now, finally, this works. You prevented me to do shit-code. Brave men.
Afaik Force added through the CMC is different than Force added to a Physics Component
And on top of that: without you showing your code, I blame your code
Had too many peeps that said "Engine has a bug" and then showing their buggy code >.>
I have no intention of judging an engine I love. I only wish to understand it β€οΈ
So that's a Physics Simulating Object?
Yes indeed.
Keep in mind that Physics and Multiplayer aren't something you want to mix
But that aside, does the Server keep the same FPS with the 9 Clients?
Probably not. I actually don't know about this. Where can I see this?
stat fps in console
My random idea would be that the Server has less FPS and physics is just shite and doesn't compensate?
I would suggest you don't use physics, but use the ProjectileMovementComponent
That is at least somewhat networked with smoothing of the Mesh
fps is 30 when i play with 10 players.
it's 120 when i play alone
Yeeeeah,
Ah I see. This would explain it
I can't 100% say that's the problem, but would be my guess
Thank you @thin stratus π
How should i handle "broadcasting" back to clients that a gun is being fired on the server and it just spawned a projectile?
What I'm doing now is calling server_RPC from client that asks server to handle shooting;
then server checks if everything is alright and proceeds to fire/spawn a projectile;
everything works just fine, because projectile actors are being replicated on creation, also its movement is replicated;
damage is further handled by replicated variables on pawns, so the damage should only be dealt on the server.
But say i wanted to also play a sound/animation back on clients after the upper mentioned gun is fired.
Now I think I could either do a multicast and report back to clients that they should play appropriate effect,
or I could fire the effect in RepNotify. Which is better? I know that multicast is more costly, but repnotify has its own issue with not being guaranteed call repnotify at the same exact moment.
Okay soooo
First of all, for the local client you don't want to use any replication for the visuals
The RPC + the Replication back to the Client might take quite long
You want to predict the shot
Means you client, in addition to running the RPC, should also check if it can fire, and should then perform a fake shot basically, playing animation, sound, VFX.
In addition to that, you can replicate the firing down to the SIMULATED Clients via OnReps
I think a good way of doing that is to have an Integer which you increase with each shot, and set back to 0 if you stop
In the OnRep you can then filter the owning player, cause they predicted already
that is how the shooter example does it i think
And either start a looping effect, e.g. a weapon that fires until you release the key, or a single effect, e.g. a pistol.
Yeah
And UT does it similar to that too
What I usually do to help with this stuff is to cut the whole thing into multiple functions, and then picture (or even actually draw) what should happen when. You can usually reuse all your functions. e.g. the playing of the sound can be reused. Just have to call it in 2 different places.
Does that mean i only have to predict on the exact client that fired the shot, so the feedback is instant? Then i could call a server rpc to check if its valid and eventually fire repnotify from server to replicate to all other cleints except the guy that did actually fire (he already has his local simulation)?
It also helps to simply leave a comment above you function with // SERVER ONLY // SIMULATED ONLY // SERVER AND OWNING CLIENT etc.
Correct
Server and Owning Client would run the same code
But you put Authority checks in place
To make sure the Local Client doesn't spawn the Projectile and stuff like that
Or set the OnRep variable
But you can even predict the ammo count with this
how come the physics of cubes aren't replicated in the First Person Template?
even though their physics are set to be replicated
even after enabling static mesh replication too
Replicating physics is essentially impossible in UE4
It's somewhat doable with some engine changes but it's never going to be an engine feature
UE5's new physics engine is pretty much built to make it possible, though it's also not nearly there either
awh but that's not the only problem, the location isn't replicating whatsoever
I would have assumed it would at least update from time to time
...
nevermind I was playing in standalone mode
π€¦π»ββοΈ
what would you suggest as a base to make a multiplayer FPS game? I took the FPS template but I feel like I might need to merge some functionality from the TPS one (and the animations)
should I perhaps go with neither and build my classes from scratch?
The ShooterGame sample is a common base for shooters
But starting from scratch can also be welcome if you'd rather add functionality cleanly step by step
I want to add functionality cleanly I think, but I'm afraid I'd mess things up
@thin stratus I can launch my stuff successfully with a projectile component (KnockbackComponenet), but if I enable physics, then it won't move.
Is there a better way you can recommend?
You shouldn't use Physics at all
The Projectile Component already moves it just fine
I feel this is gonna be a dumb question, but I couldn't find the answer. Is there any event that runs client-side when the client looses connection to the server?
I think that's what I need
The heck, HandleNetworkError is just blueprint implementable? Is there no C++ event for "I lost connection, let's display that to the user so they know they've lost connection, and do some error handling" ?
There is, just check where it's called from
Yeah, at least I now have a lead with this event. I'll go up the chain, ty!
Thank you for informations. I will do smth also in this case
Hi, I'm new to unreal engine and I'm trying to make small games with blueprints in multiplayer, I would like to be able to make a client have control over an actor's mesh transform and have the position sent to the server.
Is there any way to replicate transform from Client to Server with blueprints?
@ornate hearth Replication only goes one way, Server to Clients. You can however have your Clients do a ServerRPC from a client owned actor with the transform.
Which could then set the value on server, and let that replicate to Non Owner clients.
Thanks, I will investigate, I guess it is done this way to avoid cheating, in unity at least it was possible to replicate from the client to the server.
You get used to the nuances quickly.
Greetings, everyone!
What UE4 multiplayer learning resources would you recommend? I'm going through Tom Looman's "Creating Multiplayer Games" on Udemy but it has about 10% of its content dedicated to multiplayer, which is not much π I found "'Unreal Engine 4' Network Compendium" on the Internet and will read it once I finish the course but is there anything else you would recommend? C++-focused, if possible.
What is the best way to send client data to game server in ue4 ?
The only way is a server function on a client-owned Actor
you mean not player state or game state ?
Game state cannot work for that indeed
Player state should work well, though it's usually either Player Controller or Pawn
Or any actor owned by them
thanks for helping π
Hi, if im trying to set up sessions to make it so once the session has started other players can no longer see the session listed on the menu, where is the best place to destroy the session?
i asked this in the GAS channel but i wasnt able to get an answer. i have a projectile that's a server-side authoritative actor and i need to execute some code only on the local simulated proxy. it needs to happen when the simulated proxy is being destroyed. is there a way i can do this? the problem i'm having is that OnComponentBeginOverlap only fires on the server, and technically when the projectile is destroyed i always want it to display an effect so i don't need server authorization to play the effect. the effect also needs to happen on all clients, so in order to avoid using a NetMulticast i just want to do something on the simulated proxy
Event Destruct maybe ?
EndPlay is only called on the server currently and BeginDestroy is only called on GC
is this project replicated ?
yes
why
just spawn another one on the client
it doesnt need to be %100 accurate
it would lag the player
let me try this now, uno momento
@rich locust you're a genius, thank you. i have other issues now but they're related to GAS
I'm trying to spawn an object for each player at the start of play. I'm running the spawn object command by starting with a simple Server execution event, which is triggering a Multi-cast event. Inside the Multi-cast event is where I'm actually spawning the object. The object is set to replicate and always relevant. When I test, the server sees everyone's object and their own. The clients see the server's object, other clients' obejcts, but not their own. Why wouldn't they see their own object if I'm multicasting?
can i use steam online subsystem and use the default app id, and post my game on itch.io
only server can spawn replicated objects if you expect that to work. also, for each player means that the server RPC that starts all this is called from where?
The server RPC starts from the player that needs to spawn their own object. Server executes a multi-cast event that spawns the object. Everyone sees it except for the player that initiated the RPC
I've seen in other examples the multi-cast will be excluded from the "local" player and the local player will just run the event locally, I'm assuming so they're not waiting for the server to return the object. I just don't understand why my method wouldn't work
from the player = PlayerController, Character, PlayerState? whats the entry point
I think it's a character class. It's a custom character though, so maybe there is some unique code blocking the replication?
what triggers the server RPC inside the character? doesn't matter if its custom or not
I have a child actor attached to the character. This code is inside the child actor. It's triggering the RPC after one of the child actor's components finishes "OnComponentInitialized"
if the object is supposed to be replicated
you should spawn it from HandleStartingNewPlayer in GameMode, after calling Parent
you should avoid using child actor components in MP, as they are... temperamental
Would I also use the GameMode to do this if the object needs to be respawned regularly? It's a usable object the players will throw, then it is destroyed after use, and another object should spawn for the player to use.
have the object call an event dispatcher when its thrown or destroyed
have the gamemode bind an event to it as soon as it spawns it, and spawn a new one (binding an event to the new instance) when the event fires
Awesome, thanks for the advice, I'll give it a shot!
i just dont get it i tried it in every way i could imagine yet my characters damage events wont register any damage, anyone has an idea?
welp it wont register it only on itself
Don't Multicast RPC apply damage. That apply damage node is only meant to run on the server.
yes i know i did it for testing
Check your radius, check your damage amount, check your origin.
so im kinda new Unreal and I want to make a random game join for my fps game dose anyone know how to do that
Watch the tutorials online. They help out a lot
ok
can i change netowningplayer class (UPlayer) ? . this class is passed by Login function in GameMode.
@gray orchid Sounds like something where you would just get a list of sessions that are active and select on based on criteria and join it. Failing that, create a new session for others to join. Some older FPS console games do this, and might have a checkbox for "Prefer Hosting" or "Avoid Hosting".
I tested my project on another machine and I notice that the client's base movement is really jittery. What's the correct way to set up movement replication, so that it doesn't get corrected at that rate?
Hi
I'm new to ue4 and I'm having a problem
I'm pretty sure its an animation or multiplayer issue, but idk
When I play with two or more players and I do an animation on one, it does the animation for all players, but only shows on the original players screen. It only happens with 2 animations (crouch & crouch walk) any ideas about what the problem is or how to fix it?
Heres a vid of whats happening.
Hello. Do player controllers get replicated to all connected players like the player state does?
couldn't find any controllers that get replicated
could someone help me figure out why this variable isn't being changed, even if the criteria are met? It's in my game mode, so shouldn't the server be able to change its value?
You're certain the branch is evaluating to false?
I actually ended up figuring it out. It was something unrelated
Hello, I need some networking clarification. I have an actor that is replicating (a thunderball). I need to be able to attach a component to it on the client that does not replicate to handle a visual effect. How can I do so?
Just spawn the Component on the Client?
:no_entry_sign: Garrett#8803 was banned.
thanks, bot
That was me
lol that was fast
Is that enough? I'll give it a shot.
He was just lucky I was reading this channel as it appeared lol
hehe
Well that is exactly what your asking for.
wasnt sure if there were any consequences
hello guys do you think that you could "replicate" locations with Firebase for Micro instanciation on 2D game Or simple 3D topdown ?
Hello Everyone! Any clues why the Hosts pawn doesnt replicate the Yaw/Pitch rotation to the clients? the client hosts does to both Server and other clients π
What is the best way to counter race conditions arising from replication delays of game framework actors like game state, hud,player state etc. That may or may not have been spwned on a newly connected client
Just have to code around it. If something isn't available currently, try again later
A common approach is have those actors notify some centralised object that is always accessible when they first arrive on the client.
I use a world subsystem for it
And have an optional callback option when the actors are received
I just use delegates in game instance for it and I wondered if there was a better approach that I didn't know of
Seems fine to me
GI might cause problems in PIE though. Best to confine it to a UWorld lifetime
how can i make host and join? (i made one but it says you need public ip. when i put my public ip i need to open port 7777 and opening port is very hard i tried to do it but i don't think this is the method because other games do it without me or my friend opening ports) sorry for long explaining
Use a subsystem with nat punching like steam
Or change port to something that is already forwarded
Or if you are just testing, use a VPN that offers dedicated IP with all open ports
Would that work for 4.22.3?
@gray orchid I would assume so. Sessions are just data about servers you can connect to. I mean consoles have done this at least since UE3. It's just the idea of getting available sessions, and sorting them based on your decided criteria. A fair warning, this is much easier in C++, but it may be fairly easily doable in BP.
@kindred widget dose this look right?
Vaguely. You'll need a lot of extra checks. And you'll probably want to create a sorting function to filter down session results.
how would I do that?
Hey folks I made a listen server, now I would like to know the procedure to enter from distant computers... between me and me it works, via IP
I don't remember what all data is available on a session to start. I vaguely remember that in BP you can specify extra options. That might be using Advanced Steam Sessions though. Just take the results array for instance and iterate over it. Remove sessions in an order you want based on whatever data. Then just pick one at random from whatever is left.
are you talking to me?
question about multiplayer and players. Should the controls for the character be done through the player controllers or the character or does it not really matter
I cant get it to work I have looked for videos online but I can't find any for random join
Controls that don't depend on player possessing a specific character (think like UI control) should be done in the player controller. Anything else that controls your specific character you may as well place in the character.
(sorry in advance for the wall of text)
I'm seeing an issue testing multiplayer using 3 clients on my machine. All players connect to a server lobby, this works fine. Then when the host starts the game, a ServerTravel is executed. Then, the server loops through each PlayerState in the GameState's PlayerArray, looks for an appropriate spawn point, spawns the player pawn, then uses GetOwner() on the PlayerState to get the controller and has the controller Possess the pawn.
9 times out of 10 this works fine. But in testing with multiple clients locally, I think I have accidentally found a potential timing issue. Since there are multiple clients, each one is performing slower than usual. Probably taking longer to process the level transition. I think the end result is that the Possess gets called before the client is in a ready state. Then by the time the client is done loading it missed the boat on possessing the pawn and I think even the pawn gets destroyed because the controller isn't valid anymore.. not super sure.
I've run into this issue before where the server thinks everything is happy but the client isn't actually ready yet. In the past I've done workarounds like having the client run an RPC to the server to basically say "I'm done loading!" which has always seemed crummy to me. Not sure if there is a better alternative though.
I'm thinking I need to overhaul my logic to use PostLogin and/or HandleStartingNewPlayer to determine when a player is ready rather than just trying to spawn stuff hoping it is
can somone pls explain how to make a random game join like in most FPS game?
I can't seem to get it
Your servers should be using "Create Session" to .. well, create a session. Then if you want others to join they should use "Find Sessions" which will give you an array of results. You can pick one at random from the array and use "Join Session" to connect to it. For further explanation I'd suggest watching a video like https://www.youtube.com/watch?v=tcVEP2fqYmA (havent watched myself but it was the first search result)
In this series we are setting up the connections for online multiplayer using the base Steam sessions that come with UE4.
In Part 1 we put together the basic components and the menus for the online multiplayer connections.
SUPPORT ME
Patreon I https://www.patreon.com/ryanlaley
Buy Me a Coffee I buymeacoffee.com/RyanLaley
Donations I paypal.me...
ok thanks
Also if you're new to UE4, multiplayer can be a high hurdle to tackle, just something to keep in mind
I'm playing around with initial replication timing to try and simplify OnRep logic.
What I understand to be true:
- Replicated variables set on an actor before BeginPlay will be available to clients during their BeginPlay
- Subsystems on the server have been created by the time actor BeginPlay is called, but at this point is too late to be part of the initial replication
What would be nice:
- Is there a time where subsystems have been created (and can thus be used to generate variables to be replicated) but before actor BeginPlay has been called?
thanks
Something like the team you are currently on, it should be stored in the PlayerState and managed by the gameMode, right?
what are advanced sessions?
So... If I want the GameMode to assign a team to a player when It connects, I have to use the onPostLogin() and get the PlayerState from the PlayerController and assign the variable, right?
Is a pluging that extends the Blueprint networking functionality
It let you do some things like manage steam and so on blueprints
That's fairly complicated, how long have you been doing Unreal Engine stuff?
Also largely depends on the online subsystem that you're using
whether it's listen server vs dedicated server, etc
Also, that Plugin won't provide the tools for matchmaking
they'll have to pretty much write it from scratch
Like 2 years but im a slow learner
dose UE have multiplayer videos that do random join?
Asked a similar question a few days ago but never saw an answer. What net settings do you guys test on (pktlag, pktloss, pktdup, etc.), and when using CMC how often do you expect to see net corrections with your test lag settings? I have been doing 200ms, 3% loss, 20ms variance, and I see a LOT of corrections, but for the most part the gameplay still feels alright (not jittering too much).
ummmmm can you simplify that for a 14 year old who is new?
I do default bad settings
what would you consider bad?
i had no idea there were presets
okay, how often do you see CMC net corrections with the bad preset? Just trying to get a feel for if I've implemented custom movement correctly. I see a lot of corrections on poor settings, but I also see similar corrections just walking around.
frequent
but they won't be too large
wouldn't notice most if not for p.ShowNetCorrections
Gears of war did 500ms 15% loss tests iirc
Which is extreme but they had high standards
15% is not a play test, its a will it break test
How much is "not too large" out of curiosity? When testing I've been using ~200ms latency, 1% packet loss. On those settings I still see corrections on the order of tens of centimeters sometimes. I don't really have a strong frame of reference though for determining if that is problematic. Sometimes they are visually noticeable, sometimes not
the one i wouldn't be able to eyeball playing on 1080x720 in PIE
so is that a no?
i was asking a separate question, not sure about your question
oh ok
Is unreal's networking and UDP plugin crossplatform?
:triangular_flag_on_post: Quest#5614 received strike 1. As a result, they were muted for 10 minutes.
how do I fix jittery movement on the client?
You need to look at some tuts and make sure the movement is being replicated properly. Are you using a CMC?
Jittery movement can be a number of things. One of the most common I'd say is that the client is trying to set location different from the server. Or they are both trying to set the location and it's not being handled by just the server and properly replicated back to the client.
I think. Lol I'm new to multiplayer
For example: if you are using Add movement input > make sure these are executed by a custom event (Running on server).
Do your inputs locally and call the RPCs to move the character / pawn.
If it's the default replicated Character Movement Comp on the character class, it's handled automatically. (Some things are)
If you are having issues with jittery movement after you ensure everything is being executed properly. You may need to do some fine tweaking. This is case by case subjective though. Depends on what you are doing and what you are using to do it that determines the approach to mitigate. There's no straight forward answer on "how to fix jittery movement on the client"
got networked teleport working with prediction using the CMC and it looks good on owning client and server. However, other clients are applying smoothing so it doesn't look like a teleport but instead just a dash or something. I'm just using SetActorLocation in the actual execution of the teleport, do I need to use the physics state teleport param for that so remote clients know it was a teleport, or is that strictly for physics?
I'm just using the first person template character. Do I need to rpc its movement, or do you mean that it's automatically replicated? I'm not noticing any weird movement unless I've already packaged the game, aka playing off lan it seems desynced
Does anyone know why pulling a value from this would multicast a null value?
Taking this in at face value I'd assume you're trying to multicast something inside of a widget... But widgets are not replicated at all
oh, I see it clearly says anim instance, you're expecting a component from the character blueprints? @fair lantern
yes
it works correctly for server
but not multicast
@fair lanternYou should not network from an animation blueprint. Animations are meant to be client only. You need to network from an actor or an actorcomponent owned by an actor.
Got it chief xoxoxoxo β€οΈ legend @kindred widget
Where gets a pawn possessed in multiplayer? If I try to get PlayerState() of my character in BeginPlay it returns always null
PlayerState is set on Server via PossessedBy function in Pawn. This is called from OnPossess in the Controller. On client it's just set via OnRep.
Thanks!
@lusty badger Unfortunately SetPlayerState isn't virtual, that would be too easy. So if you want a Listenserver compatible binding for when the Playerstate is set and run, you'll have to override both OnRep_PlayerState, and PossessedBy, maybe also UnPossessed if you need to know when it's null.
Thaaanks!
is there a way to force a given type of actor replicate before another one if packages for each were sent on the same frame?
I want my Characters to always Replicate/process Replication before another actor class
is there a way to force something to be not relevant immediately and not have to wait for the timer where it waits for it to be relevant again?
you can load the dice, but you'll never get always
unless you wait to spawn another actor class until clients ack Character replication
you can either set net priorities, which will do what you want 99% of the time, and miserably fail when there is a packet lost
or you can try to do post replication in other class by starting it from Character
99% it is then
Is this ok to ignore? my game seems to work just fine.
SetReplicates called on non-initialized actor NNNN. Directly setting bReplicates is the correct procedure for pre-init actors
Possibly. Until it breaks. It's just one line. Just change the SetReplicates(true); you have in contstructors to bReplicates = true;
^ If it thaaat was okay to ignore, it wouldn't give you a warning π
like it does protect you from doing dumb stuff, but you definitely should just do bReplicates = true inside ctor instead
Errors are there for a reason. If some programmer went out of his way to mark something as an error, there was a reason for it and they're trying to keep you from blatantly putting your foot in a bear trap. Best to just listen. π
:no_entry_sign: darren77theone#8435 was banned.
What is good practice to place server join and hosting functions
like where should I
Game instance? Player controller?
StinkyButtPoop?
What about game modes. Should there be seperate game mode/states etc for the menu and then the server itself..does it matter at all..or is that a facepalm and just have one set of classes for the entirity of the game
separate gamemodes are good
more maintainable
as for the connection/session code, GI subsystem is nice
is there a way to host my game on like aws or google cloud without dedicated server? if yes why we need dedicated server then
How else would you host a game on aws or google cloud without a dedicated server build? The other option is a listen server in which one of the player's clients acts as the host.
What's the correct way to destroy an actor? I tried using a variable of the actor then replicating it, but it didn't work client side
If the actor is replicated from the server, then calling DestroyActor on the server should be sufficient.
It didn't work sadly. It says pending kill, though when I try to check if it's valid it returns true
If it says pending kill, that sounds like it's already being destroyed somehow.
Ik, which is hella weird lol