#multiplayer
1 messages Β· Page 647 of 1
Use the debugger, with engine debug symbols installed. You'll have access to the entire engine and game state and so you'll find out which variable was null
I had DevEditor config selected, I'm now building using DebugEditor to see what happens
Dev is fine
Just make sure you're running the debugger to see the local vars & callstack
in very broad terms, how would one implement skill based matchmaking?
So if I run the debugger when I parent the ActorComponent in my blueprint. I get this. https://gyazo.com/bbfe22a7ce6c290ac5cc86154aa2471e
you can take a look at amazon game lift and flex matchmaking for example it can match up to 250 players per match i think and it offers also backfilling feature ( basically when someone leaves a match it gets replaced by a new player ) idk if u need that
Hello I have an issue where the character jitters when it's in the air, and I'm not sure what so different then - something to do with physics?
(I mean in multiplayer - client only)
that does look interesting, but i was looking towards something slightly simpler. i am experimenting with a 64 players lobby and my current idea is to have a hidden numeric value bound to each player, and while searching for a session, they'll only be able to join sessions whose value is slighly equal to the session's average elo/mmr
i was just curious to know whether resources on this specific matchmaking existed online, so that i can safely implement it without causing any troubles for my coworkers
@faint pawnI'm assuming at some point you'd need a 3rd party server that hold the list of game with a SR associated to them
Whether you build it yourself or not
if you are using a public based game, I wonder if you could cheat the system into using the "public connections" attribute normally, and the "private connections" as the SR (assuming SR is always higher than public connections)
So that locally the game could choose which game to join, by passing the need for a 3rd person server. might be hard to balance the games though without a global view and so on
Did you see this? #multiplayer message
I can't leave that screen. I can only keep pressing Continue in the IDE. If I stop the UE4 editor closes.
Exception thrown at 0x00007FF911B112DE (vcruntime140.dll) in UE4Editor-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Unhandled exception at 0x00007FF911B112DE (vcruntime140.dll) in UE4Editor-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0x0000000000000000.```
The callstack panel is on the same screen
Get it from the Debug -> Windows menu if not there
You have a nullptr access - good old segfault, as old as time
Find out where in the callstack things get called on nullptr
hacked accounts
I don't see Call Stack in UE4.26 under Windows->Developer Tool.
THis is what I get. It doesn't make sense to me.
The call stack is in Visual Studio
Anyway, we got it
THat's from VS
Sounds like an actor is corrupted here, or otherwise destroyed while edited
Did you use hot reload ?
No i never HotReload. It's unchecked
So that happens when my existing BP_ActorComponent's parent class get changed to the new c++ ActorComp.
Show the code for that class
Weird. Is the Blueprint looking okay ? No empty detail panels or the like ?
Do other parent classes work ?
Other c++ parent classes work. It could be the BP ActororComponent that breaking it. but it works fine as it as BP
Try reparenting to another class
Yes that works fine.
So in my Bp i've some functions and some variables. Also it has a child BP
Also an interface
@shadow hatch you should probably do it on a "OnRep" rpc
Yeah, that was my previous method, sort of, but i do enjoy how an an animation blueprint can seamlessly change the characters animation onrep seems a tad clunky
Hi friends, Respect for being in this field
Personally I'm been playing Soldier of Fortune 2 since it's come out to this day
There have been plenty of attempts to obtain the source code, through engagements with Raven Software and Activision
By converters to other engines like jk and spearmint
Until we created part of the game in Unreal Engine 4.25.3
Lots in c ++
I'm looking for someone who wants to help lift the project back, for a fee of course
Can contact me
Inb4 C&D. Don't use other people's IP.
k
If I've got references to playercontrollers in multiplayer in order to determine which player I'm acting on in some way, and that player disconnects from the game, how do I maintain that sense of ownership or avoid someone taking over their exact playercontroller references from then on? Would it be a case of storing a list of all players in the game and assigning each one an int and checking against that instead?
ah this topic was double posted already - #blueprint message
(linking my response for continuity of discussion)
Thanks! Wasn't sure they were the same question really π
@regal storm let's talk more about this int plan of yours
I think it's a bad idea to use anything other than the net ID of a player (easily reachable from player states and controllers) for any internal bookkeeping - but even if you do track an int or something, how will that assist you here?
What does it solve
Ahh sorry, here not the other place π
That's fair, I guess I'm sort of coming from a database perspective, I need to keep all of these players who have been on the server stored and accessible regardless of whether they're online or not. I don't know why but I assumed having an int as a key to retrieve the netID would be more appropriate in that case
But I'm happy to be incorrect π
I just need to have a record in a particular actor of who 'purchased' (in-game currency) the actor and use that information to determine who can and can't make changes to the actor through interaction
Unless you strictly need sequential keys, I think the NetID is probably fine for ID purposes.
If you do need sequential keys, then I'd suggest some sort of wrapper so you can leverage the type system to ensure people are looking through your system to get a number - eg, GetEntityIDFromNetID
or GetNetIdFromEntityID
EntityID being a standin for your gamelogic ID for a player - but also being an actual type
whatever you want that nomenclature to be.
The net ID is not likely to be the display name outside of the Null OnlineSubsystem
Wonderful thanks! Multiplayer is new to me, so it's a bit of a maze to figure out. I keep referring to the Network Compendium π
Yes, I've been meaning to read up on the latter!
(those aren't per-se the same thing, EOS is a particular subsystem/provider)
I'll check it out before I end up diving too far into anything π Thanks!
np! glad to prevent that extra layer of complexity
The player controller references already exist on the server, you don't need to duplicate that functionality
Guys, I have coded the necessary functions to manage sessions, but I still have this weird behavior. I spent the entire afternoon trying to figure out. You see, i just used Sessions because my second player is possessing a Pawn, his input are being registered, but his pawn don't move. Also, I'm changing, in my custom GameState::OnRep_MatchState, the ViewTarget of the PlayerController, but only the ViewTarget of the first player is changed. Before coding the session thing, I was getting a warning telling me a lack of GameSessions, and I thought it was the reason behind this behavior. Now that I have a working seesion, the problem remains. Have you ever encountered something like this? Here is the video: https://youtu.be/T5_TIdBeFiw
As you can see, in the messages, both players are possessing pawns, and their input are being registered
Are replicated variables functional on Online Beacons?
Are they characters or pawns? Pawns movement isn't replicated.
Hello there! They're APawns
kk But I'm doing a ServerRPC, where I ask the server to SetActorLocation based on the Movement FVEctor
there's no need to do that
make it a character
and utilize the character movement component
Character Movement Components are automatically replicated?
bReplicates = true, right?
kk thanks!
CMC uses it's character to replicate.
It was largely coded before Components were given replication.
Also, do you have any idea why the second player ViewTarget isn't changing? I'm doing this in the GameState: ```void APongGameState::OnRep_MatchState()
{
AGameState::OnRep_MatchState();
UE_LOG(LogTemp, Warning, TEXT("The game state has changed."));
if(MatchState == MatchState::InProgress)
{
APongCamera* MainCamera = Cast<APongCamera>(UGameplayStatics::
GetActorOfClass(
GetWorld(),
APongCamera::StaticClass()
)
);
if(MainCamera)
{
APongGameplayController* PlayerController =
Cast<APongGameplayController>(GetGameInstance()->
GetFirstLocalPlayerController());
if(PlayerController)
{
GEngine->AddOnScreenDebugMessage(
-1,
10.f,
FColor::Green,
TEXT("Player's point of view changed.")
);
PlayerController->SetViewTarget(MainCamera);
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("There is no camera in the level."));
}
}
}```
Nice to know π
I implemented fog-of-war/line-of-sight on my game, the fog of war is just a post-processing effect, but I was wondering how would you recommend making actors stop being network relevant when outside the range of vision, like in a MOBA? Under the hood the fog of war is just line-traces that serve to draw triangles/polygons.
I have some ideas but might as well ask first
@twin juniper the "Easiest" method is to have your fog of war also being your immediate network manager
@twin juniper You can override IsNetRelevantFor in your actor (c++) for example
Yeah but what condition should I give it? if it's part the overlapped actors of a sphere overlap component on an actor? if it's touched by a line-trace?
If it's visible by the viewer i guess
Maybe shootergame or ut have some code for it
didn't know shootergame had fog of war
or unreal tournament
Has also nothing to do with fog of war
Fog of war is mostly a visual feature
The underlying code for stopping actors to replicate when they are behind walls or similar is the same
You just swap out the stuff they do to detect walls with you detecting if your actor is in the fog
You can take it a step further too
and just not replicate anything not in your field of view
Hey im using advanced sessions plugin and im having trouble on making a character select screen. Any tips to point me in the right direction?
Or easier, how can I save variables onto individual clients? That way I can just save the class I want them to spawn and possess
Theres a whole tutorial series on that by epic on youtube
let me see if i can find it
here it is
In this video we take a look at the finished project and step through each of the features that will be covered in this series. We show our functional Main Menu and its options, a lobby where players can chat with one another and select their characters for the game, some server options such as changing the map or match time as well as the abili...
Appreciate it, I'll check it out
it was quite helpfull to me
Please keep in mind that this specific Tutorial Series is kinda garbage. They teach a shitload of wrong things in it.
I called them out ages ago, but they never did something about it. There is a long Forum thread going over that stuff.
Things like RPCs in Widgets, Replicated PlayerController Arrays in the GameMode. Lots of stuff that makes no sense and is plain wrong.
Even the freaking Thumbnail of that Embed message of the First Episode has Replicated Variables in the GameInstance
Like, man this makes me so sad, even after all those years
if i destroy controller will that destroy player state and controlled pawn also?
hey, does anyone know how i could smooth physics movement in clients? Physics replicate properly but are jittery af, and thats not pretty to look at tbh.
Dig around in the physics replication settings they're jittery because the stock setting are way too strict and correct all the time.
ok but what exactly do i change to make it less extrict and correct less often, thats exactly what i've been trying to do but the way lerp works in ue4 is different from other engines i've worked with so i dont really know what settings to change
Hopefully a simple solution as I'm suuuper new to multiplayer:
The server doesn't receive the pawn, it doesn't possess anything
Does anyone know why this might be?
Not at my computer, show me the options.
1 sec
this part you mean?
this is all that i could find related to networking and replication when it comes to physics
Yeah try turning the error per linear distance down a bit, also the error per angular
With stock settings it'll be considered to be in full error at 1cm position diff or 1 degree angular diff which is pretty small
i've been trying different values but all seem to give the same result
they all havethe problem where the objects go around jittering. If i set it to 0 it goes smooth for a while and then goes nuts jittering until it corrects itself again...
ahhhh i've made a different change which seems to be working tho, changing the
"max restored state error" thing
if i set it to 10 and the other 2 to just 1
it works smoothly and the error is small enough to not affect gameplay
that did the trick thx man
Ya that's the same as 1 with other .2 and .1
I wouldn't get too invested in this old physics replication system though, I think it's getting thrown out with chaos and they've moved to a new system
yeah but im working with an older version of unreal F
i'll try to update when i can but i think it could potentially break all of what i've done with physics here... maybe? idk
Im using a particle system and some code to make a laser sight
How do I make it so that the laser particle system is only visible on the players screen and not to anyone else, and the code runs on only that player with the laser sight?
Dedicated server or P2P?
sorry just found out how
yeah listen server
just default visibility be false, and used a Run on Server + Run on Owning Client to set the visibility
Anyone here good with physics/optimization/multiplayer stuff? lol
I need to find a solution that is as performant as possible, but can handle possibly a hundred or so objects that fly around from a simulated wind field (in this case this was tornadic damage) Currently the sphere collision gets an overlapping component == to component with a specific tag. If true it adds it to an array of these components that have their physics simulated. I am calling on tick every 0.05 seconds. Once the component stops moving it's removed from the array with its physics turned off.
I know this is not the most optimal way to do this. I could use the help
tick is only on when the array has at least one element
Hi everyone, I'm new the multiplayer. If I simply want to change an actor's sprite (with an event called by the server) and replicate it on all clients, ticking the 'replicate component' on the sprite component doesnt seem to be enough to replicate it, do I necessarily have to multicast the 'change sprite' event ?
Yes and no
It is indeed not enough to just replicate the Component, because the variables inside would also need to replicate :P which they usually don't.
A multicast would solve your problem (if executed from the Server), but people who join later or come closer into relevancy range, would never get that update
You want to use a RepNotify variable instead.
And then set the sprite in the Rep Notify function that UE4 generates automatically
If that doesn't tell you anything, then I would advice reading the compendium that is pinned to this channel
Awesome, thanks a lot for clarifying ! I'll try that π
besides being in range (min<val<max ), what other validation to the input are usual?
i mean, that guide answers like 90% of the questions asked int his channel lol
You mean raw input? Can maybe check the rate of change of it
I have a question about replicating physics. Could you just have the dedicated server run the physics simulation and simply replicate the mesh transforms? Or is this how it works already in the backend?
you can do that yeah
Because replicating actual physics is kind of stupid
for m y case anyway. I can potentially have a hundred or more objects.
So long as they 'eventually' end up in the same positions for everyone is all that really matters
you could fake the funk so to speak
use set actor location to determine final position and have clients execute physics for X amount of time until it gets there
could lead to some weird results though
It's a fairly large problem that I need to solve for my project
as destruction is a big element of the gameplay itself
If I could hire someone familiar with physics and replication to develop a solution I would pay for something proprietary
what is the nature of the physical objects, what kind of ways are they going to interact with players?
in your game that is
Well, it's a storm chasing game. So that speaks volumes if you can imagine.
So if house/tree or whatever is damaged and it has pieces that are moving around and land somewhere, it needs to match for everyone
Otherwise it would be a bit silly
So its not really the player interacting with them. I mean sure if a large tree lands on the road youd expect it to block your vehicle..but that is simple enough. its the weather interacting with the objects
Does anyone know off hand what the size of a typical GameplayTag is?
I think most games handle that by using predetermined physics to ensure everyone sees the exact same thing
do you mean baked physics sims?
yes
The world is dynamic so a tornadic event may be here, may be there, may be small, may be violent etc
I have stayed away from the physics part of all of this for this reason
I am not sure how to approach it
a gameplay tag is technically just an FName
maybe the folks in #legacy-physics have an idea. But it sounds like you'll need to add some type of replicated movement for each item. Which can get very very heavy network wise. You may be able to use the logic of the ECS projectiles here: https://github.com/EmpiresCommunity/ECSProjectiles
it's an interesting problem, lmk what you come up with
if you have a lot of physical objects, as you said hundreds, but you don't need them to be super low latency
I would go with snapshot interpolation through replicated properties
but with a high enough render delay
let the engine do the network prioritization, each object will have an arriving packet every X seconds, meaning you could get away with about 2X or 3X render delay
objects will render smoothly that way and won't result in lots of snapping
but that could also increase CPU performance a bit too much
interesting, what GPU api do you have to do that kind of stuff on it?
I don't
I'm not super familiar with this area
I just read rendering and thought you could move that off the game thread
ah, yeah ideally not on the game thread
Im having something weird happen. I am doing a server travel from my lobby when it hits a certain amount of players. It travels the clients but not the host. This is a listen-server. Anybody ran into an issue like this before? Thanks
Does anyone know how to Spawn Emitter Attached in a way that other players cant see the particle effect, and everyone can only see their own particle effect
@viscid bronzeReally depends on the implementation need. What's the particle for?
So its a laser sight beam
Im going to use it to draw a laser from the player's muzzle to where they are aiming
Likely just base it off of whether the weapon actor's owning character is locally controlled. Alternatively, some multiplayer stuff uses two different meshes on the same actor for first person/other people's view. Could be hidden from other players that way. Either way likely works.
Ok, I guess that could work, thanks
Hello everyone.I already have a project with blueprints with legacy replication like multicast,rpc etc.How can i integrate replication graph in this project??.Thank you
Hi, i'm using Steam Advanced Sessions Plugin. I want to know something. How can i use FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId UniqueNetId)? I mean.. i was trying to do:
FBPUniqueNetId bFBPUniqueNetId;
bFBPUniqueNetId.SetUniqueNetId(??????); //dont know how to get unique net id from pawn actor..
bNickname = UAdvancedSteamFriendsLibrary::GetSteamPersonaName(bFBPUniqueNetId);
Thanks for help
does steam advanced sessions work in ue5?
Is OnRep called on the server?
In blueprint it is, in C++ I'm pretty sure it isn't
Hello everyone.I already have a project with blueprints with legacy replication like multicast,rpc etc.How can i integrate replication graph in this project??.Thank you
Rep Graph is C++ only
But the core replication machinery of actors isn't any different
Aaaaalso, "Legacy" would mean normal Replication is outdated :D
James, time to make a blog post about Replication Graph
Haha yeah.. still a bit of a black sheep it seems
I think a lot of people would be very happy and thankful
to be honest though unless you've got crazy high player/object counts, it's not going to benefit you much
Yeah but it's always cool to have some custom docs with examples on more tricky systems
So UPROPERTY(Replicated) is outdated?
no
You don't do anything different at the actor level when using replication graph, except when it comes to functions like IsNetRelevantFor() which are no longer used.
Rep Graph is almost entirely a Server-CPU optimisation, so unless your server is spending a lot of time working out which actors are relevant to which connection, it's not going to be of much use to you.
Na my point was that the other person called it legacy, while it's not
tbf I do that as well but mainly because it just doesn't have a name π
Got it, thanks :D
Tried it, called in C++ too.
OnRep's are only called on Clients in C++
Still unsure why Epic made them behave differently (aka, wrongly) in Blueprint
But I guess it's too late to go back now
If you want to call it on the Server though, you can just call it manually
But it works on the server too...
The code:
void AGardumPlayerState::OnRep_Damage()
{
DamageChanged.Broadcast(Damage);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("%f"), Damage));
}
I see the message on the screen on a listen server and on a client
Yeah it's weird. In BPs it's just a "Variable Changed" and not really the "Property got replicated".
Maybe it's because a listen server is like a client + server?
nah
100% garauntee it's only being called on client
If you add something to check whether the actor is on server/client it'll show it more clearly
How can I do it?
Something like
const FString Domain = GetWorld()->IsServer() ? TEXT("Server") : TEXT("Client");
Yes, it says that I'm client on a listen server.
yeah it's just the editor viewport being funky with AddOnScreenDebugMessage
Okay... Then maybe a bit weird question, but can I somehow replicate a variable without marking at as a UPROPERTY?
negative, apart from sending it directly with an RPC of course
But that wouldn't trigger an OnRep or anything
You could do a replicated event, pass it as a variable and set it.
Thank you.
My problem is that I want to call the delegate when the variable changes. If I make a templated wrapper with operators overloaded that call a delegate, I cannot mark the variable as Replicated due to UPROPERTY (cannot be mixed with templates).
It looks like I need to manually call the delegate on the setter and RepNotify :(
How? Can I read more about it somewhere?
That's pretty common to be honest
Calling a delegate from Setter and OnRep
nothing strange about that
Yes, I just have a bunch of variables, and writing for each of them is tedious ...
You don't want to send properties via RPC because that doesn't handle late join or relevancy properly
Understand. Thank you!
Anything "stateful" must be a replicated prop - otherwise only pain can result
how should i make the player control a character in one map and a ship in another map? should i have 1 player controller for both cases or 1 for each? is the server part of the game mode or the game mode part of the server?
Unsure what you mean exactly, a player can only be in one server/map at a time
And there's only one controller per-player in the Server
So when you spawn into the new map you can override that i believe its choose spawn point or something along those terms.
The GameMode is on the server, but you can get to it through the PlayerController
if 1 player change from controlling a character in 1 map to a ship in another
eg, run a server event on the controller to call to the gamemode
but make a different game mode for the level you want to be a ship
Does anyone know if there's a solution for custom gravity + multiplayer? Looking through UE4's source code, looks like it'll be hard to change
A stupid question, but is AActor::HasAuthority called on the server and on the owning client, right?
@foggy rain can be called on anything, but will only return true on the Server for a replicated actor.
set it up so you would be that controller and pawn. Now you could control the ship with the same player controller, but it might be a little clunky, so you might want to change them up. however i don't believe you can change player controllers mid map. So you have to use the same controller for both pawns.
If you tear the actor off, or the actor was spawned client-side, then the client has "authority" over it.
Oh, right, this is what I asking. So it's equivalent to GetWorld()->IsServer()?
does that mean that i can change the game mode without disconnecting from the server? if not where should i start the server?
Not the same no
Got it!
HasAuthority means the local game has full control over that actor, IsServer literally means the current instance is the game server
Sometimes you need to use a mixture of HasAuthority / GetNetMode
NetMode will tell you specfically whether the current game instance is a server (and which type), client, or standalone.
@foggy rain Anything that is underneath the ownership of a client, that client has authority on. So Client A, controls Pawn A, Pawn A get a rock, server has authority on that rock. However if you set the owner of that rock to pawn A, Client A and the server have authority on that rock.
Ownership != Authority
does it not?
"Owner" means you can call RPC's on an actor, but it doesn't mean you have "Authority" over it
So clients "Own" their pawns, but they don't have authority on them.
But they can call RPC's through that actor to the Server
E.g. "make my pawn walk forward"
I'm going to go read then, because it might be the cause of problems.
So client-side, the client would have authority over their HUD and widgets and local-only actors?
yeah
Yes, that's exactly what I thought, thanks!
I have just such a situation. I want to issue abilities (GAS) to the local player and on the server, but I'm only going to subscribe to events about changing statistics on the server. So will use HasAuthority and GetNetMode.
A client has authority over anything they spawned locally, which includes HUD. (Widgets don't have any network functionality [neither does HUD really])
Anything that is replicated, they never have authority for - unless it was torn off (by the server)
Owner / NetMode / Authority etc. all have subtle differences in terms of what they describe
does changing the game mode disconnect the server?
You'd have to "travel" to a new map to change game mode
thanks
I have one more question about architecture. I use GAS and have a health attribute. Should I check for a "death" only on the server and then replicate the event to clients?
(Not sure, maybe I should ask it in #gameplay-ability-system?)
When it comes to GAS specifically I'm not sure, but most likely yeah.
Should I use RPC to call the "death" function on a client in this case?
It depends really
If you want to replicate some specific death event information, then it's one of the few good use-cases of Reliable Multicast
Since you can ping that off before calling 'Destroy' on the Server, so clients have everything they need to handle the "death" locally before the actor is destroyed for e.g. (the reliable event is garaunteed to be executed before the actor is destroyed client-side)
If the actor just needs to disappear when it's "dead", then that'll be handled automagically when you call Destroy on the server
I just need to play animation. Is this fits this use-case?
a pawn with floating pawn movement component with all replication boxes checked doesnt replicate as well as a character, how to make it work?
@naive elm only the character class has full network support by default
does that mean that those boxes are there just because inherintance from actor but not intended to work?
Well it does "work", but ony the character implements advanced movement stuff for networking such as prediction/smoothing etc.
And that stuff is pretty complex
But sort of a requirement for having good networked movement
Most people just heavily adapt the character class to do what they need for floating pawns etc. It's not ideal but can be enough.
Epic are improving this but it's not ready yet, probably won't be in fully until UE5
that makes me wonder what im doing wrong, i always make the server movement replicate but not the client when i check the boxes
i studied the alternative but i have problems with collisions
"Dead" can be a tag
Or a gameplay effect or whatever
You could have an OnRep bool for the death and assuming that you donβt destroy actors so you can reuse the character actor than you can then do client stuff in the onRep function
So many ways... Thanks :)
Youβre welcome
@foggy rain if you're gonna use GAS, try to phrase things in GAS terms and use the system when possible.
I am currently making some UI for my multiplayer game (your player's health for example) where there will be a listening server(don't really know if that plays a role). I am currently Creating the widgets for each player on each game instance. Should I be creating them somewhere else? Where is the best practice to create the Player's UI?
HUD blueprint begin play
oh so that's where HUD is used
UI is local only, being a multiplayer game doesn't matter.
I mean I called on the player controller of the listen server and it threw me an error. The CreateWidget
That sentence doesn't make any sense.
Use the hud begin play , itβs called once the client has loaded in
probably
It does
Just needs more clarification
Like the actual error
But Iβm guessing it had something to do with the controller not being local
yea something like that
Use the begin play in the hud to call your game instance event
Can't I just do it directly on the hud?
You can
the player hud's begin play gets called when the controller is spawned?
Also there seems to be a DrawHUD function in the Player HUD. Should I just override it and call my CreateWidget() there?
No, draw HUD runs every frame
I am now calling the CreateWidget function in a class that derives from AHud and it throws this error: UserWidget.h(1467): [C2338] The given OwningObject is not of a supported type for use with CreateWidget.
Can't I call this function in the HUD?
emm.. Nothign
you mean on the template or the paramaters?
on the paramaters i passed this
AHud should have some get owning player controller function , pass that
@manic terrace
oh ok thx
Np
Guys, i need an advice: I'm changing the ViewTarget of both players, the one who is hosting the session and the one who is joining, in an overriden GameState::OnRep_MatchState. The problem is that the ViewTarget of the player who is joining wasn't changed. I read the logs of both and what I saw is that GameState::MatchState transition process only happens in the server (it makes sense to me, because "the game is running in the server", so no MatchState transition should happen in the client). So my question is: is there a better place to change the PlayerController::SetViewTarget, guaranteed to be executed in both Clients? I think somebody once told me that PostLogin isn't a good place to do this, maybe in the PlayerController::BeginPlay?
Hi everyone, if I want to replicate the position of a NPC moving from point A to point B. Is it better to
A) Call a timeline on the server and multicast the position of the npc every frame during the timeline
B) Multicast the 'start timeline'
@twin juniper just have some sort of variable representing what their view Target should be and use an on rep on it. Or just use a replicated event for the payload. I prefer to keep everything as state driven as possible so I just have an enum that drives view targets
Hello! I am trying to replicate two booleans and expose their values to my anim blueprint as a trigger for my turn in place animation
But I cannot get it to work on my client
Basically I have this piece of code to decided If I should be turning right or left
In my anim blueprint
I get those bools from my character and set them
then I use them in my state machine to decide if I should play my turning animation
When my server character turns it works correctly from the client and server views
but when my client character turns I can see it on client , but not on server so I don't think the booleans are being replicated
are you actually sending the booleans through ServerRPC to the server?
otherwise there is no way it will work
Thanks for replying! I don't think I'm doing that, to be honest i'm not exactly sure what that means. Do I need to do a rep notify function in c++? Or set up some function to tell the sever I'm updating these booleans in the blueprint?
The variables are always replicated from server to clients. You should send the input value to the server through ServerRPC and then the server have to set these bools. Then the server will replicate those bools to all other clients. Here is a link to RPC documentation:
https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/Actors/RPCs/
Designating function replication across the network
Thanks for your reply. I'm still a UE4 newbie, so let me ask you this: I understand that any UPROPERTY marked with ReplicatedUsing= will be replicated when its value is changed and a callback (OnRep) will be executed... Are you saying that I should use a ```UPROPERTY(ReplicatedUsing=OnRep_MyViewTarget)
AActor* MyViewTarget;
UFUNCTION()
void OnRep_MyViewTarget();
...
void MyClass::OnRep_MyViewTarget()
{
//Change the PlayerController ViewTartget
PC->SetViewTarget(MyViewTarget);
}``` and change the MyViewTarget value in some place inside my code? Also, I read somewhere that, since replication occurs when sending data from the server to the connected clients, the OnRep is executed in the client, is that right, right?
I don't know what it'd look like in C++ but yeah, that's the general idea. It depends on your game setup. I have a replicated Enum that I use to drive all sorts of stuff
Thank you so much trying stuff out right now!
Fixed it! Again thank you @empty axle you probably saved me hours!
yes
Hey all, I need help with a clothing system for my game. I want to assign skeletal meshes to table rows (each mesh has it's own id) and then assign the skeletal mesh according to it's ID (the meshes icons are loaded as a hotbar in the character maker level) upon clicking on the meshe's icon
you will have to change it on the server and dont forget to call the function on the server (if you are using a listen server model) because I dont think c++ calls the on_rep on the server
this does not seem like a question
are you asking someone to show you how to set it up, or do you have a specific issue ?
and probably unrelated to multiplayer channel as well
No, it's related. I'm using REST API to connect to a mySQL database to store the ID of the mesh that's being used
and my specific issue/question is that I am manually loading the skeletal meshes in, instead of having them load from an array, for example
if the rest api works then it still isn't
manually loading ?
id, imagine you would have some kind of clothing component that would load the required Ids from a data table and spawn some clothing actor that would set everything up
@dark edge @foggy idol Yes, I'm using a listen server model. So what you're saying is that I must make verify the authority of the machine changing the value of the property MyViewTarget, for example ```UPROPERTY(ReplicatedUsing=OnRep_MyViewTarget)
AActor* MyViewTarget;
UFUNCTION()
void OnRep_MyViewTarget();
...
void MyClass::OnRep_MyViewTarget()
{
//Change the PlayerController ViewTartget
PC->SetViewTarget(MyTargetViewTarget);
}
void MyClass::BeginPlay()
{
Super::BeginPlay();
if(GetLocalRole(() == ROLE_Authority)
{
MyTargetView = NewTargetView;
}
}
Or are you talking about this: ```UPROPERTY(ReplicatedUsing=OnRep_MyViewTarget)
AActor* MyViewTarget;
UFUNCTION()
void OnRep_MyViewTarget();
UFUNCTION(Server, WithValidation, Reliable)
void ServerRPCModifyViewTarget(AActor* ViewTarget);
...
void MyClass::OnRep_MyViewTarget()
{
//Change the PlayerController ViewTartget
PC->SetViewTarget(MyTargetViewTarget);
}
void MyClass::BeginPlay()
{
Super::BeginPlay();
if(GetLocalRole(() == ROLE_Authority)
{
ServerRPCModifyViewTarget(NewViewTarget);
}
}
bool MyClass::ServerRPCModifyViewTarget:Validation(AActor* NewViewTarget)
{
return true;
}
void MyClass::ServerRPCModifyViewTarget_Implementation(AActor* NewViewTarget)
{
MyTargetView = NewViewTarget;
OnRep_MyViewTarget();
}```
Should I send a RPC to the server, to execute the OnRep? Isn't the first approach enough, since I'm changing the MyViewTarget value? Also, when you say I must change the value in the server, are you talking to do a role verificationm when changing the value, right?
this wrong because you have already established that begin play is being called on the server
this is correct
just make sure to call the OnRep function after setting the vartiable (Because its C++)
im having some issues with server travel, after a server travel none of my player controller functions are being called at begin play or OnPostLogin. Anybody had this issue?
OnPostLogin will not be called for server travel
I just found it, i am trying handle starting new player
on blueprint
there is also PostSeamlessTravel tho its C+ only
HandleStartingPlayer worked. I also saw GenericPlayerInitialization and the PostSeamlessTravel for c++. Which would you recommend for efficiency? Or does it really matter much?
I spawn some widgets and the HUD and that's pretty much it
oh i do that in the player controller
my AHUD class
handles all HUD widgets
(even umg)
so nice and keeps it all in a nice place
need a hud widget? i know i can access it from my games AHUD class
I have the function for spawning the widget in the player controller but I was calling it OnPostLogin before changing it to the HandleStartingPlayer
So should I write the function in the HUD class but still call it in HandleStartingPlayer? Or how else would I tell it to add the widget when the new map loads up?
we do it on BeginPlay in AHUD
controller is valid, viewport, etc
this gets called automatically
but if you require pawn, etc to be ready, then you need to handle those cases
Ahh okay I see. That makes sense, Im gonna switch all my widgets into the HUD class
Thank you!
kk, I'll do that, after taking a shower. Thanks @foggy idol and @dark edge !
I want to perform some logic in an ACharacter only once, would this be the right way of doing so? Because if I don't do this check the logic would be performed per each ACharacter of this class, and I only want to perform it once for the ACharacter/Pawn the local client controls
but I'm getting weird results, so I don't know if this is the right way of doing what I want
IsLocallyControlled
avoid GetPlayerController by index calls
they dont work as you expect in multiplayer
massive anti-pattern
Is it going to work for blueprints integrated project??
Unfortunately, it didn't work. Trying to figure out this thing for a couple of days now, without luck. I don't know what I'm doing wrong, or I'm forgetting something out of my scope of knowledge. Here is the old code (I tried to do it in the GameState::OnRep_MatchState): ```// Fill out your copyright notice in the Description page of Project Settings.
#include "PongGameState.h"
#include "GameFramework/GameState.h"
#include "Kismet/GameplayStatics.h"
#include "PongGameplayMode.h"
#include "PongGameplayController.h"
#include "PongCamera.h"
APongGameState::APongGameState()
{}
void APongGameState::OnRep_MatchState()
{
AGameState::OnRep_MatchState();
UE_LOG(LogTemp, Warning, TEXT("The game state has changed."));
if(MatchState == MatchState::InProgress)
{
APongCamera* MainCamera = Cast<APongCamera>(UGameplayStatics::
GetActorOfClass(
GetWorld(),
APongCamera::StaticClass()
)
);
if(MainCamera)
{
APongGameplayController* PlayerController =
Cast<APongGameplayController>(GetGameInstance()->
GetFirstLocalPlayerController());
if(PlayerController)
{
GEngine->AddOnScreenDebugMessage(
-1,
10.f,
FColor::Green,
TEXT("Player's point of view changed.")
);
PlayerController->SetViewTarget(MainCamera);
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("There is no camera in the level."));
}
}
}```
And this is the new code ```// Fill out your copyright notice in the Description page of Project Settings.
#include "PongGameplayController.h"
#include "Kismet/GameplayStatics.h"
#include "Net/UnrealNetwork.h"
#include "PongCamera.h"
#include "PongRacket.h"
APongGameplayController::APongGameplayController(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bReplicates = true;
}
void APongGameplayController::BeginPlay()
{
Super::BeginPlay();
SetInputMode(FInputModeGameOnly());
APongRacket* ControlledPawn = GetPawn<APongRacket>();
ControlledPawn != nullptr ?
GEngine->AddOnScreenDebugMessage(
-1,
10.f,
FColor::Cyan,
FString::Printf(
TEXT("Is controlling a %s pawn."),
*ControlledPawn->GetClass()->GetDescription()
)
) : GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Cyan, TEXT("No pawn controlled."));
if (GetLocalRole() == ROLE_Authority)
{
APongCamera* MainCamera = Cast<APongCamera>(
UGameplayStatics::GetActorOfClass(GetWorld(), APongCamera::StaticClass())
);
if(MainCamera)
{
ViewTarget = MainCamera;
OnRep_ViewTarget();
}
}
}
void APongGameplayController::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(APongGameplayController, ViewTarget);
}
void APongGameplayController::OnRep_ViewTarget()
{
GEngine->AddOnScreenDebugMessage(
-1,
10.f,
FColor::Green,
TEXT("Player's point of view changed.")
);
SetViewTarget(ViewTarget);
}```
Here is a video, presenting the result of the new code: https://youtu.be/I0hp4FRGJ8A. The first player view target changes to the static camera I have in the map, while the second player view remains the same, I mean, the view of the camera component that his Pawn has.
The ViewTarget variable is a UPROPERTY(ReplicatedUsing=OnRep_ViewTarget), and I'm overriding the AActor::GetLifetimeReplicatedProps() method in the .h.
Yes it is
Might also make sense to go to your PlayerController class and disable AutoManageViewTarget. Maybe that breaks stuff
Generally a good test would be delaying all of this by a few seconds. If that makes it work then your code might be colliding timewise with something else
(don't use a delay to fix it of course! Only to debug)
Not sure if the variable was called AutoManageViewTarget but something similar
Let me check that
@thin stratus It was the bAutoManageCameraTarget all along. I set it to false and the view target for the second player was changed correctly, thanks π
Yeah then it's probably a timing issue
race condition?
Possessing the players pawn probably overrides your viewtarget
At least for the client
Yeah most likely a race condition
Thanks guys!
Its possible. I will try to delay the SetViewTarget to see if, just to see if works without the AutoManageCameraTarget π
I usually use the PlayerCameraManager and just supply it with the location and rotation of where I want my camra to be
Can't recall the function you can override atm
But I basically determine my current camera viewtarget via my own function, e.g. By checking the MatchState, if the Player has a Pawn etc. And based on that I return location abd rotation of cameras in the level or similar
But it's also a bit more involved setup
I will read the PlayerCameraManager class, to see how to improve my code. And I used a FTimerhandle to define a delay of 2 seconds and it worked fine, without the usage of AutoManageCameraTarget, so the view target is being overwritten when the player possess a pawn, aka there is race condition happening. I'm thinking to use OnPosses to change the camera view.
@foggy idol, there is something you said earlier that worked, but its not mentioned in the UE4 page about property replication: I thought, after reading the replication page some days ago, that OnRep functions associated to Replicated variables would be called automatically when the values of the same variables changes. At least this is the idea the page presents.
i have some custom NetSerialize code that needs to serialize another struct inside it, which i want to do with the default serialization
is there a way to call NetSerialize on USTRUCT that i didn't define custom serialization code for?
You can't do default serialisation on it, but you can use it's UScriptStruct class to serialize it
Question please. I'm working on a sort of persistent universe game. I was wondering about storing things like player data. For things like the player's current health before he logs off the game. Where do I store that health so that when he logs back on his health is set to that current health?
Is there some built in feature like the save game or do I have to use some sort of external database to store that data and load it back in when the player logs on again?
You would have an external database usually yeah.
Also, on a related note. Can anyone link some resource that tells exactly which actors(player controller, player state etc.) are destroyed when a player logs of the game.
As well as the connection between server game instance and client game instance. Thanks
The network compendium is good but it doesn't answer some of my questions
Ahh. I see. Thanks
I it really necessary to manually call an OnRep, even after the replicated variable value is changed? Like this```void APongGameplayController::BeginPlay()
{
Super::BeginPlay();
SetInputMode(FInputModeGameOnly());
APongRacket* ControlledPawn = GetPawn<APongRacket>();
ControlledPawn != nullptr ?
GEngine->AddOnScreenDebugMessage(
-1,
10.f,
FColor::Cyan,
FString::Printf(
TEXT("Is controlling a %s pawn."),
*ControlledPawn->GetClass()->GetDescription()
)
) : GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Cyan, TEXT("No pawn controlled."));
if (GetLocalRole() == ROLE_Authority)
{
APongCamera* MainCamera = Cast<APongCamera>(
UGameplayStatics::GetActorOfClass(GetWorld(), APongCamera::StaticClass())
);
if(MainCamera)
{
ViewTarget = MainCamera;
OnRep_ViewTarget();
}
}
}```The documentation presents a idea that you SHOULDN't manually call it
The replicated variable is ViewTarget
You never call an OnRep manually, unless for some reason you want it to run on the Server.
Yeah, if I execute the code without it, the scope inside the OnRep isn't executed, even if the replicated variable has its value changed, I'm still trying to understand it, since the documentation don't require a manual call
OnReps are never called on the Server unless you call it yourself
thanks! do you know if there are any gotchas to using UScriptStruct::SerializeItem to send data over the network?
OnReps are called automatically ClientSide
@spark stag well you will lose per-property serialization, so the whole struct will be sent everytime (or rather, whatever you write in NetSerialize will be sent everytime)
You lose per-UPROPERTY replication
@chrome bay, thanks, but whats the reason behind the fact the OnRep isnot being executed without a manual call?
Because OnRep is a callback for when something has replicated to a client.
Nothing ever replicates to a Server
In Blueprint it's different because Blueprint is stupid
The only reason to call an OnRep manually is if you want the same function body to execute on the Server - that's it
The Client will handle calling it automatically, that's part of the engines' replication system.
ViewTarget btw is something that is already managed locally in quite a few places by the engine (the pawn is always the viewtarget by default)
So I'd be careful about replicating it, because you'll probably be fighting the engine in some places
There's already some network code for changing view target, which is handled via RPC's
Thanks for the explanation, but this is frustrating: the documentation lacks more information about it, and you have to look deeply inside the engine to find something to help you to solve a problem like this one, or get some advice from people who already know the engine
Cedrics compendium explains stuff pretty well I think, that's pinned in this channel so it's worth a read. There's definitely a lot of poking around you need to do, UE is a huge toolset so it's impractical for them to document everything when you can look at the source.
I think Epic's biggest failing though is making Blueprint behave differently to CPP to be honest.
It just makes it more confusing for someone moving from BP->CPP, and if you're used to CPP you have to remember all the weird stuff BP does. Unfortunately it doesn't look like they fixed that in UE5 either.
Hi everyone, I'm working a multiplayer project where the core concept relies on pretenting to be a NPC. NPCs have movement patterns, and as a player you have to replicate them to hide from other players.
This of course can only work if all movements are perfectly replicated without any jittering, which is what I'm struggling with.
The NPCs move with timelines and their movement are perfectly smooth on each client. While the Player characters move with the default character movement component (on listen server with the Steam plugin), and though their movement is relatively smooth, it's far from being as smooth as the NPCs. (the movement of your own character is smooth, but other player's movement is not)
- Is there any parameters in the character movement I should tweak to make the PC movement more smooth ?
- I read about the Smooth sync plugin, would that help fixing my problem ?
Hello , does anyone knows why PixelSTreaming comunication doesnΒ΄t work in multiplayer? when the package is in client mode the pixelstreming events doesnΒ΄t work anymore...
Hi, what is the best way to send pawn rotation to the server, if it is not determined by controller rotation or movement direction?
RPC
RPC every tick, that's no big deal?
As long as it's unreliable, no, it's the only way to have movement
I guess I only have to RPC when it changes too. Thanks!
So the simulated proxies can face the right way.
It's controlled by an axis input that is separate from the controller rotation, kind of like a twin stick shooter
right...
but in twinstick shooter, you normally use control rotation?
or is it done via mouse location?
I'm using controller rotation for camera rotation... I've been second guessing that a lot though
your camera is seperate to pawn right?
I have the camera and spring arm on the pawn
top down game?
we use control rotation here
and we have a separate observer pawn
hmm, a second pawn... that's in the top down template?
not sure, π
our player controller possesses observer pawn, our player pawn is possessed by AI Controller, then we set up references, and link them, not really easy to do that in BP only.
thing is
camera is local, other clients don't care for camera
so you could just handle camera rotation manually
and not have it move with the control rotation
ah ok. I have bUseControllerRotationYaw = false set on my pawn, seemed like the easiest way to separate those
and leave the control rotation just for the pawn
this will save you needing to rpc rotation every tick
simulated proxies only care for where you pawn is looking, not your camera
yeah that's a pretty good argument for keeping the controller in charge of pawn rotation...
One thing I've never quite figured out, is control rotation some special rotation that is automagically kept in sync or is it really no different than if you just made a rotation variable and synced it?
Well, I know I have discussed this with @foggy idol , @dark edge and @chrome bay, but I guess I found the reason you must do a manually call for a OnRep_ in the server: the a RepNotify is automatically called in all connected clients, but, apparently, if you have a local client (aka a listen server), the RepNotify isn't called automatically and you must call it manually, first verifying its authority and then verifiying if its a listen server. Here: https://forums.unrealengine.com/t/repnotify-from-c-confusion/3327/10
Ah just saw this thread again, apologies for missing your original question, TheJamsh! Could you provide a little more detail here? Do you mean that the RepNotify functions arenβt called on the server? Thatβs a difference in C++ vs. blueprints, the RepNotify functions are not auto-called on the server/net-authority (and must be manually done, ...
That's not the way RepNotify works in a BP scenario, where the RepNotify is called automatically for both clients and server.
It sucks, but now I know the reason, don't know why the replication system only considers the connected clients and leaves the local client out thou T_T
That makes me think, what happens in Blueprint with a dedicated server? There's no local client, I wonder what it does.
@twin juniper well its because a listen server isn't a client, it is the server.
Nothing is replicating to the local instance because that instance is the server
RepNotify in BP isn't actually a RepNotify
That is what I thoight this afternnon
Is not?
@chrome bay do you know why they made the blueprint version of rep notify fire on the server? Seems like a weird decision
It's just a "this variable has changed" callback. You can change a value client-side and the "rep notify" will even be called ,even though nothing replicated.
BP has a stupid system that mimics repnotify but it isn't actually a true rep notify
Is there an auto magic way to do that for non replicated variables? That would make the state pattern very easy
I don't think so
I don't really know why they didn't make BP rep notify work the correct way, but my guess is they've committed to it for too long to revert/fix it without breaking a lot of peoples' projects.
T_T it makes me cry they did a wrong decision and now its too late to change it
I thought that a listen server was both a server and a (local) client, in the UE scenario. There are so many tutorials and threads telling this, so they're wrong
It is a server and a client
Referr to Cedric's compendium. pg 52
https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
I think he meant that it's a client that also acts as a server, not a standalone client?
Thanks for the reply! I have read that and the same thing on other pages
unless there's some magic happening behind the scenes, and its much easier for us noobs to think of it as a client/server?
π€·ββοΈ
@chrome bay told us above that a listen server isn't a client at all, so I guess I have to look deeper in the source
Yes, it is, by definition, running in a residential connection of the host
interesting.. rabit hole gets deeper then
But I don't know (yet) why he/she told us the listen server isn't a client, so I have to study this subject a little more
By definition, in a listen server, both the client and server run in the same process. I have to see for myself how it works in UE4, here is a good article telling the basic difference https://www.gameskinny.com/pqdqx/dedicated-servers-vs-peer-to-peer-connections
It might be more accurate to say that in a listen server environment, the process is the game server and there is also a local player.
^
When people say a listen server is a client and a server they're not talking from a networking perspective, they're talking from a player's viewpoint.
The engine isn't literally sending networking data to loopback for a listen server
Yeah, I guess so
also just from the title I can tell you that article isn't relevant
Unreal does not use P2P
client/server networking and P2P are entirely different concepts, a listen server is still client/server networking.
I know, there is no hierarchy in a P2P environment
I guess they messed up the title
No, that article is correct. It just isn't relevant to unreal's networking.
He's just saying that people uses the term P2P when they should use listen server
Both terms map to very different things
Yeah, he is telling that in a P2P environment, the data passes from a node to another, without the necessity of an authority. Isn't not the case of the UE4, like @hollow eagle said
I think we're all agreeing here.
P2P != listen != dedicated
they're all used, but only listen/dedicated are relevant to unreal's built-in networking.
That'd be custom.
thought so, but wasn't sure
I've not really worked too much with listen servers, but what's stopping the hosting client from cheating?
since they're technically the authority
nothing
Listen server is just that, a server
There's a reason you don't find listen servers as the default mode of operation for competitive multiplayer games. That and network quality.
Consoles could do it a bit more safely but it's still iffy... and then you have to worry about possible performance issues with being the host and a client.
Depends on the console
how difficult would it be to launch a dedicated server alongside the client if you wanted to host a session and have all the clients connect to that? Similar to a listen server, but secretly it's a dedicated server.
that's no different, you're just wasting resources
Didn't COD use listen servers for awhile?
how is it not different? The client that's hosting would just be a client. The would host the dedicated server on their machine, but the wouldn't be the authority, that exe would be
you're still running a server on an untrusted machine
true
Anything happening on client-owned hardware is unsafe and unreliable
On some consoles, less so
On PC, it's not even a debate
if i destroy an actor on the server with the Destroy() function, what happens if a client calls a server side RPC? can it lead to problems?
These days listen servers exist primarily for co-op and selfhosted (non-matchmade) games.
like the actor still exists on he client after the destroy was called, till it replicates its destruction i assume.
The server should ignore the RPC. The actor doesn't exist, so the RPC won't execute.
But if one node fails. the entire environment would be compromised, There is solutions for that ,but would worth it?
That's why back in the day you had host migration in some games.
so i won't get a you are nuked error message? π
I don't want to use P2P, it was more of a knowledge question
Losing a node in a P2P scenario isn't really catastrophic anyway - every client should have a complete view of the world. This isn't a distributed system where each client only knows a small amount about the game.
Host migration was more about choosing a single client that is the authority and actually decides on what happens when there's a conflict.
yeap
Mainly because a listen server relies too much on the machine ping and connection latency, giving the local player advantage
that too
Outright cheating
It's about network quality in general (not everyone has a good enough network to host), it's about not trusting clients, it's about having a server in a fair location for the group of players in a match.
Too many variables
If you're worried about anything remotely competitive, listen server is simply out of the question
Every cheat on the planet will work
Is there a good source about how to raise a dedicated server using UE4? I'm not talking about a master server, that would require programming outside the engine
π€·
T_T why are you so mean?
You're doing dedis, your network team can afford to look things up
It's not like it's some kind of arcane knowledge
Lots of people do dedicated servers
I guess isn't, but when you're a UE4 freshman like me, you're prone to fail... a lot
If you are an UE4 freshman you have no business doing dedicated servers, it's a realllly bad idea
I mean, doing multiplayer stuff in the UE4, but since I'm middle age, I must learn things more faster than the younger people. They're have more time to spend than me
I don't the privilege of learn things in a slow pace
I'm not questioning your ability to learn. I'm saying dedicated servers are a bad idea :
- you need them either because competitive game (do you have a report system ? anti cheat ?) or a game with a lot of players (how many zeroes to your marketing budget ?)
- running and maintaining dedis is expensive in a world where the average Steam games makes less than $1000
Just my 2 cents, feel free to ignore
No, what you said makes sense, these are questions related to the nature of the game, that you must do in the pre-production phase. I just asked because I must learn how to code a dedicated server in UE4, for learning purpose. I don't need to code one right now, maybe in a near future XD
@twin juniper I would recommend a listen server design. It's self scaling and MUCH easier to do.
Dony make your first game a dedicated server design.
Thanks, I have coded a basic listen server environment, using my GameInstance, that I must improve by demand. And I agree with both of you two, for a first game its not recommended
Don't make any game not funded by a publisher with a dedicated server design
If you don't want to call bankruptcy
if you don't want empty servers*
I guess my budget will blow up first
The only way I would recommend dedi is of you were going for a community hosting model like Valheim or GMod
I wouldn't, because these are two wildly successful games. Most games on Steam will never fill a dedicated server on launch day
Makes sense, indie developers don't have enough firepower to do a monstrous marketing campaign
Even with patreons, kickstart donations etc
Well yeah but those are listen as well. Just has the option of dedi. I would never go dedi only, that's a recipe for DOA
^
My thoughts as well but hey, if you have a serious publisher beyond you, go ahead
I guess I must present you one of my friends, who is starting a Diablo clone in Unity, he's thinking too big and wants me to do the LD for him
We all think too big, some of us just manage to get small enough to release eventually
We are architecting our game to be as smooth as possible and seamless between playing solo and playing multiplayer. Basically the only difference is "your friends are here too"
It helps to have a co-op design and not strictly competitive. HUGE competitive games launch and die all the time. It has to have legs on its own and not just rely on other people being around.
coug hcough anthem cough
Notice I didn't say good lol. Although good games die too, like Dystopia (a source mod that had incredible gameplay but is dead now)
I have heard, but I never played
Remembers me the catch phrases found in The Art of Game Design book
Dystopia was a class shooter with a dual layer map. Basically some players could "jack in" to a Tron/Quake style cyberspace map and open doors, arm turrets, etc. And players in meatspace could affect the Cyberspace map by destroying firewalls and affecting it's layout. Very interesting design.
Its a very interesting design indeed, I wish I could play it =\. And right now we have a lot of similar games, like Medium (but still, the player controls two characters at same time, in two maps, and there is no multiplayer, but would be nice to have a terror/horror game like Medium where connected players affect the world of each other, maybe a Silent Hill game with a multiplayer module, where the people have sins that could be related to each other? It could use character backgrounds like the one we did when playing Vampire the masquerade/ Werewolf the Apocalypse, reflecting our sins and having an impact on other worlds)
hello somebody can tell me What I`m doing wrong. IΒ΄m testing a multiplayer and I want penalise an specific player by hiding and disabling their input. IΒ΄m doing the login in the game state by calling a function that does what I want it. Also I tried to implement the function on the game mode without success. How can I get this function work?. I tried also too many possibilities with run on server and multicast events but I never succeeded
You cannot pass PlayerControllers through the network like that.
PlayerControllers only exist for each Player.
The Server also has a list of all PlayerControllers.
Other Players do not have each others PlayerControllers.
Pass the PlayerState instead, the PlayerState represents another Player to other Players.
ok Devils IΒ΄ll try it, thanks for replying
hey, I want to change maxwalkspeed in c++ when player boosted, so i defined "isBoosted" bool that changes by input pressed and released actions, but it is toggling while pressing and make lagg in animation . anyone can help?
Are you actually replicating that boolean properly?
The Boolean has to be a RepNotify variable. Then MaxWalkSpeed change has to happen in the OnRep. And if a Client pressed the key you will have to tell the Server to also set the boolean.
And on top of all of that, this is not even the 100% correct way of doing it, as this should go through the CMC in an optimal situation
yeah, i made mistake in replicating
is there any complete tutorial about unreal multiplayer ++ ?
i'm new in that
Hi!
I know that it's maybe dumb question, but I think I don't quite understand it.
I have a Character, which is driven by AI Controller. I have behaviour tree with task like "Move To" (default Unreal). On server looks ok, on client also BUT - there is problem with rotation.
Rotation is choppy and looked strange, after few secs it becomes normal (like on server).
I have similar problem with Pawn, but driven by Player, and I ended up with custom replication of movement vector.
Does Character haven't smoothing of rotation? I see it works in e.g. First Person Template, but rotation was driven by mouse, not AI.
If it has, how to handle such case? Change replication priority or interval?
Hey, so I have an FPS game and I want to implement a multiplayer, I want to have dedicated game servers for each game.
So I was wondering, can the server handle all damage, etc?
Or GTA Online peer2peer lobby cheats.
thankss
Google UE4 replication and go from there.
When I have a UPROPERTY(ReplicatedUsing=SomeFunction) it will act like a UPROPERTY(Replicated) and also call the function I have specified?
Hey guys, which networking library to you recommend ? For just multiplayer shooter or something
oh sweet
I'd like to adapt the Collaborative template from Unreal Engine by adding additional buttons to the Contextual Menu. I'm looking into the existing blueprints, though I'm struggling to understand how the list of buttons is populated.
If anyone already went through a similar process of adapting the Collab template, I would appreciate some help.
Nevermind, I think I just found out π So, I'll just take the opportunity to say Hi!
Is it hard to set up a dedicated server on my pc for my game?
Harder to build than just run game as dedi
But not too hard
whats the easiest way to test my game with others? i tried with steam subsystem but it works like twice the week , i think it has to do with the servers , btw i tried hamachi for lan connection but it didnt work
Steam is the easiest by far
Combined with a private itch.io release so that people have automatic updates
yeah but steam doesnt always work for me
for some reason
at first it worked after many times i tried it it didnt and it worked again for one more time , but thats it it didnt worked again since then and i think it has to do with the servers because i didnt change anything in the code
I'm doing a IsLocallyControlled check, and then when I try to access the ACharacter::InputComponent the InputComponent is null
any idea as to why is it null?
If you can narrow it down to more than "doesn't work" it might be possible to help
Well it worked before twice and it stopped working without changing anything , if i close steam and host - join locally it works fine
Yeah, you didn't start your game from Steam
Or failed to provide an appid.txt file
i only get that error in ue4 not in the built version
you cant connect to steam from editor
^
only launch game/packaged
And while packaged in shipping, only with an appid.txt file, or when actually started from the Steam client
Editor will never have any OSS feature
also if you using 480 id, i always had issues with that
Yes
best to get a proper id
(if you get session issues, etc)
what do you mean a proper id?
Does the built version work ?
π€
well
Yeah, confusing statements all around
in the built version
you cant connect through steam
but if you close steam you cant connect localy
i can even send you the built
you need to run with -nosteam
its really small
if you want to disable steam and use without steam
i dont want to i just tested it
Did you test with two different Steam accounts logged on two different Steam machines running the same game, with an appid.txt file, does shift + tab open the Steam overlay on both
@meager spade sorry to bother, taking advantage that you're around, this is inside an abilityTask, it worked before
yes i did
wait
what do you mean
with appid.txt file
@twin juniper hmm, need some context π
i did everything else except that i think
"yes I did" - I asked more than one question there
the appid.txt file should contain your appid, in ProjectName/Binaries/Win64 in packaged folder
Does the Steam overlay work on both machines ?
Yeah
Because if you did not start the game from Steam, Steam requires this file to identify the title being run
At least in Shipping mode, but hey, doesn't hurt to try
so i have to add the game as a non steam game and run it through there?
Yeah, or just use the appid file
kk i will test it and let you know
@meager spade @bitter oriole i tried running game trhough steam didnt work and creating this "steam_appid.txt" file
didnt work either
should i create that or it should be there automatically
btw once i created the file opened the game and closed it
the file got deleted by its self
You should create it, and I've never seen that get removed
i created it with the exact same name and i dont think that windows defender or fire wall would delete a txt file
will do now
@bitter oriole i tried it on 3 different computers and it deletes it when the game closes
cant find anything useful in the logs
No Steam API disabled or anything ? Any mention of net driver ?
i can send you the log if you would like to check it out
i didnt find anything
Sure, put it on pastebin
@bitter oriole thanks for helping me really , but i have to go now i will be back in 2 hours if you dont have any problem i can tag you and see if there is anything we can do
Looks fine, you should add logs in your session system to find out what happens
void AFFAHUD::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); if(HasAuthority()) { UE_LOG(LogTemp, Warning, TEXT("test 1")); } else { UE_LOG(LogTemp, Warning, TEXT("test 2")); } I have this Tick on a HUD and I am getting only the test 1 output. I have one listen server and one client. And the test 2 doesn't get printed out. What could be happening?
HUD only exists for local client, so will always have authority. What are you trying to achieve?
I am trying to update my HUDS with a replicated TArray<> I have on the GameState
But no luck yet
so in the HUD you want to run some code but only if it's not the server?
@manic terrace onrep, get HUD, profit
that's what I tried but it chrashed on me
let me show you
That is if get HUD can fail gracefully, you have a dedicated server?
no I have a listen server
` UPROPERTY(ReplicatedUsing=OnPlayerDatasReplicated)
TArray<FPlayerData> PlayerDatas;
UFUNCTION()
void OnPlayerDatasReplicated();`
`void AFFAGameState::OnPlayerDatasReplicated()
{
UE_LOG(LogTemp, Error, TEXT("Replicated data!"));
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
if(PlayerController)
{
AHUD* HUD = PlayerController->GetHUD();
if(HUD)
{
AFFAHUD* FFAHUD = Cast<AFFAHUD>(HUD);
if(FFAHUD)
{
FFAHUD->RefreshStats(PlayerDatas);
}
}
}
}`
this to update on the client only. I am updating the listen server's somewhere else
void AFFAHUD::RefreshStats(TArray<FPlayerData> PlayerDatas) { if(PlayerUI) { if(PlayerUI->ScoreHolder) PlayerUI->ScoreHolder->ClearChildren(); for(const FPlayerData& PlayerData : PlayerDatas) { UPlayerStatsUI* PlayerStatsUI = CreateWidget<UPlayerStatsUI> (GetOwningPlayerController(), PlayerStatsSave); if(PlayerStatsUI) { PlayerStatsUI->AddToViewport(); PlayerUI->ScoreHolder->AddChild(PlayerStatsUI); PlayerStatsUI->PlayerKills->SetText(FText::AsNumber(PlayerData.Kills)); if(PlayerUI->ScoreHolder && PlayerStatsUI->PlayerName && PlayerStatsUI->PlayerKills && PlayerData.PlayerController) { PlayerStatsUI->PlayerName->SetText(FText::FromString(PlayerData.PlayerController->GetName())); } } } } }
Don't know if you can make sense
where did it crash?
it used to crash on the PlayerController-> until I added a check for it
now it just doesn't get replicated. Only on the start
I guess at the point you're replicating it the clients PlayerController has not been setup yet?
yea could be but when I RefreshStats again it doesn't work. When I change the PlayerDatas the OnPlayerDatasReplicated doesn't get called
that's strange...
I must have messed up somewhere
unless you are using DOREPLIFETIME_CONDITION(... COND_InitialOnly)
this is the one I use
void AFFAGameState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); // This actually takes care of replicating the Variable DOREPLIFETIME(AFFAGameState, PlayerDatas); }
I don't know why subsequent changes to PlayerDatas would not trigger OnRep
`void AFFAGameState::AddKill(APlayerController* PlayerToAddKill)
{
if(PlayerToAddKill && HasAuthority())
{
for(FPlayerData& PlayerData : PlayerDatas)
{
if(PlayerData.PlayerController == PlayerToAddKill)
{
PlayerData.Kills++;
UE_LOG(LogTemp, Warning, TEXT("Player %s now has %i kills"),
*PlayerData.PlayerController->GetPlayerState<APlayerState>()->GetPlayerName(),
PlayerData.Kills);
}
}
}
if(HasAuthority())
{
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
if(PlayerController)
{
AHUD* HUD = PlayerController->GetHUD();
if(HUD)
{
AFFAHUD* FFAHUD = Cast<AFFAHUD>(HUD);
if(FFAHUD)
{
FFAHUD->RefreshStats(PlayerDatas);
}
}
}
}
}`
this is where a change happens
what does your FPlayerData struct look like?
`USTRUCT()
struct FPlayerData
{
GENERATED_BODY()
UPROPERTY()
APlayerController* PlayerController;
int Kills;
int Deaths;
};`
I'm not sure, but do Kills and Deaths need to be UPROPERTY() ?
For replication, yes
oh ok I will change them. But don't think this is the problem. I am calling a server function on a character that in its turn calls the Die function on the player controller who call the AddKill on the gamestate
Without UPROPERTY() on the int Kills; when you increment kills, the server will not know the struct has changed and will not replicate it to clients who will not call the OnRep
ohhhhhh
You might as well not even have those variables
nps
Hi!
I have a problem with moving Character via Behaviour Tree. I use simple Move To.
Location works fine, but rotation is choppy.
What can I do to have smooth rotation? I use Character especially for that purpose, but I can't get it to work.
I have listen-server game.
@bitter oriole i just came back if you could help me just reply here , thanks
Has anyone tested if advanced steam sessions works on 5.0 ?
It dont work for now
Oh, didnt knew that. Sorry
If I want a client to destroy an actor upon interacting with it, would I call a server event to run a multicast of destroying the actor? Or I guess in better terms how would I go about allowing the client to make changes that happen on the server and which is then replicated to all other clients?
You call a server event and destroy it there. That is all. If the actor is replicated it would be automatically replicated to others
Would it matter if it is from an interface event? Because calling just the server event with the actor replicated still does nothing
Just a basic actor with a static mesh and collision, it is replicated. The custom event run on the server is in the event graph to just destroy actor and print a string, along with my 'interact' interface event which then calls the server event
So it's an actor in your level?
Yes
You are lacking understanding of ownership. Might want to read up on it again via Google or my compendium.
Tldr you can only call Server and client rpcs on actors that the specific client owns. E.g. Playercontroller, playerstate or the possed pawn. As well as actors that either have one of those passed in as owner when being spawned by the server or set afterwards by the server
Due to this, interaction systems should rpc in the character or similar and perform line traces etc on the server side
the client would still initiate the action, but you need to actually execute it from the server
in order for it all to replicate properly
So since I'm not using a line trace for this specific interaction with the actor, I would need to spawn the actor from the server first?
I just fixed it, turns out it was just my silly mistake of not creating server events for my action input on my interaction
For the interaction, I'm using a for each loop with break to get any overlapping actors of class type actor, checking if does implement interface, then calling the interface interact function
On my player character
Right, that was my mistake, I forgot to add that RPC for the server
Thanks for the help!
Hi!
I have a problem with moving Character via Behaviour Tree. I use simple Move To.
Location works fine, but rotation is choppy.
What can I do to have smooth rotation? I use Character especially for that purpose, but I can't get it to work.
I have listen-server game.
Do int64 replicate correctly ?
Is it related to my question? Well, I don't know π€·
I've changed rotation precision to short (16 bits) at it works slightly better only.
@bitter oriole yeah all the different int's replicate okay
Hello , after many build tests of my game the character that joins the host suddenly just started trembling when moving around and i dont know why
How are you doing the moving ?
What would be cheaper to replicate? FLinearColor or pointer to an actor?
pointer to an actor
linear colour is four floats, so 128 bits
actor pointer is a net guid, so 32 bits IIRC (or is it 16.. I forget)
32
Thanks @chrome bay
Guys, just a question: I was reading the how the player movement prediction works in UE3 here https://docs.unrealengine.com/udk/Three/NetworkingOverview.html#Player Movement and Prediction, more specifically in the Player Movement and Prediction section, and I was asking myself where I can find information about the same thing in the UE4. Does anyone know where can I find it?
It's implemented by the character movement component
Looping all PlayerControllers and sending client RPCs vs sending a Multicast
Which one is more optimal?
Depends
Technically, you can't really multicast on a player controller
So usually it's for different purposes
What's the use case?
I'm executing Multicast from another replicated AActor in a Server RPC
Looping all PlayerControllers (FConstPlayerControllerIterator) there and calling ClientPlayAnimShake which is another reliable client RPC
So if it's a multicast, the multicast will only go to players which the actor is relevant for
If it's a client RPC via controller, it'll go to all players you loop through
So that could be quite differnet
Can you not trigger the anim shake locally somehow to avoid the network call altogether?
I'm calling this function from an input event (FireWeapon) so there isnt any place executes locally on other clients yet
But thats fine, our game is very "uneventful" and sending a couple of client RPCs wont hurt
I just wanted to follow best practice if there is any
So presumably, other players would see some VFX or sounds etc when the weapon fires already? Or is that not part of it yet?
If they do, I would trigger it from the same place
We do a similar thing for stuff like tank cannons and big artillery pieces that make the screen shake for players when they're nearby and it fires
I see, I'll check it out, thanks for the guidance π
And that's driven by a "burst counter" in our case (plug: https://jambax.co.uk/better-burst-counters/)
Didn't knew you have a blog, I'll definitely read this now
By the way while you're here, I've been waiting to ask you how you guys handle networked projectile pool in HLL, since for MG42-like weapons you also have client-only visible projectiles (thats what I remember from out last conversation about projectile prediction) do you have two pools like one for client simulation and other one for server?
No pools in our case, the projectiles are just data objects that are created locally
third-party clients don't necessarily receive all of them, but we replicate a "LastShot" struct for each weapon, and when it's Onrep fires it spawns a projectile on that client
It's lossy for remote viewers but good enough for our case
But yeah no actors for our projectiles, just particle systems if anything (which can exist without a host actor)
So the data itself is just a struct (and not a USTRUCT, just native C++). We keep a big list of them in a "projectile manager" of sorts, and keep track of them there as TSharedPtr's.
There's a DataAsset which defines the properties for a projectile "class", and that determines how it should be simulated. So each tick the projectile manager loopsover everything in the projectile array, determines what dataasset to use to update it, and calls the data assets' update function with that data.
I see, thanks for the explanation Jambax, I appreciate it π
I'll do a write up on it at some point, it's pretty cool I think π
Yeah totally would like to read π
Hey im having trouble making a character select screen. So few questions, where should I spawn and possess the pawns, how do I replicate it all properly, and how do I get each individual player controller. because right now only one player is able to possess a pawn at a time or something like that is going on
Thanks @chrome bay!
Hum, I'm reading a tutorial, and the author mentioned the usage of bReplicateInstigator, and how its important to separate server side specific functionalities from client side, but I didn't find in the AActor or ACharacter. Is there any other variable, or isn't used anymore?
If you're reading UE3 docs then they are over a decade out of date at this point
Never seen that property myself
No, I'm reading this one
in the page 6
I tried to find it in AActor*, didn't find it
I know, I was trying to find if it was removed or if it has another name.
but inside the AActor class apparently there is nothing related to instigator replication as a boolean so I assume it was removed?
Well, I believe that, since the APawn* Instigator is marked with ReplicatedUsing=OnRep_Instigator, I believe it does the same thing that the old bReplicateInstigator=true does, but isn't something internal anymore? The only difference I'm seeing is that, now, Instigator replication is always on
Does anyone know the best way to travel from an "online map" to an "offline map" and back to the "online map" again?
Didn't want to disconnect the player from the server, but I definitely don't want to be wasting unnecessary server power
Hello Does anybody know why when I'm connecting to friend session (friend in other network) my level restarts and does nothing, but when I'm using 2 PC's in the same network it works well?
Did you verify the online subsystem you defined in the default engine.ini?
What is it?
I just ran into some -interesting- behavior. I have characters spawned from the server during runtime, and then run a function which turns an Audio Component Fade in and Fade Out. I am updating a variable that is replicated on server. Locally, I'm checking for differences with a non-replicated variables, and I'm getting the following results (rep mode is listen server). What am I doing wrong?
try a ForceNetUpdate()
in your _NR function
I would also throw in a role check there too
so doing a force net update does make the audio play locally... but why was that needed?
the execution of the functions above didn't change; they still show C_0 -> Server, Simulated, C_1 Server, Client
project source control and in-game feature replication have nothing to do with one another π
If you're talking about whether they can get the updated files as you iterate them, #source-control . the short answer is no; they'll only get the updates whenever something is committed and pushed to the remote server.
Hello everyone, I would like to create an hud above an object when someone is looking it. It work well, but when I work on the network the server see what the client player are looking, even when the event is replicated on client only? Here's the event I call to show the UI, really simple
Actor HUD and UUserWidgets* are local only
Hum
RPCs are slow and it could be a bottleneck in your replication rate somewhere else. Even if they're marked as reliable, they'll get there in the net priority order you've set for the class that contains them
It show like that, and it's a widget not an hud sorry
(like this on my actor)
I see. How would you suggest replicating a variable that has to be updated by an InputAxis Binding function from the client?
Advansed steam session, and its defined, we see each others sessions but i cant join , normally it works in my network compiled instanes of game
Anyone got a clue?
What kinda of Warnings or fails do you have in your log file? Is there any fail related to NetDriver? Are you trying to create one in your code?
What's a good practice to use in the place of a RPC?
set the value on the server only, call the OnRep
that's only for changing variables though
if you want to do actions, an RPC is better
This not even prints any errors, its like im in the session but still in menu
Kk also, I was reading the SetReplicateMovement method(), and I saw that it sets the bReplicateMovement to true; but I didn't see anything about the rotation replication... Can I assume that isn't replicated directly by CMC or AActor itself, by default? Or if bReplicateMovement receives true, does the engine deal with the rotation replication in another place? This makes me think about the necessity of sending a RPC to the server, asking to rotate the Pawn inside the server
But do you can travel if you host a session in a LAN? I had a similar problem, and my error was using the same GameMode for both maps.
I have on both levels diferent gamemodes
Thanks, I will search in the Internet for an answer
What you mean by first sentece, that i can host the game?
You said that the Client travels to the destination, when both machines are in the same network, without any problem
Yes client join to server and spawns in the lobby with no problem
Are your OpenLevel options using bIsLanMatching=1?
But when im sending compiled game to my friend somewhere away they cant join/or joining just restart current level
Or ServerTravel options using the same option?
I dont know what blsLanMatching stands for
IF you calls a OpenLevel, you can specify url options, and one of them is bIsLanMatching. =1 is for lan sessions
There is no option to host a lan game, when Steam subsystem is valid lan is setted to false in my case
You can read the GameModeBase::PreLogin() method to see what makes the server to reject the client, since you said that your friend can see the session, but he/she can't join. I don't remember very well what the code does inside its scope
But its just an idea. Something is making your server reject the join request
I, will read that tomorrow, thank for help, I have a friend thats have the same problem somehow
I would start with this method. But ofc, your code could have something that is messing up the request, somehow
I maked sessions systems that many thimes that im in state where i have no idea coz code is easy, have logic and imo its without errors
T_T Its always about something stupid we forget, in the end. I'm always amused by the fact that even the littlest forgetfulness can #$%! our lives sometimes
Haha same but in my case i dont care for now coz now if i can test game locally, im doin map and gamemode, later i will cry about it
@torn bane are you opening the level with ?listen
Try this: When the client is interacting with the object that needs the widget, have the client spawn and attach a widget component to the target object. That way the client owns the widget component attached to the target object.
Of course i do
hey man, some times it's the simple shit lol
T_T x100