#multiplayer
1 messages · Page 700 of 1
as for optimizing CPU use
blueprints really don't have any of the tools available
none of them work with BP, i think
which tools?
like replication graphs, fast array serializers, net serialize functions
only thing BP has is dormancy
push model also doesnt work with bp i believe
hii I have the player with all the movement logic written in anim BP.. but after testing I had some replication issues with the movement animations.. so planning to convert all the movement logic into GAS abilities since it has better replication.. so is it good idea to do that?
or should i just polish the replication code?
Definitely the second one
Gas will just add complexity
You need to understand the fundamentals of replication BEFORE you try to implement gas
@low helm tq for the quick response. appreciate it. I'll look into it
At a high level, Network Dormancy set to "Dormant All" is essentially the same thing as disabling Replication, but they are technically different things. Is that correct?
The workflow you need is the server replicating movement state variables on the character, and each computer client reads those variables from the animbp
If I disable Replication of an actor just sitting there not moving, the clients will no longer see it, but if its just set to Dormant, then its still visible but not replicating. Is that correct?
Wouldn’t flushnetdormancy work for dormantall? I think the difference is that with replication turned off the replication system Doesn’t have it at all. With dormnat all, It is registered with the replication system but it doesn’t receive updates from it
You may want to ask again in case some wizard is online
I think your explanation of it makes sense
I do remember hearing that initial dormancy is the preferred mode for open world objects in Fortnite
Right, so an actor such as a Tree in Fortnite has its Replication controlled by the Replication Graph and its Dormancy is set to Initial so it's not doing anything until a player walks up and starts chopping it down. Furthermore it won't even bother letting other clients know about what happened to this tree unless the Replication Graph tells them to based on their distance to the tree or something.
Hi everyone ! I have set multiplayer with replication, but I have a little problem, replication works well at low speed, but at high speed it starts flickering. Does someone has an idea on how to fix this ? thanks !
hmmm actually it seems the flickering starts if both client pawns are moving, so maybe I am doing something wrong during the update. What I mean is if one client stays still and the other moves, it doesn't flicker
What is replicating? What is flickering? What is moving?
pawn movement is replicated, pawn is flickering and pawn is moving
yup, flickering happens when both pawns are moving, if one pawn doesn't move and is spectator, the other can go fast without having this flashing effect
I mean, don't move like a spectator, not being an actual spectator in game network
@neat tulip https://www.youtube.com/watch?v=RtQRMcupJs0
Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv
Join our community discord!
Discord: https://dis...
thanks ! I will check if it resolves my problem (just saw the start and it's actually something I didn't do as said by video's author, I used a simple tutorial, maybe problem comes from that)
hmm yeah, I am not using CharacterMovementCpt, so it probably comes from that
can use delegate on server func to figure out when the func end its job in client?
You can never reliably know if a client has finished a function. You can have the client send an RPC back to the server, but that then opens up a potential vulnerability in that malicious clients could call that RPC whenever they want, or they can block it from being sent at all.
i mean in reverse way
if server done it's job
client should know this
Then have the server RPC to the client or use an OnRep variable to notify of the state changing.
what is server RPC to the client ?
"Run On Client" events.
you mean i can call this by server?
and this run on which client?
Use the appropriate event for what you may be trying to do - normally "Run On All" is used when all clients need to know about something happening (eg. An animation or sound playing) whereas "Run on Owning Client" is used if only the "owning" client needs to know about something happening (eg. the server wanting the specific character to do something, but only on the one client). If it's something stateful however, use an onrep variable.
i mean can i call "Run on Owning Client" function by server?
That's the only place it should be called from.
Hi, Should all state variables be replicated/rep notified in some way? things such as IsDead, IsReviving, IsDowned, HasKey ect... Im understanding how to replicate variables and use rep notifies a lot more now so now I'm trying to figure out exactly what variables actually need replicating and what doesn't
You may have state values on the server that the player doesn't necessarily need to know, so replicate only what you need to, and if possible try to simplify state as well. For example, based on the examples you give, IsDead, IsReviving and IsDowned sounds like they could all be related and if these were booleans, it seems like only one would be true at a time - this kind of case it may be better to use an enumerator containing:
Alive
Dead
Downed
Reviving
Then just swap between these 4 as appropriate rather than having to manage 3 different booleans.
interfaces dont work with server calls unless it is already server? edit Z input gives "test works" aswell if it is played as server character
Nice one, thanks mate!
You can't run RPCs to the server on actors that are not owned by the client. You need to have the client RPC to server first, then have the server call the interface.
Hey there ! What would be the best way to show connect/disconnect/death notification to a player in a multiplayer game ?
Array in game state ? A rep notify ?
A RPC net multicast ?
Gamestate seems a good candidate to me since it's on the server and replicated to clients
@twilit hearth it doesn't work the same, blueprints don't actually have a replication callback at all
its a property changed callback, hacked to serve as OnRep
its also why it fires on server in BP, and why it fires if client changes the value of BP OnRep variable locally
none of which will happen with c++ OnRep
so just use BP then ?
my preference is just use c++ for networking exclusively
debugging a network issue on a packaged version in blueprints is just not possible
ok
It seems like no matter what I do, I'm unable to find steam lobbies lol
I can find them just fine using the steam SDK directly, but when going through the online subsystem stuff, it's no good
is your OSS setup correctly?
also im pretty certain that the steam OSS doesnt work in PIE so you will have to package your game to test it
It works completely fine with dedicated servers, but it seems like Epic has interlinked the Steam IMatchmaking API (lobbies) with Listen servers, and SteamNetworking() api (p2p)
I don't want Lobbies to be directly linked with p2p networking.
I'm just going to implement the lobby system myself, without the subsystem.
I'm trying to learn UE multiplayer and replication and am having some trouble, if anyone could help out:
ChatSubsystem.h
void GenerateChatMessage(FText Content);
virtual void GenerateChatMessage_Implementation(FText Content);```
ChatSubsystem.cpp
```void UChatSubsystem::GenerateChatMessage_Implementation(FText Content){}```
Error:
```ChatSubsystem.gen.cpp(272): [C2511] 'void UChatSubsystem::GenerateChatMessage(const FText &)': overloaded member function not found in 'UChatSubsystem'```
After a while searching I found a forum post which fixed it, I turned my parameter into ```(const FText& Content)```
In that case, the question now switches - is that always necessary or did I mess up somewhere else?
You didn't
Whenever I set movement mode to custom then set it back to walking my character cant move
anyone else experience this ?
hey, I set some attack combos using anim montages and i want to halt the character to stop whenever i attack and i used disable input but it also disable the camera movement as well, so if i anyone can gimme some better alternate to disable just forward and right movement.....
There is also a handy free plugin if you don’t want to do all this work. The plugin is called smooth networked movement.
Lock forward and right movements with a simple boolean variable. Check the outcoming Axis values. Then you can conclude when a player walks forward or right and block it.
If you want to simply stop your complete character movement for a while, then simply set 'Movement Mode' to none, afterwards turn it back to walking.
Hi ! So, thanks a lot, I watched the video about Advanced Networked Movement (Sprinting & Wall Running). For my case I need to set the actor exact position and rotation at each frame. Can CharacterMovementComponent satisfies this ? Because I can't find anything to set transform in the documentation.
I will check the smooth networked movement
Will try this, thanks
it worked, thanks...
@hazy matrix So I checked it all out, and my problem is really that I need to set the location and rotation of my pawn at each frame. So I can't use either FloatingPawnMovement or CharacterMovementComponent, because all I can do with them is to addInput with fixed max speed, acceleration etc... Put simply I did my own mini physics engine using c++ and set actor location/rotation. Since I have the velocity I could be able to use already coded predictions from epic & unreal engine with parameters in c++. But it's really vague to me, if you have a course/tutorial on how to create predictions based on velocity and happening them to clients it would be very helpful.
I found this : https://github.com/UnrealMultiplayer/4_Krazy_Karts which apparently shows how to implement custom MovementCpt as well as a custom MovementReplicator + interpolation
(ref: KK_UEM) http://gdev.tv/uemgithub. Contribute to UnrealMultiplayer/4_Krazy_Karts development by creating an account on GitHub.
yes
is there a callback I can reliably use to initialize variables on server that will be replicated only once for the lifetime of the object?
Sounds like something you would dump the properties into a single Struct for. Set it once on the server and they'll replicate together.
I mean, you can mark the property COND_InitialOnly?
Oh, yeah that. I don't know why I read that as he was looking for a single callback when all of them replicated.
hello! I'm welding an actor to a component (in a multiplayer context) and their physics channels are set to ignore each other. this works perfectly on the server, but on the client they do not ignore each other causing the object to glitch away as the objects are fighting each other. when I check the client actor's collider settings they are identical with the server's actor, does anyone know what I am doing wrong?
I literally just saw a video about it. let me fetch it for you
oh yeah, it's the "Network Multiplayer Fundamentals" unreal official live video. It shows exactly your question as an example
in short: most probably the server is not replicating the variable to the clients, so the clients still think they should collide, while the server is constatly adjusting their replicated position because he says that they shouldn't actually collide
hmmm... I implemented the KrazyKarts solution and it's worse actually.
@peak sentinel I tried to change the NetUpdateFrequency, but I still have this jittery movement
You should not have
Its using CubicInterp
Something else is wrong probably
I was able to make it work even with 5 netupdatefrequency
Yo! So Android, how do I get the server files? Which packaging varity do I use? I'm used to packaging for Windows VR so using Windows Server
Hello everyone,
I have create a demo, I want it to make Mutiplayer, I setup a widget with text name of each player, for some reason, some players we could see their name, if I test it, the server seem to see all the player but client #2 I can see only player #1 and itself but not the player #3, it is because I'm running it from the same host machine ?
Hey Buddys I need a bit of help with replication :o
I've a button in the world players can go up to and interact with.
Once they do it does an server rpc and execute the Interaction Interface call on each overlapping actor (interface).
which then sets the button state (repnotify) only visual.
My concern is The interaction logic is now on the server no matter if a client of server called it however how do I filter clients out? I only want certain buttons to work on the server. like start game and stuff
@peak sentinel Looks like I didn't have the root set, now I don't have a jittery movement, I have a sort of spring movement, mesh going forward and backward, "gravitating" around its true position
maybe it's possible to get the buttons through their class/name or tags, then when user interacts you can cast the button, verify it's the button you want user to interact with ?
nono not that. So if I want a button to only work on the server I gotta use switch has authority but since I'm creating a Server RPC I'm always on the server anyway which leads to clients being able to do the same things as hosts do
when clients are connected to server, absolutely no client have authority on it, unless you run like in editor "play as listen server"
Yea but I'm doing a RunOnServer event which means it's the authority executing this event FOR the clients
yes so in this event, filter your buttons, check if client can push it
@peak sentinel I don't get it, by manually changing the factor in VelocityToDerivative, I can kinda improve, but it seems like something is off. Is KrazyKarts an incomplete code just to forcebuy the course ?
Its a free course in Epic Games portal
And not to throw a dirt to someones face, but all of their courses are shitty
Including KrazyKarts
Whats the net update frequency
CubicInterp is not good at close distances
do you have some better course to advise ?
Nope
I changed it to 10
And still jittering?
yes, it seems like some vars aren't set properly, I am sort of turning around a good enough solution, but I am pretty sure it shouldn't be impossible to interpolate all this with success
it's more a spring movement now
going backward/forward around the server position
It was working fine when my a few years ago past self copy pasted it
That points you are having issues with CubicInterp
Try another interpolation method to see
yes I am pretty sure the problem is around the interpolation now
If still persists, you totally got something wrong
You should not use CubicInterp if this is a human movement anyway
See how CMC handles extrapolation
And steal it
it's a space ship movement, for my test now, just going forward at constant rate...
but fast
@peak sentinel What is CMC ?
Character movement component
NewLocation = FMath::CubicInterp(ClientData.Location, ClientData.LinearVelocity, NonQuantizedLoc, ClientData.LinearVelocity, LerpRatio);
LerpRatio is const float LerpRatio = ClientTimeSinceUpdate / ClientTimeBetweenLastUpdates;
Try this if your implementation is different
Client data is struct that cached in onrep only on simulated proxies
NonQuantizedLoc is just authoritative location
ok I try, it's close to the code I have with KrazyKarts
Do you mean to filter out if the originator of the interaction is the server or client pawn/controller?
Presumably your interaction interface is passing over the interactor, you can filter on that
It's all serverside, just the interaction in the button ignores interactions from pawns/controllers that are NOT the host.
Physics should work pretty good for spaceship movement and there's a lot of tunable replication stuff
I Perform a Server rpc to check overlapping actors (to prevent cheating)
Then I had issue coming back from Server to the usual Server/Client call so what I did now is at the very start have a switch has authority and pretty much 2 different paths for Server or clients
Should work perfectly out of the box for something as smooth in motion as a spaceship
hey guys , i got a question . player 1 spawns a fire on the ground and any player that overlaps it must receive damage . but in my case only the player who spawned it receiving damage ? does anybody knows why its happening ?
If you don't want any cheating like pressing a button from across the map, the client -> server RPC should just be TryInteract.
Serverside is where you choose what to interact with and do the interface call.
All the client is telling the server is that it wants to interact
Is the fire being spawned serverside or clientside?
Yea I can show you the logic in a bit might be that I still can improve something
Show the execution path from input to where the fire is spawned
You basically have 3 stages
Button Press -> Choose what to interact with -> Interact with the thing.
The RPC can happen between stages 1,2 or 2,3
If you want the server to be super authoritative then put the RPC between 1 and 2
Pass the interactor (pawn or controller) in your interaction interface and then the thing can filter on that.
That's the very first thing the Button press -> This calls the interaction for all overlapping actors
Where is the RPC?
I removed it cause it didn't work :o
Just do this
Input -> RPC -> Choose what to interact with -> Interaction Interface Call
server side
@dark edge no really I tried with physics and it works way better if I do the setLocation by myself, now since I have the exact infos on the location and rotation of the pawn I should be able to set all this, as my system is deterministic. I just can't grab a simple multiplayer interpolation that works
it sends me back to SA:MP when modders were creating a gta sa multiplayer where there was these kind of jittery movements
Have you tried messing with the physics replication stuff? You can make it as tight or loose as you want and it handles extrapolation etc.
But if you must do it yourself, you'll want some sort of cubic interpolation. How do you know your system is deterministic anyway?
Show your code from input to apply damage
If your system is truely deterministic then just pass input around. I doubt it is tho.
Like that? :/ Sorry but I'm hardcore confused rn lmao
No, just have 1 RPC, the client->server one
so this... but this was what I did before and it didn't work
@dark edge believe me, I can't do what I want with unreal engine physics (chaos or physX) I tried during some years now, and got more motivation some days ago, finally managed to get what I want. And before going further I want to interpolate the movement I have in multiplayer
How are you doing your integration? Verlet, semi-implicit Euler, Euler, etc?
cause then in the button I'm always going to have authority no matter if it's the client or host :o
Who cares. Everyone can TRY to interact, you filter it after it reaches the server.
Filter the interactions on the interaction target after the interface call
the script is raytracing => take the barycentric coordinates of the hit triangle to mix the normal vertices with a weight, then place actor at fixed height above hit using the interpolated normal. Finally use also the interpolated normal for rotation, up vector being aligned
and how do I know if the person who called it is the host or the client?
(f zero like game)
After the interface call, check if the caller has authority or not
pass caller in the interface
That's the problem since it's already on the server it always has authority
ye sorry try Is Locally Controlled or whatever the test is
don't remember which one but it'll be one of them
that works :o
OK so that'll be quite different from a space game that I thought u were doing. You'd doing more like a racing game's netcode
I take it you have a velocity and desired acceleration vector?
yes
but before coding it all, I wanted to try a working interpolation just on a straight line
Are you totally bypassing the Unreal movement replication?
I am unsure since on beginplay the KrazyKarts code set the replicates to true
but replicatesMovement on false
yeah
so replicating the actor but not movement related properties
Right now what are you doing, replicating a position vector and in an OnRep applying it (moving self clientside)?
So I remember seamless travel didn't work in PIE in ue4 :o But since I'm on ue5 I'm confused does it work there? I mean the host is being transitioned correctly but the client is getting thrown into titlescreen so I'm not sure if it's my fault or just the SeamlessTravel PIE thing
I am making a cubicinterp between (clientLocation,clientvelocity,serverSateLocation, clientvelocity, lerpRatio)
and changing the factors to try understanding what is happening
Are you running your sim clientside as well or just trying to smoothly view what happens on the server?
I am running 2 clients, I am not using play as listen server
You still have a server tho. Is any simulation happening clientside?
or is all simulation gated by authority
yes the simulation is on SimulatedProxy
yup, server is running in background on editor process
That further complicates things, I'd start by just letting the server do all the sim and getting the client view to smoothly reflect the data from server
Then get a 4 point buffer going, and run cubic interpolation on it.
Get that smooth, then reintroduce simulating clientside as well
simulating clientside would be your extrapolation
you'll have to sync input state as well for that (steering, throttle, etc)
what I already tried is to replicate movement, but since there is no replication/interpolation, and raceships are going fast, there is a flickering effect. Now with the KrazyKart code and bit of help from @peak sentinel I set up the cubicinterp and it's indeed working to smooth the movement, but it's not perfect, there is still a sort of spring effect at high speed
Vehicle netcode is hard man. If you wanna do any sort of prediction then it's a total rat's nest. My game is EZ but I'm ok with no prediction, it's slower paced (heavy vehicle combat)
so waiting ping ms to see it accelerate when you punch the throttle is fine for me
how is playerarray replicated? in code it seems to not be /** Array of all PlayerStates, maintained on both server and clients (PlayerStates are always relevant) */ UPROPERTY(Transient, BlueprintReadOnly, Category=GameState) TArray<APlayerState*> PlayerArray;
@dark edge well I don't think I will abandon, I am just looking for maybe good books, good courses/tutorials on how to interpolate / replicate / do some prediction to achieve what I want
GameState just keeps it in sync with RPC i think
just found this with search This is one of the main reasons that the PlayerArray in GameState works the way it does. It isn't replicated. When a PlayerState arrives on client it adds itself to the array and runs callbacks.
void APlayerState::PostInitializeComponents()
{
Super::PostInitializeComponents();
UWorld* World = GetWorld();
AGameStateBase* GameStateBase = World->GetGameState();
// register this PlayerState with the game state
if (GameStateBase != nullptr )
{
GameStateBase->AddPlayerState(this);
} ```
and when gamestate reps it searches for playerstates for (TActorIterator<APlayerState> It(World); It; ++It) { AddPlayerState(*It); }
@dark edge actually, using a low NetUpdateFrequency the movement is smoother
a bit counter intuitive
Hi all, guys. Anyone of you ever worked with ALSv4 with replications?
Does anyone know how do you save player permanent inventory on dedicated server? Is it in database in table as some strings, Json, ...? 🤔
What ever you want. We use a Backend service that our servers communicate with and this service at the moment stores the data in a DB but actually it really doesn't matter^^
Cool. Thanks 😁
You could probably start with savegames, that's the Minecraft model
1 file per player
GamePawn isn't owned. Thus the rpc isn't being fired
I guess this is a server rpc so you should be having an if statement before it's fired making sure you're running on client
Something like this:
if (IsLocallyControlled())
{
S_SetLocation();
}
Omg i remember searching a fix for this error for WEEKS!!
But yeah that function you're trying to call is being called from a client which doesn't have the ownership of
Yea I've used
if(GetLocalRole() = ROLE_AutonomousProxy)
{
}
That what I wrote at first, but I ended up changing that as that function is aimed exactly for this
This check is generally for AActors
But Pawns are Actors :P
You can also use "has authority ()"
I mean Actors that are not pawns
That's exactly what he doesn't want
Lol sorry then
It means that he's on server
Yeah i always wonder what was the difference so that makes sense
Wait so it means he's ON the server not THE server?
Well i would imagine clients being on the server does not count as the server
Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv
Join our community discord!
Discord: https://dis...
that explains it good c:
Oh thanks!
Nope. They are clients connected to the server. Now there are multiple game framework classes in unreal. Some exist only on the server. Some only on the client. And the rest on both.
Yeah that does make sense. It's really complicated how the networking works in unreal
Just takes time to get how stuff work and why
Does InitNewPlayer() get called for rejoining players?
Can someone remind me, im having a brain fart here, does OnRep_XXX get called when an Actor comes into net relevancy range?
you would hope it does but I couldn't give you a definitive answer :/
are you having a replication bug related to that?
what node can I pull out to get player number?
Like how and where can I assign player number, so the one that joins become player 2, 3 and so on
Yeah some visuals not appearing correctly.
But i couldnt remember if they were supposed to get called on simulated proxies or not when coming back into range
No. To be clear, its not an issue with OnRep not being called. I just couldnt remember if they were supposed to get called when it comes back into relevancy.
Brain fart blocking me from remembering lol
They are afaik. The only issue I encountered was when I tried to predict some state on an actor in the scene and the server didn't know about the change or so
I gave up the prediction and it worked as intended
But if you spawn it runtime or not have it set to net load on client, then it shouldn't be an issue anyway
they have to be
if the actor is static, it hasn't been sending any updates while not relevant
if the actor is dynamic, it will be respawned, so OnReps
one thing though - if it hasn't been sending any updates and not much has changed
your OnReps might not fire on account of having the same value as they receive from server
unless you're running RepNotify_Always condition
👍
how to hide ui widget multiplayer?
Hey, how can I keep some of player data when changing levels. E.g. inventory state from previous level? (Inventory is on the server)
PlayerState has support for copying player data when switching levels
Thanks
Hi, Im having an issue with adding a HUD on to the screen for the server, I've got a Is Locally Controlled check before it creates the widget and adds it to the viewport on the BeginPlay of the player character, it works fine for the client but not the server, it seems that when the host spawns, there's a brief moment where its returning False on the Is Locally Controlled check so it isn't adding the HUD to its viewport when called on BeginPlay, if i add a small delay it then appears for the server but i know that this isn't a proper fix, any ideas how to get this working properly?
It also works if i dont have the Is Locally Controlled check in there at all, but im under the impression that i should have it in
Is RPC queue always in order?
Can I assume first RPC I sent will get processed by server before others?
Hey There! I have little problem with Super call.
I have a BaseWeapon class and its child class RangeWeapon. I override the UseWeapon() function in RangeWeapon and call Super::UseWapon() with the expectation that the logic in the base class happened before the child logic, but it runs after the child, or just works some other way. Can anyone explain my mistake?
BaseWeapon.cpp
void AKT_BaseWeapon::UseWeapon_Implementation()
{
if (!CanShoot || !Character->ItemsManagerComponent->WantShoot) return;
ActivateTimerBetweenShots();
}
RangeWeapon.cpp
void AKT_BaseRangeWeapon::UseWeapon()
{
Super::UseWeapon();
if (AmmoInTheClip <= 0 || IsReloading) return;
//Another logic that works
}
How can I replicate the Array I have, for a simple inventory system. I get an error when I try standard replicate methods.
simply what I wanted to do. a simple 2-slot inventory system
There is so much wrong with this
Would recommend looking at this
Does anyone have an idea why my variable keeps incrementing twice on overlap? i have a Switch has authority node so it should only increment once, also my variable is set to replicated.
Could it be that since the server is a player AND the host it executes once on the host and once on the BP placed on the map?
Show us your code
i tried skipping past the other mess in my blueprint lol
Are you in player controller?
Im in my BP_FlagPickup
an actor with a mesh and a capsulecollision
Ah it seems i fixed it with a bool failsafe, it might have something to do with the overlap happening once more when i set its location somewhere else. I walk into the flag, overlap event happens -> i teleport the flag -> overlap event happens again
Or specifically it can have something to do with the fact that i set transform not set location. So maybe rotation or scale might have something to do with it, kinda weird
Hey, I have a few questions about RPC and destroying actor.
Lets say I have a function that is executed on server.
- Can I call client function on another actor before destroying self?
- Can I call client function on self before destroy self on server?
- Can I call multicast on self, before destroying self on server?
Obviously I have tested locally (PIE) and the answer was yes, but I am not sure if it's not "undefined behaviour"
Basically I am wondering if this behaviour is well defined and the functions will always be executed on clients before the object is destroyed on the client side.
If they are reliable, they will execute before destruction
Great, thanks 🙂
But bear in mind that if ownership changes etc. have replicated first, ClientRPC's may not execute
If you use gameplay ability system you could also force client and server to sync before destroying with waitnetsync i believe, i know this isn't the gas-chat just wanted to get it out 😅
Thanks. Haven't really dabbled with GAS yet, but it's on my reading list (hopefully sometimes soon) 😄
If it is Reliable then yes
Thanks
Why UseWeapon in BaseWeapon has _Implementation?
BlueprintNativeEvent or RPC?
Ok if you're overriding an RPC in child then you override the _Implementation
^. You also need to call Super::MyFunc_Implementation(), not Super::MyFunc() or you'll get an infinite loop
UMG is client only. So the client does that
Well I clicked "build solution" in the IDE and then "Run", if I did something wrong please tell me
If I write a call to parent functions in instead of calling the parent itself, then everything works correctly
What do you mean?
Check in editor if HotReload is turned on
void AKT_BaseRangeWeapon::UseWeapon()
{
//Super::UseWeapon_Implementation();
if (!CanShoot || !Character->ItemsManagerComponent->WantShoot) return;
ActivateTimerBetweenShots();
if (AmmoInTheClip <= 0 || IsReloading) return;
//Another logic that works
}
It works
You should call Super::UseWeapon_Implementation() and not Super::UseWeapon()
^
You're still overriding UseWeapon
Exactly
You need to override UseWeapon_Implementation
The original UseWeapon() function shouldn't be virtual either
@true grotto
{
UFUNCTION(BlueprintNativeEvent)
void SomeFunc();
virtual void SomeFunc_Implementation()
{
// Actual Implementation
}
};
class Child : public Parent
{
virtual void SomeFunc_Implementation() override
{
Super::SomeFunc_Implementation();
}
};
And using virtual/override on RPC's is grounds for being shot 😄
What do you mean by "is grounds for being shot"?
adding a HUD on to the screen for the server
This isn't allowed. HUD is client only.
IMO overriding RPC behaviour in child classes is bad practice
Better to make another virtual you can call if neccesary
I did it like this, right?
BaseWeapon.h
UFUNCTION(Server, Reliable)
virtual void UseWeapon();
BaseWeapon.cpp
void AKT_BaseWeapon::UseWeapon_Implementation()
{
if (!CanShoot || !Character->ItemsManagerComponent->WantShoot) return;
ActivateTimerBetweenShots();
}
RangeWeapon.h
virtual void UseWeapon_Implementation() override;
RangeWeapon.cpp
void AKT_BaseRangeWeapon::UseWeapon_Implementation()
{
Super::UseWeapon_Implementation();
//Some
}
Does not work
Be sure you understand what overriding means. The parent function returns early, but the overridden function will still execute all code after that.
Yeah I've never had the need to override RPCs myself so no idea what's better on my end
I think it's better to really make a separate function that can be simply called from the heir
E.g, whatever you write for //some will still execute
Also it's still not 100% correct, UseWeapon() should not be virtual
You can't override those stub functions
It should work though
Hey, its a listen server, so the server is also a client playing the game too
In case it's a hot reload issue, read this: http://hotreloadsucks.com/
Yes. That's why you you need to make a check when your gameplay events run and before you create/add widgets
I removed the server call, it turned out like this. But it still doesn't work
BaseWeapon.h
UFUNCTION()
virtual void UseWeapon();
BaseWeapon.cpp
void AKT_BaseWeapon::UseWeapon()
{
if (!CanShoot || !Character->ItemsManagerComponent->WantShoot) return;
ActivateTimerBetweenShots();
}
RangeWeapon.h
virtual void UseWeapon() override;
RangeWeapon.cpp
void AKT_BaseRangeWeapon::UseWeapon()
{
Super::UseWeapon();
//Some
}
I did that but it didn't seem to change anything, but thanks for the info
Now I get your issue better. There should be no issue in adding widgets to viewport on BeginPlay. Probably some other logic is affecting this.
You can try using PostLogin from GameMode and calling a Client RPC on PlayerController to show HUD.
It also works if i dont have the Is Locally Controlled check in there at all, but im under the impression that i should have it in
It's because HUD isn't replicated so server has no idea what's that. But yeah you should have it as you can get errors in editor sometimes
Why would you say it is bad practice? Just curious.
What do you mean by "rejoining players"?
If you can reproduce the "rejoining" thing then debug that function and see if it gets called
So ive put it into the OnPostLogin event and its working now but i dont have the IsLocallyControlled check, do i not need it now since its running in OnPostLogin which means a player controller has been assigned?
@blazing spruce use a class derived from AHUD for managing UI, its what its there for
1:1 relationship with local PC
I just think keeping your networking code abstracted from game-specific code helps with debugging etc.
I will routinely override replication callbacks, but havent overriden a RPC in 5 years
I think by and large, sure. But it also depends to me.
Server_Attack() being a virtual function and implemented differently for melee and firearms would make sense to me.
AWeapon
-AGun
-AMelee
I'd imagine this would be a fairly common chain for inheritance.
And Server_Attack() would be in AWeapon
Hi, if i do that how do i set the initial values of the health and max health for example, those variables are stored on the player character and if i cast to it in the HUD BP and feed them in to an initialise health bar function it doesn't work?
Nice layout!
Could use a bit of spacing, though. 😛
Why aren't you attaching anything to the owning player pin?
lol thanks! and only cause it was working without anything in there atm, it still adds to the viewport just doesn't initialise the values
Do you need to connect something to the target pin on your last node?
Naa that function is on the same BP so self should work
Debug the function.
See what's going on in there.
It's possible you're somehow ending up with 2 copies of the hud object, one that's being displayed and one that's in your bp.
Shrug
Or your hud object bp is broken.
hmm looks like the begin play of the HUD gets called before the begin play of the player character where the health & max health get set in the first place so there all passing in 0 to the initialise health function when its called
not really sure how to get around that tho lmao
On begin play of your character, trigger an event in the hud?
@blazing spruce avoid the GetCharacter/Controller[Index] functions in MP
those are only good for 2 scenarios - splitscreen and iterating over all player controllers from BP
HUD has a function to get a PlayerPawn
i think its GetOwningPlayer for the controller GetOwningPlayerPawn for the Pawn
also, try the following:
put a BP_VictimCharacterBase ref inside your widget
mark it editable, and exposed on spawn in details panel
then refresh that CreateWidget node
HUD is there mostly to add/remove hide/show widgets to/from viewport
its not there to run the widget code
give your widgets a reference to the object they are displaying and let them handle their own stuff from there on
Like this?
and now the widget has the character reference
and that entire InitializeHealthBar thingy can go inside that widget
instead of cluttering the HUD
EventConstruct will work just fine
after that you add an EventDispatcher to your Character, and you call it whenever the health changes
and during widget's construct you bind to that EventDispatcher, OnHealthChanged, and have the widget update its values when it happens
Can you not spawn instanced meshes from thje server or something? Can anyone spot why this wont spawn on client? Thank you
You probably can't call the server rpc on your ism.
You can only do it on certain objects, like player controllers, controlled pawns, etc.
You aren't supposed to use IsLocallyControlled here as the PlayerController you have is a server PlayerController. So simply do:
NewPlayer->ClientRPCThatShowsWidget
can you call RPC on the gamestate?
Yes. Multicast RPCs for example.
Server RPCs won't work
Client RPCs I'm not sure if they work, but I think yes. But it doesn't make sense to use them as you should be using the PlayerState then
What's an average KB/s for outbound traffic from server to client? AWS charges a lot for this. My netprofiling shows around 2.5KB/s for my base character not sure if that's good or bad.
One client on ShooterGame has around 3.6KB/s average. So I guess I'm doing something right? 🤷♂️
To put it in perspective, you could support 2-300 clients on the traffic needed to watch one 1080p video on Youtube.
the bandwidth is tiny
The pricing calculator for gamelift servers defaults to 4KB/s and adjusting it down to just 3KB/s results in a huge price difference (at scale)
Well yeah but it's still tiny. It's like 10 cents a gig. Assuming a client plays for 1000 hours at 5KB/s the entire time, they've spent like $2 of your money. That's a rounding error in the grand scheme of things. If you can't get $2 out of a 1000 hour player then that's another problem.
Checkout the calculator here https://calculator.aws/#/createCalculator/GameLift (scroll to the bottom and click to expand the Data Transfer Out (DTO) and try adjusting the DTO per player. It's like a $100/month difference when using the default values for everything else.
AWS Pricing Calculator lets you explore AWS services, and create an estimate for the cost of your use cases on AWS.
That's... yes? That's how scale works. With default options that's assuming 365 thousand hours of playtime - a $100 difference in monthly costs seems like a drop in the bucket. Not that cloud bandwidth is cheap by any measure, but at the scale the calculator is assuming by default that's really not a huge difference.
Any chance to save $$$ is of interest for me 🙂
Then optimize your bandwidth usage, tools exist in the engine for that. But there is no "average bandwidth" for games, it is way too dependent on what you're building.
And for the record, the default calculations - $1300 a month for 1000 max CCU... if you sold your game for $20 you'd be able to run the game for 15 months if you have no other costs. Obviously that isn't realistic, but 1000 CCU means you have way more than 1000 paying customers.
I suppose ShooterGame is the best to compare against
If you're making an FPS with a similar player count and limited interactions, yes.
Yea I built out an entire spreadsheet calculator with steam and sales taxes built in
Estimating CCU is so tough lol
Is it really like 50%?
it depends on the game
literally everything in that calculator is entirely dependent on the game
I guess it rolls up and down like a sine wave overtime as players return home from work and play for a bit then go to bed...etc
Then you spread that across different time zones / countries and the average concurrent users becomes nearly impossible to predict until you've launched and see some numbers start to come in.
These really aren't costs you think about until you're at a point that you can accurately estimate things. You don't just throw random numbers into the calculator, you profile your game, decide what a reasonable target for performance is by the end of development (both in terms of actual VM requirements and bandwidth usage), and then you figure out at what CCU the game becomes profitable.
These aren't things you can estimate from the start unless you personally have historical data from similar games.
An accurate estimate is kind of an oxymoron lol
It's not.
Maybe I should have said an "educated guess" as opposed to throwing random numbers in.
The point is that you reach a point in development (not necessarily near the end) where you take a look at the game and try to decide how much you can reasonably fix performance issues, and you choose a target to further estimate costs.
You weigh the cost of paying for higher bandwidth and higher tier VMs versus the work required to fix performance issues. These are costs that you have to balance over the course of the project's development. Not from the very start - it's something that should be in your mind, but guessing at values on an AWS cost calculator will tell you literally nothing at that point.
Who said I'm at the very start of my project??
Given that you're trying to estimate bandwidth from other random projects.
If I knew the targets for other similar games I could then use that information to make a better decision for my own one.
But what decision could possibly be binding if you're at the point where you can't even profile your own game?
Looking at other similar games is useful as a target for your own, but not to estimate your costs.
"Profiling should be done early and often" - Zak Parrish of Epic Games
I agree
To some degree, at least.
This is not profiling. This is estimating costs based on unrelated projects.
So why do you say I can't even profile my own? That's assuming quite a lot
I'm assuming you can't because you're trying to estimate based on other projects rather than your own.
So either your project isn't far enough in development for those profiles to matter, or you're looking at other projects unnecessarily.
For the record, when I say "for those profiles to matter" I mean for them to matter towards estimating costs at release. Obviously they matter for the current state of the project.
Let me take back a bit of what I've said - knowing what general costs will end up being isn't a bad thing even early on. With emphasis on general - you're getting lost in the details of a $100 difference in a monthly cost. Yes, that adds up over time or at scale but you don't even know if that's going to be relevant until you have some actual data to show it matters.
That's the same conclusion I said a short while ago yes, its nearly impossible to tell until there's actual numbers coming in.
Glad we can agree
Yikes. Really? If estimates weren't accurate we could never do proper project planning and would miss deadlines and not ship games on time
I agree but also "accurate estimates" and "project planning" don't go well together lol
What you think we do sprints by drawing random numbers out of a hat and assigning them to tasks?
In plain English terms the words contradict one another so yes.
An estimate is a definitive thing, accuracy is a moving target, a property of said estimate. Definitely not an oxymoron in my book
The better the accuracy of the estimate the better for the team and game/project in general
We're getting off topic here.... so to steer things back towards a more #multiplayer related topic has anyone here used https://docs.unrealengine.com/4.27/en-US/TestingAndOptimization/Oodle/Network/ before? Was it worth spending time to learn and implement?
An overview of using Oodle Network to improve streaming performance for your project.
Haven't tried it myself but it looks simple enough. Given how good oodle is elsewhere it's almost definitely worth investigating
I'm not too sure how well network data would compress since it's usually lots of small packets, but that looks simple enough to be worth trying.
downside is it sounds like you'd want to take new captures and retrain it if you make big changes to network stuff, but it's probably not a huge amount of work to do so.
hmmm I wonder how long training takes, seems similar to ML stuff. Could be hours, or mins probably depends on lots of factors.
Seems like something worth doing much later on once the network changes have stabilized a bit like you said.
Sounds like one of them good problems.
I don't believe it's ML-based, it's just building a dictionary of common groups of bytes from packet captures which can still take a bit but we're not talking ML training times. For packet captures that you feed to the program you just need to play a single "realistic" game with capture enabled on the server.
So how does Oodle network save bandwidth percentage wise?
10%, 20%, etc?
I thought Oodle is just turning plugin on and it will do work in background.Do we have to do any extra steps
Seem like Oodle Network require additional steps,
Yes I think so.Did anyone tried unreal dynamic network relevancy.I might tell it wrong but it will dynamically change network update rate
Of actors
Fortnite uses this
Having an issue with server travel and streaming levels. I have a lobby level visible at the start, once server loads a new streaming level all clients load it as well, but server also unloads the initial visible lobby streamed level and so do currently connected clients so they match the servers state for each streaming level. However when a client joins after the server switch, the new client sees both the lobby visible and streams in the new streamed level the server switched to. What is the correct approach to ensure that connected clients match the servers streamed level visible state no matter when they connect?
Making a battle royal game I have spawn island that spawns to the plain but I want to create a new separate map to spawn characters from any help would be super appreciated
Most likely stop accepting connections when your servers goes to actual map
@neon merlin can you explain a bit better.You can use server travel to travel between maps
@neon mango generally if you are joining by ip you should join map where dedicated server is currently is
It does but because by default there is another streaming level visible you see both. The server travel tells clients to hide it but joining clients don’t. I could on loving check to see if the new client is in any other level let’s say and I’d so unload the lobby but trying to better understand if there is a more official way. I’d imagine the engine by default should have clients streaming levels match servers at all times.
What is the significance of NetUpdateRate when push model is enabled?
Hi, Is there is any way to only replicate players who are in x metre radius or something like that.
@rare widget you can use net cull distance in relevant section of actor
Replicate section
Thank you for the help.
AFAIK it simply marks the property as needing to be replicated on the next update. Therefore the update rate would still be relevant in push model.
Hi, so ive got the HUD Widget BP like this and then im calling the event dispatcher in the RepNotify of CurrentHealth on the player character, should that work?
yes
weird.. cause that print isn't printing at all
and that lets you replace the widget without replacing the game code
its as if the event isn't firing for some reason
check if you have any accessed null errors after play in editor
typically, there is no guarantee you'll have character replicated by the time you run that logic in the HUD
Cant see any errors or warning relating to the HUD, ill keep digging
The object the FastArray is in isn't replicated.
The object the FastArray is in is an actor component and it's owning actor isn't replicated.
The FastArray property itself isn't replicated.
The Fast Array wasn't implemented correctly.
You didn't mark the item dirty when changing it.
an actor in the world getting all the time the camera manager component location from player controller 0, always get the local in use player, correct ?
I want something to get the active camera location (for effects etc)
Use GetController then access CameraManager
It might return listen server depending on the case, not the local
yeah but talking about controller 0
like getting it from world, I don't have the cast
Calling it on the Listen-Server will return the Listen-Server's PlayerController
Calling it on a Client will return the Client's PlayerController
Calling it on a Dedicated Server will return the first Client's PlayerController
In replicated environment %99 of the cases you dont need/want controller 0, if this is an actor that separate from players pawn to control the camera, I recommend referencing that pawn and accessing it controller anyway
@balmy gazelle If you want an easy global for the local controller, use GameInstance. It has a function to return the first local controller. Most times GetPlayerController(0) is okay. But there are conditions where it can spectacularly fail, specially on listenservers.
Thought it was dedicated servers where it it doesn't get the controller that you want.
You shouldn't ever be using GetPlayerController for anything server code related. So if it runs on a dedicated server, you're already doing something wrong.
Does the server not already have a list of connected player controllers?
The server has a list of connected player controllers, yes.
You shouldn't be referencing them by index, though. Which is the problem with using GetPlayerController functions.
I’m trying to remove duplicate players via checking if their name already exists and kicking them but my test seems to show that The old player controller is still there even after the kick and even after calling remove player
Are you using the PlayerArray from GameState?
Yes, agreed. But my comment was about GetPlayerController(0) not returning the expected one in dedicated server. Where as both client and listen server, it returns the one that you do expect.
Announce Post: https://forums.unrealengine.com/showthread.php?127674
In this session, Sr. Technical Writer Wes Bunn takes a look at a few different local multiplayer setups (split screen vs. shared screen) and how you can support a couch co-op style of gameplay. We also take a look at the Steam Blueprint Networking project and modify it so it s...
YT has so many
Youtube
Not that I know
There's this GetPlayerController(i) or GetPlayerPawn(i) based on what you want and they this index you specify to them. The index specifies a specific player.
AFAIK, first player is index 0, second player is index 1, and so on...
There is this one from the marketplace: https://www.unrealengine.com/marketplace/en-US/product/split-screen-template?sessionInvalidated=true
The only course I could find: https://www.pluralsight.com/courses/setting-up-split-screen-multiplayer-game-unreal-engine-1941
ok i've gotta be missing something basic. i've got a "tutorial" actor on my level, and within that is a child actor that is an item from the game. when the game starts, the game state iterates through all the tutorial actors on the level and runs this destroy function on it on server only.
the server properly removed the tutorial actor and it's child actor no problem. but on client, the child actor remains behind, even though the tutorial actor is destroyed.
does anyone know why my player controller has a netmode of NM_Standalone with using "Play as Client" in PIE?
im also getting this in the logs LogPlayerController: Verbose: Spawned spectator SpectatorPawn_1 [server:0] but i cant find the spectator pawn anywhere in the outliner, either for server or client
Hey everyone ! I have been looking for a solution for the following problem for 2 weeks now : When I do a servertravel (in Seamless travel) if the client loads faster than the server, the client is getting stuck (some random camera placement, no controll) and is completely ignored by the server. Has anyone encountered this problem and could they please help me ? Thanks
how can I make an actor execute something on the client, if “Run on Owning Client” executes on server?
it doesnt
thats literally the point of that
are you testing this as a listen server host? if so then you need to do an additional check inside your client side function
I was testing as a client. I'm using Easy Ballistics and wanted to spawn a bullet hole decal but that doesn't work and no matter how I wanna spawn that decal, it only works on standalone and on the server
but that just returns player states
What would be a reasonable way to store some specific variable (integer) for each player state, which will be replicated to all connected players?
any reason why timeout would not work for client? I exit client application and the timeout value set in config is no longer kicking in
oh looks to be an editor thing, packaged version respects the timeout time
Player states are a direct reference to individual players iirc. They can be used to reference the controller, as well, and stop existing when the player is no longer online
by default they will last another 5 minutes sitting in InactivePlayer array in GameMode
and they can also be used to reference the Pawn directly, as referencing other player's controllers doesn't really help you when the code is running on client
Yeah i think what I was doing was working the whole time but not in editor, packaged seems ok but need to run a few more test scenarios. I was second guessing a few things especially since Timeout in editor never times out when client disconnects.
i find PIE singularly unhelpful for testing anything to do with network connections
If you don't know you can also launch the game, should be closer to the packaged experience. We do all testing over the internet through launched games, takes no time at all since you're not packaging.
pie got some cool features to enhance the testing such as netem or join new client
really really helpful
but yeah... launch game is closer to the real thing
Hey guys, struggling with some movement jitter (client / server fighting I suspect) after a gameplay effect. Struggling to find the source of the jitter, it is oddly 'reset' by a CMC command like jumping. Tried printing out all CMC variables but can't find any issues. Any recommendations on how to find the source of the conflict? I don't think its max speed
Never mind, Gameplay Tags replicating too slowly for my movement functions to see that the character is no longer 'mounted'... Sadge
is using root motion for anims / montages in a multiplayer project generally a bad idea? for attacks and such for example
PlayerState->GetOwner() returns PlayerController
Also this ^
PlayerStates are replicated to all clients by default
@fathom aspen that's what I thought, but how may I store this data on them?
You simply declare the type of data you want in .h in your player state derived class and put it as Replicated in UPROPERTY
Just like any other variable you have there already, like Score, Ping, etc.
@fathom aspen Thank you. I'm working with a template so I didn't create all of that from scratch, but I was able to search for it and it makes sense.
Is it possible to make a code based lobby system out of the box with the Steam OSS? As in you'd host a lobby and get a random code that anyone can join rather than having to be friends with whoever you are sending invites to
What NetPriority you guys are using for weapons?
Hello guys, can somebody help me. I am moving an object with a timeline. The server sees the movement flawless, but for all clients its stuttering. Even with replicating the timeline it doesnt help
This article can give some insights: https://forums.unrealengine.com/t/why-is-there-a-twitch-jitter-in-the-movement-of-a-replicated-actor-on-client/424160
I have an actor blueprint set to replicate, within which I have a static mesh component. I am moving the static mesh through a timeline (each hop is 0.2 seconds). The movement is instigated by a click on the Static Mesh component. While the movement on the listen server is perfectly fine, the same on the client is fine as well for most part, b...
Thank you
I tend to believe it's the same value for their owning pawn which defaults to 3.0
Thanks
Can i use world origin rebasing in multiplayer?
Yes, but just bear in mind the Server always operates in zero origin space
So it doesn't solve the issue of world limits etc.
And your game code has to deal with the server and all clients being in different origin spaces
Hello, I'm having another likely noob issue. I have a game mode management blueprint that runs on the server. In my BP_CustomPlayerState I have a variable 'test var', an int with replication set to replicated and replication condition set to none. So in the server I get player state, cast to BP_CustomPlayerState and set the value of the int to '2'. Then in my BP_CustomPlayerCharacter 'tick' function, which runs on the client, I get player state, case to BP_CustomPlayerState, and print the value of test var. The behavior is that the print statement shows the default value for a few frames, then switches to '2' shortly after. Great, this seems to be the intended behavior. Next I try exactly the same thing, but instead of using an 'int', I store an instance of a custom object from c++ (derived from AActor), and spawned using 'spawnActor' in blueprints. In this case, even though replication is still enabled, the variable on BP_CustomPlayerState always remains none, all other things equal. -- how can non-primatives be replicated? Are there certain derived classes that need to be used?
The Actor derived class you are spawning has to be set to replicate. You can do that in that class constructor like this: bReplicates = true;
So I have to use Non-seamless travel in my project but it's disconnecting my client's immediately when triggered. Using seamless "works" but I can't use it for other reasons. Not really sure how to progress, it's almost like ClientTravel isn't being triggered at all
@fathom aspen Thank you, I appreciate the advice. I did set this line in the constructor and recompile, however, the issue still persists.
I just clicked the 'compile' gui button in the top-middle of the editor
There's an arrow next to it, if you press it and you don't have Enable live coding turned on, then you're using hot reload
Now that you know hot reload sucks, still live coding won't help here as it's not meant to be used for changes in the constructor or .h files. So you should be closing the editor and hitting F5 from your IDE
Do I have to have a dedicated server already running to launch using the -game flag?
Yes, or a listen server
Sorry, I needed to perform some other sanity checks before I concluded what to check here
To I have het compile, saved and closed the editor, them opened it again.
Okay, then I close editor, hit F5 in visual studio, it automatically launches the editor again
And I should also check the 'enable live coding' box?
You don't have to as long as you do this
But LiveCoding is really good if you do changes only in .cpp files, so you don't have to close editor and relaunch, but you just hit that compile button in editor
i keep running into strange replication issues when using construction scripts on my replicated pawns. when i create child actors in my construction script, it seems like the behavior is really inconsistent. are there some sort of rules i should be following?
for now i'm moving stuff into begin play, but it would be nice to have things in the construction script for easier editing in the viewport
I guess that's because replication doesn't work at that point(too early)
huh. i figured the behavior would be the same as manually adding things to the root scene component.
but that kinda makes sense.
intuitively, though, if the construction script runs on all clients, then that should be the same on all, including server
so it shouldn't have an effect. but it almost seems like the construction script only runs on the server instance?
just some clarity on that would be helpful so i know what i can and can't get away with
Think about replication as a thing that won't run at editor-time and would only run at run-time
Replication starts somewhere there at BeginPlay(probably earlier)
And it's allowed only after the actor has been initialized. Construction Script executes before actor initializes.
I don't think there is client and server at that time
right. so as long as i don't need to do anything with the actors that are created at construction time, then i'm good.
for example, if i add a hud element at construction time (donno the official name for this), i could hide it at begin play for everyone except the owning client.
is there anything fundamentally wrong with doing that?
No, but I wouldn't do it that way
the goal is to make it so the artist is able to position the hud element in the viewport without writing a readme
i could see only creating it on owning client on being play.
but then there's not reference for the artist
right.
so how would you achieve having the hud element position-able in the viewport, while also only making it viewable to the owning client?
It's that way by default
I'm not familiar with VR
are you familiar with widgets in 3d space?
Not really
Here I will show you how to add a 3D widget into a 3D environment or level
+++++++++++++++++++
Donate - Paypal - https://paypal.me/markom3d
https://www.markom3d.com
https://www.patreon.com/Markom3D
https://www.facebook.com/markom3d
https://www.instagram.com/markom3d/
Now I'm though hehe
It's easier than I thought
So is it viewable to other clients?
it is. it’s like any other actor you’d create and attach at construction time.
yo I had a question
Ah- right of course!
Okay so I am a bit confused on how to explain this but
Let me send a video
@fathom aspen as you can see in this video when I am looking side to side my character is delayed
Do you see the same delay in single player?
I am the host of the server, but when I am on a high ping server the delay is more evident
that wouldn't make sense, though
That's normal
listen server hosts are always zero ping, aren't they?
That's why you need to do client side prediction and stuff
I don't think so
I would print Ping from PlayerState to know though
How would I get started with client side prediction?
UE4 has it's own already implemented. But if you want to mess with it I really has no idea where you can find tutorials on the subject
If I run a singleplayer there is still a delay, could it not be an issue with replication?
That's why I asked that in the first place
It seems that way
I would think that but if I go on a laggier host, 200+ ping the delay is even more evident @fathom aspen
Most games I am familiar with have no issue client side seeing your character such as CSGO, Rust etc.
if you're on a laggy server for those games you don't seem to have a delay
Sorry if I'm explaining this poorly
I am messing around with it doesn't seem to have an effect
Could this be something
Could be. Try lowering it.
The delay still persists
By the way, you sure you changed the Z value?
Yes I tried changing the Z value as well
It basically seems the character is being replicated always instead of clientside
As long as you take any ue4 template example project and stick your character in, there shouldn't be such issues. Probably some other thing is affecting this
You probably can change the animation speed and make it faster
hi , I created server build But It's crashing on start. Here is the crash log
that was working with 4.24 . its happening after upgrade to 4.27
Delete contents of this folder: "C:/Users/{system username}/AppData/Local/UnrealEngine" and rebuild
let me try
but another thing is , I created FPS template project and It's working
only saved folder in local data
Looks like you will need to install a .NET Framework
But I'm not sure which version you have and which version you need to install
then how Its working on FPS template ?
Is it 4.27?
yes its 4.27 release source which is 4.27.2
Guys
I am stuck from two days on it 😭
i have a question
how do i package a multiplayer game
?
cause.... when i packaged it and runned it
it didnt have 2 players
I see that you are using engine source, so probably #engine-source could help
can we create Dedicated server build from UE4 epic version ?
I don't think you can
It wouldn't
You would have to run a server and make clients connect to it
How to build Unreal Engine from Source: https://youtu.be/MRJUWC90aJM
In this video, we go over how to set up and package a dedicated server for your Unreal Engine project. Dedicated servers are becoming a popular alternative to other game server options such as listen servers and peer-to-peer for multiplayer games. Dedicated servers provide man...
This video can help you both btw
No, you cannot
can you help with crash ?
No crash in that log file, so it's something else.
Now that's a crash, debug it
Run the server in VS - you'll want to keep the PDB files generated with your server for that
You should find the error quickly
its working when run it from editor or bat file
I tested complete flow run 16 clients all is working proper
I thought you had a crash?
yes when I create Build then server does not launch
crashed on started
So debug the build
by attaching process ?
okay let me try
LogSerialization: Display: AllowBulkDataInIoStore: 'true'
LogWindows: Error: === Critical error: ===
LogWindows: Error:
LogWindows: Error: Assertion failed: IsValid() [File:D:\Source\UnrealEngine\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 890]
same on VS
Cool, so now check the call stack to understand the issue
may be first i need setup symbols "BootstrapPackagedGame-Win64-Shipping.pdb could not be found in the selected paths"
getting the error on load symbols
Yeah, like I said, you need to pass the PDB you generated with the build
Just add the file you stored it to in the symbol search path
where i can find this ? in build folder ?
sorry it require this one "BootstrapPackagedGame-Win64-Shipping.pdb"
Yeap, that's the one
Though probably the client here
You should always back up PDB files every time you do a release, client or server, sicne that's the only way to debug crash reports
but i have "PhotonDemoParticleServer.pdm"
when i try to add thin one , complaining this is not the right file
No idea what a pdm file is.
Yes, that's the one you build
Check the staging folder
Your build log when packaging the server should have the location
hmm okay
If you're using project launcher to build, make sure to tick the "debug symbols" option
i think I am missing that one not sure
You can always simply compile the server target in VS and replace the executable+PDB file in your build
It'll behave the same
And the PDB file will be produced
pdb file there for project
i think vs asking for "BootstrapPackagedGame-Win64-Shipping" which should be under source\bineries\win-64
i think am also missing this file \
i never discovered how you can run shipping binaries directly from VS
Test is very close, and usually does the job though
I run it and debug it
it's in main class during loading of InstallMissingPrerequisites
Hey, we're trying to replicate aiming in a game based on the Side scroller
More specifically, we'd like to replicate the player's controller's rotation so when we shoot a projectile from a client, it replicates the rotation/forward vector to all other clients for this projectile
Thanks in advanced 🙂
Is there anything special i must do to use the DOREPLIFETIME()macro ?
throws me an error about identifier not found
have you included UnrealNetwork.h
That, and the class getter for replicated properties must be defined
Gonna check, this is the ACtionRoguelike sample project by Tom, I believe
made for 4.24, i converted it to 4.26 as thats the lowest engine i got currently installed
That worked, thanks! 🙂
hoi, if I set this to true, it'll mean blueprint props will use the push model right?
Looks like it 
Holy shit that makes porting so much easier, only have to worry about C++ ones
I think Base aim rotation is what you're looking for.
Cheers, I'll have a look
how are you rotating the character? using the movement component? there is, i think by default, a "smoothing" of the rotation of the character movement component. you could make sure this is instant. or set the rotation of the character in a way that's instant.
is it possible to have cheat manager working on clients as well?
right now cheat manager only exists in server
Do EnableCheats() in controller BeginPlay and cheat manager will instantiate on client as well as server
Does PlayerArray in game state include spectators as well?
Yes
Hello! I have a pawn which uses server spawned and attached actor components (via sockets) as legs. This works great server side when the pawn is possessed by the server and the pawn is standing correctly on its legs, but when the client possesses the pawn its legs go through the floor (but stops at the body of the pawn) - what could be the reason for this?
on the server the legs are still touching the ground while the client is trying to replicate its non-touching position, causing serious rubberbanding like behavior
I'm spawning an actor that act as a pet, when running multiplayer the client can see the server actor getting spawn, moving and attacking, the client can also spawn a pet but then nothing happen he stand still. I did made sure that movement was replicated on the actor.
Need clarification. Is the client spawning that locally, or is the client making a ServerRPC to have the server spawn a pet that gets replicated back?
Why wouldn't it
wym, it is possible.
He means from a ue4 binary version
no need to do engine edits, since Global defs was included
(From the Epic Launcher)
I didn't say you have to
why is it not possible? is there any particularity I don't know of? 🤔
But as far as I remember you can't
Stranger probably can elaborate on this.
prior 2019 you had to recompile the engine for these details, that's what got me hahaha
But I think they mention the reason in this video
I see xD
ahhh what a bummer I was planning to use launcher version to reduce some overhead compiling the thing @ every version
Yeah it would be really nice if it worked using the launcher version...
The engine source takes ages to compile 😢
Like I literally remember myself leaving it compiling and going to sleep lol
But that was old my setup, no idea what's going now
😄 lol, anyways, this is getting quite off-topic... yeah
Haha yeah, the orange hammer is watching us
It's a spawn AI from Class directly built in the character
Show your code. You can't spawn stuff on the client locally and expect others to see it.
Nice little bug I just discovered.
Blueprint Integer Increment or Decrement nodes do not call OnRep on the Server, only for Clients.
I thought OnRep has to be called on server manually?
In C++ thats true.
In Blueprint its done for you.
OnRep_ functions in Blueprint are not BlueprintCallable so they cant be dragged into the graph.
To be clear
This is only for Blueprint Properties
Not ones declared in C++ that you would have defined a OnRep_ for which you can mark as BlueprintCallable if you like
did you try has authority check before calling the decrement node?
Use the Set method instead lol
Fair enough
If that's true, the bug has to be reported
But I have hard time believing no one has noticed it all this time
I dont
Well im sure someone else has, but whether its been reported or not is another story.
And considering its pretty easy to avoid.
Its most likely not high priority if its known.
Yes, but it's crazy, considering incrementing/decrementing does a Set
It does a different type of Set
Ye probably
Which is specific to blueprint macros
Oh I hate BP macros
Nothing works out of the box in Unreal
Well technically most things
So who calls SummonPet?
Where is it called?
Player Index 0
oh actually not right now it's while pressing G, sorry forgot to remove the custom event, Im trying to have it done through the interface so I'm trying various thing.
Ok if it's on button press(G for example) then that's the client calling SummonPet -> not good
oh, 😅
So decide where you want that logic to happen
If you still want that to happen on button press you can
You can send a server RPC
So you have to make SummonPet event as a Server RPC
And make sure AI Pet is replicated
so it is replicated, I tried to make the event Server RPC and it endend up having the pet summoned by the client to follow the server pawn
So Player 1 (server) can summon no issue with anything.
Player 2 ( client ) can also summon but no movement.
If I set the Server RPC, the pet will move but will follow player 1 instead of player 2
Then it's connected to the logic that tells the pet to follow the player
How do you make the pet follow the player?
That's no doubt
But the reason you getting this behavior is that you're doing GetPlayerCharacter(0) on the server which always returns Player 1
Who calls FollowPlayer?
I thought GetPlayercharacter(0) was a way to say "current player"
now I feel dumb!
If you're on the Client
But if the Server, then it returns the first player in the game
?
Send a screenshot
The thing is that the logic to follow the player is set on AI, so what you're doing is that you're telling all your AI pets on BeginPlay to follow Player 1.
You're not doing a distinction between the players
This shouldn't be handled this way
Also don't use recursion for AI when you have BT please!
yeah now that you told me it was ref player 1 , use a playerarray to get reach player ref
I won't 😅
You can think of it this way. But remember that this logic will run on each AI, so it's up to you to make the distinction
got it thanks will fix that!
How do I origin rebase clients on a dedicated server?
I don't think this works properly as each world just has one origin. If you now are in a multiplayer scenario, and players are scattered all over the level, which would be the correct origin for the server?
If you plan large multiplayer worlds, I'd go for Unreal 5 as with double precision there is no more need for an origin rebase which makes it easier to build larger multiplayer worlds.
The clients rebase themselves locally. The Server is always in zero-origin space.
Then you have to carefully make sure you send zero-space coordinates between the two, and rebase them client-side when required.
Hello, not sure if this is the correct chat to ask for this. I'm making a local multiplayer game which won't have split screen since both players will be on the same screen at the same time. My questions is how to handle UI for both of them, since both have HUD's and technically both of them are showing in the screen, how can I have only one HUD?
I'm using an actor with a 3D Widget Component and want to disable/enable it runtime :o
but the Widget Reference is always null for clients
so this part here returns nothing on clients
You don't. You use one viewport and two huds. Widgets are still owned by individual players, you just have to manage how they're handled in the viewport. How you do that depends on the layout you want. It can be as simple as using the player index to pick an anchor point when adding a main widget for each player.
i have a ammo widget in the local player that updates when i call an event dispatcher. in the gun when i change the Ammo(replicated) variable on server i call the (update ammo) event dispatcher but the ammo variable is not updated yet on some clients so it shows the old ammo. how would i make sure i only update the ammo after the variable is set. should i use repnotify for this? does repnotify cost more bandwith then replicated variables?
If the event dispatcher is called from the server it will only run on the server. You might want to add some custom events that are replicated from the server to the client, for ex. when the gun is fired and ammo decreases the client runs a RunOnOwningClient function that updates the UI.
i call the shoot function on server and client
but it only does damage on server and call the event dispatcher on client
because event dispatcher is only bound on client with ui not on the server
repnotify on ammo with event dispatcher works really well but i wonder if it costs a lot of bandwith to call it all clients
repnotify is a purely clientside concept
Not true, repnotify also executes on the server
Oh whoops wrong quote
repnotify only executes on server in BP, and it's still client side as in not networked at all
repnotify doesnt work on server
Hmm lemme try
if you print string in repnotify it doesnt print on the server
(I should have said "local" instead of "client", but I'm a C++ guy so to me repnotify is client only while in Blueprint it's both)
but you can only call it from the server
i just wonder if you can do something like repnotify only on 1 client not all clients
Sure, just replicate on that client alone
call on owning client function?
From a multiplayer perspective, is 'Player Index 0' always the locally controlled player? Is this safe to have in my multiplayer game (no split screen) or should I replace with 'get owning controller' or something?
repnotify is a purely local concept, again, no networking involved
Ah im a BP guy so theres the issue 🙂
No, and no
Ah... Ok 😅 What should I replace it with?
You should never need to get an arbitrary player controller, really
If you're on a pawn, get the controller
If you're on client generally you probably want the player state
Remember PC isn't replicated to remotes
E.g. checking if the player has an input key pressed. Should I 'Get Controller' and cast to a player controller?
That code should probably be replaced by a player controller action but yeah, since you'll only call this code when the Pawn is Locally Controlled, get the controller and do that I guess
This specific implementation is a local on-tick check for having the input key down. But reviewing some code and I've noticed I've used 'get player controller at 0' a LOT, especially on widgets. Suspect I should change them out for something else. What's the best way to get the locally-owned player controller, e.g. from like widgets safely in a multiplayer setting?
Using them on widgets is fine, they're always clientside
You should not use the player controller generally speaking
Well, you should never need to get it that way really
Will they always be 'index 0' when called on client-side?
Your UI being local only should be owned by the player controller
Code tied to a Pawn should use the player state instead (member of pawn)
You saw how to do it for input, etc
Don't use that node at all in MP
Instead, think a bit about who owns what and what's live on client or server
If you only have 1 player if should be yes
But listen to Stranger and maybe read Exi's network compendium if you haven't already
This macro might also be handy
Please don't do that
Is Local Player Controller
Here's your "is local"
The rule is simple: if you have GetPlayerController(0) in your MP project, remove it
Have personally had that node explode on me at work. :/
When in doubt. Widgets have a way to get local controller. Anything else you need, should really be a C++ BP Library static for GetGameInstance->GetFirstLocalController
Thanks Stranger, really appreciate your help on this! I have loads of that node floating around so trying to find the best replacement for it
Thanks, I didnt know IsLocalPlayerContoller also checked the netmodes
Ohhhh, do you have a screenshot to hand? I have a C++ BP library
How can widgets get local controller?
A clean hierarchy of ownership is the absolute best way to work.
- Working on Pawn? You have PlayerState for all replicated player data, and GetController if you're on server OR locally owned.
- Working on UI? Your widget should be player-owned most of the time, sometimes attached to a pawn (see above).
Keep it simple, use the engine API, don't make assumptions
what do you mean by this just that is a function that gets called and only executes locally on the client?
UFUNCTION(BlueprintPure, Meta=(WorldContext="Context"))
static APlayerController* GetLocalPlayerController(const UObject* Context);
APlayerController* GetLocalPlayerController(const UObject* Context)
{
UWorld* World = Context ? Context->GetWorld() : nullptr;
UGameInstance* GameInstance = World ? World->GetGameInsance() : nullptr;
return GameInstance ? GameInstance->GetFirstLocalController() : nullptr;
}
repnotify = client (server too inBlueprint) calls this function when the value changes
Nothing more
Something along those lines, may be typos.
okay thanks
In particular repnotify implies zero networking, it's not an event sent by the server or anything
Which seemed to be misunderstood here
It's also not a good idea to manually call RepNotifies on server. Better to have a second function/delegate that server and the notify can call. It makes network breakpointing much easier for debugging.
its just the same as replicated then but you call the function when the variable changes
Yeah (which doesn't mean every server change has a client call)
While we're on the subject of good practices, I'm using a Map variable for my master item list in the game mode. This map holds small structs of items spawned and crafted in the game. Is there a max size to a map variable like there is with an array? Couldnt find anything on Google.
Maps aren't replicated, but yeah probably
I'd guess something like 2 ^ 31 entries, but idk
Thats plenty, thanks
Above is the static call. And all UserWidgets have a blueprint callable GetOwningPlayer that returns their player controller. When you use the CreateWidget node, you pass in some form of context. This function runs through the gameplay framework to find the local player and set it as a context for the widget. They use that context to get the associated player controller for it. You should be able to use it safely in any UserWidget.
I checked and TMap relies internally on a TArray
So the limit should be the same which IIRC is 2^31
Thanks for checking
I'm not as savvy with the engine internals yet
but in blueprint when i change the variable on server it calls the on all clients? so every change on server does have a client call ?
"every change on server does have a client call" is never true
In Blueprint, changing a replicated repnotify property calls the event locally on server
Clients will call the event when the value change
Multiple server changes may result in one client change
Do you test in the editor or standalone because I've had issues with repnotify in BP and using "Run under one process" in the editor settings
when i call a repnotify on server it calls the function on all clients and when i call it on a client it calls thefunction on the client isn't that how it is supposed to work?
Changing a replicated variable on server does not always mean the new value will ever be replicated to clients
Repnotify events are handled purely locally so no change = no repnotify
Stranger is trying to tell you that networking isn't immediate. Replication is considered at the end of a frame, and isn't always considered if you have a lot of actors or things are out of relevance. If you change things a bunch of times before it's sent, it means that you can change a value 10,000 times on a server, and still end up with 1 RepNotify on a client.
If you have a replicated frame counter that increments each tick - guarantee most changes will be skipped and you'll see repnotifies on client for like 1, 3, 5, 6, 7, 10
Which is why I'm insisting on the fact that repnotify doesn't change network behavior and is not networked at all
ahhh
so you want to make sure i know that repnotify just gets updated when the variable changes on the client
Thanks Authaer, Giving it a try now
and when the server changes the variable it can get updated on client but if we change it another time in a short amount of time it would only updates once to the newest variable, only calling the on rep notify on the client once
thanks!
yes, because two things need to happen outside of normal RepNotify setup - server needs to change the variable, and server needs to decide to replicate that Actor to the client
if you change it several times between the 2 updates, you will get only one RepNotify
Just implemented it and it's asking for a 'Context', added your 'Meta=(WorldContext="Context")' line and now it's dissapeared. Never seen that before, thanks!
Super helpful dude! Just to confirm if this is the right node you're talking about?
Hey Guys,
I'm trying to implement a test scene for multiplayer functionalities,
the idea is to have the same build executed twice,but the first one that is launched becomes the server and the other one connects to it.
If I play from Editor launching 2 instances like this ,it already works,but I have problems doing it with the build...
Anyone able to help out?
I pretty much use variations of the GetLocalPlayerController type, but the widget version is useful if you don't have C++ access in a project. But yeah. GetPlayerController0 should be avoided. It will work in 99% of cases. But there are some listenserver places where it can actually return a client's controller on the listenserver. 1% of cases is more than enough for plenty of bugs.
If its returning null, you're either trying to reference it on the server (not possible) or on a client where it hasn't been initiated properly. I would check your initiation code. Or just have it hard-coded to initiatise on begin player for the client
There's no reason to put good code at risk 😂 Thanks Authaer
it's an actor component. so I'm just getting that... the reference for the component is valid however the Get Widget returns null
Also it works on the server (listen) and only returns null on the client
This is what I use on mine for a health bar
I tried that and still is same result :/
You sure you're not destroying it accidently somewhere when you try to toggle it? This is working for me
(It's a widget component on the actor)
I'm not toggling it at all. it's essentially some buttons in the level the players can interact with
with some text
(On Begin play)
yup
GetWidget works fine for me as well (client/listen server). Check if it's not replicated, maybe listen server somehow destroys it and replicates to client?
I'm never destroying these
People keep telling me this but I don’t even get how to implement it.
You just turn it on, then move the world origin on the client