#multiplayer
1 messages Β· Page 572 of 1
Ah I guess that makes sense actually, since GS dispatches BeginPlay
Still.. I trust nothing π
FFastArraySerializer can only contain one array property yas?
Or can you have two in the same struct..
it can have only one Items array
Oh duh ofc
the callbacks etc..
But also, dammit
I guess I can wrap two of those in yet another struct
i am used to writing in fastarrays for pretty much everything nowdays
current flow can be summarized by:
GameMode::PostLogin -> bunch of stuff -> RPC PC::ClientPrepare
PC now wait for the OnGameStateSet, calls other initialization, sends some update rpcs -> RPC to GameMode::PlayerReady
GameMode::OnPlayerJoin -> calls game-mode specific functions -> calls PC::ShowCharSelection
there is one slight caveat with fastarrays
their item callbacks get called before the arrays OnRep does
yeah.. it also serializes the whole item each time IIRC
Which is the main annoyance in this case
Ah well
unless you do delta for items
That might work
Actually, that would be heaps better. I'll do that
Has anyone done a NetDeltaSerialize for something that isn't a TArray?
you can alternatively do the NetSerialize the way FHitResult does
pack a bunch of flags indicating which properties are serialized in that bunch
@chrome bay Thanks for the feedback on steam leaderboards and stats. I just published my first Steam game and trying to add a simple Kill/Death ratio... and been messing with it for 3 days.
My C++ is shaky and I don't want to write a library. I finally found a plug in that works for leaderboards.. but statts don't work at all..no idea why. Unfortunately the plugin author is MIA
https://nte.itch.io/steamuer
Hey guys, good morning/afternoon. Quick question.
How can I trigger an overlap event only for the owning client in c++?
you can adjust collisions so you get overlap only on clients
I tried Pawn->IsLocallyControlled() and UFUNCTION(Client, Reliable) no luck π¦
Probably don't want to use network to send overlap events anyway
you definitely don't
Good way to get kicked out of the server when something overlaps a few too many times
I don't want it :P, but the trigger is happening in the server and all clients because the BP is on the level.
All you do is filter is after the event
The trigger should occur on all instances anyway because collision profiles etc. will be the same
OtherActor->CastToPawn->IsLocallyControlled
Thank you!, will do
you can adjust collisions so you get overlap only on clients
@winged badger not sure how can I do this
that only works if you have a Pawn collision just for that overlap or just for local overlaps
you mean something like this
you simply turn it on if its locally controlled on BeginPlay
and leave it off for every other machine
then it wouldn't even trigger the overlap
BoxComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
BoxComp->SetCollisionResponseToAllChannels(ECR_Ignore);
BoxComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
ohh got it!
that makes sense
Thank you
is a good solution
another question: how to properly override default game mode player start selection.
by default game mode in InitNewPlayer calls FindPlayerStart, but by game mode rules need to wait for user to choose character/team.
current code just returns null in ChoosePlayerStart_Implementation and sets spawn point later, but the warning message remains and irritating me a bit
c++ involved @violet sentinel ?
if so override this abomination in GameMode to just return false
/** Return true if FindPlayerStart should use the StartSpot stored on Player instead of calling ChoosePlayerStart */
virtual bool ShouldSpawnAtStartSpot(AController* Player);
yeah, lots of cpp and blueprints mashed together
characters selected during game, spawn points selected during game (based on team or random)
and caches it as StartSpot in PC
yeah, i have AssignSpawnPointToPlayer(PC, PlayerStart) which does "assigning"
this abomination of a function above is "optimization" so it doesn't run find again
but uses the StartSpot that was cached on join
it it returns false, ChoosePlayerStart will run normally after teams are selected
the more i dig the more weird things i find.
"make this singleplayer game into a coop game" realises into a nightmare now
been there, done that
Is there a way to do multiplayer with blueprints connected to aws gamelift without paying $250 for a plugin to connect to aws? Or do I have to rewrite everything to C++?
I wrote a game in blueprints and now that i'm trying to add multiplayer with aws gamelift, I see a lot of issues.
This is my join and create lobby code, it creates lobby then finds all lobies adds it to array then creates join buttons each with one session result attatched to them, I am set to 2 players running as clients and hosting server and finding server works fine but when trying to join server it fails
@sick totem plugin is mostly a blueprint wrapper over c++ aws sdk. you can implement all needed features and expose them to blueprints in form of plugin or game module, but i don't think you can keep it as a blueprint-only project. we had to write own wrapper because management didn't want to pay for plugin.
Is there a blueprint way to make a projectile ignore his owner? I canβt find any working solution online π¦
@violet sentinel Thanks! I'm pretty much a novice to this but do you have any tutorials or resources I should look into for help on this?
elenby when projectile is released save owner name and then on collision check against it
@sick totem there were some articles about aws sdk and some documentation, but don't think a tutorial about it. there were videos for the aws plugin, i don't remember anything else publicly available
@inner sand Great! that's a step lol, but now only the spawning client sees the ignoring projectile, even though the branch is on multicast
Solved it with "Ignore Actor When Moving". Thanks anyways π
Does anyone here have experience using the replication graph? Is it suitable for use in a game where the host is also playing, without a seperate client for the server? I've seen a lot of references in the code to using framerate as a constant tick rate suggesting its designed for use where the server is running seperately with a fixed framerate. I'm wondering if anyone's heard of it being used with a combined game-server game
Is anyone else using Steam Sockets, and if so, where is a source of info for it other than the plugin source code? I can't find anything other than how to enable it.
Like, just a couple example questions: in the source code for the plugin, it's trying to include header files which does exist, like steam/steam_api.h and I have the sdk which has those files, but do I just toss those in the core engine path, or should those exist in my project? There seems to be little to no info on this stuff.
I'm not married to the idea of Steam Sockets, but to my knowledge, it's the only way to accurately get the ping of a session without joining it (when using the steam subsystem), which is something pretty important for matchmaking
@twin juniper is there a question here, or are you just showing?
is question
What is the problem you are having?
I start the built server, but the console is empty.
If the problem is "when I start my dedicated server, it's not showing any information" you need to make sure you're passing the "-log" argument.
Like C:\MyGame\MyGame.exe -log
I'm pretty sure you also need to specify a map to open in the same place, I'm just not sure what the parameter is
Yeah, so you have to tell the server to open up a map
MyGame.exe /Game/Maps/MyMap -log
@twin juniper The flags we use when launching our server via console are: -server -nosteam -log LOG=ServerLog.txt
LOG=filename is just to specify a name for the log file
nosteam had to be added due to some issue we were having before, but I wasn't the one pulling the trigger so I don't know the exact details there
Saved/Logs/
empty
If you still see no logs, make sure you are not cutting them when building
Building in Release mode almost sure prevents logging
there are no files in the folder
There should be if you're following the steps
So my best guess is that your build configuration decided no logs were gonna be produced
is mouse location playerindex 0 only too like virtual joystick?
hmm...
@twin juniper I'm sorry, I have no idea what that's about :/
I just needed to clean the ini. the warning was gone.
Apparently, you can enable logging in shipping builds
Hello UE Users :)
Iam competly new to C++, i only work with blueprints but my game crashes after i packaged it and in the editor its working perfectly...
I
I'm using Advanced Sessions to create a session. Creating a session works, but I can't Find the session I just created. It always returns 0 sessions. Whtas up with that?
In my code in the game mode I am getting the amount of players, making an array of player controllers and an array of start points, then looping through the arrays teleporting the player controlers pawn to the start point. There are no problems with the array though however the pawns are teleported to a random one of the start points instead of the corresponding one. Any help is much appreciated, been stuck on this for a while and I think I am just completely missing smithing
I'm trying to spawn particles, if I spawn particles on the server with multicast it works fine however, if I do multicast on the client it works only on the client and if I do server on the client it only works on the server
how do I spawn particles on all?
I've tried calling a multicast, server and client function when the client fires but that did not work either
I got it to work this is what I did:
if (HasAuthority())
{
MulticastFire();
}
else
{
ServerFire();
}```
so serverfire is just calling multicast fire from the server
wait
a photograph of a computer screen π€
prob shouldnt use multicast btw
what is it for? why would server need to call it?
what i do too sometimes is have the particle on an actor thats set to replicate then spawn that
I could probably do something different when a client fires
but for listen server I have to use multicast
oh ok. i normally use dedicated so not sure about that way then
still for dedicated, if I send particles to server only they don't get replicated to all clients
you mean if you call server event from client?
i mean yeah it should as long a you call from remote
so if I'm the server I'm calling multicast from server
if I'm the client I'm calling multicast from server from client
it seems to work
if you client you should only call server event
but then other clients don't see it
screenshot event you use to spawn the particle
yeah thats fine
FHitResult Result;
const float WeaponRange = 20000.f;
const FVector StartTrace = FirstPersonCameraComponent->GetComponentLocation();
const FVector EndTrace = (FirstPersonCameraComponent->GetForwardVector() * WeaponRange) + StartTrace;
FCollisionQueryParams QueryParams = FCollisionQueryParams(SCENE_QUERY_STAT(WeaponTrace), false, this);
if (GetWorld()->LineTraceSingleByChannel(Result, StartTrace, EndTrace, ECC_Visibility, QueryParams))
{
if (ImpactParticles)
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ImpactParticles, FTransform(Result.ImpactNormal.Rotation(), Result.ImpactPoint));
}
}
if (MuzzleParticles)
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), MuzzleParticles, TP_Gun->GetSocketTransform(FName("Muzzle")));
}```
and that's multicast
Yeah im not a pro at c++ but i dont see anything weird
you want me to show you how i do it in BP?
So I want to make a server client solution for my game. The player will be playing single player with option to join a map with another player. Now for the server solution. The server can only have one map. So I would need to make instance of every map. Because players will be playing these maps single player, I would not need to replicate. Does this mean I can have 1000 players all playing on the same instance but do not see each other playing? If the instance is over loaded spin up another?
The client would be built with all maps?
@vale ermine I think im confused by your question. Are you asking if the players offline will still be on the server but just not see each other?
no basically asking how I would go about having multiple players on one instance to reduce how many instances need to spin up. I need a scaling solution and I know the world map would need to be dedicated run 24/7. I just don't know how I would go about dedicated maps vs instance maps that are short lived.
cost would be the biggest factor here in the design. Players see everything replicated on world map. When player selects a planet the see missions and can select one. This is when it would join an instance a bunch of players are on be each player is playing their on game.
i am using game spark for database and i want to use gamelift for server
world map wouldnt matter cause thats just local not server though right?
world map is server because when other players send out troops that will be replicated so other players can see where other players are sending troops
but all other maps can be instanced
hi guys how do I get the player index of each player in multiplayer?
so what would be offline?
I found this solution here....but not sure what it means by set to player state https://answers.unrealengine.com/questions/167617/view.html
do not use player indices or GetPlayerXXX[Index] functions
getting player Index is super impractical
There is no offline but what I am trying to get at is. say someone clicked on mission 1. A instance spins up. player 2 clicks on mission 1. server sees that there is an instance that is not full. Server sends spawn locations for buildings enemys and other stuff to player. Last player competes mission. no more players on instance instance shuts down
i hope im thinking about this right
i think running a bunch of instances will go over the specs of a commercial dedi
thats why I am trying to figure out the best way π
how many maps you talking about and how big?
Ideally I would like to cram as many as i can get on one instance. Trying to figure out the pricing for that is not easy.
no I want to start with one. There is one main map everyone sees and rest is missions.
you would have to run it and test but for what you talking about spatialOS might be better?
so anything you cram into it is a one time bonus
I did look into spatialOS and ran some test. The problem is that they do not keep their sdk up to date with the engine version
spatial is for large persistent open worlds, not for world map + instances tho
im confused i thought thats what he was going for. never mind lol
i got a feeling its more a guild wars type of setup
ever play lords mobile? its like that but space
i never play anything mobile
π to true. same here
So what Im thinking is that every player on the instance will have to spawn their own objects that do not replicate to other players that way I can have many players playing on one map. That seems like a lot of objects for the instance to handle.
how many is many?
well as many as it can handle I would not push it over that. Then I would spin up another if the first is full.
so every map needs to be compiled into its own server and needs to communicate with the lobby server so that I can manage what instances are spun up and handle closing them?
using game sparks databse to manage ip's and ports?
Honestly im not sure. im still kinda confused what you going for. I can tell you for instance with what i use on gamelift i have matchmaking set up that matches to which server/ instance i need if the instanced get to max alloted, a new server is started etc
how do I get current session, I know find session exists though how do you get your session after you host it for ref
Anyone have any working code (BP or C++) to set/get Steam Stats?
spacewar.
Yeah. Spacewar in the steam SDK should have that
you can include the SteamShared module, and then use the steamapi directly
you can use something like UWorks for wrapper
if you share a dislike for std with a lot of people here
thanks ... been looking at all those plugins on the marketplace .. big money.
Last I checked, UWorks wasn't for sale anymore
so i assume controllerrot having diffuculty with replication to others clients here, right?
there are more than 1 players and it just returns client 0
yeah UWorks is MIA
I found this plugin and it's free. It has all the code and BP integration.
https://nte.itch.io/steamuer
I got leaderboards to work fine... however stats don't work... and I haven't been able to figure it out. Going through Steam SDK docs like for 3 days.
I've been using the Advanced Session plugin, though I've done nothing when it comes to actual interaction with steam other than getting the Steam username and creating/joining sessions. Annoyed by the ping issue though
@peak sentinel You're calling that print on the "remote" pin, which means it's not going to get called by anything that doesn't have authority, so it makes sense that it's only getting called once if there's two player (assuming one is client and one is server)
understand, what about rotation? i am processing everything in the controller then pass the replicated variables to character and call server function to SetActorRotation();
normally it should have replicate to other clients & own client but, could this be about "mouse is local controller only"?
Typically the ol' "replicates movement" handles this for me, but I assume you're changing the rotation somewhere else? If you're talking about mouse stuffs, then I assume you're directly setting the rotation, correct?
yes, setting the rotation towards the mouse location
Ok, so what you want to do is take the part of your function which sets the rotation, and turn that into an event which replicates to server. I'm pretty sure. Since you're setting the variable on the client... damn... I mean, try that, if that doesn't work, I'm going to link you to a doc I mean since I'm going to bed soon and won't be awake to explain it
@peak sentinel https://docs.google.com/document/d/1tDduU4-V-fkymvmmtKf4GrFQQ2HUiqqM4N3Cdo3arV8/edit?usp=sharing in case you want a look, it's specifically about save and load games, but it's also about passing variables set on the client to the server
okay, thanks
np
General MP question. What to do when logic depends on multiple replicated variables? It seems like not all clients have the variables replicated when trying to execute the code leading to mismatched results.
Send the data with an RPC or bundle the variables into a struct and repNotify it
Ah ok
Each of the two ways is for different things though.
Although I think my issue is something else for the moment. I'm having a hard time wrapping my head around what Types of Classes should call what types of "Executes On ..."
As RPCs only affect the users that are relevant and repNotify calling for everyone who's relevant and later for the ones that become relevant
I feel like I'm having Client call server to only call client back again just to do something
I think I'm doing very silly things
Or have Server call Client only only to call server again
You only need rpcs if you need to move from server to client, client to server or server to all clients
Custom Events that are marked as execute on iirc
Like I'm trying to do a vote system
The term RPC is not a cpp only thing. It's a general term you should use
I thought it would be easy
Did you read my compendium?
but every time I try to predict the behavior
Something else happens
or rather doesen't
It's pinned to this channel
Like Rep Notify has confused me so much, at first I'm like its Server to Clients only? Then wait says both?
Mean while it doesn't seem to do anything
and I don't know if that is because I'm calling it in the wrong class?
I have looked at
It's theoretically all explained in it
Sadly My results are different or too specific
I'm like having an Event called Casted Vote call a Server Casted vote
ecall a rep
only to call a Server Cast votee again
Its messy
It probably shouldn't be this messy
By rep I mean Rep Notify
You only need one server rpc to tell the server that you voted
And that rpc needs to be in a client owned class
E.g. Playercontroller, playerstate or playercharacter
I think I'm just using everything all at once...
I don't know
Perhaps I'm using Rep Notify to do something an event is capable of doing just fine
Then start from scratch with it if it's too confusing
Or vice versa
Maybe write it down first with pen and paper
THis is my start from scratch project lol
I think Rep Notify just doesn't work how I think it does
At this point it might need someone to look at your code and explain to you what's wrong. I sadly don't have the time during the week to do that
and it's throwing me for a spin
Well I'd pay someone for 30 min to an hour of their time to just walk me t hrough this
I think if it got explained to me first hand once I'd get it.
RepNotify is very simple. It's a normal replicated variable which calls the OnRep Function whenever a change to the variable gets replicated, including on the server when set.
At least in BP. In cpp it only calles on clients by default
So if Client calls Game State Event which is set to "Executes On SErver"?
@neon mango is it actor or uobject where you are trying to update variable
GameState can't execute server rpcs
Ah...
It's not owned by a client
In your compendium it says it is shared by all
By reading the ownership part of the compendium
@rich ridge Game Sate?
It's and actor , and doesn't owned by client, so no rpc
(despite multicast)
You can do multicast
But to go from client to server you need a server rpc
is UMG client owned Actor?
Umg is client owned UObject
UI is something that should not have any replication in it
hmmm?
Ok well that sounds like another problem in my code then
UMG was calling that Event i showed
Yeah
So UMG should get Pawn then from pawn call that event in GameState?
As per your event name, PlayerCastedVote
What I understand is a player does server rpc, and then server does multicast.
UI Button Press - > PlayerController - > ServerRPC - > GameState - > Set Replicated Variable
And UI can then bind to the replicated variable or you make the variable repNotify and tell the ui to update if you want yo avoid binding
I think you are trying to do multicast from client
He's trying all sorts of things haha
I thought from Compendium it was shared
And yes
Sort of trying all combinations of things
to see what sticks
lol
Brut Forcing it
not proud
Apart from network compendium, you need to understand the underlying components like GameMode, GameState, etc
When these components are created..
For example PlayerState is created in Login function of GameMode.
The example i usually let peeps figure out is how to make a door that a client can open by pressing E and everyone else also sees it opening. (so server and other clients)
If you understand why you can't just call open on it or place a server RPC i to the door that's in the level you will already be a lot further
It's also close to your voting issue
Yeah there is a lot to know, last time I did networking I used C++ and the Shooter Example to hold my hand. Now I'm doing this from scratch via BP and I did a lot of stuff on my own so far but voting for some reason confused me, probably because I also want to update the votes to all clients to show them in real time what is being casted
And I tend to do a log of logic in UMG
And I tried to do net logic in there too
Probably why there is no Has Authority Switch node in there
To discourage it
But that worked! @thin stratus and @rich ridge Thanks
Can dataasset be replicated?
Data assets are assets
There is nothing to replicate since they're supposed to be constant
Hmm true
Any reason why this breaks in Multiplayer?
Blueprint Runtime Error: "Accessed None trying to read property CallFunc_K2_GetPawn_ReturnValue". Blueprint: BP_PlayerController Function: Execute Ubergraph BP Player Controller Graph: EventGraph Node: Add Movement Input
cause you are trying to do it before pawn is possessed maybe? from those nodes, who can tell
so you have no possessed pawn or pressing input before pawn is possessed
There is nothing to replicate since they're supposed to be constant
@bitter oriole
When you say that I'm assuming all assets are deployed to both the client and the server.
Are there client-only/server-only assets?
If they aren't, they can't replicate anyway.
Replicated actors are created on clients too and there is no built-in mechanism to download new assets from a server ; not that it's impossible to add such a feature
Though if you do create such a mechanism you still won't need replication on data assets, since... they're supposed to be constant.
you can replicate a pointer to the static asset though
tell the clients "lets switch from dataasset A to B"
well, to B
Hey guys im having a problem with my game when i get a client to join the server host the client has a black screen and cant see anything
(Im using the steam plugin)
(And following this tutorial
https://www.youtube.com/watch?v=ngBI40tjirE&ab_channel=UnrealEngine )
We continue working on our Find a Match screen by scripting how to populate and find available games to join. By the end of this video we have our basic multiplayer functionality in place and test out a server hosting a game while a client connects to that game. We also show r...
it seems to crash mostly when i don't have the headset on my head
there is a way for pass throught it ?
Amazon DB or Amazon RDS, which is better According to pricing, efficient in unreal using vaResT,For a Realtime Multiplayer shooting....
why server can't see client event?, but client can see any client
i already running two custom event, 1 on server, and other on multicast
I have first person arms/weapons and third person arms/weapons. I can toggle between first person and third person by changing the active camera and setting the "set owner no see" on the arms/weapons accordingly. It works great but I can't figure out how to allow spectators to see the first person arms of the person they are spectating while keeping the first person arms hidden from other players alive. Ideas?
Whats an easy way to store a players nickname from their client so that it follows them into a server
@cedar finch don't use ownersee/nosee
do it manually, with IsLocallyControlled checks
then it won't automatically screw up spectators
Anyone know of any resources on Push Model?
i created my own
with NetworkManagerActors and FastArrays
can run any interactable Actor in the game through fastarrays there without the Actor itself being replicated
Were the gains worth the effort to do that?
Nice
basically, my interaction works with Interface on Actor + InteractableComponent that does the heavy lifting
@winged badger Ahhh ok thanks π
my FFastArraySerializerItems carry the snapshot of relevant parts of the InteractableComponent, a Timestamp and a uint8 Payload
which InteractableActors encode when they update the network managers on server and decode when fastarray callbacks call PostReplication (custom function) on them
yeah
but network performance improved massively
has slight troubles coping late game prior to the change
Though by the sounds of it, yours only works for this Interactable Component?
what is a push model?
during the demo (after the change) we had a bug that allowed 16 players to connect instead of intended 8
and the game ran fine
Manually marking properties as dirty for purposes of replication @twin juniper
Saves the Server from doing property state comparisons
Every rep update
Interesting.
Yeah im finding that out as im reading into the code.
as all the Actors are still replicated, so it doesn't save server from evaluating them
I cant even check if a property has already been marked Dirty
it just saves bandwidth
Gotta save that mandwidth
which is a secondary concern usually
π
Yeah, im actually more interested in using it to avoid having to call a Multicast.
my problem was with so many replicated actors, actors with short lifespan, like thrown grenade, sometimes wouldn't even show on clients during their lifetime
that makes sense.
even after net priority adjustements
i just put 16 NetworkManager Actors on the 80kx80k level
had all InteractableActors register with the closest one and turn replication off on BeginPlay
Not using RepGraph?
no, didn't have time for it
Ah
i would had otherwise
Its relatively easy/quick to setup if your not deviating from its already implemented nodes
i made network manager system in 4 days, 2 weeks before the demo
Ive had to put our RepGraph implementation on the backburner for now, to much other stuff to get done, plus ours will be extremely tailored thus increasing dev time to write it.
nods
as long as you have a lot of Actors that fit the same replication pattern
this is awesome
as this has full benefits of a Push Model
the Actors need to be NetAddressable for this to work, obviously, as part of the replication payload is a pointer to the Actor
at least the name wasn't taken π
Heh
yeah
Ehh
its where the client side BeginPlay gets called from
Makes sense
Question about spawning a large amount of replicated actors (projectiles). It seems that if they have a lifetime of say 20 seconds and I shoot even 10-20 into the air so they arent getting destroyed it seems that the continual spawning/shooting of more projectiles slows down client side and looks more sparse. Is this due to the continual creation of so many replicated actors or should I be optimizing how they move or update? Iβm unsure where my bottleneck lies.
But shooting at the ground they spawn just fine and continual on the client
Do they get destroyed when they hit the ground?
Yes
They are replicated spawned by server with projectile movement component and when they overlap on server they get destroyed
thing is, if they never actually overlap something to be destroyed, they will just persist
So if Iβm on the client shooting at the ground no problem but as soon as I shoot into the air it starts to slow how many I see coming out
Is it really that big of an issue to replicate 20 moving actors like that?
Seems to stress things out for my client badly
As soon as they die in the air its back to smooth shooting again. Server has no issue shooting into the air
Is it rare for games to have that many actors ticking movement? I would think that should be fine
Given that when you shoot at the ground your most likely not having multiple alive at once, however when shooting into the air, many are alive together.
Also it may not be a network bandwidth issue, it could be a processing bottleneck.
You really need to profile it.
A good place to start is stat UObjects
Then get familiar with the Session Frontend and its profiling tools.
Hmm I find it strange that it could be a processing bottleneck though if the server is fine doing the same action without a hitch. Do those tools handle network bandwidth measurements? That could tell me more of a story
If its a Client Side issue its more likely processing/graphics related than network.
Again, profile it.
There are network profiling tools.
Network Insights
For example
But its only available with 4.25 IIRC
Ok. Im on the latest 4.25. Iβll look at some videos and see what I find thanks.
If I don't want to use Steam, is there any alternative OnlineSubsystem to use? Ideally one that doesn't require an external client running?
@dusk night Explanation of a Subsystem is a heavy use of services without Unreal Engine. Even when you use Epic Online Services whenever it's plug-in external services is needed to function depending on what extent. Theirs security practices that block you and not suitable/comfortable for gamers to develop. It's basically software engineering practices to enable players. Which the answer is a very slim yes and no, meaning you must create yourself.
In my case I just need really basic functionality to have sessions and relay network traffic so online games work outside of LAN. I'm hoping the Epic Online Services plugin(when it comes out) doesn't require the client running.
@dusk night It's software engineering practices, you'll always need to have a client and a host it's the basis of things. Unreal Engine doesn't allow host migrations due to multiple issues with cheaters I believe. Also I highly doubt Unreal Engine will be paying for everyone's dedicated server. That will easily reach past 100 million on top of millions. What's your end goal... What do you mean you don't want to have a client?
@dusk night Pace yourself and take time studying Computer Science an you'll be able to sit-back and easily tackle everything you need to like a champ
I'm already quite familiar with networking. The players would be hosting the server(listen server). Its just the Online Subsystem is used as a relay server to get around NAT issues.
I am p new to replication, trying to set billboards to hidden with a simple unreplicated event. When I call the event of a keyboard press it works but if I do it off any other part of the graph it doesnβt, any explanation would be very helpful
I use C++ so I don't understand.Sorry
@inner sand are you saying it doesnt trigger from other logic on the graph?
stuff that might be happenign on the server?
the keypress is something the client does.. so it is happening on the machine that does it
but if you're trying to do something from any where else on a graph that might be getting execution from the server.. it wont work on clients
unless you replicate it somehow.. either with an RPC or a replicated property.. enums are nice for state replication
use that repnotify
dont know if any of that helps
So I take it I canβt just call it off the end of my event begin play. I am trying to make its so that only you canβt see the billboard. Is there anyother way It be considered run by client. Even the option to Run on owning client doesnβt seem to do anything
on begin play it should happen on both machines
server and client
have you tried restarting the editor?
Nvm got it to kind of work, just needed to put a delay after begin play, It looks like a bunch of stuff was getting loaded before it possessed the pawn, possessing the pawn was called before but I guess it just takes time to execute
aaahhh oh yea those race conditions'll get ya
Race condition?
well im not sure if thats the right word for it
race condition is where like... 2 things are trying to call eachothers variables on begin play
and its like... one of them cant be initialized yet before the other one is trying to find it
so delays are super simple way to handle it
but then you forget about what you delayed and where and it gets messy
Oh, thanks I imagine thatβll come up again
delegates are super nice cause its like... "whenever this is done.. let people know"
Replication is more an art than a science
so you can be like "initialize this after this other thing fires its ImDone delegate"
lololol uhhhh
im finding that out now with optimizing lol yea
but its good to know the science
Pawn/Controller thing is not a race condition though
its just a sync execution
i fucked that up
Anyhow Iβll check out delegation
his problem is probably because something hasnt been replicated yet right on begin play
right Zlo?
if that delay fixes it.. that's probably what it is
client has controller on BeginPlay
i'd maybe make a comment anywhere you make a delay and have a shared word.. that way you can look it up in your findall
later on
as there is no possessing done there, its just a replicated Controller variable, and those are set prior to BeginPlay
Yeah just did thay
anyhow, there is always a way to avoid delay nodes
Iβm possessing a character I spawn in on begin play
which will bury you as you add complexity
Makes sense
yea and they're not reliable.. like if there's super laggy conditions
when you have 50 things initializing in order
maybe that delay wont work
good luck timing the delays
i like delegates
the day i found out about delegates i let out a big loud "hooraaayy"
lolol
Are delegates c++ only cant find anything in blueprints
what are you playing as Zlo?
ah, im just looking at some UI atm
you can do em in blueprint
lemme do a screenshot
see where it says event dispatchers at the bottom
you click the plus button.. dont worry about giving a signature
you can add inputs
you can have other scripts "bind event to YourEvent" as well
oh event dispatchers
yeaaa
got itttt
they're called delegates in the code world
i came from C# in unity
but now that im thinking
uhh no this isnt somethign to do with casting i dont think
you would still have to cast to bind the event from whatever you're trying to get the data too
one moment, screenshot
no i get what ur saying I think
They're really helpful when you start using design patterns
but u need a rferece from what ur casting to to the caster with delegates, usually other way around
here's me inside a FortressActor (its got a castle mesh and some spawn points) and it spawns guys and then binds an event to their health change...
cool cool, the variable change ones are going to be very useful
replicated properties are the way to go for variable changes i think
like.. ill fire my delegate in my "repnotify" function from my replicated variables
you know what i mean?
then anything on the client side thats bound to the delegate will get it right when it gets replicated
Anyone familiar with UCharacterMovementComponent? I want to disable location replication whilst keeping replicate movement enabled. I'm trying to figure out how to do this in my custom movement component
Essentially, I want to replicate everything normally (character rotation, for instance) but not the location. I want to do custom client authoritative location replication with interpolation
I figured out that my code works while their is a delay even if the delay is zero seconds, not a problem just thought it was weird
delay of zero means one frame
@lucid vault dont know of a checkbox that lets you do that.. might have to change source.. i made a pawn class that i put a skeletal mesh on and replicated movement..
@fossil spoke yeah, my network managers only work for InteractableActors with InteractableComponent, but those are over 75% of my Actors (doors, windows, loot lockers, power switches, terminals...)
it could easily support additional different Actors, but it would require writing an additional FastArray for the NetworkManagerActors for each replication pattern you'd need to support
Yeah figured
i do have 2 FastArrays, 2nd uses an extended FFastArraySerializerItem, this one also able to carry the payload from DamagableInterface
since some of our InteractableActors can also be damaged and destroyed
the entire system was around 600 lines of code, so much less then i originally expected
what is the player index of the client in a 2 player game? 1? why is Get Camera Manager with player index 1 returning nothing?
Clients don't have access to other player's PlayerController or related classes
@bitter oriole okay then how can I access clients camera ?
because right now in my Character blueprint which is for both server and client
its using the same camera (servers)
im getting the forward vector on the actors camera to do calculations
Get the Character that you want the camera for, and get its camera.
The camera manager is player-based, not character-based, and players are not replicated while characters are.
@bitter oriole how do I get the character?
get player character still requires the index
Player index simply is not a multiplayer concept
You need to use some other logic to get characters
i dont get it
what node do i use to grab the character? both client and server uses the same character blueprint
Iterate on all characters and find one that isn't locally controlled, for example
GetPlayerCharacter(0) will always return the local machine's character pointer. It relies on the player controller list. On a Listenserver PlayerController0 is the listenserver's controller, on any client there's only one controller, so they're also PlayerController0
You can also iterate on player states, find the other player's, get the pawn from there
ohhh I see so get all actors by class and then find the one
It really depends on what you're trying to do
well I am trying to get the forward vector of the given player
to do some calculations right now whats happening is that its using the server (player 0)
i understand that get player camera manager is not going to get me what i need
Do you need this information on a client or the server? And if it's on the server, do you need it for a client's character?
good question I need this information on the client and server...
inputaction lanzar (throw)
im using it to apply the vectors to an AddIpulse....basically each player gets to throw a ball
and right now the direction is fixed (it uses the servers forward vector)
I think part of the problem here is that you're going outside of the character to get the character. You're already in the character. When you have two players, you have four characters. Two are locally owned by their machines and these are what receive input events like your InputActionThrow there. So when you press a button on that machine, that machine's locally owned version of the character plays it. That means only one out of those four characters plays that input when one person clicks. So what you do, is make an RPC to the server like you did right after the event. You can either pass in an aiming vector from the client saying "I want to aim here", or you can use this instance of the pawn on the server to figure out your aiming vector, probably based on BaseAim or location of the camera, etc. You shouldn't need any calls like GetPlayerCharacter or CameraManager here.
Get Controlled Pawn?
so maybe I need to call the RPC after running it on the client?
I am using where the player is looking to get the direction and feed it into the vector...so you are saying I should pass this vector to the RPC
(in playing in the editor) my level has an actor who (on the server) spawns another actor and stores it in a RepNotify variables.. then in the OnRep_XX function it calls an interface on that actor.. When the level loads the OnRep_XX fires on the server; however when clients arrive they don't call the OnRep_XX - I'm pretty sure all replication is OK, etc.. If I add a 5 second delay in the initial actor so it does not spawn it (and store it in the RepNotify variable) for a few seconds, it works.. I thought OnRep_XX fire for clients joining when they get the network copy of the actor.. what am I missing?
onreps only call when something changes. If they join, they receive the actor in it's current state, thus, no onrep.
Ah ok, so the actors once replicated to the joining clients will have the variable set (and available in BeginPlay) -thanks
@kindred widget ohhh I think I see what you mean now
@kindred widget fixed it via using Camera location and getting forward vector from that! was using base aim rotator but it was giving a Quaternion
Using OnRep for a variable that changes every tick (variable comes from an input) or processing everything in tick and calling functions
Which one is better?
OnRep
You won't get all the updates anyway if it changes every frame
And calling an RPC on tick is a good way to kill your server
@gleaming niche @soft shell You will get an OnRep during a join in progress
OnRep will be called if the value differs from the construction-time value
@strong vapor I indeed need to modify the source, or at least a subclass
I'm just not too familiar with the CMC. I'm looking through it for a place to disable location replication
@chrome bay i'ev always had to manually call the OnRep for things that rely on the OnRep to be called, from PostNetInit or whatever, because they would never call for me. I have no idea about blueprint ones though.
i no longer have many that rely on it, because of that
If I TearOff() an Actor on the Server before calling Destroy(), shouldn't that NOT Destroy the Actor on the Client?
Do I need to wait a frame so this doesn't happen? It seems to skip the TearOff check on the Client ;-;
What do I need to do to setup my game in UE for online multiplayer? Setup so that the clients/players can connect to Google/some other server working as a host. Thanks!
@gleaming niche you sure you didn't manually break the engine there?
tbh in Blueprint anything is possible π
blueprint doesn't even have OnRep
Yeah that have that awful fake on rep
its a callback from IPropertyChangedTracker, definitely not a replication callback
me no likey
its just terrible
OnReps calling before BeginPlay is fun too
"Oh your logic relies on BeginPlay having called? Too bad!"
thats client or deferred spawn in BP
i usually do deferred spawns for everything so that i can use unified BeginPlay logic on client/server
I'm a bit annoyed at Epic's tear off logic
If I tear off and destroy I don't want to have it destroyed on the client
Yet TearOff has to replicate first? wtf?
and for that it has to be not destroyed long enough for net driver to get off its arse and send it
π
Yeah which is a gamble
just elegant
I wonder if I can set Replicates to false
But then it's not teared off either
oh man
My fave thing is replication graph, which doesn't destroy actors until they are relevant again
but that carries another bag of cats
It's such a simple concept: Destroy Actor on Server without it destroying on the Client, because the Client will take care of it itself.
when a client enters relevancy range it will not get its last update if you do either of those
boy oh boy π
i usually just hide/disable mine, set lifetime for 10 or so seconds
:perfect:
but yeah, however you look at a concept of destroying replicated Actor on server only
It's fine if this is for visuals
its a chicken or the egg scenario
But the Client needs data from the Actor before destroying it
If the client lags and doesn't perform that logic, I have an issue :D
Guess I store the data at teh start and use it at the end, no caring about the pointer anymore
i don't have that problem, as most of my Actors don't replicate over their own channels in the first place
and have replication off
so bp's repnotify doesn't actually have anything to do with replication?
no, its property changed callback
you can set property on client locally, and OnRep will fire
its just... bad
oof.
@thin stratus @winged badger @chrome bay you guys rock, love these 'gotcha' traps you are covering in UE4 π thanks for stepping on the landmines and sharing your pain so we hopefully won't repeat the same π
Oh you will repeat. Every single painful step. Don't you worry :D
lol
@chrome bay that explains why in fortnite, you see things and boom, they just dissapear in front of your eyes LOL
figures π
OnReps calling before BeginPlay is fun too
i was about to use onrep and this just saved me 30 mins before i rage quit unreal and try to solve why engine crashed
OnReps calling before BeginPlay is one of the most convenient contracts in unreal networking imo
(after you are aware of the fact, you can structure the code to take advantage of that)
What happened to the "Auto Connect To Server" checkbox in the advanced multiplayer options?
It merged into the DropDown that lets you select if you want to play Offline or not
What is the difference between a Net Multicast and Just having the server Loop through all players and calling a RPC that is set to Replicate for Owning Client?
Can't call a client function on an object a player doesn't own
You can call a NetMulticast on a random box in a level for example, that all players can see, but not a client function.
Yes but in the example I give the RPC is on the pawn
In case that wasn't clear
so is there a difference aside from how it is being called?
to one player?
So if server game mode loops through all players from Game State and calls an Owning Client RPC is that functionally different from just doing a Net Multi Cast there instead?
Reliable ones get fired immediately, unrealiable ones do not
Don't they all have reliable/unreliable flags?
well, you can't really multicast from a gamemode π
Nobody owns the gamestate, so none of them will receive a client function
And server won't call one
You can only call a Client RPC on an object that a Client owns
yes
And only that client will receive it
that is what I've done Zlo
So would it be better to just do a Net Multi Cast somewhere else?
Or is that just fine?
my very much preferred way of doing it for something important
there is also the bit where multicasts take relevancy into account
So you would approve of me doing that? it is a wise thing to do?
i do that for my match end info/screens
Which is what I'm doing right now
as does Jambax if im not mistaken
My understanding has moved me to do that for my Player Vote screen
But before I was doinig Net Multi Cast and seemed to get the same behavior
so wasn't sure which was best
direct client RPC doesn't have some border conditions multicasts do
that can cause them to fail
That sounds handy to know
like being out of relevancy
ok
btw, most efficient way to do it from BP
is GameMode -> GetNumPlayers -> For (0 to NumPlayers - 1) -> GetPlayerController[Index] -> Cast + RPC
the only use of GetPlayerController[Index] i approve of π
Hmm so this is less efficient ? https://gyazo.com/63822ec647c592bd76937f24c606491b
slightly, if you start from GameMode
it has an extra layer of indirection
but its fine
ok
the above one is basically loop through all PCs in blueprint
the PlayerState version will fail if the World didn't BeginPlay yet
as the array will be empty
yeah, but there is a way that can come to fail
say you seamless travel into the map
and you override GM's ReadyToStartMatch to return true only after NumTravellingPlayers is 0
this is the scenario where you can have 3 players fully loaded, 4th still loading and BeginPlay didn't start yet
my point is
PlayerArray is populated when PlayerStates call BeginPlay
and register with GameState
But PC is always good to go
before they do that, the PlayerArray is useless
My issue with PC is that they don't possess pawn until some time after they join
I didn't want to have to use a delay there
ofc, does your RPC more naturally belong in PC or Pawn is also a question
(PlayerState can RPC as well btw)
I guess this is why Shooter Example does all this in PC, I recall them doing that at least now I know why
voting stuff thats visible to all players belongs more naturally in the PlayerState imo
Well the votes var is in there, in PS
then send the RPC through the PS
hmm I think not
now you have a PlayerState accessing Pawn to send a RPC for the Pawn to access PlayerState and set the variable
2 steps in this chain don't need to be there π
Yes... tell me about it, this is what it's been feeling like
No shooter C++ code to hold my hand
I'd just peak in there and be like, oh they are doing things this ways lets copy
but now I'm going solo
and I'm doing silly things
What is the best practice in terms of interactive events? I just realized another silly thing I was doing that was leading to Interactive events happening twice.
I made my "Fire" event Server RPC call so that when Client "Fires" it tells the server to try and do the same thing but then on top of that I was having other RPC events get called if Client was doing the Fire to tell server to do those events leading to them happening twice.
A simple solution would be to just not make those events fire a second time client side and just let the server verify that the hit occurs but I have a situation now that since Rag Doll physics doesn't rep and this needs to happen on the ragdoll that I'd need to trust that Client is seeing the rag doll where they are meaning I can't strictly depend on server verifying the hit since server and client rag dolls usually wont' match.
I guess this forces me to use a death animation? That should then match server/client but is Rag Doll really out of the question?
You could replicate the position of the ragdoll mesh and move your client ragdoll to the same position
Using impulses
I have tried this myself and it works for the most part but there are still some bugs/caveats that I have yet to figure out.
The client ragdoll jitters pretty badly and sometimes the ragdoll disappears completely if the client isn't looking at it.
I wonder how other people make multiplayer games with this lack of documentation/knowledge about networking in UE4
Even replicating a ragdoll movement requires tons of research π
There is UDN Unreal Developer Network that I know you can pay for to get better more direct INfo
never used it
and I don't know if you need to be a certain company to get access to it
How much they ask for?
I mean look at my name, i could call them every second π
Yea it's almost remarkable to me how solo/indie devs even manage to release a product. The amount of work to just learn how to do things the first time around is crazy, and then optimizing and doing them correctly too.
Not everyone is in the same situation. Some people have more time, some people are more disciplined, have fewer distractions in life, etc...
Some have the advantage of working in the industry amongst other professionals at a AAA studio and know the ins and outs.
I seem to be in a pocket where no one around me even in my profession want to make games on the side or collaborate for that matter.
That's probably the biggest advantage that I lack.
Nobody asks to learn matchmaking or making advanced wall running system with replication in 1 day
But least essentials should be documentated
unreal docs are slowly improving, them taking down the Wiki was the worst move ever
Like no docs. teach you about you should check for if controller is valid before coding inputs
or no docs. explain how you can make a "only* owner see" mesh visible for spectator actors
you should come here and beg for help from people who did it before
Seriously the knowledgably people here who take there time day after day to answer mainly old questions are true heros.
totally agree
And they are a handful
I sadly am one of those that just comes in to ask questions but when I do if I can answer another question someone posts that I know the answer to i will do so
Yep. There is no lack of respect for the experts who answer questions like that. I hope one day to be able to repay it myself.
But after all the knowledgably people in community carries the responsibility of Epic which they dont need to actually, I am surprised they have a paid service to help the companies
Having a Unreal Slackers in the community urges them to "not improving docs"
Yea I definitely do agree that with all of the money they bring in they could pay a few positions or a department to release some short tutorial series that cover specific things in depth to help the community understand things better. Or maybe they do that? I haven't found anything.
With the upcoming updates they also update the docs but most of the docs and espeacially youtube videos are mediocre
Yea their videos are like 2 hour long mess around and talk sessions nothing that is tailored or directed at specific tasks or learning.
I saw a YT video which uploaded by UE about replication, the "network engineer" who was tutoring just added a server function to "spawn projectile" weapon then video ended
Why is replicating TMaps not supported?
@dusk night Another good question J, I believe Unreal Engine only support UPROPERTYS A UPROPERTY,or it's just a UPROPERTY that's simply not replicated.. I believe is something that can be enabled in editor to view and a ton of other low level stuff within ue4. Simply to say, I don't know their framework. But to me they just didn't, Either way work around it
@dusk night Best bet when you encounter issues like that spend a little good time to see if it's your fault. If not work around it
What are you working on sounds interesting a shooter or rpg?
TMaps can be UPROPERTYs, they have give an error when you try to replicate or RPC them.
strategy
Cool, Well spend time to see if it's your fault. Make sure you check things you need to if not,think about it you spent a good amount of studying checking for human error. IF your satisfied to with your time spent on research work around and don't waste to much time researching
I found a forum post from 2015 from Tim Sweeney "That's great news! Implementing a UMapProperty and supporting TMap replication was on my todo list in 1998." I guess they never did get around to it.
lol
lol
Yup, take that into practice. How long did you waste researching and how far would you be if you worked around. Good practice, then when you find something put it back in.
Simple Replication question that is giving me a lot of trouble, I am calling an event as server in game state that is multicasted, after key is pressed. The event has seemingly no ouput whatsoever though. It is supposed to set a billboard component to hidden and then print something. any help much appreciated.
event called from player controller
@inner sand Dedicated Server?
....
that is dedicated server
So yes lol
sorry
RPC?
Your Key input is on the Client side
Therefore your SwitchHasAuthority will always read as Remote
So the input would need to be from the server
Or
Your Client sends an RPC to the Server that tells the Server you provided input, then the Server sends the Multicast RPC
Run On Server - Client sending info to Server
Run On Client - Server sending info to Client
Multicast - Server sending info to everyone
These are the different types of RPCs
So yes you are correct.
This is the new setup didnt change anything on player controller, no results?
You need to remove the SwitchHasAuthority node FYI
Remember, player input is on the Client side, therefore the Authority pin will never execute
removed the switch that still doesnt seem to do it
You cannot connect these this way.
You have broken the execution line.
Also you have called an RPC. Any information you want to use on the other side of the RPC you need to pass through or access in another way.
I make a replicated Variable and Set it, that should fix it right. Also what is an RPC, is it just any Replicated event?
Remote Procedure Call
Create a parameter on the RPC like you would normally, it passes that along.
k got it
Looks really helpful, acutally explains stuff, was working of some yt tutorials and trying to adapt it to fit my project and wasn't getting anywhere
added a param on custom event zero so it passes through that now, however it isnt setting it to hidden let alone printing it so I don't think it is the variable I think it is just not getting called at all
i have a small question. about my dedicated server and multiplayer. Id like to cast a server event that starts when server boots. but i guess im unclear which blueprint it should be in. Multiplayer and replication still a bit fuzzy for me.
there is an onrep event for ControllerRot but it is not firing
i wasnt calling Super::
still dont work tho
@keen warren I think you would want to run that in the game mode, unless it is a player specific event
i boot into loginMode login screen. then continue into mainMode. mainmap
hmm
i think might be fumbling over my own feet here.
so i can safely put this server event in the login game mode. because clients wont cause a trigger. and login game mode is compiled by the dedicated server ?
@inner sand
but then i switch game modes. so i dont know what im doing
The game mode is only exists in you server, I think that maybe you could move your game mode code to your game state and switch that. As long as you don't switch your game mode mid match you should be fine.
does each RPC mean a single packet?
Or does the engine somehow package RPCs together if say, they all occur on the same tick?
might have asked this but forgot
well that was fun
i remade a prototype i'd made in 4.10, only with 4.25 character movement interp it becomes choppy as all hell
i really wonder how did the 4.10 charactermovementcomponent manage dashes and teleports so smoothly and the 4.25 just completely fails
It feels like it's completely ignoring all the network settings
Anyone here know of any common issues with 4.25 that keep people from connecting to your hosted game? Servers won't populate in the list to join
so i have replicated my rotation via onrep (as Zlo recommended like this), but its not replicated at all
Been doing a bunch of research on listen servers, and I have a couple questions if anyone has the time to answer them.
Can listen servers use Multiplayer Origin Rebasing for all players?
Can listen servers use Level Streaming?
Does anyone know exactly what variables need to be marked to replicate when using FFastArraySerilizer?
Should the FFastArraySerilizer be replicated?
And theres also the FFastArraySerilizerItem. Does that need to be replicated?
Items array doesn't need to be marker as replicated, no
the FastArray itself does
as with all struct replication - if struct is marked to replicate, all its UPROPERTYs replicate unless marked NotReplicated
Alright thats good to know then. So the only thing that needs to be marked as replicated is the FFastArraySerilizer?
yes
Can you use the rep condition owner only?
note that if you use OnRep for the array
that will fire way after all the per item callbacks
you can
all normal property replication rules apply for the fastarray
the difference is just in how its (de)serialized
note that if you use OnRep for the array that will fire way after all the per item callbacks
@winged badger Do you mean the OnRep for the FFastArraySerilizer or the actual Items array in the FFastArraySerilizer?
for the FFastArraySerializer
items will do callbacks as they are deserialzied
fast array will do it later, after entire property replicates
nice. this is starting to make sense
Zlo is good at helping with that
So. I did a simple test by painting some foliage actors down, about 2k give or take. Replicated actors with no tick, just a single function that gets ran on the server when the client interacts to 'pick up' the object that adds to an inventory and destroys the actor. I already noticed that this is going to be an unacceptable route because the client takes quite a bit of time before they can receive input updates because of the amount of traffic of the initial replication. So... TLDR, how do you generally handle the initial replication of potentially thousands of actors? My initial thought was creating a foliage manager that has an array of active foliage. Yaw rotation doesn't really matter so I could replicate just a vector array of thousands of vectors on one single actor which is more likely to replicate faster than thousands of actors themselves, right? I could easily build that into a workable foliage placing tool with different settings and even reusability with respawning logic. Or, should I be considering something more like the replication graph?
The Array will at some point bite you
If you have a lot of actor that need to load then your players will have an initial loading screen i guess
So I just did a test with a single actor. Very simple test. Just created 2k vectors on the server into a repnotify array and then on notify event, added instances to an ISM for each vector. What's odd is that the vectors replicate immediately it seems. The meshes all spawn instantly upon client load in the locations they should be in. So this data is already processed and sent, yet it still takes the client ten to twenty seconds before they can move or see the server character moving? I'm a bit lost as to what this bottleneck seems to be, since the vectors are already instantly replicated and done and that's only checked once per second.
So, what can cause a client to not be able to move for several seconds? I can't imagine that it's replication causing it since the values are already altered and the player can send RPCs, but it's like they don't receive anything for a short amount of time. Normally I'd assume the network was clogged, but I can't imagine that replicating 500 vectors once and checking that array once per second can cause that much lag?
if i want to use RPC functions from a class, does it have to be an AActor and in the level? (GetWorld->SpawnActor...) or is NewObject<...>() ok for this?
@kindred widget Well, does it work if you don't replicate the Array?
You can also test it to just replicate those vectors without spawning the foliage
The Client should not get locked up. If it's bandwidth related you should still see the client trying to move but getting corrected
At least I think so
@twilit oak Well you need a reference to an instance of that class.
NewObject is for UObject based stuff. Everything AActor and lower in the hierarchy should be spawned via SpawnActor and only from the Server if it needs to replicate.
Further you can only use Client and Server RPCs if you make sure the Actor is also owned by the Client that wishes to execute the ServerRPC or that you wish to forward the ClientRPC to.
Despite that you can always use MulticastRPCs from the Server to all Clients that have an instance of that Actor replicated.
ah, this does get complicated very fast =P what im trying to do is a sound-manager type class that each client has a copy of (does not need to be replicated) but that allso can be used for the server to multicast sound effects etc to all clients. currently trying to make an instance of it in my gamemode, but i have no idea if thats the correct place
It has to replicate to allow Multicasts
Make it an Actor
Spawn it on BeginPlay of your GameState, but filter it with SwitchHasAuthority.
AInfo should be sufficient no?
Save it into an OnRep variable if you need to bind to anything on the Client or generally need a callback for when it's ready
AInfo should also work yeah, but I basically never use it and just make htem Actors and set them up like I want
If you work in c++ then SwitchHasAuthority is just if (HasAuthority()) //SpawnActor
Cheers
@thin stratus It's definitely the array. Leaving the Array on Repnotify but disconnecting the spawning still locks up. Can look around with AddControllerYaw/PitchInput but AddMovementInput doesn't even move on the client to get corrected for several seconds. While leaving the array on repnotify, if I either lower the loop count that's adding to the array to like 20, or don't add anything to the array at all, the client can move immediately. But it's odd, because like I said, the vectors are all already replicated. The foliage is spawned the moment the client connects on the notify function. Can look around and see it all in place in the same places it's at on the server. But the Client can't move with AddMovementInput, and cannot see the server move.
Either way, big array replication is not a good thing
so, am i correct in assuming from what you said that GameMode only exists on the server?
Yes
Does anyone know where I might be able to find some tutorials on levelstreaming in multiplayer ? π
@kindred widget why not use a seed and generate the same array client and server?
no replication needed
just send clients the seed from the server, let them figure it
using RPCs on tick is not a good way but is there any other way to replicate rotation/movement without tick?
@meager spade What about for saving though? If the server saves and I restart, how am I supposed to know which ones not to spawn on the clients?
@peak sentinel you don't need to replicate rotation or transform...
Engine automatically replicates your actor
so i just call setrotation? is that easy?
have i been trying to solve a problem that engine already does it self for 4 days? lol i need to headbutt the wall π
What I'm still at a loss for, is why there is still a huge lag? The vectors are ALREADY REPLICATED. There shouldn't be any traffic. I can look around and see all 2k plants in the same spot on the client as they are on the server. They literally cannot be there unless the vectors are replicated. More over, if I set the actor doing this array replication and holding the ISM component. If I set it's net priority to 0.5 instead of 1.0, the client can move around fine even at 2k vectors being replicated. The client can't see the server moving yet of course, but the client can move their character. I'm confused. The character's NetPriority is 3.0. Why is it even affected by another actor's net priority changing from 1.0 to 0.5?
Is anyone good with replication here?
I was reading this and I have a question
Why don't we just plug the increment directly to the server event instead of creating two events
@echo snow cause one is on the player controller, one is in the gamestate, and its always good to use events/functions over just setting properties directly. How about in the future you want additional stuff to happen when something gets updated?
@peak sentinel you are doing it wrong...
Just set bReplicates your true in character class
also you aren't checking if it's locally controlled, so it's running both on server and client, but server is the auhoritive one
and both are clients
so server side is basically always setting nothing, while clients are setting it to their local value
Client is not supposed to set it's transform
you can for prediction reasons.
Client is simulating on server so server knows
when you use character by default, and control rotation
it's setting locally, and on server.
Yes right
update instantly on client, set on server to replicate to others.
but he's just setting it on tick directly fro mouse, and server doesn't have that info.
but he's just setting it on tick directly fro mouse, and server doesn't have that info.
@gleaming niche he should not do that..
so really all he needs to do is make an unreliable RPC, that goes from the client -> server, to update rotation and also update locally
implementing now
@peak sentinelhttps://youtu.be/a8ukx6nPub0
An introduction to multiplayer replication in Unreal Engine 4. In this video, learn some basic techniques to effectively produce multiplayer mechanics involving server and client logic. Topics covered: Blueprint scripting, level blueprints, RPCs (Remote Procedure Calls).
LINK...
ie:
if (IsLocallyControlled())
{
do mouse rotation
setrotation
sendRpc_to_server_with_new_rot()
}```
@gleaming niche why do this, when engine already handles this
yesterday someone told me to use onrep instead of rpc
because ticks not good for rpcs
then i changed my whole setup
CMC ticks
and sends rpcs
lol.
the problem is you're doing it backwards
you're effectively asking the server to read it's mouse cursor
and replicate the value to clients
well server doesn't have your mouse, does it?
of course doesnt have
so you need to tell the server.
and then it can replicate to others.
just like you do with movement inputs, and weapon inputs
i understand, but about another scenario, isnt it about just value?
@gleaming niche I still don't understand why you write additional logic inside character class to replicate it's movement , when engine already does it
server doesnt know my mouse, but there is a mouseloc variable
@rich ridge he's trying to make it rotate to where the mouse cursor is on screen
which that stuff there is also wrong, but that's another issue
Ohh now I understand
is there any other valid method to rotate to cursor? whats wrong
I can suggest you one optimal solution, inside your mouse input function, you calculate delta and then do RPC...
well in order to actually look at the mouse cursor, you would do that hit result, and then you calculate the direction from the player, to the result
and then covert that to a rotation
then lerp, i guess?
i saw tons of lerp on forums while rpcs rotation
I can suggest you one optimal solution, inside your mouse input function, you calculate delta and then do RPC...
i will try this
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
could be simplified a bit, and just take the rotation directly and then just write yaw. like
SetActorRotation(FRotationMatrix::MakeFromX(End -Start).ToQuat()); //use the Quaternion version, and just set it; assumes pitch and roll will match.
SendRotation(GetActorRotation().Yaw);```
since above i match the hit location Z to the actors Z, so it will be flat.
whether the cursor is on a pillar or in a hole.
i am working on a vr/pc hybrid
where would the code go so that I can have the player choose VR or PC?
@gleaming niche i was about to give up until you helped
thanks a lot
works 10/11
may god help you with your fps projects π lol
I have a multiplayer game (listen server) with a scoreboard on the HUD that should provide an updated score whenever a player registers a kill. There's logic in my GameMode (i.e. server only) to process the death and call SetScore on the PlayerState (included function to the PlayerState base class). In the PlayerState OnRep_Score, I call GetPlayerController(0) and update the HUD with the new score. The Score variable is (internally) set to replicate with COND_NONE and REPNOTIFY_OnChanged.
With a listen server, only the clients get the updated score, and the server itself never triggers the OnRep function. Is there another way of doing this? I'm thinking of calling the update HUD method directly from GameMode but that seems a little messy.
I found this thread that suggested that in C++ you have to call the OnRep function manually, whereas in Blueprints it's done automatically https://answers.unrealengine.com/questions/31305/replicateusing-does-not-call-client-on-listen-serv.html
So I will simply call OnRep_Score() in my GameMode then, after updating the score.
EDIT: That worked like a charm.
@meager spade thanks for the help
What ever I do I get FailedJSession, anything I'm doing wrong here?
So, I finally solved the initial few seconds of lag issue I was having earlier from replicating 2,000 structs(two uint8s). I did not realize that the default engine limit on bandwidth is 10,000b/s. However, I'm still rather confused by the phenomenon. What data is being transferred over the network AFTER the array replicates? Like I said before, the client already had those 2k struct and used them for it's setup. I could move around on the client and see all of them just fine, but any other traffic from the server was ignored for seconds leading me to believe that it's download limit was capped. So is there some sort of other download traffic that follows array replication? Something like a data check, or something like that?
hey guys, quick question. What is the proper method for PlayerController to query the level for info? such as spawn points or other actors?
