#multiplayer
1 messages · Page 651 of 1
This is my first project that is multiplayer and I can't say what and where I am doing something wrong
I have this function to know where is which variable
if is the server or the client
then I send them both in the game character with index 0, that means the server, right?
I set the variables
and check if both are set, I did a simple logic gate and it is always false, which means that one variable isn't setting, but after testing both should be set
I think here is the error but idk how to do it right
What is alternative for OnRep_PlayerState() of Character class when using PIE in standalone.
OnRep_PlayerState is not called in stand alone mode, because in stand alone mode its server.
and other alternative function which simulates same effect
search for what sets the APawn::PlayerState and override that @rich ridge
@winged badger only 3 functions calling SetPlayerState
- UnPossessed
- Possessed -> but called on server.
- onRep_PlayerState
and SetPlayerState is not virtual
{
if (PlayerState && PlayerState->GetPawn() == this)
{
FSetPlayerStatePawn(PlayerState, nullptr);
}
PlayerState = NewPlayerState;
if (PlayerState)
{
FSetPlayerStatePawn(PlayerState, this);
}
}```
that is awkward
but all functions that call SetPlayerState are virtual
so you can just make your own wrapper and override all 3 😦
that may do the trick
likely isnt a straight forward way to do this, but I figured I'd ask, is there a way to ensure a message has been received by clients, sent by an actor, before destroying said actor, right now its kinda hit or miss, the only method I can think of to solve this is to either disable the actor for a long time after and clean it up later, or send a message back from the clients to ack the message back to the server to allow it to clean up at that point
the delay while seeming a little sloppy makes the most sense, disable+hide, wait 10 seconds, clean it up.
Depends. Does it matter to people that didn't manage to receive the message for 10 seconds?
Eithet way, look into TearOff and TornOff. TornOff is the callback to the server calling tearoff. Probably c++ only though.
@cosmic badge
its highly unlikely they wouldnt have received it after 10 seconds, that much of a delay there likely to disconnect at that point, but I'll look at TearOff, thanks for the hint 🙂 @thin stratus
How can I add widget to a specific players viewport ?
Hello guys
What technologies are needed to make an online multiplayer game?
what should I learn to be able to make a n online multiplayer game?
I recommend reading through this document for making games that run over a network.
https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
Thank you very much . I will read it.
But can you give me a short digest what I should learn?
like: c++ , node js, etc.
The document itself mostly goes over how different classes interact with networks and how you would send information over with things like replication and RPCs. Also some later parts discuss managing servers. Can't really say much beyond the technology required as that will be unique to your setup.
You should also look up how the online subsystem modules work. They're basically different services that would "host" your multiplayer, so like Steam for example... they usually cost to run though and each has different functions you can use.
Thanks for explanations. 🙏
Since I began implementing a server authoritative approach to multiplayer all of my logic using "Get Player Controller" suddenly stopped working. I'm not sure what I'm doing wrong here. Does the index of Get Player Controller relate to the client?
On a server, Player Controller 0 is always the first player
So the code I'm trying to run is on an actor, but I guess right now its hardcoded to branch based on Player Controller 0. I'm missing a key piece of functionality here to know which is the current player controller. How would I go about setting that up and where? Would that be part of Game mode? Game State? Game instance?
Of the code is on an actor that's not the pawn, it shouldn't really depend on the playercontroller. What's the use case here, what are you trying to do?
In standalone, I had a working on event tick self actor vs player pawn vector distance measurement to display a material outline to indicate this item can be picked up.
In my game mode I have an Event On Post Login which adds to a player controller list and sets the player controller ID, but I guess what I'm struggling with here is how to implement that list into the various actors that need to know which player is interacting with them.
Your interaction interface should pass over the pawn or player state that is doing the interaction, maybe even controller if you need to. Do it like that
Clear as mud lol
I don't have any player state or interfaces yet.
I think I need to start moving blueprint code out of my player pawn and into player state is that the correct path to start heading down?
I keep everything in the pawn so interactions between the player pawn and NPCs or between NPCs is all handled the same way.
What type of interaction are you talking about here?
It's like I dont understand that first key step to start wrapping my head around dealing with multiple controllers.
The controller shouldn't even come into question here. That's the whole point. It should be at Pawn to pawn interaction
What type of interactions are you trying to do here?
I have a handful of interactive items which I presume will follow a very similar structure so once I get one working I can adjust the rest. The use case for your sake would be when my player is within a certain distance of an item he can pickup, the item material changes.
and it works fine with standalone and with client 1, but client 2 is all broken
The first key step is to barely use the GetPlayerController node
If at all locally when you know you are working with the correct pc
All right for that I would have an interaction interface or an interaction component, I use components in my project, and the pawn should detect which items are nearby, and tell them to update their state. Specifically, to get nearby things to glow, I would have a overlap sphere attached to the pawn, on overlap, get interaction component, set is nearby to true, and then call update material.
All other times you should work relatively to the actor you are on
Pawns have Get Controller, PlayerStates have the Owner etc
To make it to where you only see items glowing that are near your pawn and not near another player's pawn, I would have a switch somewhere in the logic chain the only does the glowing if the pawn is locally controlled
If a player interacts and you call things from the pawn, pass it along and use GetController if you need it. +- the fact they don't exist on simulated clients
blueprint interfaces. enough said.
I prefer to use a component so you can have a location that interaction should happen at, and it also can store some state. But same idea.
im nearly positive devaddict has a yt video out there specifically showing how to do item pickups with interfaces
multiplayer* item pickups
Is there a way to send information from a menu to a session ( I want to allow players to select their name in the main menu then the server that they join to pick up that information and use it for the player name
Hey guys, ive been working on and off on an online multiplayer project, and ive been struggling with transferring player data between scenes (trying to allow them to pick a color and have it load their character in a new level with said color). Would anyone be able to jump into a call sometime to break down the process of transferring player data between scenes? If not, any resources would be appreciated for a lobby system with player settings.
if you have seamless transition then the player controller will persist between levels so you can save it there. if not, the game instance exists when the game is launched until it is exited, so that is also a good place to store it
@slender totem
Would I create some array of whatever data type i need to store in the GI then use the playernet id to get their index?
I was having issues with the colors getting mixed up when I used the game instance the other day, and tried to use save data instead, but it started getting convoluted.
One message removed from a suspended account.
have the server keep track of how many people have pressed the button via RPC
and if it equals the total amount then play
just make sure someone cant press it twice
through verification on the server
the way you described it, it sounds like each player had their own color and you needed that player's color to follow them without being told it again by the server.
Gameinstance is client only so that works for the one local player.
For other players, you should probably put that information on their own playerstate, set to replicated, and pull the color information from there as needed
I see, thank you for your reply. Ill give that a shot
The best feeling ever is when your replication works perfectly as intended
Whenever a player updates bIsReady on their PlayerState, check if all players are ready.
hey guys when I start a server and try to join it all I get is a black screen with these two warnings: Warning: OSS: No game present to join for session (GameSession) , LogNavigation: Warning: NavData RegistrationFailed_DataPendingKill.
what must I do ? I'm totally new to networking so I'm lost..
and these two are the commands I'm using.
oh nvm I solved it!
why, when playing as a listen server, is RemoteRole set to autonomous proxy on the server?
@meager spade how to prevent pawn being destroyed when player disconnect?
i saw older post you talk about it
iirc there should be a GameMode function override that handles what happens when someone disconnects
do you need a dedicated server to create a multiplayer system like fortnite
Well, yeah
Only other alternative is a Listen Server
Go for Dedicated
Thanks!!
Hey if a player is in a vehicle (either possessing or passenger), how can I: damage the unposessed driver and passengers, allow drivers/passengers to have limited control of their seated characters (ie shoot out windows). Would the possession system still work for this?
How do i create a dedicated server for ue4 multiplayer?
Get the engine source, build as dedicated server
Then rent a bunch of dedicated servers to host your dedis
How to set up and package a dedicated server for your project.
Thanks!!
Hi, guys, i wanted to ask, what can be used to make online multiplayer game, with session matches, if i don't have money for buying a lot of dedicated servers?
Listen server means one of the players hosts the session.
If you can make your game design work like this then zero server costs.
Yes, i know, but what is this player leave?
The session ends 🙂
It's possible (but not easy) to build Host Migration support so the session will continue with another player taking over.
Someone made a plugin or something to help with this...
I have a website and API to handle my games' services
I had this concept
But you still can't escape lags when host leaves, before server transfers
Also, there is a chance of timeout
And to handle server you need to sacrifice some performance, also cheats are harder to fight
yes, these are all valid points
It's still the best way for me at this point, i will use it
But these problems sadly still exist, so i think i may find some way to make it at least better
dedicated is best but can be expensive, and is a constant drain on cash to keep the game live.
you may be able to ship the dedicated server and get community to host, depends on your game etc.
Community games are good concept
If im right, Listen Server model is used by Overwatch's workshop games
Owner hosts the whole game, and if he leaves, ownership is transferred to next player in list
And BF4 has community games, so players host their servers
It would be a LOT of work to recreate the Overwatch workshop system in Unreal IMO
BF4 community games is a good model imo
Agreed
that's the model we're taking at the moment: operate a few Official servers, and ship the dedicated server so community can host / mod server etc.
At this point i ran alpha build within my team, using Amazon's server
Overall it's good
But costs money if i order more servers
yeah, same - costs add up for sure. Out of interest - what machine type are you using?
We are using standard Amazon EC2 if im right
I mean the specific type - we're using 'c5.large' at the moment but I've not profiled at all
hoping we can save some money by reducing this as we get nearer to release
C3.medium
Our game is not heavy actually
It's basic 8vs8 shooter in futuristic apocalyptic world, it's something Battlefield inspired
I spent 3 minutes to type APOCALYPTIC
I think a few official servers + community hosted is a good move in that case - anticipating you'll be starting small anyway, early access etc.
and it saves a lot of headaches re: listen servers etc.
Yep, it's not gonna be that big, i want to get scale of interest at this point
We gonna start beta in September on PC and XBox only
If it will take interests of people, we are gonna release on PC, XO, XSX, PS4, PS5
Nice! Console release is no small feat 👍
Yep, it's hard to get here, but we believe in the project, so we are gonna try and promote it!
Best of luck to you and your team
Thank you very much!
How do you create a dedicated server ue4 for world wide online multiplayer?
Hi everyone! I was wondering if any of you came across a similar problem when running the Collab Viewer template from UE.
If Playing In Editor (PIE) a client machine fails to join a game from a host machine throwing a TravelFailure error:
To avoid getting the error I had to duplicate the map giving it the name it was looking for (prepending the UEDPIE_0_ string as PIE does)
anyone know the difference between gamelift and AWS?
they appear to be the same concept to me
Gamelift is basically a layer on top of AWS that is responsible for provisioning servers based on demand. It does a lot more than that, but raw AWS you have to spin up/shut down servers yourself.
how do i replicate to server if not owning client? right now I'm trying to allow the player to target an NPC, press a button, and then the NPC faces the player (replicated). but afaik I can't use a "replicated to server" event on the NPC because it's dropped if the client doesn't own the actor
ty noggs
i guess i have to replicate to server on the player character and then from there communicate with the NPC blueprint. seems weird but i assume there's some kind of security or stability reason
Yeah that's right, has to be owned by that player. So commonly these functions live on PlayerController or player character.
is there a point to steam keys if ur game is free or are they only to protect paid games?
Steam keys are used to gift the game to reviewers when it's paid
if they're release override keys then there definitely is a point when it's f2p
asked this last night but nobody saw cuz it was late.
can someone explain RemoteRole? My understanding was that it told you how much control a remote machine had over the actor. This would imply to me that any actor spawned on the server and owned by the server would have SimulatedProxy as remoterole. However, ListenServer players have a remote role of autonomous proxy, even though there is no other client machine controlling them.
that is just a side effect of Listen server
as it is techinically autonomous, and other systems use the RemoteRole to decide things, so its more of a hack
weird
so my understanding of what remote role is supposed to mean is correct, except there's a weird exception for listen servers?
yeah so remote role indicated what role that actor has based on the object. So connected client player controller will be on the client side "LocalRole == Autonomous Proxy", "RemoteRole == Authority", on the server side, that player controller will be, "LocalRole == Authority", "RemoteRole == AutonomousProxy"
@vivid seal
ListenServer just has a weird exception
yeah that makes sense, i just thought that logically on a listen server it would be LocalRole == Authority and RemoteRole == SimulatedProxy
okay thanks
okay i'm trying to use ResetReplicatedLifetimeProperty to change the replication condition of a variable in a child class. the variable is protected, but I'm getting "member is inaccessible" errors trying to pass it into the function (I also tried using the RESET_REPLIFETIME_PROPERTY macro, which basically just calls this function).
specifically the GET_MEMBER_NAME_CHECKED macro does not let me pass it the protected variable
Has anyone worked with the Replay system?
Is it possible to record the whole session + display instant kills (killcams)?
When the killcam is played, the session recording stops.
Hi! How do i setup login/register in ue4?
need some more info
How do i create a login system where players can create an account or login
what backend are you using?
I don't use one
you need one for a login system
I have Firebase
either a custom made backend, using w/e framework you want. AWS Cognito, Steam authentication, Epic Online Services, etc.
Can i use Firebase to?
yes
you'll have to configure all of that yourself though as that's outside of the purview of this discord
Look at Unreal Tournament
pretty sure they show off a KillCam
Replays are annoying
it essentially runs all your code back
executes the exact same function calls that took place
yea
but from I remember from the Documentation you can play replays without leavbing the current session
ah
most normal tutorials for simple multiplayer games don't write their code in a way that allows it to handle replays.
and the documentation for replays in woefully lacking, even in the engine
but also most normal tutorials use a multicast for spawning actors😂
true
lol
Hey people!
This might be a simple question, but how do i get the player state of an other player?
The game state has an array of all player states, get it through that.
You got any example on how i would do this? Sorry i am a bloody beginner 😕
@cerulean wolf also, if you have a Pawn reference, you can get its player state. Just drag off the pawn reference and get player state.
What exactly are you trying to do here?
I have a "ready"-button which should start the game once both players are ready. But i stuck at the point to check if really both are ready. Confuses me a lot..
I know how to play a KillCam, but what I do not know is how to have KillCams + the record of the whole gameplay. For now I recording the whole gameplay and on death replay last few seconds. But this stops the whole gameplay recording.
Yes, this is so bad :(
Working with Unreal Engine feels like reverse engineering to me -_-
Most of it is fine but the replay system is just ???
Other stuff feels like this one too. Maybe it's just me. To understand how to do something, I have to open the engine source to understand how it works :D
Thats the intended way afaik
Stuff changes too quickly for documentation to keep up
I've got some components that only exist in editor that I use as gizmos to drag around and determine things in an actor on the scenary, for some reason these components aren't on the correct location in multiplayer, does this sound familiar?
BTW, does Unreal Tournament have the ability to play the replay of the last match?
Anything is possible.
Make sure they're replicated
I just never played UT, so asking :)
the gizmos don't do anything in runtime, I expected the default values to just work out of the box? when I do a package and multiplayer this actually works correctly
Gonna try it anyway, thanks for the idea
the replay system literally plays back a list of function calls and replicates it. Replaying an entire match is definitely possible.
Yes, but my problem is that I cannot combine it with KillCam. If at death I start to play the last few seconds, then the recording stops.
it's been awhile since I looked at it, but essentially you have the server record. You have the player transfer to the servers recording server, play back X seconds with w/e viewpoint, then transfer them back.
in the meantime, the recording is still going on in the game server.
You have the player transfer to the servers recording server, play back X seconds with w/e viewpoint, then transfer them back.
I do not understand this part. Should I record all gameplay on the server and then stream it to the client?
you don't need to stream it all the time
again, it's been over a year since i've looked at this stuff
but essentially you start up a recording playback server
and the game server is responsible for streaming the replay to the replay server.
you just have the client connect to that when playing the replay
that's as far as I was able to understand it
and the amount of refactor it would have taken to make our code jive with UE's replay system was too far out of scope
Oh, got it. So you used a separate server for replays, right?
So you have two instances of the engine running?
no
it's in the replay code
i'm nowhere near an expert on this stuff
so unfortunately I can't really help much further than this
Oh got it, we always have two NetDriver classes. One for replication and the other for replays. This is how it works by default. And you recording the whole gameplay on the server and then plays only a few seconds for KillCam?
you can set it to record only the last X seconds
and just constantly be playing that a bit delayed on the replay server
I think I get it, thank you!
And on the client I will be able to record the whole session.
BTW, do you remember how to set to record the last X second?
not off the top of my head, no sorry
Anyway, thank you a lot! Again :)
no worries, best of luck!
anyone here know of an example of dynamically created (+replicated) components within the engine or sample project?
I can get them spawning on both the server and client, but no property replication
yeah c++
nope i got supers all over, in the constructor i have both SetIsReplicatedByDefault(true) and SetIsReplicated(true)
SetIsReplicated is also set for the newly spawned component
and GetLifetimeReplicatedProps is actually hit
GeLlifetimeReplicatesProps has super too?
yeah
maybe its cause im replicating a custom struct - its never been a problem before though, ill try an int or whatever
generally
there is nothing to it, spawn a replicated component on replicated actor
and it works
only UPROPERTY members that are not NotReplicated of a UPROPERTY struct can be replicated
struct member needs to be marked Replicated, and added to GetLifetimeReplicatedProps
Yeah I thought the same
there are few other ways to fuck it up
like
using a derived class that doesn't call Super
making a mistake overriding NetSerialize on the struct
damn, no go on an int either
What does your property declaration look like?
I take it this should work on actor components, not just scene components
It's all the same.
UPROPERTY(BlueprintReadWrite, ReplicatedUsing=OnRep_SomeInt, Category="Test")
int32 SomeInt;
It's also worth asking if you're hotreloading?
then set without any conditions
yeah i tested that - did an actual restart of engine
it has to be something in the host actor
well, its time to decide not to trust you you created the component right 😄
UDTSensorDataComponent* SensorDataComponent = NewObject<UDTSensorDataComponent>(InPlayerController);
InPlayerController->AddOwnedComponent(SensorDataComponent);
SensorDataComponent->RegisterComponent();
SensorDataComponent->SensorActor = Cast<AActor>(Sensor.GetObject());
SensorDataComponent->InitializeForPlayer(InPlayerController);
that is run where?
from er
a GameInstance subsystem that hooks into OnPostLogin
i confirmed they spawn on client by logging a message in BeginPlay that only fires on the client
you confirm client creation
by putting a breakpoint in AActor::OnSubobjectCreatedFromReplication
void UDTSensorDataComponent::BeginPlay()
{
Super::BeginPlay();
if(GetNetMode() != NM_Client)
{
// ...
}
else
{
UE_LOG(LogTemp, Warning, TEXT("UDTSensorDataComponent::BeginPlay"));
}
}
hmm, ok ill take a look at that
yep im getting that subobject created hit
[2021.07.20-00.26.18:877][199]LogNet: Warning: UActorChannel::ProcessBunch: ReadContentBlockPayload failed to find/create object. RepObj: NULL, Channel: 2
that's a new one, i added SetNetAddressable()
will implement ReplicateSubobjects and report back
nothin 😦
Does server function replication requires a _Implementation
yes and Validate
UFUNCTION(BlueprintCallable, Reliable, Server)
void SimulateRangeAttack();
void SimulateRangeAttack_Validate();```
UFUNCTION(BlueprintCallable, Reliable, Server)
void SimulateRangeAttack();
void SimulateRangeAttach_Implementation();
bool SimulateRangeAttack_Validate();
alright i've sort of gotten somewhere - the property replicates if it's changed in tick, but not where i'm changing it (in response to an event)
Is there a way to manually mark a property as needing sync?
So do I put my code ONLY in implementation right?
yes, and just return true for validate for now
Got it thanks
how do i make physics objects to be in sync on multiplayer server and replicate
How do I get a specific player's game instance?
For a very basic implementation just checking "replicate movement" is almost enough. Still a small chance they can go out of sync but not if they're always moving.
can there be issues with pie editor not reflecting those changes correctly, i checked like everything in the prop that is simple cube related to replication , and also in character pawn
and the cube goes out of sync almost from the beginning
usually its not pie related, but a quick restart for sanity's sake never hurts
also the cube is set to height that it falls, and it does on the server, and on the client
but on the client it should be already on the ground
Problem you have is if the client simulation moves the cube, but it's stationary on the server, then the client will go out of sync until the object moves server-side.
so something needs to be disabled?, i searched for something related to the client
For persistent physics, or player-controlled physics - it's a hugely complex problem.
Well, you can disable physics simulation on the client (though you'll need to do this constantly, because replicated movement will overrule that) - but then the objects will just "snap" between positions.
Wonder how Chaos fares on determinism now
Yeah I wonder that too. The async ticking probably helps, but I wonder how it copes with objects being inserted into the scene at different times etc.
Supposedly Chaos is meant to address all this stuff though, despite being so damn slow compared to PhysX
i'd like to see it first handle a basic rigid body stacking usecase without the stack eroding to the ground
yeah some level of stability would be nice first 😄
I feel kinda bad for Epic 😄 Myself and a few others went to town a bit on Epic in the official Chaos thread on the forums.
But I honestly don't know how they can seriously be considering deprecating PhysX with Chaos in it's current form.
This is now #legacy-physics ...
I'm staying on UE4 if they're gonna push it down our throats for UE5, and I LOVE real time lighting
They have a year of work until they actually do
yeah
And I suspect many games will work perfectly fine on Chaos
I've heard that nvidia devs are kind of weirded out by Epic as well
As in they don't believe Chaos is going to be better than PhysX5
Yeah I think Zeb linked to a Github thread where they basically said "we aren't going to maintain a PhysX build of UE5", something about the abstraction layer not being particularly great.
my two cents are: Epic really wanted vehicles to work in a deterministic 100% their-own-code way for fortnite. They embark on the Chaos journey, they market the shit out of it, literally years pass and it's turning out to be way harder than they thought, but they already promised, so it's all being forced in a weird, awkward way
that's how it feels like at least
My feeling is that multiplayer physics is a really really big box to check on the engine feature list
Having essentially nothing on that in the engine has been a problem
yeah definitely
their effort to make it predictable is salute-able
this was helpful for me, to sync the cube https://www.youtube.com/watch?v=H4frXTRwZqI
This shows you how to replicate an object simulating physics across all clients, and how to make a blueprint class out of one so you can call events on your replicated physics object.
PhysX being entirely unable (apparently even in newer versions ?) to support multiplayer means they need to get rid of it
That will still have the same desync problems
btw @chrome bay remember me wondering about snapshot interpolation like over a year ago? I got it working flawlessly, it's 100% jitter free now
I gave up 😄
PhysX can support multiplayer if you're doing snapshot interpolation or state synchronization
without the option presented there i did not have evene a bit of sync, now it works better, although client pushing cube, makes cube stutter for him, so there is something wrong related to updates
the only (seemingly) difficulty that arises with PhysX and networking - at least when UE4 integration is concerned - is that it's not easily deterministic and ticked in a decoupled way, meaning you can't predict it nicely
but that can be worked around with a little bit of validated client authority
What do you plan to do with the implementation atm?
use it in a first person shooter I'm working on
with a lot of physics based mechanics
roger, I wasn't sure if it was just for a proof-of-concept or self-punishment sort of thing 😄
i think definitely a little of both ^^
Quick video demonstrating the recent work to support physics in Network Prediction.
UE5's network prediction plugin makes physics replication much nicer
It's still very experimental
Hasn't been updated for a while AFAIK, but yeah that's supposed to be a solution for player-controlled physics.
Yeah AFAIK it's only Dave working on it. It'll be interesting to see how well it scales with Physics. Last time I checked in with the physics portion it has to send a continuous update stream about every physics object to avoid desyncs.
Ideally stuff like this is deterministic
I don't think it ever will be
But allowing physics to at least tick with a fixed timestep is a step closer to it
The plugin actually has to disable bandwidth limits
It's definitely cpu time oriented for now
Yeah looks like they're only working on it in UE5 now too.. urgh. Expected that though.
Probably even more ue5 dependant with the new fixed thread
I'm just praying for CMC 2.0
I think they've already started on that one
CMC via that plugin
They'll probably keep the legacy ones for backward compat, but I wonder if they'll restructure it
is smooth sync plugin worth to look at?
depends, what are your project's needs?
i am basically referring to the simple physics i was experimenting before, actually i dont have plan for any extensive use of physics in my project, but i would like just to know if that plugin is good for solving issues that engine itself doesn't solve
It doesn't solve much, it'll just put objects vaguely in the same spot
If you need player interaction with physics it might not work well
hello here I'm checking whether it is the server that is overlaping a trigger volume, but even with the client this check still returns true why is that ?if (HasAuthority()) { FString CompName = FString::Printf(TEXT("OnOverlapbegin called!%s"), *OtherComp->GetName()); if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, CompName); }
Maybe it's not replicated.
the player ?
The class this code belongs to
Also, if you test in PIE, AddOnScreenDebugMessage adds on all windows IIRC
Is there a way I can make a specific client authoritative over an actors movement?
(in single process mode)
Sure, just write your own player class and do that
wait you mean UPlayer?
Is it for a character or any random actor we're talking?
random actor
I wanna be able to "pickup" and build with an actor and have the server take the clients account of it
Assuming that's a random actor, just replicate the actor the way you want to
There's no built-in actor movement
I could do some kinda server move RPC but dunno if that's good practice
So it's entirely up to you
I mean the actual built in rep movement
it's server authoritative
The attachment will replicate by itself so long as you've enabled replicate movement on it
The built-in "replicate movement" feature is completely pointless and shouldn't be used in a real product
well the only issue is that i'm doing some manual location manipulation, It's not really just "attaching"
oh fr?
Hmm in which case, you'd have to RPC the transform to the server
I kinda thought that way in the past, Do I just throw a "Server Move" rpc and lerp it manually then?
It will simply teleport the actor every few frames without actual movement, it'll look terrible in any real-world situation with non-zero lag
yeah
ah fair, good to know
For actual movement this gets a shitload more complex
ty guys!
yah I could do character movement myself, just wasn't sure if similar concepts were the way to go
i set the actor to replicate.. but still It's working on the client
I try to work with the engine where possible
but I guess this just calls for some DIY
all gud! thanks so much
Basically for moving actors you need movement on tick on clients and server ; the authoritative movement source needs to RPC the server if it's a client ; and the server needs to tell the other players about the new transform
Remote clients will need to interpolate
Since you'll get like, one network update every 5 or 10 video frames
And more probably a packet of 3 updates every 20 frames
yea
could it be because client and server character are using the same characters ? because if I don't check for authority it is getting fired twice
If you have two characters and they overlap, then it makes sense that both characters will fire their own overlap event on the serve (authority)
"has authority" means "is on server" (for the most part), not "is locally controlled"
no, its not that. I have a pressurePad and when I step on it with either server or the client. it is being fired twice
if I have three players it gets fired three times no matter with which one I try it
Dunno then but make sure to confirm it's actually called multiple times on the server with authority - play on editor can be confusing with that
Also where are you checking HasAuthority? The pressure pad or the character?
If the pressure pad is placed in the level and not replicated, clients will have authority over it.
PressurePad and in OverLapBegin function
its not about authority
if I check for authority it is only called once, no matter how many players I have nor on which client I overlap that pressure pad
If the pressure pad isn't replicated, then that sounds correct.
Each client will move the character onto their own local copy of the pressure pad, so you'll get three overlap event printouts - one for each instance.
if I don't check, it gets called for as many players as I have
Sounds right then
Assuming the pressure pad is a replicated actor and only the therefore Server has authority, only the servers' instance will print the message if you branch based on that.
If you don't branch, since every client is overlapping the pad in their local instance of the game - you get three messages.
One on each
the thing is I get three on each
and one on each when I check authority
and the PressurePad is replicated
How do you know it's three on each?
the messages appear on all of them
Like I said, that doesn't mean much
Yeah, doesn't mean anything really. Messages go into all the viewports sometimes
A better way to verify it would be to log the message instead
In PIE single process, pretty sure every message goes everywhere
yeah
ok gonna try logging it
hi guys 🙂 i'm trying to force a player movement by invalidating his input and adding forcing movement input but for some reason the client that is being forced sometimes stutters.. like it moves, then stops, then moves again and so on.. so wanted to ask if you guys got any advice or a better way to do it.. thanks 💙
Hey guys, can anyone help me with find sessions blueprint?
I have an issue that I can only find sessions in my own computer, opening the game twice, and I managed to join from another computer but in the same network
The lan function is set as false, and anyone from another computer cannot join, not make a lobby which I could join
If I execute a custom event which runs on server, and in this custom event I do a 'set with notify' for a variable, and this 'with notify' has a lot of logic attached, is the 'with notify' logic guaranteed to run on server?
@twin juniper Yes and no. Semi complicated topic since the functionality differs in Blueprint and C++. In C++, no. You purposely have to call the OnRep yourself after setting the value, which is why a lot of onrep variables are set with a wrapper function that also calls the functions the server needs to update it's own state, be that bindings or the OnRep function itself. In blueprint, this is different because the OnRep will get called for the server automatically whenever that variable is set. I don't remember if the value needed to be actually changed in Blueprint for the onrep to run.
ok thanks
What algorithm do people use to handle lots of inconsistent network speed, like consistent lag spikes, where latency varies a lot? Say a range of 50 ping to 200 ping. When this happens, character movement component doesn't compensate for this inconsistency, so it will keep see sawing back and forth. But the information to account for this is there, the server time vs. the client time. The delta between these two times would be inconsistent. So say the server and client are pretty in sync, say at a high latency of 200 ms, then the network is better, so suddenly the client seems behind the server, and tries to catch up, but then the network reverts to 200 ms latency and then the client is too far ahead. I've managed to make it a bit smoother by looking at the delta changes of the server time and client time, but I suspect the algorithm I did can improve a lot.
Just wondering, is it possible to created a server game like Rust, same server design as where someone could join the same server over and over again and have their inventory/base there
yes
Okay thanks
How would I best count the number of players currently connected to my server? I tried NumPlayers of GameMode but it doesnt seem to update once a player quits.
What is the rule for storing data in FSavedMove_Character as a variable (such as uint32 bPressedJump:1;) and when to store data in the uint8 compressed flags? (such as bPressedJump)
get the length of the players array from your gamestate.
i want to implement in my project such feature that, when player gets disconnected from the server, it will stay on the same map that it was before so it's like it became host of singleplayer game, what should i look into to make this happen?
Pretty sure without bigger engine changes you will always have some loading involved into this
Idk if you can even stop the engine from throwing you back into the level you originally came from without adjusting source code
is it truly not possible to prevent it from throwing? im curious what's the logic behind getting disconnected, is it always last level , or last streamed level?
I think it's the url you came from. But keep in mind even if you get this to be the level you were on, all your classes despite the gameinstance will be created from scratch
Nothing survives the hard travel that a disconnect is
it's possible to save necessary state and recreate that, but the need to reopen level bothers me, if this is performance hit or that it could flicker or something else
It's a loadingscreen situation
It won't be seamless
Even if you directly go from multiplayer to the same level disconnected
hello again 💙 i'm forcing a client's player movement via "SimpleMoveToLocation" and on every other client the movement looks fluid except for the one that is being forced.. it looks choppy.. any ideas on how to deal with that? 🙂
i will try to perform experiment now, with getting kicked and reopening level immediately, there is event onclientwaskicked, but i dont see where i could get something like clientwasdisconnected
GameInstance has calledbacks it listens to for BPs
Should be some global delegates or so
Travel and network failure
They will call when this happens
If you need it to be seamless then you might need to exchange the whole network stuff of ue4 with something custom or thirdparty
in blueprints there is travelerror and networkerror
i hooked up quickly to both nodes, printtext, and when host decides to close server, network error fires
and it does two times, first is connection lost, and second , failure received
interestingly enough calling openlevel there does nothing
that's the only reasonable explanation
what's better digging where i could hook it deeper in the engine, or maybe just set flag there , and do it on other event?
rn i just did that on gamemode's event tick, put there widget placeholder that simulates loading screen, and it kinda works, like any other transition to level
would this include someone having some massive ping spikes and lagging pretty hard?
We wanted to drive some UI in that instance
https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/Engine/ENetworkFailure__Type/
https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/Engine/ETravelFailure__Type/
Types of network failures broadcast from the engine
Types of server travel failures broadcast by the engine
right, but i meant more is that constantly being broadcast somewhere?
I can always just look in the code, was just wondering off hand
these events are accessible from game instance
those aren't events, they're enums
they're broadcast in HandleNetworkFailure from UEngine. You can override it there or use HandleNetworkError which is a BP only event (which seems silly)
by silly, do you mean for example that enums are not that good in bp?
no, i mean that there's no place to hook into it from C++ in the game instance. You have to create a child of UGameEngine in order to hook into it.
that's what's silly.
not the only thing silly in this engine
how does it work, cant you just override handlenetworkerror, im not so good at this?
but the engine version is more extended
Can anyone give me some advice? Something is just not clicking for me..
I've got an actor spawning in my GameMode's BeginPlay Event (this means the actor is spawned on the server right?)
In that actor's BP, I have it spawning other more actors on a timer and it's using a custom event on multicast. I also have the spawned actors set to Replicates.
I'm seeing that the object is apparently spawned on the server and I can also see that it is ticking through spawn events, but I don't see any items spawn on my clients.
Why are you multicasting?
i'm not sure what you mean.
This is a really weird issue
Anyone know why a Client would be able to send a value to a client hosted server but the server wouldn't be able to send it back
Eg Chat:
Its all the same code
Client sends a String "WASD" and the server gets it and can see it
Server sends "WASD" back but it never gets to the client
How and on what blueprint (or class) are you sending it back to the client?
Server > Multicast RPC
Sending it on the actor that is spawned on both server and client.
It looks like it was an issue with checks I put in place to stop spamming empty/same values from the client to server to optimize the code a bit, im about to test now
So you have an actor that is spawned separately on the server and the client? Ie. Calling Spawn Actor on server and then on client (via multicast or otherwise?)
That's bot true though?
Aren't they statically accessible to bind to?
Spawn is called on the server which spawns the actor on both ends
maybe I missed a call?
The spawning of the actor is fine, we're trying to send data across.
Its the lip-sync system again lol
Is the actor owned by the client?
Yeah
I thought they are statically accessible
The Client actor owned and controlled by the client is working as expected
the server one isn't
So you can bin in any BP to them. Maybe i misremember
Hm no. There might be better ways to do that
I just woke up. 
when I glanced at it, it seemed to only call the BP implementable event, and that was it. Which seemed weird
yeah, just checked again, it's just calling this in UnrealEngine.cpp
Will have a look ince I'm awake and at my pc
UEngine::HandleNetworkFailure
that's the function I checked
if that's the case, that's really weird
At the basics, I'm guessing you're doing something like this on your actor:
Output:
So long as client 1 and client 2 are within range of one another. If they're distanced then net culling may be occuring.
Yeah
They're basically standing infront of eachother at all times but thats a good point, I might disable culling
Its really weird because there's a component that crashes if it exists on the server I create it on your own local character only (IsLocallyControlled) and then get its values and pass them through to the Player Pawn on Owning Character then parse that through to the actual networked component that I'm having issues with, but it does work, its backwards as heck and I don't like it but at this point I don't need to like it
Ignore the PacketID stuff, thats just to stop visemes appearing in random order
and the 2nd one was just a quick screw around to see what would happen if it passed the order
how do i I get the current locally controlled player controller on each client?
every time I run getPlayerController it returns the same one
I tried but it still doesn't decrease the count when a player leaves. Maybe there is something wrong with my Widget displaying the value?
@trail hill are you updating it when someone leaves?
@fading birch no i dont touch it but the engine should update it when someone leaves
I update it in tick
so should be fine
@fading birch Thats all I am doing in the tick of my widget And the GerConnectedPlayerCount simply returns NumPlayers. I also tried PlayerArray.Num() but had the same result. When someone joins the game the count increases correclty. But when I Alt+F4 to quit it doesnt decrease
So i suspect that Logout isnt called on AltF4 maybe?
Because in the Logout of the gamemode the cpunts are decreased
Try waiting a bit. If someone alt f4s that's not a clean exit. Iirc a server will hang on to their player state for a bit so if they rejoin they don't lose their attributes.
It's something like 30s or so
It's customizable
Yeah the playerstates stay on the server for 300 sec by default
Sounds about right.
Correct.
I'm not at my pc right now but I'm not sure if the player array is actually updated when they're moved.
I could set the value to 0 but then I can't have fancy reconnects in the future
This is called in the logout
Logout may not be called when they alt f4 immediately
Yeah thats my guess too. But its hard to test as I have to deploy the server everytime I want to try something :/
No?
Just launch your project with -server
I usually make a config to do that from my ide
And a shortcut for non debugging
Hmm I am kinda new to networking in Unreal. How would i then connect to the server?
Is there some documentation or guide on that?
Would love to have a better workflow
I build the server and client everytime I need to test something server specific and have to deploy. Its a pain
Yeah thats not necessary lol
Noooo
You can launch client using -game
You can add -log as well
Yeah you can. Generally I make a shortcut from my uproject file.
Ohh wait nevermind I remember why I dont do this
Server is on linux
But I could add a windows config for testing stuff
It's like:
"Full engine path\ue4editor.exe" "full project path\projectname.uproject" - server -log
Thank you
Swap -server for -game to open a client.
I will give it a try
Will also add a Windows server target for easier testing. Otherwise I still would have to deploy
You don't even need to build your server binary. It'll use your windows build of dev editor just fine.
Wait what
No need
this works
I will give it a try. Thanks for all the helpful tips. Its really hard to find any best practices on multiplayer workflows and I would never have found this without you 🙂
I honestly stumbled across it in some random YouTube video 3 years ago lol
There is documentation for it let me find a link.
Collection of arguments that can be passed to the engine's executable to configure options controlling how it runs.
Is APlayerState::ExactPing or APlayerState::ExactPingV2 more accurate? Seems like ExactPing is averaged but ExactPingV2 isn't?
I'm replicating a time (for date/time system) from the server to ensure that player's time stays in sync, and when I do so I add their ping to the time to compensate for the difference in latency to get as precise a match as possible, just not sure which one is best for that
Anybody know if there's a better way to set ownership from a client on an actor than just doing a server RPC with Actor->SetOwner(NewOwner);
I have NetTakeOwnership RPC on my Player Controller but it seems like a pretty dirty way to do things
@fading birch Thank you so much! I just tried your commands for launching the server and client locally and it works like a charm. You can imagine how much time you just saved us as we no longer have to package and deploy to a remote server for testing server specific stuff 🙂
This doesn't seem to replicate to other clients running on dedicated server can't for life of me get it to spawn
This is within a widget?
2 things:
- Clients can't multicast to other clients - only server can multicast.
- You shouldn't necessarily be spawning on all clients, as then each client has their own client-only version of the object you're spawning which may not necessarily be what you want.
What you need to do:
Your button click would need to call an "Executes on Server" event that exists on the character or player controller. The server should then do the spawning.
If you want each client to have their own client-only version of the object, then from the "Executes on Server" event, you can do an "Executes on All" event to spawn the cube for each client.
awesome so like this instead
does changing a replicated variable on the server automatically flush dormancy?
@fading birch And I also figured out why logout wasn't called for me. I forgot to call the Super::Begin in my playercontroller. I found a post on someone else having the same problem and now everything works. Interesting how such an unrelated thing doesnt cause any issues anywhere but on the logout.
how do i get the player id for players?
I think my issue is that I don't have weapon reference in client side, so it's not calling the fire function
How do I get it on client?
I spawn actor and set the output to a variable
Usually by making sure your actor is marked for replication and the variable is too
I have a couple of questions please.
I'm using a replicated variable to set actor rotation. It doesn't work without replication and I don't want to use RPCs.
I notice that there is a very slight discrepancy between server's value of the variable and those of the clients. (I'm talking about orders of 3rd or 4th decimal place). It's not any issue for me. The difference is not even noticeable.
I'm just wondering if this is normal since there may be other situations where it might become an issue).
Secondly, which is more taxing on the server/consumes more bandwidth.
Using replicated variables or using RPC functions? I understand each has their place but I just want to know what choice I should be making if I have to choose between the two.
For stateful changes you should use replicated variables
It's not necessarily about which is faster, it's more about which is more suitable
For things like speed change, I'm using a replicated variable that I change it's value then use that to update character movement max walk speed.
I feel like I should be using a RPC to do that.
It's for a remotely controlled character not client controlled.
Speed changes are difficult, the controlling client needs to be able to "predict" those changes as part of it's predicted character movement, which means changing it on the client first, then telling the Server what the new speed is rather than the Server changing it.
Yeah. I'm doing that for the player character. However mount movement is not predicted for now. The speed change I'm referring to is for mounts. And those are not possessed. I route movement input directly to their character
i heard fortnite does not really predict speed changes
not even sure how they handle sprint, cause they said in a UDN post they dont do anything special for speed changes
tbh we just do the same thing as shootergame and that seems to work fine for us
How does one react to a jump on a simulated client? Seems like the JumpCurrentCount and all of that is all non-existent on Simulated Clients.
Anyone here ever play around with custom quantizing vectors down to 16-bit components (or 8-bit even though it'd be wildly inaccurate in most cases outside of unit vectors)?
FVector_NetQuantize?
normal goes to 16
oh nice
Could just roll your own too
tho, depends what your needing to do, i find 20 just fine for most usecases
16bit only makes sense for normals (-1 to 1)
I probably need a refresher on network concepts but I’m having some trouble assigning teams to characters on spawn
I can assign them to Player Controllers just fine
And spawn at a given location based on team
But I want to change some parameters on the character as well on both server and client
And it’s throwing me for a loop
On post login I get the player controller and assign it a team based on a rudimentary balancer
And then I need to pass that team all the way down to the character that’s going to be possessed by this controller
But there doesn’t seem to be a reliable point where I can grab this team ID and give it to the character
I’m assuming I need to handle this on server and multicast
Is there a way to get the spawn point of a character before they spawn?
I do it on the event "Handle starting new player" in the game mode and to change a parameter of a replicated actor on spawn mark it as "expose on spawn" and make the property replicated
more generally, use rpc for event and replicated properties for states
Might also be worth noting that something like Team should likely be on the PlayerState instead of the character. Characters are often throwaway actors. Keeping team state on them would be a hassle versus keeping it on their Playerstate and using it from there.
Yeah that makes sense
I have it assigning to a TeamID variable on the player and that actually works fine
The next step would be to grab it and change the color/mesh of the character before the player spawns
and that's where I'm lost
but i think this helps, thanks
Repnotify
Can Unreal compress pointers in RPC parameters?
And it says with 32-bit computers its 4 bytes, with 64-bit computers its 8 bytes, does it differ in UE too? 
they use Net GUIDS
they dont send the pointer
from my understanding
hence net guid
🙃
anyone online with a good understanding of movement replication (rotating a child static mesh of a character, which has the camera (players viewport) attached to it)? It's jittery on the client and smooth on the listen server. @thin stratus told me I am missing the client side prediction part, but no idea on where to start fixing that 😅 . Could someone point me in the right direction? I am working in Blueprints, but if it's a quick fix / much easier option to do it in C++ that's fine too.
Nice to know, thanks 🙂
Whats the size of the GUIDs though?
Anything significant?
I have a randomly generated actor spawning. When i do multiplayer the actor is different for every player. How would i replicate it so every character sees it the same?
Is the randomness being generated on "begin play" or something like that?
yes
Is the randomness being stored into replicated variables?
The variables aren't replicated I don't think
So you have two options:
-
replicate the state of each variable that is being set by the randomness using "OnRep" variables. On the OnRep functions, you make the variable modify the part of the actor it's supposed to.
-
Look into random from stream - this can allow you to replicate a single OnRep variable and on that onRep you generate all your values from that "stream". Think of it as a "seed" system where you only need to distribute the seed value and then all clients can generate the actor on their end without having to replicate all the values.
Ok thanks will start to read it
Its cover the whole thing but you can just implement the interpolation part to begin
ok thanks will look into it. But it's going to be a CPP party then 😦
I'm having replication issues with animations. My blendspace has blend by bool(used for third person ADS). The remote clients send RPC to say bIsAiming, the anim instance gets the replicated variable and updates the blendspace. however, this isn't working for simulated proxies
rather i bIsAiming as replicated or onrep
If I have a LobbySteamID, can I connect to server using p2p?
for example: Lobby leader call open L_Game?listen and after members will call open steam.LobbySteamID, but it not work, members can't connect to server
been a few years since i messed with online subsystem. but i remember using GetSteamGameSession and connect using the ip
Have you debugged to check that the Boolean is replicating or not?
It's only replicating to remote clients if I'm a client with authority(listen). The server rpc doesn't even register when the remote client sends the rpc
Like the function on the server never gets executed when remote client sends it
Does the have to anything to do with the actor sending server rpcs if it doesn't have correct ownership?
I'm gonna try something different when I get back home
Instead of the weapon actor sending the rpc, have the weapon return Boolean to ACharacter and send rpc from character
Actors that aren't locally owned cannot RPC to the server
Only possessed pawns, player controller can
Ah, there's probably my issue
The weapon I spawned isn't possesses but does have owner and instigator
@bitter oriole thanks
quick question. I'm trying to do multiplayer with AI enemies. I'm using AI tree to drive behavior. Where is the best place to call damaging a player from? the AI tree, the AI controller, or the pawn?
From its controller or its character
I topically make my ai behavior trees as read-only. I never set data to the actually character. If I need to send data, I use events
So ai character receives damage taken, sets a Boolean or enum to dead if health is zero. Behavior tree can read the isdead variable
yeah thats what I was thinking
so right now the AI tree calls this on the pawn
the controller calls a server event to get asny players in a range in front of the enemy and apply damage
i dont think AI need to called server functions do they?
Think of the pawn as the vehicle, the AI or player controller just being the brains driving it. The pawn should have the attack functionality, controller just calls it.
oh wait thats attack. i was thinking damage
right. so right now the AI tree calls the animation but the controller actually figures out who to damage and how much
I mean it depends on your design, but the AI controller should just call DoAttack or DoAttackToActor, that's it. It shouldn't be manually playing animations.
right. it calls the melee attack interface which causes the pawn to do the blue print I pasted above
then when the montage hits the right point it has the controller apply damage to the correct area around it
The controller should not be applying damage.
All the controllers should do is trigger the attack, everything else should be handled in the pawn.
Think of it this way, design your pawn such that it doesn't matter if a PlayerController or AIController is driving it. All they are doing is giving control inputs.
Designing in this way also makes development much better as you can manually control any of your pawns for testing.
I didn't look at it too deeply but yeah, all the capabilities of a pawn should exist on the pawn. A controller should just be doing the thinking and giving orders to its pawn.
got it. that makes sense. thank you
so now when my enemy gets to 0 health how do I let my ai tree know?
do I pass to the controller and have it tell the Behavior Tree?
I am trying to make a dedixated server for the first time. I used the blockout tools plugin to build my level. When I try to build the dedixated server it fails due to "unable to find" blockout tools plugin error
It says I need to install it or remove it from the required plugins list. Where is this required plugins list? And if it remove it will that break my game since my game actually uses actors from that plugin?
If i build development editor from 4.25 then it finds that plugin just fine. Why suddenly cant it find the plugin when I build development server from source?
Hmm I see the source based engine doesnt have the Marketplace folder nor the block out tools plugin within that folder but my editor engine does. I copied marketplace folder over to the source folder and it seems to be doing better so far....
that's generally what I do when dragging over marketplace plugins
unless I install them in my root folder
you should be using source for both client and server if you're using a source build though.
will save your build times too
you can use a behavior decorator. You should also ask in #gameplay-ai as that's the appropriate channel
ah thank you
Hello,
Is it possible (and if so: how?) to Transfer an Array<UObject> by a RPC without having this UObjects in a Replicated Array with "ReplicateSubObjects" ? Like only transfer the UObjects once on a Event ?
@fading birch thanks I see that copying it over fixed the problem and server build works now
I will try and make sure the client code uses the same engine
it should, from the sounds of it, you're changing your engine version when you swap builds?
Yep. So once i get this built and working, how do i get my clients to find a session on the dedicated server? Or is that the wrong question and I should just hardcode the dedicated server's IP address into the clients? Or something else?
that's a question for #online-subsystems
but it depends on which online subsystem you're using
Currently using onlinesubsystemNull and playing on my home LAN to test playing between android and PC (which works by the way)
yeah that'll work for a local network
But it is coded to expect listen server
let's move this to #online-subsystems
So the host is a player. Okay
my projectile is replicating but the trajectory is jittery on the client, what can i do to fix? I have the spawn projectile run on server, and the actor set to replicate
hey I'm trying to do item pick ups.I have the item currently set up with an input task and it will add a player controller to the actor's input when a player gets near. the task calls a server rpc which is linked to a repnotify to destroy the objects. Am I thinking about that the correct way? Right now it's getting stuck at the server rpc because it's saying the object doesn't have an owning connection.. I've tried to research but I'm coming up short
@tribal yarrowyes owning connection is a thing.. you have to sort of "dial up" from something that that player controller does own
like itself.. or the pawn
and then once you're on the server version of the pawn or player controller
any recommendations on how to keep that clean? I was really hoping to keep the logic for that on the item itself
you tap over to your world BP
yeaaaa it would be so sweet wouldnt it..
no i dont really know a great way to keep it clean
interface?
maybe use an integer or an enum to keep track of what state you're trying to provoke
you can pass that to your world actor and maybe it can nkow what to do with it
ya.. an interface with an enum might be kinda clean
the enums being different things you could interact with or something?
doors, chests, items on the ground, levers, etc?
well.. i had this issue when i was trying to do multiplayer dialogue choices
for the player to interact with NPC's with
and its like.. i dont wanna write 7 diffenret functions to trigger on that NPC
but however you do it... owning connection is an important thing
a player controller on the client side.. can't just call up a server event on some actor in the world
even if it is has a reference to it
what are you trying to do exactly?
I actually figured out a way to get around it, did end up using interfaces but I'm still not super happy with it
just trying to destroy an object for everyone
The pawn should handle equipping the item. In my project, items don't even know who has equipped them.
Specifically we do it like this.
- Button input (E)
- RPC to server in Pawn
- Call TryInteractWithClosest.
- If thing we're interacting with is an Item, call EquipItem on Self.
- EquipItem does its thing
?
Hey everyone! I was wondering if someone could help me. I am working on a multiplayer game. I'm trying to do a spectate mode for players when they die. I using PlayerController->SetViewTarget(Character); I am calling this on the client and server. This works, but it is very choppy / laggy for the person spectating. I am using the template third person character setup. It appears the problem is the camera is dancing around. The actual character movement replication is pretty smooth. Any ideas?
Interp between the server and client position to get a relatively smoothed movement?
or just create a spectator camera and force its rotation/location to the targeted client camera position
Does anyone know of any reason why a server would be forcing their morph target values on the client to 0?
Clients morph targets are moving perfectly on the server, but servers are really struggling on the client
How would i go about doing this: I have a Pawn class in my GameInstance, i need to move and replicate it from client GameInstance to client PlayerState before GetDefaultPawnClassForController_Implementation is called on the server?
My first Q would be why does it live in the game instance
If it's replicated and/or gameplay relevant it probably belongs somewhere else
But probably the most important part is you can't replicate anything in the GI
Presumably this is for choosing a pawn to spawn with, so I would just RPC the chosen pawn to the server when you initially join, then have the server make sure it's okay and use that when calling GetDefaultPawnClassForController_Implementation(). PlayerState is a reasonable place to keep the pawn class, or player controller if other players don't need to know.
It lives in the game instance since it is set in the main menu and needed in all other scenes; i know GameInstance can't replicate, that's why i want to copy it to PlayerState.
If you want the server to spawn you as that pawn, then you need to RPC the chosen class to the Server when joining it.
And add some custom logic to the game mode to not spawn the player until the server receives a pawn.
But how do i keep GetDefaultPawnClassForController_Implementation from beeing called until everything is replicated?
You'll need to customise the GameMode to not spawn the player until they are ready
You could also send the pawn via the "options" string during join, but that can make the options string quite long and cause problems.
It's quite common to have a "Client_OnJoin" function in a player controller that get's called from PostLogin
If i just mark my PawnClass variable in PlayerState as replicated, is there a way to force replication since all players might not have joined at the time of the replication? or does the value automatically get replicated to new players?
Replicated properties will automatically be updated for late-joiners
That's why you should always use them for state/persistent vars
Well it depends, how are you going to know what pawn class they want during postlogin?
That will be selected in the main menu and stored in the GameInstance.
On the client
Yeah, but the server won't have that information on PostLogin
You'll need to tell the client, to tell the server what it is
Oh, that's right....
Something like this.
{
Controller->Client_OnInitJoin()
}
Controller::Client_InitJoin_Implementation()
{
Server_RequestPawnClass(ThePawnClass);
}
Controller::Server_RequestPawnClass_Implementation(Class)
{
if (CheckClientClass(Class))
{
GameMode->SetPlayerPawnClass(this, Class);
}
}
GameMode::SetPlayerPawnClass(Controller, Class)
{
Controller->PlayerState->SetPawnClass(Class);
RestartPlayer(Controller);
}```
Psuedo-code but you get the idea
And override PlayerCanRestart in the GameMode to not spawn them until the PawnClass is set.
Is this needed when i have delayed start on?
Also GetDefaultPawnClassForController_Implementation seems to be called before PostLogin? For some reason?
You'll have to step through it I'm not 100% sure, but yeah you'll need it for DelayedStart too, for late-joins when the match is already in progress.
GetDefaultPawnClassForController_Implementation is called before PostLogin, can i somehow assign the pawn manually without the GetDefaultPawnClassForController_Implementation function?
If it's calling it then presumably it's trying to spawn
how do i ither enable so i can type console commands via the running dedicated server or use a client via a bp tell server to server travel ?
Hello folks. I have a bit of a question regarding replication of a variable:
I have a float that I would like to keep synchronised between server and client. I can either replicate it 10 times a second or give the client and server the means to calculate the value ten times a second independently (and then - somehow - only synchronise the actual float every now and then to discourage cheating).
Direct changes to the value itself can only happen on the server, the client at best has some indirect influence.
Is it ok to have such a "high traffic" replicated variable? Would it be ok to have a few of them per client? Or should I do whatever I can to avoid this situation?
That's good to hear. Although there is probably a limit to how many of these floats a game can handle with this approach. Any idea where that might be?
That looks like an extremely useful tool for later! I'll try to just update my value really often and rely on the engine to be able to handle it for now. Thank you!
Also bear in mind variable replication is lossy, just because you change it at 10 times a second does not necessarily mean the client gets all of those changes, just the eventual state. They almost certainly won't arrive in equal intervals either.
Hey guys - question. What's the current state of testing Steam features in the Editor? Such as Authentication, Achievements, etc.
I'm also talking about Multiplayer. Like, testing two Steam accounts etc.
My last gig around Steam + Multiplayer was like a burden.
For multiplayer you need two PC's or at least a VM
Steam doesn't allow you to have multiple connections from one machine
You can test the game-level stuff in editor, for OSS-level the only true way to test is package, distribute and test.
You don't need to package, you can just launch from multiple computers
Yeah true, though presumably you want them all on the same version
Yeah we always have everything in sync through perforce.
When i want to test multiplayer from editor then I use PowerShell or command line and execute UE4Editor.exe with my uproject as the argument, and do that for as many players as I want to join plus the host they will join to.
Works better than standalone
Anyone have big steam patches when you submit a new build, even though not much actually changed ?
Check in Steam's Builds page for the patch size of each build
yeah they're always >200MB even for small changes
everything
PDBs are completely recreated any time you compile
dont upload that to steam?
you can exclude it in your steam uploader file
put that last line in your Depotbuild.vdf file
thanks
it says >1GB changed for that file but the update is not that big though
so I can't really trust the depot_build log
nevermind the x changed is just the file's size lol
Yeah was going to point out that the next changed size will be the PDB size
but why ?
but it doesn't diff against a local version right ?
The tool might tell you the changed size ; the build page will tell you the exact download size for the update
Gonna be a pain and repost this because I'm hoping someone has dealt with this before.
Does anyone know of any reason why a server would be forcing their morph target values on a client to 0?
The clients morph targets are moving perfectly on the server, but servers are really struggling on the client and it's both on release builds and in editor
I doubt that anything about morph targets is replicated by default, what are you driving the most targets with?
Why are you not just using an RPC to get to the server and then replicating a value back out?
The values are clientside and being sent to the server via a locally spawned actor.
We can't spawn the actor on the server as it crashes due to the plugin we need for it all to run
So the case is currently
Local actor gets input > sends to Pawn as Owning Client RPC > Sends to server to send to Multicast to tell everyone who doesn't own this pawn to update the pawns skeletal mesh with the morph values
That sounds all sorts of f***** up
Yeah it's fun
It's the Oculus LipSync Plugin
Which crashes a client the moment it touches the server
So it's skirting around jank by building up more jank
I just don't understand why the server is happily receiving variables from the client but the client isn't getting the servers vars.
It's really odd
Is it possible, that i spawn something on Client first, then spawn on Server which will replicate to other clients, but i want to keep the client copy who initiated the spawning ?
The client copy will only spawn on the client
If you want it to spawn for everyone you have to spawn it on the server, you can then "Get Instigator" to get the player
I assume the question is about doing a predictive spawn on a client. The common solution is to spawn on the client, call an RPC to spawn on the server as usual. When the server's version is spawned locally it should delete the client-owned version and reconcile whatever state with whatever the server sent.
Does anyone know how does Battlefield do hit detection?
Since they don't use instant hit trace, hit rewind would sound very expensive.
Or is the server catch up to client's bullet based on round trip time? Would still missed if there isn't some sort of hit rewind to compensate lag.
most shooters do rewind. Keep a short buffer of player positions on the server, interpolate back in time by the shooters' RTT when verifying hits.
For hitscan, sometimes just a larger bounds check is sufficient.
Depends on ping and how much you're worried about cheaters
sounds like the player hitbox rewinding moving would be much more expensive than anything the bullets themselves are doing
Ok thxs
It's extremely cheap, you don't actually move the players - it's just data.
We can simulate thousands of bullets and impacts, the main cost comes from RPC's to check hit validity.
is there an example of that somewhere?
Yup its in UT source code, looked at it few weeks ago.
Also did Fortnite uses rewind?
Not sure if they've ever said one way or the other,
Ok
I had thought they used the internal version of GAS for everything
maybe that's just building stuff?
awesome, ty
When dealing with things that modify the Players Location from outside the Timestamp flow (so not via ServerRPC etc.), how does one resolve corrections on start and end of those actions?
E.g. applying an upwards Velocity while being in a volume.
It's smooth while inside, but Server and Client enter and exit the volume on different timestamps it seems, causing corrections.
Or simpler: A Launchpad, where stepping on it launches you.
If that velocity value is high and the Client steps on earlier or later than the server, you will get a teleport correction.
And only doing it on Authority will cause a correction anyway
I can't come up with any other way than making this stuff client authoritive, by letting the client send the server the additional force. But that's not how competitive shooters would solve it
I assume that in theory you should not have to deal with any issues here, as when the Characters move correctly, they end up on the Launchpad at the same timestamp 
Is there a simple (even not secure) way of passing some data to the server when you try to connect to it via OpenLevel? Something like CharacterID or similar
Input server IP, input character ID, click connect and the server receives the character ID that you requested
Any reason you can't pass that data immediately after joining? I know it's possible to send data on joint attempt, but I think it's a little bit involved
I don't seem to be able to even load a value from the game instance and replicate it to the server so I figured I need some other approach
You make the correction client side so you can alter you correction condition during the jump pad flight maybe
Show how you're trying to do that
1 sec then
This is in a simplified login screen widget
And this is my controller's begin play
And unfortunately it's not being set properly
I even tried replicating it to the server after joining but still 0
Okay nevermind managed to fix it! 😄 Thanks for your doubts
Can you not store FUniqueNetIdRepls in a map as a key? Everytime I do it, I get a Pair != nullptr after implementing the hash, compare and equals method
Is this expected? What am I doing wrong?
this is the first spawned character and im trying to get playerstate
but this cast always fails
im trying to set some defaults for these guys
if i run the functions from the event tick it works for all clients
anything else ive tried fails either for all clients or a few, seemingly random
Is this for AI or player? Make sure ur PS_Versus is set in gamemode settings. AI does not use PlayState by default.
What are you trying to do with this?
Store a map of friends in BP that has the id as the key and the value as the new friend data with the updated presence whenever it changes
theyre both players
i got around it by doing a delay after beginplay
I assume this is EOS.
I have not gone that far with it, and recently switched over to PlayFab, since its almost impossible to get a store page on Epic.
Probably copy the values from FUniqueNetIdRepls to custom struct could work.
Use On_RepPlayerState on client or On Possess for server.
This is a better way, but a delay will work.
oh sweet ok
thanks
another quick question, how do i check if a playerstart is unoccupied?
you need to keep track of them
You could subclass playerstart and add Sphere trace function to check for overlap of existing pawn.
Will require somework in C++, but do able in BP.
I'm trying to teleport a player to a set location and rotation when an AI catches him. It works most of the time but for clients I can't seem to fully stop them from moving and rotating. So they sometimes wind up rotated incorrectly or not in the right location. How do I instantly stop the clients from moving so I can teleport them to the correct spot with no inconsistencies? Currently I've tried using a Server event and a multicast to "stop movement immediately", "disable input", and "disable movement". Neither seems to work. I execute this logic inside the AI that catches the player so IDK if that makes a difference. I just need clients to not be able to move. Any ideas?
I think for now I’ll just stick with an array but this sounds like it would work well for TDM or modes like that
Current mode is more like SND so players only spawn once
So choosePlayerStart doesn’t happen after on post login?
it does
Trying to choose spawns based on team and my player states don’t have teams when the game mode hits that
I’m assigning team at onPostLogin
100 percent sure it does
Seems like it should right
Lemme see if I’m doing something else wrong
New to UE4 so could be anything lol
FindPLayerStart gets called
that calls ChoosePlayerStart
that gets called from InitNewPlayer
which gets called from Login
which is before post loign
sooo, you need to do it in PreLogin
or you do what i do, spawn them hidden, at a neutral playerstart, then teleport them over to the correct one
this happens same frame, so player does not even see it
Yea I tried disabling movement on server first but that didn't seem to work so I've been trying everything from multicast to owningClient, etc.
If I stand sill it works fine. But if I'm moving aka walking, then it's like it teleports me to the correct location but I keep walking even if I let off the keyboard. I can't seem to stop the client from accelerating
i am new to multiplayer can someone give me some hints here?
I am calling ClientTravel on a specific player controller to a new map (but it should stay connected on the current server), however i see a bunch of warnings on the output ClientAdjustPosition_Implementation could not resolve the new relative movement base actor, ignoring server correction and then it suddently crashes the client, can someone give me some help or hints on what I might be doing wrong? Thanks a lot
Hey
can anyone help me with something silly, I can't manage to get work the find session blueprint, it only works for the machines in the same wifi, but I cannot manage to connect anyone from another wifi
I have the lan set as false
any ideas?
Which online subsystem are you using?
None
I have followed a tutorial for steam, but I am doing a game for android
Can someone give me a basic understanding on how putting my game on a dedicated server works so online people can connect
Steam doesn't work with Android.
You gonna have to do research on what third party sdk to use for Mobile. Try asking #mobile
I managed to export it to the phone
And I can host the game on one phone and join from another
however, this can only happen in the same wifi
I cannot find the server when it is on another wifi
Because it doesn't work like that.
Does steam overlay shows up tho?
nope
I used the plugin called advanse sessions
But I haven't used the steam features
Yup it doesn't work, even if it does, the host has to open their port, which most of player port are closed.
I haven't followed the thing related to steam at all
what can I do then? dedicated server? or I can manage to have matchmaking through google play systems
?
guys is it true that seamless travel dont work with PIE ?
No, only works in standalone, not PIE.
Yes look into GooglePlay, idk if it lets players host.
Another option is dedicated server where client conenct to it, so no one is required to open thier port.
and for testing, could I use hamachi or something similar? i mean for pc
Since I would like to test the game with some people to change few settings before launching it
been reading some questions on answers.unrealengine that states in 4.25 was still not working properly
okay so let me put the question on another way:
- is it possible to have 2 players in different levels? player 1 is in level 1 and player 2 at some point moves to level 2 using seamless travel?
while player 1 staying in level 1
You don't have to use VPN to do private testing.
Override AGamemode::Preloggin() its where you can reject people if they have right password or what ever your authentication is.
I have none, my setup is just host session blueprint and find session bp
I followed this tutorial https://www.youtube.com/watch?v=EDNF2DNLhPc
Check out my Unreal Engine 4 courses:
►Souls-Like Action RPG with Multiplayer: https://devaddict.teachable.com/p/souls-like-action-rpg-game-with-multiplayer
►Multiplayer First Person Shooter with Dedicated Servers: https://devaddict.teachable.com/p/multiplayer-fps-inspired-by-cs-go
►Multiplayer Top-Down Dungeon...
You'll have to test in standalone and find out, have both client use ClientTravel out of the server to a diff map and try come back in.
Are you trying to make open world game or something? Have you looked in SpatialOS?
yeap kinda of, but really in baby steps still learning a lot about multiplayer, seems hard, thanks a lot man, I will test in standalone then