#multiplayer
1 messages Β· Page 587 of 1
oh yeah totally
now I gotta go think about another idea for a game lol cuz the one I had in mind focused a lot on multiplayer
Gotta start with baby steps man.
you dont have to pivot your entire game development future
ikr
you can do a small project, 2 months, learn the basics and come back to your original idea!
I just want to learn how to replicate movement well which will take me a bit of time so it will be a while before I come back to my original idea lol
if that's what you just want to learn (rather than develop a game in the near future), then read up on solutions and tackle it head first
(you can do it!)
lol. ship it
lmaooooo
@chrome bay if I limit the fast array to something like 100, everything works great.
are you updating all the time?
cause my fast array had 3k items in it, and not one issue
something you have done must be screwing it up
without seeing your code or w/e we can only guess
what part are you wanting to see?
I'm not permitted to just post all of it, I can show snippets as necessary
not sure tbh, probably your struct, how you are adding items, and your actors rep settings
or at least some bits of it
struct FItemEntry : public FFastArraySerializerItem
{
GENERATED_BODY()
public:
UPROPERTY(Transient)
FString ItemName = TEXT("");
/**
* Optional functions you can implement for client side notification of changes to items;
* Parameter type can match the type passed as the 2nd template parameter in associated call to FastArrayDeltaSerialize
*
* NOTE: It is not safe to modify the contents of the array serializer within these functions, nor to rely on the contents of the array
* being entirely up-to-date as these functions are called on items individually as they are updated, and so may be called in the middle of a mass update.
*/
void PreReplicatedRemove(const struct FVEItemArray& InArraySerializer);
void PostReplicatedAdd(const struct FVEItemArray& InArraySerializer);
void PostReplicatedChange(const struct FVEItemArray& InArraySerializer);
// Optional: debug string used with LogNetFastTArray logging
FString GetDebugString();
};```
so your just sending a FString out?
class VIRTUALENVIRONMENT_API AMyGameState : public AGameState```
show me your Serializer
I've simplified it to that base case ya
how many props do you have in your full FItemEntry?
struct FItemArray: public FFastArraySerializer
{
GENERATED_BODY()
public:
UPROPERTY()
TArray<FItemEntry> Items;
bool NetDeltaSerialize(FNetDeltaSerializeInfo & DeltaParms)
{
return FFastArraySerializer::FastArrayDeltaSerialize<FItemEntry, FItemArray>( Items, DeltaParms, *this );
}
};```
and you hve the other part to go with it right?
struct TStructOpsTypeTraits<FBiomassDamageFastArraySerializer> : public TStructOpsTypeTraitsBase2<FBiomassDamageFastArraySerializer>
{
enum
{
WithNetDeltaSerializer = true,
};
};```
like this?
this part?
struct TStructOpsTypeTraits< FItemArray > : public TStructOpsTypeTraitsBase2< FItemArray >
{
enum
{
WithNetDeltaSerializer = true,
};
};```
just making sure, cause that is important
Yup
then i have no idea, how quickly are you adding items?
are you calling MarkDirty after each add or after you added all ?
MyGameState:
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AVEGameState, RegisteredItemsArr);
DOREPLIFETIME(AVEGameState, Test); // replicated int32 incremented on server frame
}```
cause you need to call MarkItemDirty after every item
when you are adding/changing
and MarkArrayDirty when removing iirc
else your ID counter ends up messed up
creation: partially cut down
{
UItem* ItemObj = nullptr;
UItem** ItemObjPtr = RegisteredItems.Find(Item);
AMyGameMode* GameMode = Cast<AMyGameMode>(this->AuthorityGameMode);
if (!ItemObjPtr && GameMode)
{
ItemObj = NewObject<UItem>(this);
RegisteredItemsArr.Add(ItemObj);
FItemEntry ItemStruct;
ItemStruct.ItemName = Item;
RegisteredItemsArr.MarkItemDirty(RegisteredItemsArr.Items.Add_GetRef(ItemStruct));
ItemObj->SetItemName(Item);
}
else if (ItemObjPtr)
{
ItemObj = *ItemObjPtr;
}
return ItemObj;
} ```
ignore all of ItemObj stuff
i had issues doing that
Doing which part?
RegisteredItemsArr.MarkItemDirty(MyItem);```
i honestly has weird bugs
when doing what you did above
Lovely, so what did you change to? Also, to note, is that I was having this same lockup problem with a regular tarray of this ustruct before moving over to fast array
err i can't show you my code, my pc died, (motherboard or cpu gave up)
and my works project is all NDA π
Guess I'll try
RegisteredItemsArr.MarkItemDirty(RegisteredItemsArr.Items.Last());``` π
no
just do FMyStruct& MyStruct = RegisteredItemsArr.Items.Emplace_GetRef(); MyStruct.Name = "Blah"; RegisteredItemsArr.MarkItemDirty(MyStruct);
also nice and clean
Launching now. I always forget which array libraries have which convenience function lol I hop languages and over to stl too much
Interesting. Stalled for a while then client started getting regular updates.
I think I've got something totally unrelated stalling network traffic for a good while at startup π and all of this I've been screwing with is just a side effect.
yeah
get the profiler out
and get insights running
find out what is happening
insights in 4.25+ will show you all network traffic
and sizes
thats something I gotta do myself
still havent managed to open the profiler and get it working
Thanks for the help man. I've used the profiler plenty.
Hi, I was wondering if anyone knew how to sort a scoreboard like in most shooter games with kills and deaths. I have the scoreboard made I just need to know how to sort an array of PlayerStates by the kills variable in it. I'm using bps
@meager spade reading the docs on it right now!
If you explained how it works I might be able to figure it out in bps.
i honestly can't think of an easy way to do it in bp, but in C++ i can do something like this TArray<FMyScores> SortedScores = GameState->GetScores(); SortedScores.Sort([](const FMyScore& A, const FMyScore& B) { return A.Kills > B.Kills && A.Deaths < B.Deaths; });
something like that
wow that looks a lot cleaner than what I'm about to have to do in bps
yeah in BP, i would have no idea how to do that
for things like that, i normally make some C++ function
cause i can do it so much easier
most loops are highly inefficient in BP
not just that they take several monitors worth of space
they aren't extremely performant, either
basically, i think you would need to loop till you find the highest kills shove it in an array, then start your loop again, and make sure they are not in your array, then find the next one, add it to the array, then loop again, that seems really inefficient in BP
does BP not have a sort node?
does BP have Swap function?
for array
Sort requires an operator< to be implemented on array element
which you can't do in BP
it has a swap iirc
but you could do for (0 to num -1) for (0 to num - 1 - outerloopiterations) if A < B, Swap(A, B)
in BP
basically implementing the simple sort manually
yeah
(where A is Array[OuterLoopIndex] and B is Array[InnerLoopIndex])
@delicate zinc https://gyazo.com/b3283e7ee99cd042d19abfc05a8008ae
if that helps
@meager spade Thank you so much. Sorry I went to go do something.
I have a multiplayer game over a year into early access and i've always been bugged by getting information out of 1. saved files and 2. steam profiles and making that accessible to all clients.
I'm trying to pull these into the player state on begin play,, with RPCs. I think these variables shoudl then be accessible ad hoc to all clients, but it doesnt seem to be that way.
Is there a more sensible/reliable way to do this?
Hello everyone, I read that SetControlRotation should be used to replicate character rotation smoothly (as it is handled with prediction and such)
However, I see that the springarm and camera use that setting mainly for rotating it
Which basically makes calling SetControlRotation get the camera always stuck behind the character (especially when moving)
The reason why I'm not using SetActorRotation is because I read that it'll result in jittery rotation on every client (owner and proxies)
Any kind help would be highly appreciated
Hello everyone, I am trying to make a small project that is a Top Down Multiplayer game and I used https://forums.unrealengine.com/community/community-content-tools-and-tutorials/103887-template-multiplayer-topdown-template-c?131269-TEMPLATE-Multiplayer-TopDown-Template-C= as a template and fixed it for 4.25(https://github.com/shelltitan/UE4TopDownMultiplayerTemplate). I tried to set the lag to 75 using the console and the camera starts to jitter when you stand, I think this probably because the interpolation but I would like to know if anyone has a solution.
This is the place to show, share, and link to your stuff!
I'm trying to replicate sitting on chair. So it's easy but having trouble replicating the character's rotation based on which way the chair is facing.
Hello, im new to networking. How would i make it so that an enemy can look at both the players instead of just the first player?
@summer tide client is perfectly aware which direction the chair is facing
meaning it can run its own animation and calculate its own rotations
nothing needs to be replicated except which chair you're sitting on
Hey guys, having one issue this happens always for one Hand, I am doing a VR multiplayer, and one of the hand never gets updated for other clients.
Not able to find why, this happens If i update the hand position using rep notfies + multicast, but if i do reliable then it does work.
Is something related to network congestion ?
i think its safe to say no
It does not happens locally.
but always on Android
Does Engine.ini Net Driver settings goes to Android, or is there anything specific we have to do, Like increase limit or something.
i am totally clueless.
@winged badger In blueprint I get the transform from chair then face the char that way. If the chair is facing away from me VS facing toward me, diff situation.
what does that have to do with replication?
The rotation of the char appears wrong on server for client
all client needs to know is that you're (about to) sit on that chair
it can do the rest itself
I still have to rotate the char manually.
@winged badger hey is there anything i can do debug this i mean start from somewhere
wihtout knowing your entire structure, i have no idea
Hi, does anyone have experience with using OnlineBeacons, and specifically OnlineBeacon servers (separate from game server)? What I'm trying to do is have a separate game server of online beacons that will be used to issue valid "ticket/tokens" to clients to use for security purposes. I.e if a client want to initiate match making they will need to supply this ticket reserved from the server.
Or if there are other standard ways to do this ticket thing. Cus right now my matchmaking server is open for any 3rd party to just request (since its just a simple Nodejs server that takes in REST requests)
What do you guys recommend for hosting online servers? Linode? AWS? Google?
@velvet brook I recently worked through this blog post which met my requirements. Deployment of servers to AWS. Really great post.
https://medium.com/swlh/building-and-hosting-an-unreal-engine-dedicated-server-with-aws-and-docker-75317780c567
@silent valley thanks! i'll take a look
Are AInfo classes always relevant?
@velvet brook I recently worked through this blog post which met my requirements. Deployment of servers to AWS. Really great post.
https://medium.com/swlh/building-and-hosting-an-unreal-engine-dedicated-server-with-aws-and-docker-75317780c567
@silent valley for AWS i recommend looking into gamelift, as its very cheap and support scaling very well
Yeah that's definitely the right thing for session based, but our game is persistent world with fixed dedicated servers per territory.
more like Rust if you know that game?
so one world per server, aiming for ~100 concurrent users
Ooh awesome!
Hey Guys!
Can Anyone HELP ME Out.
I want to learn multiplayer but it's just too complicated.
Everything going over the top.
I UNDERSTAND The Theory but can't make it HAPPEND
Can Anyone teach me OR Just Puch me so that i can start Somthing.......
Sorry there's no easy way, start by making something small, follow through the basic tutorials on the unreal site
gradually your understanding will increase
then make something single player first. multiplayer is WAY more complex than single player.
dont bite off more than you can chew or you'll get frustrated
i had create simple single player game
i just Can't make it Multiplayer
For Example
i created a box game
Short and simple
when you start game
you play as box character
and can shoot things
everything work on single player
but on multiplayer
it's just spawning two or three player
and that its
it's working on server side
but not on client side
some thing like that
i have experience in creating single player games.
but multiplayer.............
i had seen tutorials and read some documents
Follow any good tutorial about RPC, some important multiplayer classes like GameMode, PlayerController and PlayerState, etc. And then follow one multiplayer tutorial
but nothing start to click
YouTube has abundance of such tutorials
Even epic games also have one multiplayer tutorial entirely in blueprints
in my experience ( till now ) tutorials on YouTube have two types
- there start with theory and end with something confusing
- thart start with somethng build on and just explain what there did
Follow above link
They build it live during the stream
there don't explain how things works. there just explain how there did it
like hey we did this and this
and you can copy past it
ok
That tutorial is for starters or designers...that's why theyr doing in bp..and that's why they aren't explaining the science behind the logic because beginners or designers can't understand that.
If they can understand that than they can code in c++ and don't need anyone's help.
Just learn the building block and when you think you have gained some knowledge then you question
I know..... I know......
i just not in my best mood
like usually don't compline about thinks
but it's just more than one week
but when i open unreal engine for multiplayr
i don't know i am doing
Are you a student or professional engineer?
i am a student
Yeah I can understand ..
One thing you need to understand is that singleplayer and multiplayer are really done different than each other.
It's definitely not a beginner friendly thing. Multiplayer that is.
you can have loads of issues that single player doesn't suffer from
I am working on Unreal non-multiplayer for like 5 years and when I look at multiplayer stuff I all make is a surprised pickachu face.
just bugs and depending on game hacking
it's definitely not rocket science but surely asks too much from you, especially at the patience department
there are tons of stuff that could go wrong
yeah
i was just hoping that someone will just teach me something
like just basic
to get stared
You are not in a position to question the science behind the logic.. just learn as it is.
as others suggested, your only bet is youtube tutorials and such
there are really good videos out there
also, people don't have to teach you things for free π
ESPECIALLY multiplayer xP
Even though you are curious to know how stuff works behind the scenes, if someone explains you the science you won't understand.
Indeed. You really need to delve into it face front.
i know i know
And then get ur face smashed into 2000 pieces
I don't think UE4 devs got any face left so to speak π€
Monkey de luffy is right.
you guys clearly haven't attempted multiplayer in any other engines :)
UE4 is a DREAM compared to most others.
what i was hoping for is that someone teach me and in return i can do some programming ( IN SINGLE PLAYER ) or stuff like that in return.
I HAVE SOME FREE TIME RIGHT NOW
As ive heard
well... People who knows multiplayer does not really need help on singleplayer themselves. Again, you can only hire someone to teach you stuff. And be prepared to pay a lot for multiplayer.
@fiery badge here is a good video that helped me understand it a lot
Try my C++ Survival Game Course:
http://bit.ly/unrealsurvival
Discord:
https://discord.gg/meFRZfm
Today I do my best to teach the basics of networking to you in under 30 minutes. Enjoy!
Download the test content as well and mess around
Uk theres a bigger mess called ue4 for mobile
Thatβs the only way u learn, try to make something, fail, try again
Mobile is the true Hell QQ.
But then there is Mobile Multiplayer. Extreme Hell for the truest sinners.
Unity has no multiplayer other than 3rd party libs. It's a mess. It's the reason I switched to UE4 and I'm so happy I did.
Same
People like dani dont seem to have a problem with it
Unity is not changing with time.. they are stuck and not adding any revolutionary features for their Engine.
well... People who knows multiplayer does not really need help on singleplayer themselves. Again, you can only hire someone to teach you stuff. And be prepared to pay a lot for multiplayer.
@earnest comet Why not if you have lots of stuff than you can teach for one or two hours and i can for them for like two to four hours so it's win win for both.
Teaching someone multiplayer is not something can be compared to helping them in singleplayer in return.
Learning multiplayer is a long time
Lol
I would say... 1 day of teaching equals to 1 month of singleplayer payment in return π
I would say... 1 day of teaching equals to 1 month of singleplayer payment in return π
@earnest comet WHAT.....
What do you think multiplayer TEACHING is? Walk in the park? π
Yes! lets scare the new devs here
it isn't a scare
π
It's not about scaring them.
most of them want a MMO in a week
Multiplayer is hard. Whoever thinks it's easy for a BEGINNER is doing it wrong in the first place.
eXiβs document is insane as well http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
I think you guys really forgeting the times that Unreal Forums were SWARMED by people who wanted to make MMORPGs years ago.
We lost so many good folk trying to tell them "it doesn't work that way" π
Well the most imp skill is to be able to browse source code now
There isn't too much source code
@fiery badge the number of things which you can learn from self exploration is infinite, if you hire someone to teach you he will only teach things for which you are paying him.
Even youtube has some hidden gems
The way I learned as a complete UE4 beginner was to follow this tutorial from start to finish. I did not understand it at all but by the time I reached the end I had something working and some concepts had started to make sense to me.
When I am learning I'm more of a do-er than a video watcher so this worked great for me.
Once you complete this you will be network programmer lvl 1. Ready to start slowly adding new features.
https://docs.unrealengine.com/en-US/Gameplay/Networking/QuickStart/index.html
Create a simple multiplayer game in C++.
depends on what you do
Well it doesn't help to depend on people
If u want to stand out
U have to do it differently
Basically if u have a problem
Then look into source code
Try a bunch of stuff
Ull only learn
The thing is if you want to do third person stuff
you will have some source
but that might not work well if you want to make a game with players
ok
i have question
if you have class for example bullet
you want to spawn from you character
how you do it
ok
C++ ?
Spawn actor
i make bullet class replicated and than when character press button than spawn
what the bug is
Don't forget to add projectile component
done
- Tick the Replicated box on the Bullet class.
- Make sure only the server spawns an instance of Bullet and if it's replicated all clients will also spawn it.
it's spawn in server but not in client
I'm guessing UE4's networking does an attempt at load balancing of some sort? I replicate a large amount of data in an Actor and there is no network communication for 20 seconds and then it resumes, another somewhat big piece of data gets sent and networking blanks out for 2 seconds then resumes to normal, regular updates of the small data I send. Any ideas what is going on here? My information is from looking at networking insights.
how large amount we are talking about?
how much data are you talking? It's easy to flood the network driver and it throttles right back in my experience.
"large amount" of data was 178000 bits
how are you sending it?
I don't think this should cause a 20 second delay though...
This is 21Kb
replicated fast array in gamestate.
seems ue4 limits data to ~1kbyte per network tick
I can see it takes 24 of the networking ticks to send but then there is that huge 20 seocnd gap before any data is sent
This is all running client/server in pie locally btw on a relatively high end desktop. 8700k 64gb ram
worst case why not send it in chunks yourself via RPC
You are doing something wrong .. in pie it should be like speed of RAM.
ok back to WAR with MULTIPLAYER on my own.
WISH ME LUCK. (and have a nice day to all)
64gb ram?
yeah I'm sure that somewhere in the engine it's throttling the connection
Ya somewhere is throttling but at an extremely low amount of network traffic.
int32 UNetConnection::IsNetReady( bool Saturate )
{
// Return whether we can send more data without saturation the connection.
if (Saturate)
{
QueuedBits = -SendBuffer.GetNumBits();
}
CVarDisableBandwithThrottling ?
You entire unreal process is in RAM and your networking behaves like IPC @autumn vine
"net.DisableBandwithThrottling"
21kB is not much for a one time send. I'll look into the throttle variables.
one sec.. I'll get back to you with if that helps
honestly I never really got to the bottom of my problems, the cvars didn't help. eventually I just send less data and now I have no problem.
replication etc. is tuned more towards lots of small packets at high frequency, rather than larger packets at lower frequency
Sometimes you just have to break stuff up
π easiest solution is to do this unless you want to fight Unreal engine
as a really newbie in networking stuff
I thought 21kb wasn't abig of a deal?
Aren't MMORPGs doing much more than this?
I am abit concerned about this.
it's a massive amount for one single property
oh
If it's a replicated property causing the trouble it's trickier to workaround, you can't really break it into chunks
Unless doing so artificially with multiple properties ofc
I see. Let's just say I want to replicate an integer value.
This is what would be send in a sense, yes?
size-wise
4 bytes for an int32, plus any additional header data that identifies the property etc.
Got you. Then thats why you think 21kb is massive and I understand. π€
yeah for one single property on one actor it's a lot
I'm back so I'll try the throttling now. @chrome bay you say this is bad to do with a replicated value. My other stall is on an rpc (server to client) that sends 14kbits one time and stalls networking for 2 seconds.
yeah I can just imagine a case where you've set the replicated value up over several seconds or something so it replicates in chunks, but then a new player joins and it has to replicate in one go anyway
I think there is a max size for RPC's also
In my use case, the client is relatively dumb, so the server has to send over the initial conditions and then as the game progresses, changes to those conditions after the fact which are small and not often. Overall network usage is very low, but I need to be able to dump data to the client at the beginning
Hmm, it might be that you need to use a TCP socket or something to send the initial data perhaps
Isn't the whole point of replication to avoid working with a raw socket?
it's just not designed for the sizes you're talking about
if you need this tech for your game then you'll either need to write a wrapper that replicates an array of data in chunks, or make a wrapper for TCPSockets but that's probably gonna be more painful
Disabled thottling and it worked beautifully
I'm just gonna leave throttling disabled lol. The data sent during runtime is so low I won't have to worry about any client hogging the network. The throttling algorithm just stalls everything out at startup
lawsen can you tell us how you did it exactly? I might need to use it when the time comes ^-^
did you bump the default throttle limits in DefaultEngine.ini btw?
As @silent valley said. Console "net.DisableBandwidthThrottling 1"
Thanks!
@chrome bay I have not touched any engine network settings. Behavior I was getting was so bad I assumed I missed a line in my c++ or something wild.
InitialConnectTimeout=120.0f
MaxNetTickRate=60
NetServerMaxTickRate=60
LanServerMaxTickRate=60
NetClientTicksPerSecond=60
bClampListenServerTickRates=true
MaxClientRate=10000
MaxInternetClientRate=10000```
These are my current settings - you can bump MaxClientRate and MaxInternetClientRate up, I think 10K are the defaults, but lots of games go up to 30-40K IIRC
Clamping the network rates can be nice too, as it can help prevent clients with extremely high framerates from hammering the server
created a lot of problems for me in empty test maps, especially where client can exceed 120-150FPS or something stupid
Ya I've done a decent amount of ue4 networking before. Just never run into it completely starving a connection. Yesterday, the stall was so long that I assumed it was completely locked up and something in the code was silently failing.
yeah, it just doesn't like big chunks of data
"big"
Would be nice actually if Epic would write a utility struct similar to FFastArraySerializer that would stream data out gradually
For one time data it is quite small, on frame, ya it would be absurd.
yeah I use the term "big" in relation to normal gameplay packets π
Or is the throttling algorithm was just less sensitive to large one offs
I assume they're using something like a moving average. Could change it to be more "intelligent" about the occasional spike; especially within x seconds of a client connection
IIRC they don't do any dynamic bandwidth control, it's just once you hit that cap they consider the connection "saturated" and send nothing more
I mean that's about what was happening to me. And it got extremely oversaturated because a single property was so far over what was considered saturated that the connection got stalled for 20 seconds.
yeah
it's probably trying it's best to get other actors through as well instead of choking on the one property
I haven't yet looked much at the underlying code, but I'm assuming this fast array of ustructs will be more efficient network-wise as small amounts of data in the structs changes compared to a regular tarray of uobjects?
@chrome bay In this test case, the gamestate, playercontroller, playerstate, etc were all that was set to replicate actor-wise. Nothing in the level.
the advantage of FFastArraySerializer is that it will only send 'dirty' items, but the indices aren't preserved and the full item will be sent each time
Whereas with TArray I believe if the elements/number of elements are changed, it can potentially send the entire array again - though I can't remember the specifics now
Full item? Ouch. This was originally stored in a TSet until networking got added; indices don't matter here. Hmmm I may use TArray then, array size does not change after initialization, just the data in each object
And UObjects can serialize individual UPROPERTIES iirc?
Yeah same as an actor/actor component etc.
But the downside is you need to replicate the UObject itself then too, which has to be done through an actor
Ya I already have all of that code written. I was doing it that way and getting the massive stall. Which made me try the fast array
if you change a UPROPERTY inside a struct, then so long as you don't have a custom NetSerialize() function, only the changed property will be sent
And I believe the same is true for structs within an array
So sometimes a regular TArray property can be preferable over a FastArray
Ahhhh interesting. I guess that is easy to confirm with the network insights tool.
I hadn't used the UnrealInsights tool until yesterday. It blows the SessionFrontend away.
yeah, the old net profiler is still useful too
Thanks again for your help with talking all of this through!
Hmm this might be interesting to you
net.MaxConstructedPartialBunchSizeBytes
net.PartialBunchReliableThreshold
just found those digging around UDN
But yeah the older suggested solution to this was indeed to throttle somehow via gamecode
net.PartialBunchReliableThreshold
to a small non-zero value, such as 4 or 8. This will help mitigate packet loss that would otherwise cause an entire large array to be repeatedly resent.```
@chrome bay I've apparently got a udn account, just have never set it up. Sounds like I definitely need to. Company prevents me from asking any questions on there because of some language in the eula for udn lol.
@autumn vine careful with net.DisableBandwithThrottling it's not valid for SHIPPING builds!
@silent valley worst case I make it valid for shipping builds πΉ
πͺ πͺ πͺ
@autumn vine whats you big data cant u just compress them ?
@autumn vine server either creates the initial data from purely static data
or static data and random
either way, you can get away with replicating as little as single int32
for your intial conditions
provided none of them depend on player input
@winged badger ICs come from a different process running on the same machine as the server ue4 process
Not my design choice, but Iβm stuck with it. Server is completely dumb until it receives the ICs from the other process. No way to seed the client except send the full ICs
hey guys, small question, what if you want to implement a simple timer that is visible on the players HUD at all times, obviously the server needs to track the time but how do i replicate something like this? isnt it unnecessary server traffic to update the time every second for example?
i also thought that maybe the server just says start and the clients start counting themselves but then you have the problem that a guys timer with bad ping will start later
I really need it to be exact for all the clients
Prob just make it a replicated variable
Sending it regularly isnβt so bad, like location on replicated actors
Could be on anything really
You can never make it "exact" as such, but replicating an int that counts up/down is probably fine
You can use a timestamp otherwise
And link it to the game states' ServerWorldTimeSeconds then round it
okay okay perfect π thanks guys for replying so quick!!
it's good enough to just show a match timer usually
yeah were making a multiplayer fast-paced handball game and we just need it to track time and I was wondering if unreal had something special for that
sounds like im just gonna replicate a variable
Are there any examples anywhere for getting the unique net id for each player ?
APlayerState::GetUniqueId()
π
Yeah that's definitely the right thing for session based, but our game is persistent world with fixed dedicated servers per territory.
@silent valley thats very cool, have you guys considered SpatialOS?
hahaha, I've been there a lot. Hey, how do I get this special thing? Oh, there's a function.
im curious how you guys split servers into spatial regions ingame, or are ur worlds small and dont need cross server persistency?
@keen thorn actually yes we prototyped a game in SpatialOS for about a month before we started down this route. Very impressive for what it is, but we didn't need the full capability of SpatialOS.
In our design the worlds are small enough to be entirely hosted on a single server, so no need for SpatialOS.
aha cool, i guess you guys implemented replication graph to minimize replication yes?
it is normal that my tick in my derived gamemode class doesnt get called? o_0
how did you guys feel about SpatialOS btw, im also curios and wanna try
Yes we have a basic RepGraph framework setup, but we've not done much profiling or stress testing at this stage.
right
Re: SpatialOS I think it's worth firing up a trial and building the sample app. Very impressive tbh, but I gotta say it was such a big complex system that it made me nervous thinking about how our small team would be able to handle sucgh a big black box in the run up to release.
right
currently Its the only viable option for spatialization across servers no?
cus UE4 servers are single instanced atm
not suitable for mmo stuff
By nature I'm quite cautious so the more 3rd party libs/systems involved makes me worried.
Yes that's right, nothing out of the box in UE4 for MMO.
I don't know if Rare have released any details how their system works for Sea of Thieves?
Im not sure
but for small teams i dont think MMO is within indie team's capabilities atm
100%
π
I myself just finished a multiplayer game that will launch for few thousand users... fingers crossed nothing goes wrong. The servers run on gamelift with custom matchmaking server
its my first one that will go kinda large scale for an event
@royal rampart Tick is disabled in GameMode by default if I'm not mistaken. You might have to set it in the constructor in your inheriting class.
@royal rampart Tick is disabled in GameMode by default if I'm not mistaken. You might have to set it in the constructor in your inheriting class.
@kindred widget thanks, just fixed it π
internally we play it fine, no bugs yet, but never know when things scale up, will be an experience to learn
yeah are you softlaunching / beta?
no we created it for an event. you know cus of covid19 so some event maker (our client) wanted to create virtual online event
normally they create a festival outdoor
but now they have to do it online
basically a virtual festival with multiplayer battle game
ye i hope it will be fine as well π
Anyone here have some experience with OnlineBeacons?
Trying to replicate Spawn Sound At Location. I have a server Event and Multicast. Multicast has the Spawn Sound At Location and a variable. I also have the same event setup to stop the sound.
@summer tide where does the server event get fired? only controller & pawn can do rpc calls
In char BP
The thing the sound replicates but it sounds like it plays multiple times and doesnβt stop on time
Behaves diff than server
@rich ridge I know that using beacon you can create steam party without a lobby. Do you know if you can totally avoid the usage of OpenLevel at all? I've streamable levels and I don't want to use OpenLevel ?listen.
Anyone know off the top of their head how to up the ue4 packet size? Seems to be limited to ~8000 bits
[2020.11.10-18.26.32:298][107]LogNetSerialization: Error: FBitReader::SetOverflowed() called! (ReadLen: 1, Remaining: 0, Max: 75)
What does this means , it showing on server
Simple question..what is the difference between game mode base and game mode..and game state and game state sub class...I mean I assume the sub class and game mode inherit in a hierarchy...is one more difficult to work with then the other and why would you use one over the other
@autumn vine It's 10k bits by default. You can up that by adding a few lines to your project's DefaultEngine.ini
This one works for me at least for testing. Sets it to 1Mb/s Overkill, but eh, testing.
ConfiguredInternetSpeed=1000000
ConfiguredLanSpeed=1000000
[/Script/OnlineSubsystemUtils.IpNetDriver]
MaxClientRate=1000000
MaxInternetClientRate=1000000```
Oh, I just reread that. Did you mean the general bandwith or the literal size of each packet?
hi,
what is the better solution to make a networked inventory:
-replicated slots and item
or
rpc management like create an item on server and if ok call create item on client
It depends on what you need the inventory for and how your game is going to be set up. There is no 'best case'.
Hey, anyone can look at my network profiler data and can tell me is it bad or good ?
@kindred widget something for a survival game like
in replicated inventory there are the possibility to reference an object by network
Still depends. For example. I made an inventory system once that was nothing more than a replicated TArray of a struct that was an Int32, uint8, and an enum. Weapons and the like really had no 'state'. Durability on weapons and tools was the uint8, which also counted for item stacks of items that could stack. The enum was a quality modifier and the int32 was the Item's internal ID. Client and server independently populated a non replicated array in Gamestate from a datatable that was all item's information. Name, Weaponclass, etc etc and all of that could be gotten with the ItemID. I had another data table for crafting recipes that could take stuff from the inventory via the ItemID and the uint8 stacksize/durability. It worked incredibly well, but it was also very complex. Every item in game could have an InventoryComponent and the RPCs to interact with other components was all done through the player's inventory component on their character.
ok i understand
but it s give more control i think
@kindred widget the problem for me is how to designe the notification systhem cause in version with rpc it more simple to handle this stuff on the client part
and in a replicated pattern the only way i found was to get a notification component to keep the ref as soon as the player were correctlly notify
because if i don t replication will override data and you couldn t know what was here before
Does calling GetPlayerState in a pawn class get that specific pawn's player state or the client's actual player state?
@kindred widget I meant literal packet size π
@summer tide the servers basically run BeaconHost.. and when a beacon clinet tries to connect to BeaconHost via ip and port you just send the message to client.
Party beacon code in Engine doesn't mean that it has to be party to function.. that party beacon code is coupled with OSS and can be used for ping to server as well.
When I was using party beacon I used for reservations on server as a single player not as a party leader
So..calling GetPlayerState will essentially always return that controllers player state no matter where you call it? @meager spade
I thought pawns can call GetPlayerState to get the state associated to their pawn..
Okay I think I see, because i"ve been calling GetPlayerState inside IsNetRelevantFor and it's always returning the same state, I assumed it would return the state associated to the pawn it was called in such as "this"
So I assume this->GetPlayerState() is different than GetPlayerState()?
But isn't IsNetRelevantFor called for each pawn individually? Which means anytime it calls GetPlayerState it should return the state associated with that specific pawn?
correct
Perfect however when I call it, it just returns the same player state everytime despite how many pawns are in the game.
how do you know its the same playerstate?
I'm checking the pointer
did you check a property on it that is guarenteed to be unique?
UE_LOG(LogTemp, Warning, TEXT("IsNetRelevantFor called on state:%p"), GetPlayerState());
Like so
like PlayerName ?
No but the pointer should be different right..?
sure
Or should I just use GetName or something else instead
Hmm maybe I'm not doing something right.
I'll double check
UE_LOG(LogTemp, Warning, TEXT("IsNetRelevantFor called on state: %s"), *GetNameSafe(GetPlayerState()));
could try that
see if it prints different
Yes @meager spade It prints the same thing repeatidly...
and that actor is different?
UE_LOG(LogTemp, Warning, TEXT("IsNetRelevantFor called on %s with PS: %s"), *GetNameSafe(this), *GetNameSafe(GetPlayerState()));
I place it inside my character class
So am I doing it wrong by overriding the method inside my character class because what I'm assuming the listen server is doing is going through all the actors in the level and calling the overrided method for them
Oh here
nor can i see what you are doing
So that's the character class overriding the method
and every client connected uses that character class
or every actor
why are const casting
That was just so I could pass them into my gaamemode method.
but.. why?
Should I not const_cast?
anyway, i don't know what is going wrong then, but why do you need the player state for relevancy check? is it like team based?
yes
also never cast like this (AActor*)this
okay
okay
go clean that up
and show me again, cause i am cringing reading it π
you also removed some additional checks
like i sent you before
meaning the controller will never replicate to owning client etc
you must have this as your first few lines
|| IsBasedOnActor(ViewTarget) || (ViewTarget && ViewTarget->IsBasedOnActor(this)))
{
return true;
}```
else you will break things!
There was a problem with that though.
When I put that in the code,
my listen server began lagging severely.
And when I removed it, it ran fine.
So something with that.
that would not cause lag
Was causing me to lag.
that is engine code
That was the only variable I was changing though,
When I was testing the lag .
And when I would add it, I would lag severely.
And when Iw ould remove it, the lag would clear.
So I'm not sure.
But I can put it back in.
that would not cause lag
I'll take your word for it.
ah
you might need to do this
if (bAlwaysRelevant || RealViewer == Controller || IsOwnedBy(ViewTarget) || IsOwnedBy(RealViewer) || this == ViewTarget || ViewTarget == GetInstigator()
|| IsBasedOnActor(ViewTarget) || (ViewTarget && ViewTarget->IsBasedOnActor(this)))
{
return true;
}```
put the CA_SUPPRESS above it (if you get warnings)
CA_SUPPRESS(6011);
if (bAlwaysRelevant || RealViewer == Controller || IsOwnedBy(ViewTarget) || IsOwnedBy(RealViewer) || this == ViewTarget || ViewTarget == GetInstigator()
|| IsBasedOnActor(ViewTarget) || (ViewTarget && ViewTarget->IsBasedOnActor(this)))
{
return true;
}
AVisibilityZeroGameMode* VisGameMode = Cast<AVisibilityZeroGameMode>(GetWorld()->GetAuthGameMode());
AVisibilityZeroCharacter* ViewTargetCharacter = Cast<AVisibilityZeroCharacter>(ViewTargetActor);
const bool bIsRelevant = VisGameMode->AreActorsRelevant(GetPlayerState(), this, ViewTargetCharacter->GetPlayerState(), ViewController, ViewTargetActor);
return bIsRelevant ? Super::IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation) : false;
}```
Alright yes that's how I set it up too
Okay let me test
if the print is different now.
@meager spade it's still printing the same state every time
So for whatever reason, I'm not sure what.. it's only being called for one actor and not on every connected actor
Could it be that IsNetRelevantFor is never called on the listen server's actor/controller?
But every other client connected to the listen server.
@meager spade I tested with two clients and a listen server and it gets called for the two clients but never the listen server.
And I think this actually makes sense..
Because technically the clients are always going to have to be relevant
to the listen server
They don't have a choice
Anybody knows where it went wrong in client? Server looks fine. @inner cove
https://gyazo.com/8e59a497a8a8015c6cbd2aeec2c56484
So I have attached my character to the horse and from my character I pass the axis values via server event.
Ohhhhhh boy, I have a problem.
It's one of those days where the deadline is today and I thought I would be able to get done what I wanted to get done by now but nope, can't.
I was tasked with making a small server as a demonstration for a company, I've never worked in networking before so naturally I followed this tutorial: https://www.youtube.com/watch?v=QGrRV-11sx4&t=3s to a tee, and I've basically gotten everything done properly except for two issues.
-
The server doesn't recognise the ServerMap that I've created in the project, nor is it able to find it when I have the line "/Game/Maps/ServerMap -log" written in the shortcut, everytime it will fail to find the map.
-
When I try to open up the server on localhost with 127.0.0.1 the server will throw up a bunch of code but it won't say that I've connected to the actual server, and I have no clue how to fix this.
Obviously the client won't connect because even the localhost can't connect to the server, I have no experience in networking so any help or opinion would be much much much appreciated.
Hello guys welcome to another tutorial. Today I will show you guys how to compile a dedicated server for your own game. This will allow you to host your own server, and have anyone join it from across the world. I demonstrate this by putting the packaged final game on a usb an...
No that that is done the multiplayer kit comes next π
Multiplayer Kit?
Guys, do you have any tips for someone trying understand how prediction works in the gameplay ability system? I can not seem to follow the execution flow
Hey, I need some kind of advice here. If i'm working on a vehicle movement component using Physx AddForce is it possible to replicate and using Client Side Prediction and Server Reconciliation with it? or i have to have my own "AddForce" to be able to simulate?
unlikely @shrewd terrace
physx is not deterministic
which makes network scenarios really difficult to control
@arctic turret i seem to remember a full 2 page explanation in comments in the header where PredictionKey was defined
@winged badger thanks, does that mean that ACharacter doesn't use Physx? cuz AFAIK it works pretty well in multiplayer
CMC works... okay
when its not affected by physics
when it is, sure, no lag PIE scenario seems okay
enter net pktlag=200 into console and watch it explode
thanks
So I'm currently using 4.25.1 source build and just found out GameLift supports 4.24. Is there any way around this? or do i have to change version.
Hey all, I have a maybe stupid question but do the footsteps sound should be replicated if yes how ? π
Thanks ! π I was not sure about that.
What could be the reason of Client dsync on server, and both clients see each other at different places.
Anyone made a Replicated Actor Pool? Was there an option to have them AlwaysRelevant but at the same time dormant?
Trying to see if we can somehow have a pool of actors that would otherwise be spawned nearly all at once and use up too much bandwidth for the initial spawn.
Need to focus on replicating the player controller and not the actors. You pool them on the client and have them not replicated from the server. The client sends inputs to the server and the server will either accept the input or decline it. I would work on sending the world actors data to the players and the client simulate its own actor pools based on the data. Then the server just verifies if it will accept the input. It might not work that way but it how I would think it should be done.
Once you are using the client pool you can use the world actor data replicated to your player to fake everything.
Im trying to figure out the best way for a client to send extra data to the server of basically any type. Essentially I want to have an βActivateServerAbilityβ RPC that a client component can call, passing a struct of arbitrary stuff that an ability needs from the client to execute on the server, like a HitResult, transform, or object/actor pointer. I donβt want to create separate functions for βActivateServerAbilityWithHitResult,β βActivateServerAbilityWithPointer,β etc. for obvious reasons, but struct inheritance doesnβt work in blueprint, templates donβt work on blueprint, and I canβt use an object to contain this data since Iβd need to replicate it (since Iβm sending from client to server). TUnion is also not exposed to blueprint, and I donβt if UE has a variant type but I doubt itβs exposed to blueprint either.
It has a Variant type
But it's not exposed to BPs
And yeah, you won't be able to get this working in BPs afaik
Even if you setup customthunk stuff to allow wildcard structs, it will fail when sending it via RPCs
Yeah I found the forum post with the custom thunk wildcard stuff and it seemed kind of clunky and I donβt know enough to understand what it was doing
I know that the #gameplay-ability-system uses EffectContext and last time I talked with Epic they said they just push everything into that and use the serialization to nuke things that aren't needed for a specific ability
So basically, a huge struct with all data that could be needed, but the serialization makes sure only the required things are actually send over.
But that's also less than ideal in my head.
Doubt there is much you can do.
At least with ue4's native stuff
@thin stratus why always relevant? so they are not destroyed on clients when they become non-relevant?
Yeah, because then they would all be spawned in again I assume. I also don't yet know what is actually eating up the bandwidth that much when they spawn (it's pickup actors).
our approach with pickups is
But I would assume the required setup would be an actor that is relevant and not active for the time being in the pool
spawn on server and client separately from the same seed
and keep dormant until they are interacted with
Yeah, we have lots of data that the server determines before actively spawning it
The Client probably can't simulate that
At least not in a way that doesn't require me to spent lots of hours that aren't available
Yeah I know, so they are netaddressable
I think that works even without overriding those. Can't recall us doing that.
bNetStartupActor and bNetLoadOnClient to true
At least for components
Yeah exactly, we have a setup for that for Components.
Where they are spawned with the exact same name on server and client
And then made netaddressable
Just have to make sure you never send a package from server to client before the client has their instance
:D Ran into that problem already
slightly different with Actors, have to force the static NetGUID
Hm
Right. Let's say I only spawn them on the Server and have them replicate by default.
What setup is required to have them sit in place on server and client until I need them?
they get treated exactly as if they were loaded from package
that is already too late
I guess I barely save anything, as they still need their data replicated when the Server determines it
client doesn't resolve static and dynamic NetGUID in the same way
with static, its "oh i don't have this actor yet, but im sure im about to load it, so i'll just wait resolving this NetGUID for a bit"
and with dynamic, it spawns a new Actor
What controls static vs dynamic?
Okay so:
- Spawn (non-replicated?) Actor on Client and Server with exact same name (?).
- Set
bNetStartupActorto TRUE - Set
bNetLoadOnClientto TRUE - Override
IsNameStable(and do what?) - Override
IsFullNameStable(and do what?)
4,5 return true for that actor instance
So just a flat return true;
So if one has a pool of those Actors, what are the steps to utilize them as well as returning them to the pool if used?
I assume I would have some logic on the Server that says "These 15 items were looted. I need 15 pickup actors." and then it grabs them from the pool.
Unless you perform that on both server and client, which we won't do
So I would fill in the data, turn on replication, and once they done their job, turn off replication, clear the data, and send them back to the pool?
we augment the approach with a manager actor with ffastarrayserializer
its most basic form is FFastArraySerializerItem that has
UPROPERTY() TWeakPtr<UObject> ReplicatedObject;
UPROPERTY() TArray<uint8> Data;
Right, so your pool is utilizing that?
post rep callbacks access the object and call PostReplication() or some such function on it
Gotta have to look into FastArraySerializer eventually >.>
when server changes something on the object it encodes it in byte array
and pushes the change to the NetworkManagerActor
when clients receive the item, they send the data to their own version of the object
and then object decodes it and applies the effects
lets you run a push system where 1 Actor is responsible for replicating few hundred Actors
they are not evaluate for replication or replicated
What if the objects are actors already? Do you have all data set to not replicate?
I assume so, as otherwise that would make no sense
the moment they register with network manager
SetIsReplicated(false)
mine can work just fine without it
but they don't replicate if they have a network manager
Yeah okay, that's something on top of the pooling though
Yeah
the 2nd approach unburdened our network tons
got 1800 Actors that are not replicated, instead using 16 network managers
But even with such a setup, the amount of data to replicate if 50 Pickups are required, stays the same, or not?
and there is a cap on how much time server is allowed to spend evaluating actors for replication each frame
Even if it's just a money pickup and the only value you replicate is the integer
It has to move from server to client either way
ah, when combined
i don't need to replicate anything
until one of the interactable actors is changed
Right, the scenario here is opening some chest and receiving, let's say, 50 Pickups.
Right now they are spawned from the Server with whatever Data they need.
That's not so nice for our bandwidth
that scenario
That's why I wanted to have them pre-spawned and requested when needed, so that at least the initial spawn of 50 actors is not part of this but only the transform and the item related data
if client can't take a seed and generate the same data as the server
you're fucked
Haha, that's fair
Guess stuff like that is what you want to think about before implementing a system.
Lucky me wasn't around when that happened
Thanks for your time though (: learned a bit more
fastarray can still help
as you don't need to replicate whole actors
just bits client can't generate
getting that stable though.... that is not a quick afternoon's work
we do not spawn actors on client + server after world's BeginPlay
Yeah, I guess the first step right now is to identify what is taking the bandwidth and reducing on that first.
and we don't have normal replication on on those Actors until after BeginPlay
Yeah okay, we are far from having the option or time to add such a setup now
bright side
network manager implementation took me around 3 days
i made it work for InteractableComponent + payload
The Systems setup usually doesn't take long yeah. However only if you don't already have a full system build around something that needs to change afterwards.
im also not sure you're suffering from bandwidth
That said, you should write a blog post about that network manager. Might make some peeps happy
as you can just have problems evaluating that many actors
Ah well, I can see other replicated stuff being delayed when that happens
non-optimized system will start breaking past 500ish replicated Actors active at the same time
Yeah pretty sure my test didn't have that many in the level at that point. Far less even.
It also only starts to come in delayed the second all those pickups spawn
Even though the data in them, despite the overhead of AActor, is not much
Like, replication wise, it's maybe a location (where it has to drop to) and a e.g. an int for the value of it or so
NetworkProfiler will get some love next I guess
not on 4.25 yet?
Why are you asking?
Ah, yeah, wasn't aware of what that all offers. Haven't needed to touch it yet.
there is a smoke and mirrors approach, if those pickups don't need to be actors after they are picked up
then you can just put a fastarray in the chest
and have the client do a full simulation
just need to be netaddressable for that to work
hi i have a little concern about component replication, so if i replicate a component that has member variables that get the replicated tag lets say health and mana for a unit, if something changes like health, but mana stays the same in the component, the data of the full component will be sent to the clients so both health and mana, or just mana since that is the only thing that is changed?
only stuff that changed is sent
thanks for response i see
hey all, I'm struggling with a UObject replicated property that does not get replicated on client object spawn. What is strange is that this property is replicated afterward, if server changes it, then it's correctly replicated to client.
This property is owned by an ActorComponent, and is a pointer to a UObject coming from a package
I tried to spawn the owning actor dynamically, put it directly in the level with always relevant and netloadonclient... Nothing works. I also override IsSupportedForNetworking() in the replicated uobject class definition.
what is strange is that networking is working for this property, but not before server changes the property again after the client connected.
For instance,
- server starts with property = nullptr
- Server changes property to "pointer to UObject_0"
- Client connects, property will stay nullptr
- Server changes property to "pointer to UObject_1"
- Client receives a correct repnotify
I don't understand why on step 3, client does not trigger a rep notify and has its property value set to "UObject_0"
I checked with another property on the same UActorComponent: for this other property, everything is working normally. What is strange is that this property is also a UObject, in the same Package that the other property π€
This other working property is initialized to nullptr in the same way in the actorcomponent constructor.
If you change the gamemode on seamless travel but the new gamemode uses the same playerstate, does CopyProperties not get called as usual?
It seems CopyProperties does get called but the old PS has default values when it shouldn't... does PlayerState->Reset get called if changing gamemode via seamless travel or something?
Ok it does seem that Reset is being called somewhere, probably in engine code
Hey there!
I want to set up the multiuser team editing using a VPN on google cloud. Has anyone have experience how to start to do that?
is there any way to force a property to be replicated without changing the value ?
@rose egret How come you need to replicate it if it hasn't changed?
I am doing some client side prediction, client changes several properties locally, cash, health, ...
then an RPC is sent to server for verification if verification failed, I want to replicate the new properties again.
it sounds easier than writing some rollback function for resetting properties in client
but it seems UE4 don't have such feature
I just want to say hay imagine this property is dirty, resend it
Should I be guarding all my PlaySound calls with if (GetNetMode() != NM_DedicatedServer) {} ?
Does it even do anything on dedicated server?
I mean, I know for sure it doesn't cause me any problems because some are guarded some are not, but I wonder how wasteful it is to call PlaySound on dedicated server
if it's sat in the cloud on a machine that doesn't even have an audio device
It 'might' be possible. I don't think they normally write prediction that way though. Usually a client and server is supposed to just do the same thing which leads to the same value or nearly. But since server takes time to travel and update, the replicated value would always overwrite whatever the client does. So in that regard, the only RPC would still be just the one telling the server what the client wanted to do. For example, if you wanted to predict money and buying. You click buy. client lowers the money based on the item's cost, you rpc to server to tell it that you wanted to buy that item. Server also sets money along with the buying logic which replicates back to client a quarter second later and overwrites whatever the client set, which should be about the same unless the client is cheating.
Is there any way to not have PlayerStates get reset when seamless traveling to a different gamemode with a different playercontroller other than overriding APlayerController::SeamlessTravelFrom and copy paste what was in super but delete OldPC->PlayerState->Reset(); ?
@silent valley engine already does it 99% of the time IIRC
You can use the pre-processor UE_SERVER to prevent the code from running at all on the dedicated server once compiled out
π
Doesn't look like it. One is just an event calling and function to do something and the other is the event doing it directly. Both should only happen on the server.
Okay, thanks
is there any way of creating a widget in c++ and using BP widgets as components of that widget?
@vocal cargo Do you mean a UserWidget that you can have C++ code in?
If that's what you mean, then in short, you need to create a C++ class that inherits from UUserWidget, and then make a BP class that inherits from that C++ class to be able to use the designer.
I meant, I downloaded an Asset from the marketplace that has BP only widgets
but I want to add them to a UUserWidget c++ class
Is PlayerState::GetUniqueId() Replicated?
Meaning if I get a UniqueId For a player state on the server, should it be the same for when the client calls it on a player state?
I have a wierd probelm, where if components are located to Head Component, Everything gets replicated, if not, Then it wont get replicated.
Like i have hands and Head, if hands are closer to the head, replicate, only one of them has this issue, if not, only on of them keeps replicating.
Im spawning a AActor in the server with a server function, while the colision is there the actor doesnt show up? does any 1 have any ideasΒ»
can confirm that it shows up on the server, its jsut not replicating for some reason?
is it replicated ?
yep
nvm i am an idiot xD
i ticked the replicated in the component and not in the object itself
Just wondering if anyone tried 4.26 Multiplayer and maybe Steam integration? Have you had any issues? Last time I did multiplayer was on 4.19 and I guess some things must've changed since then.
Something already on the map, just wants to show it clients separately with there client side events only, Do i have to spawn it from client ??
@tranquil yoke played with NetCullDistance maybe?
What is the check in c++ for role authority
HasAuthority()
GetLocalRole() == ROLE_Authority
@winged badger I believe HasAuthority() is the shorthand version of that.
i prefer this because of different syntax coloring for the ROLE_Authority
easier to skim the code
Since the listen server has access to all the player controllers, how can I get my own local PlayerController
There we go..thanks guys lol
Isnstead of another clients.
GetLocalRole() == ROLE_Authority
@winged badger Thank you
Do I call UGameplayStatics::GetPlayerController with index 0?
GetGameInstance()->GetFIrstLocalPlayerController()
it will, but better not start developing bad habits
i am spawning an actor with an RPC, while it works fine in the server the clients see the actor spawned at the wrong location it has a slight offset to the left
any one faced anything like this?
Could there be some collision issue?
no its just a decal
Hey everyone. I am working on a project that requires multiplayer. Can someone please recommend someone who does tutorials that covers everything from hosting, lobby to joining and UMG?
@limber gyro if the actor is set to replicates = true and the server is in charge of spawning it, then it should be in the same location when it's spawned.
You can also do a quick verification by setting it's location on the server to see if that updates its position properly on the clients as well
@limber gyro if the actor is set to replicates = true and the server is in charge of spawning it, then it should be in the same location when it's spawned.
@steel vault Is a variable is replicated from server the clients automatically get it..but if a client needs to update everyone, it sends a value to the server to send to clients?
sorry for tagging not sorry XD
it needs to tell the server to update
if server ever updates a variable - it replicates
as in
sorry, if it is set to replicate
@round star yes if you are a client and you need to update the position of an actor (be careful because this opens you up to cheating) then you tell the server it needs to move and the server handles moving it and everyone else should see its replicated position
I mean, I'd have an event called client side on (i.e.) W pressed, this is a event on server that replicates movement input.
Okay..and a multicast is meant for..if everyone needs to run the same function
Multicast is for a one off event that doesn't pertain to the state of something (which is what a replicated property is for). You can technically get away with not using multicast at all and using replicated variables for most things, but it depends on what you're trying to achieve.
If you want to send a message to everyone just once, then you can multicast
Anyone get this packet handler message error before when trying to connect via beacons in Steam?
[2020.11.11-21.00.35:425][250]LogNet: Warning: PacketHander isn't fully initialized and also didn't fully consume a packet! This will cause the connection to try to send a packet before the initial packet sequence has been established. Ignoring. Connection: [UNetConnection] RemoteAddr: 76561199016571282:7787, Name: SteamNetConnection_1, Driver: SteamNetDriver_1 SteamNetDriver_1, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: EPIC:PUID: 000260a3badb42808d1f8a910f7cd066; EAID: INVALID
gosh I wish I had your knowledge xero
Yea that makes perfect sense
haha I truly still don't understand or at least have the confidence when it comes to UE4's replication
multicast is ofr stuff that doesnt replicate from what i understand, you use it for networked VFX's for example
Lol if you read the channels of this discord you will pick things up really really quickly. The people here taught me everything I know and they're geniuses compared to me lol
that's very true.
Like if you were to set a variable that had some random int or whatever..and you multicast from function everyone would get a different value (unles of course thats what you wanted)
when I first started I would use mutlicast for absolutely everything.
Already a month or so in (to ue4 networking)I realise how silly I was being
that's why I love this server :)
What is a optimal way to shoot and deal damage with a shotgun? I've tried everything I know but clients always lag/rubber band when shooting hordes of enemies with their shotgun. I tried shooting multiple linetraces for each pellet, then taking all of the hits and adding them into a single struct, then sending that struct to the Server using a "run on server" event. That event then applies damage to everything. Am I missing something? Or is my network logic flawed? Normal bullet weapons work fine but shotguns lag since they are shooting 8 linetraces in one shot which I guess is a lot of hits to apply damage to.
Aim for the h ead
8 line traces should not be causing lag.
@round star I don't think I follow you. If you multicast from the server, you are telling all of the clients the same thing.
@round star I don't think I follow you. If you multicast from the server, you are telling all of the clients the same thing.
@steel vault If the multicast had a variable be set with a random int theyd get different values
thats all I meant by it
Gotcha. Yea if you multicasted an event but didn't send any info just told them to generate one themselves yes it would differ. But if you sent the random value in the multicast itself everyone gets that value
Oh. That's what they meant.
Only reason I am even saying this is because I have only started to delve into networking recently and I was one of the plebs who thought.."multicast multicast multicast"
idk just multicast set actor transform on event tick, that's all i've been doing at it works great π
^^^lmao literally
is there a way to get an output from the server from client?
Like calling a RPC function that returns something
Reminds me of "lightning bolt, lightning bolt, lightning bolt". But yea, I prefer the control that replicated properties offers and I try to limit my multicast to very specific things and it seems to work nicely
@marsh gate yes you can either replicate a property or call a Client RPC from the server
Ah...
Trying to figure out the best way to do cell based movement. How would this be handled? I am thinking that the server spawns the cell actors and the client uses the cell data to move its client based pawns around. The only interaction the player will have is will the cells on the ground and the server will do the rest. What issues would I run into or could avoid when replicating that many walk able cells. Say 500x500. That is a lot of actors to replicate. Maybe have a component on them that when a player is a distance away from the cell turn on replication.
If the cells are already present in the map you dont rly need to replicate them i think
what exactly are you trying to achieve
I want to use the data from the cells to fake the client
I was thinking about a chaining system as one cell starts to replicate it lets other know they may need to replicate soon.
but why are u fakeing the client?
You definitely don't need to replicate cells as actors if they never move
its a top down game so only the cells in view need to be replicated and a few out of range
That can all be handled client side. If there's no information you're sharing about those cells across clients then you can get away with simply replicating a few choice properties on the characters
why cant you just replicate the client?
@cedar finch it is not safe to do that hit calculation client side
The client uses the cell data to move its pawns maybe. And that data is replicated from the server. Think of the monsters and everything as data on the client and server the client is the only one that spawns fake pawns to represent the game play.
@empty axle what do you mean? Are you talking about cheating? Because It's just a small coop game with no competitiveness.
So if it was a competitive shooter, then I'd do my linetraces on server?
@vale ermine you can just replicate normaly and make a local check for the cells in use
yea so the only hit the client would make is to the cell then the server would look at the data for that cell.
you dont need to replicate the cells
So the method that you described should be fine
thanks ill try that
Having the pawns know what cell they are standing on or moving to is good enough for replication at that point
You don't need any info about the cells themselves
well thats the thing
@cedar finch yes and you would need to consider the fact that you need to do the traces at certain timestamp from the past
the cells will also control what particles are played on that cell
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
This might be interesting for you
Then you simply spawn the cells from the server with their appropriate properties like what particle effects they have. If that never changes you don't need replication
ok
The cell will know what things to play when you're on it
@empty axle Ok so If I leave it where I do the traces on client, then send the hits to server, why is it that clients 'rubberband' when they shoot 8 linetraces into a horde of zombies? Is it too big of a struct being sent to the server? Too many hit actors stored in it?
I send "hitactor" , "hitLocation", "hitrotation", and "physical Material" in the struct
what do you mean that they rubberband? Their pawns are lagging after the shot?
Yes so lets say a client is walking left to right and shoots into a horde of zombies, the client gets snapped back and forth like he's lagging. But only when shooting into zombies, not when shooting walls, floors, etc
@cedar finch what version of UE4 are you running
You might see what your network graph looks like with insights to see if it's spiking really hard for some reason
and whats your server?
Maybe processing all of the hit results is taking to much CPU time on the server
I'm on 4.23 I can look at net profiler to see. I'm just testing in-editor right now so maybe that's the reason. "fingers crossed"
it's hard to see in the gif but I my location gets snapped back
.gif's always hide the lag lol
i can see the rubber banding
I can see it. I do know there is an issue with listen servers that hasn't been resolved so you might try it as two clients instead, but that might not be it either.
Can definitely try it as a standalone and also as client and see if anything changes.
Do also cpu profiling, because if you spike on the server that would cause the same effect
There definitely is a spike in net profiler
No
If I'm not mistaken you could simplify your struct quite a bit by instead of sending actual actors and materials to simple enums that the server can break back down into their appropriate objects. Like an identifier for the actor and an enum for the phys material.
If you can simplify your struct even for now to see if it helps, that might be a solution
Try only sending the location and rotation and see if it rubber bands
Sending actor pointer is IIRC like sending integer so it won't help
Hey Guys, ran into a problem today. Basically have a dedicated server, but whilst getting access via windows client works fine, the mac client does not refuses the connection, saying that the version is wrong and you should update your build.
Both running 4.25.4, windows one is from source though, could that be it?
@empty axle I don't really know how to read the cpu profiler. I have it pulled up
I see a spike which is probably where I shot
Might be
Click on it and check out what is happening in the game thread
Is it client profile or server profile btw? Because you need server profile
I typed the command in on the server, the began shooting and playin on the client, then ended the command on the server. https://i.gyazo.com/ca9ef61638460338792967c71be70fb9.png
Oh yeah. 80ms is really a lot
You need to unfold it and check it out further to know exactly what caused that
not really sure what this means lol
I'm running another test to see what happens in the profiler
Garbage collector, that is probably not related to the shooting and the reachability analysis is not done in shipping so no worry
Ok so I did a really quick test this time where I started the profile, shot a few times, lagged really bad, then ended the profile. It looks ok on the game thread https://i.gyazo.com/906aa5f4c2574b82c009b39962c7b783.png
pretty solid line all the way across
So it's gotta be network related right?
comment random parts of the code to see if any part fixes it
You can see each shot spike here. @limber gyro I tried that. I removed impact fx, dismemberment, etc. Basically everything accept damage, and it still rubberbanded and lagged.
If you want to know if it's network related, get rid of your server RPC
looks like u didnt try the dmg then lol
Ok so I commented out everything so all I do is send the struct to server and it still lagged. So I tried not sending the struct to server and it didn't lag, But then I don't have damage, fx, etc. lol So it's clogging up the network with a fat struct being sent to the server I believe
You could use quantized hit location and rotation if you are not using right now or send just location and direction of the shot and do the tracing on the server
Yea, like I was saying earlier, you should try simplifying your struct and see if it takes away from the spike
If it does, then you have your answer
Just for simplicity's sake send the location and rotation and nothing else, those shouldn't clog things up. If it does, then I believe you're somehow calling too many RPCs
I thought I had it simple lol. My enum has 6 values. So I'll do what you guys said and see if I can remove some and figure out which one is causing this
I only use the hit location and rotation to spawn particle fx on hit actors, same with physical material
Yea start with a small struct and increase it to find out what the bottleneck is. Also check to make sure you aren't spamming the call
It only gets called once per weapon fire. So everytime you pull the trigger
That is okay. You can't call less for a shooter
@empty axle Ok so good news. I took out each thing one by one and it looks like "hitBoneName" was the cause. I only have "hitActor" in my struct right now and I have no lag. π But that sucks because I used "hitBoneName" to give points and dismember zombies. π¦
I basically got the bone hit and if it was the head bone, leg bone, arm bone, etc. I'd hide the bone and spawn some blood.
Wait sending an FName caused the spike?
I'm not sure I follow
I assumed since i'm shooting 8 linetraces, each with bullet penetration. That's a ton of names all being stored. I have 24 zombies on screen at one time so it's unlikely but it could be 192 names stored if every linetrace hit every zombie. Now I've put in a check to prevent bullet penetration from going through more than 4 zombies so it wouldn't get that high but still.
convert them to something more efficient
then send that over
GameplayTags seem like a fitting solution
Bone.Bonename
sent over network as ints
and you can create a tag from bone and convert tag to bone easily enough
I'll have to research GameplayTags. I haven't used them before. @dull lance That's food for thought. So if I did all the linetracing onServer wouldn't it lag a listen server when all players are shooting like crazy?
just linetraces that get the hits and apply damage and fx
So basically clients request access to fire their weapons, the server then does the linetrace, and does the damage, and plays the fx for everyone to see?
lots of players shooting like crazy
isn't all disadvantage
you can afford yourself some freedoms and small inaccuracies
as when 5000 bullets are flying every minute
doesn't matter if some of them don't end up on same spot on every client machine
and even if it is
So instead of sending a big packet of info inside a struct every shot from client to server, I'd be send a simple request such as a boolean "canShoot?" to the server and the server would do the rest?
it only matters for the player doing the shooting/being shot at
my firing package is the following
Enumeration for FiringMode, boolean for FireButtonPressed, AActor* for Target (Applicable in Automatic and Targeted fire modes) and a packed FVector for weapon target in manual firing mode
thats all
clients do everything else themselves from that information
they also calculate their own shots and RPC to server, co-op can afford that
ammo is replicated
weapon state is a state machine ran by firing package
it never goes out of sync
we are more 8v150-200 AI
Can I get that in layman's terms? hahahaha
my clients have the same information server has to determine what happens based on player input
and while i try to minimize any discrepancies, i also don't care if minor ones happen
Mine is a 4 player coop zombie shooter. Survive waves, kill zombies.
and they run the entire firing on their own
24 on screen at a time right now
but in a wave it gets higher per wave
never more than 24 at a time though
just move to player and attack
let your owning client calculate its own shots
so no
RPC those to server
that's what I'm doing. I to the linetrace on client, then send the hits to server
because players will notice if server starts correcting health of the zombie they are shooting at upwards
it also allows you to inflict predicted damage accurately
for owning player
as for simulated proxies
use best guess, instead of replicating all the details
your client #2 sees zombie that has its left leg shot out, client #3 sees it without the right leg
there is no difference between those 2 scenarios