#multiplayer
1 messages · Page 618 of 1
thank you very much!
Yeah I know what they do. I'm not sure why I didn't install them but I was hesitant to because I didn't think knowing the engine lines would help me in this case. But hey I might be proven wrong
whenever you get to the point where you think theres the tiniest chance it could be a bug or a glitch in the engine, or even you misusing it, those will help lol
they help, but it also helps other folks help you, since a lot here know the engine pretty well
here you go guys
Looks like it's just trying to get the AI class from the GlobalClassReplicationMapList or something before its present
did u add the class to the rep graph?
to this is before the rep graph initializes?
Yes I need a way to delay my AI from even calling that RPC before initialization thats my issue
oh then just set a flag for when the rep graph finishes initializing?
and check that flag before doing rep calls?
Like a bool on my replicationgraph you mean?
something like that, many ways to do it probably
Yeah I get what you mean
also u need to make sure both rep graphs are initialized, client/server I assume
nah actually u don't
I'm quite new to ReplicationGraph, in what method can I be sure its fully initialized?
client won't care if u send down something that it doesn't know about
I don't think
Not entirely sure myself which function, I know that InitGlobalActorClassSettings builds the class stuff
Would any point after adding the class to the global rep class list suffice you think
I'll try that
Thanks for your help either way
hey my find session instantly fails both on steam and on the epic subsystem
If you turn logging to verbose for OnlineSubsystemSteam then you should be able to see detailed logs of what is actually going wrong, like maybe an error message from the steam service
Is there any way to get server travel working in PIE for all connected users? It would make iteration much faster
I have some features that persist across levels and I need to test them. But I have to build and deploy my dedicated server every time as server travel won't work in PIE
no
you dont need to build and deploy a ded server to test
you can run ded server from command prompt
"I:\UnrealEngine\Engine\Binaries\Win64\UE4Editor.exe" "%CD%\Kaos.uproject" TestingLevel -server -log like this
clients can connect like: "I:\UnrealEngine\Engine\Binaries\Win64\UE4Editor.exe" "%CD%\Kaos.uproject" 127.0.0.1 -game -ResX=800 -ResY=900 -WinX=0 -WinY=20 -log
no need to deploy,build or cook
hey guys so quick question. How would you all implement a networked system for acts like in diablo?
so far the only idea i have is level streaming but i hear that's a bit janky multiplayer?
The thing that comes to mind is Level Streaming as well, you mean multiple players on the same map but in different sublevels correct? It will work in multiplayer but you have to work with StreamingLevel names to determine whats relevant to replicate to actors in which streaming level etc
Not really a multiplayer question exactly, but is there any way to change the default match state? As far as I see, when a level is loaded, the state is always 'match in progress' but I'd like it to be 'ready to start match' on level load, as I want to have a 'pre-round' screen so to say
hi, wondered if anyone could help. I have a butterfly which moves in 3d, basically I spawn a 2d invisible mesh underneath it which uses 2d pathfinding, every tick in my butterfly blueprint I calculate the distance+direction this has moved and divide it by the tick interval to SET the velocity of the butterfly's character movement component, plus some z value which varies over time according to a timeline. My movement is fine and dandy. HOWEVER I am having no luck getting the rotation to work either in single or multiplayer, the capsule and mesh will face the same way no matter what direction I move in. The only success I had was using projectile movement instead of CMC and using 'rotation follows velocity' but this doesn't work in multiplayer (plus movement is choppy).
I am trying 'get rotation from Xvector' at the moment (my Xvector being the velocity I calculate on tick) along with 'use controller desired rotation', seems not to do anything. Have tried all sorts of combinations, including 'orient rotation to movement' (and not changing controller rotation on tick)
It's not that initial rotation needs to be adjusted, it's that there is no rotation of the capsule + mesh at all
Edit: eventually got it to work via 'set actor rotation', what the hell... thought that would be bad for replication.
Hi
I have a bp of a weapon that spawns a bullet, which is another bp with a projectile movement, like the first person template.
It calculates the location of the bullet from the location of the muzzle (socket in the mesh). This works fine on the server, but for some reason it spawns under the character on the client. Does anyone know why?
Hello, I would like to ask if anybody knows about a good solution on how to wait for Actor to replicate to client before replicating another property to the same client from server.
For example. Suppose I have Actor A and Actor** B** and both are replicated.
A is spawned on server and he spawns** B**.
Then A will assign B **pointer **to its custom struct's property with custom replication.
In "pseudocode":
struct CustomStructType{
Actor* pointer;
}
class A{
CustomStructType customStruct;
}
A.customStruct.pointer = B;
Nothing in this struct is marked as UPROPERTY.
I need to wait for B to replicate to the client before the custom struct replicates.
If the struct replicates first, then it will point to null since the actors do not exist yet on the client.
And I do not want to mark anything in the struct as UPROPERTY since this is only simplification of the problem to its minimal form.
(in reality the pointer is in a TMap which cannot replicate by default)
SInce UE alredy has a mechanism for waiting for its UPROPERTY marked properties which hold pointers to Actors
I would like to leverage this mechanism.
Does anybody know how to do it, or where in the code could I find it?
This is the first time I have tried to run a dedicated server w/ separate process since UE 4.26 (using the editor) and I am getting the following exception:
[2021.02.14-18.27.02:863][ 0]LogStats: FPlatformStackWalk::StackWalkAndDump - 6.047 s
[2021.02.14-18.27.02:865][ 0]LogOutputDevice: Error: === Handled ensure: ===
[2021.02.14-18.27.02:866][ 0]LogOutputDevice: Error:
[2021.02.14-18.27.02:867][ 0]LogOutputDevice: Error: Ensure condition failed: !IsRunningGame() [File:C:/Source/GH_Repos/UE4/Engine/Source/Editor/MainFrame/Private/MainFrameModule.cpp] [Line: 514]
[2021.02.14-18.27.02:867][ 0]LogOutputDevice: Error: The MainFrame module should only be loaded when running the editor. Code that extends the editor, adds menu items, etc... should not run when running in -game mode or in a non-WITH_EDITOR build
[2021.02.14-18.27.02:868][ 0]LogOutputDevice: Error: Stack:
[2021.02.14-18.27.02:869][ 0]LogOutputDevice: Error: [Callstack] 0x00007ffb7fa1d3ab UE4Editor-Core-Win64-Debug.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalseImpl() [C:\Source\GH_Repos\UE4\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:497]
[2021.02.14-18.27.02:869][ 0]LogOutputDevice: Error: [Callstack] 0x00007ffb3703352e UE4Editor-MainFrame-Win64-Debug.dll!<lambda_9a01b534919071e5a1ae147e2e310ab8>::operator()() [C:\Source\GH_Repos\UE4\Engine\Source\Editor\MainFrame\Private\MainFrameModule.cpp:514]
Has any one else encountered this?
I'm using Debug Editor if that helps
I'm really struggling to understand why all clients UI won't update with my setup. I'm trying to show a 'player wins' screen for all players at the same time.
Here's what I'm doing to try and debug this:
- Fire a Custom Event on my PlayerController on Keypress G which sets the visibility on an ESlate Visibility variable type and some other information variables. At the end I'm firing an Event Dispatcher
- In my InformationHUD User Widget I'm triggering a custom event that is bound to the Event Dispatcher that sets the visibility of a Victory Message Panel.
It works but only for the server as you can see here (it even flip flops nicely). Any thoughts on what I'm doing wrong? (am I even doing anything right?) What do I need to do to get this to trigger for all connected clients?
@stoic acorn Always remember that only Actors can replicate. The only default object besides them that can is an ActorComponent, but that also uses it's actor to do that replication. Widgets cannot replicate or RPC.
Which looking closer wouldn't change your setup really.
Realistically, I'd probably just put a replicated variable somewhere like GameState. That or a multicast if you don't care about state. And call that when the match ends with some information like the winning player that the local client can add a widget to screen and populate.
hmm. I've been bumbling around in the dark with this for a few days now with zero success. How would you go about setting that up.. What I'm actually trying to do is...
- If the final human player crosses a gate (finish line) it triggers the Player Wins screen. How I'm doing this is with an ExitGate Actor that sets a player crossing variable on overlap .. Which then triggers a custom event on my Game Mode to check who has won with the rules that I've set. If valid it will trigger this Update Information HUD screen.
Do you want it to show up at the same time for all clients, or individually based on their own progress?
All at the same time.. It's essentially the end of the match
either that 1 player escapes, or they are caught and the other team wins
I can't even contemplate making a leaderboard screen after failing to get a simple win screen working
Probably GameState then, like I said. You can easily just pass a PlayerState pointer through a Multicast RPC, or set a PlayerState pointer as a repnotify variable. Each client can use that pointer to get info from the passed playerstate to populate a widget and add it to each client's screen.
Winner crosses gate, GameMode confirms, tells server's GameState who won, GameState RPCs or sets the Repnotify variable, each client adds their widgets to screen with the winner's name.
ok.. so I'll attempt to give that a go. Repnotify seems to be a logical choice right?
The bit I'm lost with is "each client adds their widgets to screen with the winner's name."
You could do either. I like Replication for important things. I tend to leave Multicasts for simpler effects that don't really need to persist. Ending the game feels kind of important so I'd probably do a repnotify.
"each client adds their widgets to screen with the winner's name." how would you go about doing this bit? I mean what method?
I thought I was onto a winner with the Event Dispatcher
Before attempting to use Debug Server, do you first have to cook your project?
@stoic acorn If you do something like this in your GameState and a Widget...
Something like this for the OnREP for the WinnerOfGame, which would be a PlayerState type pointer.
Then all you need to do is GetGameState->CastToYourGameState->DisplayEndOfGameScreen with a valid playerstate for the winner.
from where ever you decide who the winner was on the server.
Alternatively, you could also make the widget get the local gamestate to get the winning player on it's OnInitialize to avoid a custom event. Either way.
Ok thanks for all the advice Authaer. I'll give this a go. The hardest part for me is knowing where to put the logic.
Any idea why steam won't work in UE4.26 but used to work in UE4.25?
How can I debug it? Any help?
Are you using pre-built binaries or source build?
I'm at my wits end with oculus
I create a moderated room, I get a room ID back
oculus documentation says to use "Find Moderated Sessions" to find the server and it will return a session to join
(makes no sense cuz there's no session creation anywhere, it's an http post to create the room)
so join session "succeeds" and adds the oculus ID to the room, but fails to join the session on the server, server doesnt see any communication and the url that oculus uses is the same as the client id that is attempting to join (is that by design?).
UEngine::BroadcastNetworkFailure: FailureType = ConnectionTimeout, ErrorString = UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 60.01, Real: 60.00, Good: 60.00, DriverTime: 60.01, Threshold: 60.00, [UNetConnection] RemoteAddr: 3716067065179764.oculus, Name: OculusNetConnection_2147482506, Driver: PendingNetDriver OculusNetDriver_2147482507, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID, Driver = PendingNetDriver OculusNetDriver_2147482507
Is there anyone on this wonderful discord that has literally any idea on how to deal with moderated oculus servers
(Noob) How do I get an owning connection for actor?
How do you think people do timers in a texas hold`em game and make it smooth?
So in my situation, the server tells the client it's your move, then the client starts its clock, but before the client's clock is finished, the server already told the next player it is there turn.
I figure I could have the client send a probe to the server saying the clock is done, but then a hacker could probably prevent that probe from going through giving them-self a lot of extra time.
do the timer on the server and just replicate the end time of the timer to the client.
TheGameState.GetServerWorldTimeSeconds()
Found out I can do that
so what you said, but there is a function for it
Does anyone know how to make a login system like pubg or any AAA quality title . Where we can create a game account or we can login through google or Facebook
Try YouTube for some tutorials, there should be some online login tutorials for unreal.
I think that pubg uses xsolla
@round meadow forget about my question I am only 17 and do not have credit card .
just I think I will use game account login
I guess by recursively going up the Owner Hierarchy until you find the UConnection?
Or at least the APlayerController.
@thin stratus Hi Cedric, ich will mich persönlich bei dir bedanken, für die NetworkCompendium die du öffentlich zugänglich gemacht hast! Ohne die wäre alles viel viel schwieriger geworden 😅 🙏
Liebe Grüße aus der Nachbarstadt MG 😋
No problem, feel free to text me this via DM if you want to write in German though. :P
@dusky echo
Ups sry 😬 🙈
hi
I am spawning a bullet from the bp of the weapon.
When I play in standalone, everything works fine, but when I play as client, the bullet does not work.
I have done some debugging and it turns out that the socket location of the weapon is different on the server and on the client.
Does anyone know why?
@round meadow Hard to say without seeing your spawning logic. Initial assumption is that you're trying to get a socket location from an invalid mesh somewhere, which is returning a default value rather than the expected one.
it's this
@round meadow Well. That looks fine. Unfortunately you're attempting something that is a bit complex. Multiplayer games don't really spawn actors that often for fast moving projectiles. You are right that the socket locations would be in different places. How you fix that really depends. You'll find that a lot of games will spawn a local version for the client to use and that version will decide of the client hit anything and have that client RPC to server to have the server verify the hit. Each time the client fires, the server will have all other clients play an approximate visual that will just exist for nothing more than cosmetics. If you do things like what you're doing now, the issues are that everything only ever happens on the server, and that will feel bad for clients. For instance, if you spawn that actor, it might not even spawn at the same place on the client. If it isn't considered for replication until the next frame, it could be several hundred units in front of the client before it actually spawns on their screen. Some projectiles don't even get replicated because they can spawn and die so fast on the server that they don't get replicated.
My initial recommendation would be to start with some hitscan stuff that are line traces. Make a weapon that behaves well like that between it's functioning and visuals, and then complicate it with actual projectiles.
When I draw the locations from where the bullet comes out, it looks like this
ok I'll try that
@round meadow That definitely looks like your socket is returning the location of your root. Let me look at that function really quick.
@kindred widget what function?
The GetSocketLocation function. Which has now just baffled me.
@round meadow dedicated server?
if so animations don't play on dedicated server by default, so your characters bones/sockets do no match the client
How does that function even work? It takes in a SocketName and doesn't even use it?
FTransform USceneComponent::GetSocketTransform(FName SocketName, ERelativeTransformSpace TransformSpace) const
{
switch(TransformSpace)
{
case RTS_Actor:
{
return GetComponentTransform().GetRelativeTransform( GetOwner()->GetTransform() );
break;
}
case RTS_Component:
case RTS_ParentBoneSpace:
{
return FTransform::Identity;
}
default:
{
return GetComponentTransform();
}
}
}```
thats scenecomp
Oh right. Dur. Inheritance.
{
QUICK_SCOPE_CYCLE_COUNTER(USkinnedMeshComponent_GetSocketTransform);
FTransform OutSocketTransform = GetComponentTransform();
if (InSocketName != NAME_None)
{
int32 SocketBoneIndex;
FTransform SocketLocalTransform;
USkeletalMeshSocket const* const Socket = GetSocketInfoByName(InSocketName, SocketLocalTransform, SocketBoneIndex);```
yep, when I play it as a server it also works, but it never works as a client.
but i'm not playing any animation on the weapon
it was already set like that
on the character mesh?
np
Does anyone knows why Steam Subsystem can't be packaged?
@late cedar I would consider posting that question in either #mobile or #packaging. You'll likely get better answers there since your question is not very multiplayer related.
How would I store and use variables for two bp sidescroller characters ("Score, etc.")?
Like to have each player object have its own stats?; How would I make the OOP?
Local multiplayer btw
Each player has their own PlayerState - override that and store your data there
Ok cool
I'm a bit confused by the network profiler. Is this a known bug issue or is there something I'm missing? I have this NewVar0 array that I'm adding one entry to on keypress on the serverplayer. That is each one of the 11 large spikes. Each of those when checked individually say that 13 bytes was sent. Which is expected, it's a struct of one bool and three ints. Yet when I select the whole area, it says 134 bytes... 11*13=143.
In the shootergame weapon class, AActor::Destroyed is overridden and after the super call, there's a function that stops cosmetic FX playing and deactivates + sets all particle system components to null. My question is why is this even here as if the weapon is being destroyed, wouldn't it naturally stop cosmetic FX by no longer existing?
@kindred widget You might want to check Unreal Insights and see if they have Network profiling. That might give you better info
Hi everyone! I'm trying to use OnlineSubsystems to create and join sessions in a multiplayer game. So far, it works well in LAN. Find session returns the game correctly and I can join from another client.
To enable WAN playing, I port forwarded my PC so that other players can join. When they use the command open X.X.X.X (my public IP address), their player is spawned in the game correctly. However, when we try it through Find Session and Join Session, the Find Session returns an empty array of sessions. How can the sessions be discovered in WAN?
The NULL subsystem just pushes out a "Are you hosting?" question via Broadcast IP.
I haven't really dealt with WANs, so not sure that's supported?
Hey guys, quick one, any idea why when launching an item the client throws the item twice as far
{
// Don't allow the item to collide with the character or environment
R_bAllowPhysicsInteraction = true;
// Call the function manually as the server doesn't do this on rep notifies
On_RepModifyItemPhysics();
// The vector to launch the object with
FVector LaunchObject;
// If we are just given a normalized vector (direction with no magnitude) then multiply by Blueprint values
if (LaunchDirection.IsNormalized())
{
LaunchObject = FVector(LaunchDirection.X * LaunchForce, LaunchDirection.Y * LaunchForce, LaunchForceZ) * LaunchForceMultiplier;
}
else // We are given the full trajectory
{
LaunchObject = LaunchDirection;
}
DetachFromActor(FDetachmentTransformRules::KeepWorldTransform);
StaticMeshComp->AddImpulse(LaunchObject * StaticMeshComp->GetMass());
}```
Uff, Physics and Multiplayer
It's not deterministic. Shouldn't be twice as far, but will probably never be the same
Compare the values and see what both sides do
Also, you are only doing this on Authority anyway?
That's fine, not too fussed about it not being perfect, auto corrections will do this time. It'll need rewriting when unreal handles networked physics anyway
yeah so its an item that it owned by the server
And?
sorry, it's owned by the server, and the throw is triggered by a gameplay ability on the parent class
You mean that when trying to find sessions, this question is broadcasted? Is there a way to ask a specific remote IP adress if it is hosting?
then this method fires after running the super version of the function
Okay, so the only thing you do is add an impulse on the server? And I assume you replicate the transform of this actor?
Well, no.
SubsystemNULL only does the Broadcast stuff.
Other Subsystems, like Steam, ask the MasterServer for a list of registered/created Sessions.
Ok think i found the problem, in order to run server commands the ownership is handed over to the character carrying it, however this was not reset to null so i guess when the function above was firing both client and server were firing it
"Server commands"? Try to stick to terms that are generally used :P
Do you mean ServerRPCs?
Apologies, yes ServerRPC
Can totally be that there is a mixup if you manage to not set the Owner correctly
Theoretically you should be aware of where you are calling a function on
e.g. Server vs Client
yeah i just tested it with setting the owner to null and it worked correctly
okay! thanks I will check if NULL subsystem supports WAN
Thanks @thin stratus you triggered the thought to check that when you mentioned who it was owned by 🙂
I'm struggling with the basics of replication in blueprint. How can I destroy an actor on all clients & server?
If the actor is replicated, and there is only one instance of it on the server which means it will replicate to all clients, then you simply destroy the server instance of that actor and it will replicate the destroy to the clients as well.
Thank you, I didn't have the actor set to replicate.. explains why I've been having so much trouble lol. I appreciate it
HI all, got a bit of a challenge. When my multiplayer round restarts, I want it to clean up the level of dead bodies, dropped items and so on. I'm handling this with ActorItr which is fine, but what I'm having trouble with is cleaning up particle effects like lingering smoke and so on
I can use an ObjectItr to grab every UParticleSystemComponent and destroy it, but then it would destroy any emitters that are placed as part of the level
Is there a way to differentiate between particle systems that were placed in the map and those that were spawned dynamically?
Yea, tag them.
You could always subclass these things that have extra particles and such and just override OnReset and call a LevelReset from game mode.
@steel vault Ah good shout, forgot about tagging. How do I do that? Looking at UParticleSystemComponent but don't see an "add tag" function. Do I need to call ComponentTags and add it manually?
Do they belong to an Actor? Actors have bNetStatic to indicate if they were part of a level or dynamically spawned
^ Even better, if that works.
@silent valley Nope, they're spawned using UGameplayStatics::SpawnEmitterAtLocation, so not attached to an actor
I'll try the tag
That still spawns an actor. Components cannot exist outside of actors.
What would be the proper way to replicate SetActorLocation?
If the object is set to replicate, it should replicate its position. Try checking replicate movement.
Thank you, but that is checked. Its a Character I'm trying to move
Oh, well then if it's a character you need to use the Character Movement Component.
Although, I'm pretty sure it has replicate movement checked so just setting the character's position should work I believe?
On the server all clients move, but not on their client
And i cant find any events related to position in the Character Movement Component
I have an event being run on the Server to loop through each player controller, and tell their pawn to move
Move as in set their location? Or move as in you are calling AddMovementInput
Set their location
I think this is a pretty simple question for anyone experienced in networking in UE4. ...my understanding is that replicating this entire function is pointless (this runs from a dedicated sever)...what's important is what I circled in red..the end result of the function..the actors location and scale etc...this is what needs to be in sync with everyone..so thats what needs to be replicated...correct or no?
What we are currently talking about pertains to this as well. If you are trying to change an actor's position and the actor is replicated, it should just replicate the change as long as it has replicate movement checked.
It seems obvious why I'm having an issue - My event is set as Run on Server, so it makes sense why it only happens on the Server. But i made a custom event (Multicast) to move the actors that is called from this server function also, and that doesn't set the location on client either which has me confused
You don't need to multicast the movement of a replicated actor.
If you set it on the server, it moves for everyone else.
Ah I see
You're not doing the same move a bunch of times separately. Replication of that actor if its movement is replicated means it will change positions after you do it once on the server.
yea for sure multicast here would be terribad
setting values on server and then the result is replicated down to everyone else
Yes.
You can test this by creating an actor, setting it to replicate, setting movement replicated, then set its position with HasAuthority()
Should this event work? This is what I have, and it doesn't
executed from the Gamemode class
And here are my settings for rep
Don't use sequences like that. There is no promise that your shuffle even finishes before the loop starts. That should be a straight execution line.
Oh thank you, I thought it would wait for the first line to finish. I'll change it
Also my StartGame event is called from a button press in a widget, that I'm pressing from the server
Most times it won't pose a problem. But I'd hate the be the person who had to debug it when it is. Just safer to use them when you have two completely differing things that need to happen on the same event.
Thank you, that makes sense
Just so you know, I use set actor location on my Character and it works properly.
Hmmmm
It is odd that it isn't working though. Presuming the pawns are replicated, and your controllers are actually possessing pawns at the moment, that should work fine if called on server.
Yep those predicates are true but still nothing
Worth a debug to remove the spawnpoints, and just put in like 0,0,10000 and see if they all move into the sky at the center of the map.
Then again, even if that was invalid it would still be 0,0,0, which would still move them.
I'll give it a shot to see if they move at all
Yes, try taking out loop iteration.
Simple single set location
Then worry about your loop being the issue
@dense ocean Wait a minute. What blueprint is that event in?
my Gamemode
I have no idea what blueprints replicated events are even capable of being fired within
from what i understand they just need a net owner
The RunOnServer is unnecessary. And your Array of Controllers is also not going to work. GameMode is only on server, and even if it could replicate that array of controllers, only one of them would ever be valid on any client. You're sure this event is even running from your widget click?
Okay so breaking the Location pin caused both characters to move
And i printed out the controllers on all clients, it seems to work. And yes my widget click is the only thing that calls the event
Meaning the location is incorrect? What location pin
Not if it's in gamemode on the server
and @steel vault I broke the New Location pin on the set location node
You can let the server determine where the locations are and set the locations
Oh okay so I'm not sure, yes its on the server in the gamemode
Nothing needs replicated. Since you're calling this on the server machine inside of GameMode, there's no extra networking code required besides the pawn being replicated.
Yea if you have the pawn and you're on the server calling set location you're good to go
You just need to make sure your locations are correct
Put in a fake one like Authaer said
I did put a fake location in
And it moved?
Yes
Ok.. so there's your issue
When it's just 0,0,0 on the node, all works. Why would plugging in the get(0) from the Spawnpoint array cause the issue?
Technically it shouldn't. Unless your pawn is already at that location.
Removing something from the array isn't going to change your 0 value in the array
Oh you're removing index 0
I see
Yes all elements should decrement their index
Even if the pointer was invalid, that GetActorLocation should return 0,0,0, shouldn't it?
Or at least throw an error, which it did not
And the pointer has to be valid because on the server, everything is perfect
You need to put a print in there for get location
And see what it's printing out each time
Okay I'll try
The print returns the correct locations
However it's only printing on the server as it's run in the gamemode, and my issue is on the client. Not sure if that matters
It should only be on server since gamemode only exists on the server
Setting the actor location on server is what you want
Check is valid on the pawn?
Update, when i set the client to hidden in game, then set it back to visible, its location updates to where it is on the server (where it should be)
Might be possible your array of player controllers is empty or less than you think
I can't even use the Steam SubSystem, when I package it it doesn't detect it and when I run it in other computers they can't join sessions
the array is good i did many print debugs for that
Trying to set it too soon
But he already said splitting the location and setting it to like 0,0,0 works.
Yeah so the array is good
im not sure why hiding then revealing the actor puts it where it should be
Hmm yea I dunno then. Sounds like everything should be working.
It's worth asking, does moving that pawn on that client with like normal controls after calling this function make it move to that point?
It doesn't, however, i have these loot boxes that give an item after coliding. After I walk into one with the client, it immediately moves to the desired point
So running into the boxes moves it to the start point that the function should have set it at? O.o
Are you doing a lot of startup replication? Is it at all possible you're saturated or over the upload/download limit?
Definitely not
Pretty much a new project
I think the answer is somewhere within the fact that the server puts the actor at the right location, but the client wont go there until triggering my overlap box, which calls another replicated event
Characters replicate so often for their movement that it should update immediately if that was the case though. Even moving to the edge of the correction radius should do it, which is fairly small by default.
I'm not sure I'm very stumped. I'm not sure what Relevancy even is.. could this be apart of it?
Okay so i was wrong about the loot boxes
It's JUMPING that puts the client at the correct location
Tick teleport on for the hell of it
I doubt it
Alright, I appreciate the both of your efforts either way very much. I learned a lot hopefully someone ran into the same problem and could give some insight
the thing is I can't use servertravel in PIE so i cant get to that level
hey question, if I wanted to be able to use both Steam and LAN subsystems in my game, how would I allow this? I can use one or the other by specifying in in the .ini, but what about both? A launch parameter would be the best solution, but I don't know how this is done.
if you want to use the NULL online subsystem, then just use IOnlineSubsystem::Get("Null") instead of the Steam one when in LAN mode
My host won't see its HUD but client sees his HUD. Any reason why that would happen? I can manually toggle it but not with this: https://gyazo.com/39dd51b83036be0dd157b279ee935986
I have a custom component in my character.
I'm doing that in my component. It used to work and works in standalone but not on 2 separate PC over steam
Before that I've this: https://gyazo.com/7653c1079337e61b770b64e1ec38e146
is there a reason you didn't do something like subclass AHUD instead?
no
Hey...i have some questions about Listen severs. Are there some documentation?
Sorry was that a possible solution to my issue?
emphasis on a solution, yes
since we use it as a general purpose way of managing UMG widgets
Okay so ... you're working with the pawn's controller right?
why then, do you GetPlayerController(0) ?
Don't use GetPlayerController(integer) when you have better context!
Not sure that will fix your problem, but it definitely will cause a bug somewhere if you ignore your context and GetPlayerController
is there a way to get your current online subsystem? basically i want to know if the game went into it's fallback (NULL) online subsystem
IOnlineSubsystem:Get()->GetSubsystemName()
Thanks!
@severe widget So I narrowed down my issue. The host's HUD get's removed when the clients joins the level. Any idea what to debug?
Sorry IDK exactly if it removed it but the host's character event begin play gets trigger again when client joins
So I see the HUD for a sec until the client joins then it disappears
Instead of “Begin Play” and “End Play” you should try “On Possessed” and “On UnPossessed”
On Possessed even doesn't exist in character BP
So you saying whatver is in my character's event beginplay should go in my PC On Possessed. So I should server event
Well you have to realize a few things.
-
BeginPlay gets called on everyone who has an instance of that Actor. So if you aren't limiting it it will call on everyone who's currently in the game. At least for classes like Characters.
-
BeginPlay is too early to perform any owner related things because on BeginPlay, no one is controlling the Character yet. You can't perform rpcs or check if locally controlled.
That's why they are suggesting OnPossessed to you as that would allow to send a client RPC to show the UI.
I am trying that right now but it was working in ue4.25 before but not in ue4.26 even-though I have changed many other things.
Didn't work for me. It seems that after the HUD disappears I still have the ref but when I try to set it visible it won't show.
Hm not sure then. The whole "UI for the player alone" thing is usually pretty straight forward.
In BP
ACharacter -> OnPossessed -> ClientRPC -> ShowUI
In C++
ACharacter -> OnRep_Controller -> IsLocallyController -> ShowUI
In BP/C++
APlayerController -> BeginPlay -> IsLocalPlayerController -> ShowUI
In BP/C++
AHud -> BeginPlay -> ShowUI
And that's just the very basic options you have.
It shows my HUD until client joins as I mentioned before.
Yeah, but that's your code doing it
There is nothing in the examples I gave that would remove the Server's UI when the Client joins
So you are doing something wrong somewhere.
Maybe show us your code
And not only "What is called." but also "Where.", so where it starts etc.
Somewhere you must be removing the UI
@thin stratus is rpc needed? Doesn’t OnPossess trigger on Autonomous Proxy?
What do you mean by this? How would you see a HUD on an unconnected client? Are you describing a situation where you server travel then the HUD disappears?
Cause your HUD definitely gets destroyed when traveling maps
No - From lobby both host and client travels to the main level. the Host spawns first and sees the HUD. After that the client spawns and that's when host loses his HUD. Strange.
AHUD subclass is really the easiest
What do you mean? Create a child of my HUD
"HUD" is a class, in our game it manages UMG widgets on the screen
works just fine in multiplayer
It seems it gets removed from the viewport. strange
Could explain how that could fix my issue?
I'm using BP. I didn't understand then
our implementation is C++ but it's not impossible to do it from BP
the issue is that I have to pass components info to my main widget which i called InvHUD. SO I don't think i can do that from AHUD
it needs an owning player
and when the HUD is created, you might not even have possession of a pawn yet
that's where you make things event driven
@summer tide One of the great things about using the AHUD class for widgets like Swires said, is that only one exists on a client at a time. It's a nice place for UI, specially since anything can get a reference to it very easily via GetPlayerController0->GetHUD->CastToMyHUDClass. You can set up events easily in there that add or remove widgets from screen and keep all of your widget logic in one singular place, and simply let other objects that need to affect UI get and use the AHUD to do it rather than having to open up twenty different classes where you're Creating and adding widgets to screen to track down bugs like this.
Now if I include my custom AHUD in my level gamemode, it should load it
Unless char cast fails
And it does fails - cast fails
Maybe I can create an event here then call that from my controller
You can also do it in the Pawn's Beginplay behind IsLocallyControlled. Then you can also use the same event to update it if you ever respawn the character. Custom event in HUD that gets called and passes in a character reference. If the widget isn't created, create it and add it to screen. If it is created, set new variables and update the widget. Then Character's Beginplay can check if it's locally controlled, if yes, call that event with a self input.
SO currenly I have a widget container with all of the widgets in it such as health, stamina, time, etc.
you might not have a valid pawn at this stage
it's a bad idea to require components to be passed to the HUD creation anyway
I was creating my main widget from my player's custom component . So let me try the new solution to see what causing the issue.
well you were told that hours ago, which was that you were using GetPlayerController(0)
I had a ref to my character in that component, then I tried using the ref as well. Both works it's only when the client joins and host loses his main widgets. So let me try AHUD now.
You can also do it in the Pawn's Beginplay behind IsLocallyControlled.
No.
Pawn's aren't controlled on BeginPlay
You spawn them, they call BeginPlay, you possess them.
That's why you use the PlayerController or HUD for your UI and if it really has to depend on the Character, then you use OnPossessed with an RPC or OnRep_Controller if you have access to C++.
That's fair. I'm used to the game start version rather than respawning. Pawn is already controlled before beginplay is called, but I hadn't considered that would be different if you did that in the middle of a game.
@steep terrace Widgets can't be replicated. So making a replicated pointer to one will return invalid on another machine. And checking for authority right after a server event isn't worth it. It'll only run on the server.
@steep terrace
- Don't mark Widget Refs as Replicated, they "can't" replicate and they shouldn't.
- Mark your HP Variable as "OnRep" and call the Widget's update function in the OnRep
It work!! Thx 😆
Also, the ServerRPC is not really what you want. This would mean you update Health if a Client says so
Step in my mind :
- player shoot a bullet
- Monster damage and reduce HP in Server
- After Server get the updated HP , It use
ServerRPC to send the updated HP to all Client?
I add "switch has authority" so it is not only work in server ?
Well, the Server RPC would mean you let a Client tell the Server to execute the code
HP and Damage should never need an RPC from Client to Server
i realize that this is a newbie question, so i apologize. i just set up extremely basic gameplay for my game and i just turned on dedicated server. after fixing the possession issues, i'm now faced with this problem:
- my character is t posing, so no animations are playing at all. i'm unsure if the anim blueprint is even playing whatsoever
- the player controller is receiving inputs, but the movement is not replicating to the server
can anyone point me in the right direction? i realize i have to replicate the character (and i'm replicating the actual actor itself) but i obviously need to do more
wait, i already see a problem 🙂
So how to the server know when the client hit the target if the client not tell the server ? I know this question quit stupid but I really want to understand it. Or you mean the server check all collision ?
The Client should tell the Server about the performed input.
E.g. if you have a Gun and fire with Left Mouse Button, then the Client should only tell the Server about it wanting to fire the weapon.
The Server can then check if the Gun can be fired, fire the gun and perform the damage stuff.
getting this error in my logs:
LogActor: Warning: SetReplicates called on non-initialized actor BP_PlayerBase_C_0. Directly setting bReplicates is the correct procedure for pre-init actors.
I look like understand it now. It means the client just click a button and all logic will do by server. 😆 Thank ~~~
Yeah, in very simple words :P
Iirc it's because you use "SetReplication" in the constructor while Epic wants you to just use bReplicates =
Started with 4.26 iirc
the thing is that i'm not :\ that's the weird part. i'm inheriting from ACharacter
ConstructionScript?
i'll look around
Might be worth breakpointing SetReplicates and seeing where it gets called from (callstack)
so this is actually happening from my player controller 🤔
happens during APawn::PossessedBy
basically, my actor's bActorInitialized is equal to false when my player controller decides to possess
Sounds like it hasn't been fully spawned
i'm just wondering why it's doing that. not sure why the order of operations is wrong here. should i not be using a Player Start actor?
Are you just using the regular engines' method of spawning pawns or have you changed it to do something custom?
no custom logic
That warning being printed during possession is a bug in 4.26
oh ok
so it's just a bug
The problem is, calling SetReplicates() from the constructor causes actors to be added to ReplicationGraph/NetDriver with the incorrect settings, because they haven't been loaded yet. I suggested a better fix on UDN which was to just assert if it was called during the constructor, but apparently they went with a different fix that just causes warnings to be printed non stop.
That and it doesn't really "fix" anything, unless you happen to be looking for warnings in the log.
Might PR a better fix because it's annoying as hell tbh
makes it seem like there's something going on with the replication when there isn't
I mean there could be, but it sounds like something else is happening in your case. Notably because you don't have any animations and such.
Ah yes, you need to reinitialize Master/Slave quite often
i'm diving into networking now... i can tell this is gonna be fun 🙂
If you've possessed the character, all you need to do is call the "AddMovementInput" functions, and it's built-in networking will handle the rest.
i'm using SimpleMoveToLocation and i'm pretty sure that doesn't work with networking
Yeah that definitely won't work
christ
If you want the pawn the pathfind to different locations (i.e. point-and-click style) then you have to RPC the desired location to the Server, and the Server does all the movement.
But you probably also shouldn't possess it in that case
Are you supposed to use SetReplicates() in the constructor? I just do bReplicates = true; which works fine.
yea i figured i'd need to do something like that. right now i'm just trying to figure out why my master pose component is not working
bReplicates = true; is the correct method
If you make any changes to the mesh, you need to reset SetMasterPoseComponent
Kay. I did something right this week!
Also MasterPoseComponent isn't serialized IIRC, so you probably need to call it around BeginPlay time too (or PostInitComponents in CPP)
yea, i just put my blueprint "Refresh" function on tick and it's working
so definitely i just need to figure out a better way of doing this
BeginPlay should be enough in BP, or anytime you change the animation/mesh asset itself
Also be aware slave components don't/can't have any collision
So the master has to cover for it
If you want collision you gotta use the anim-graph 'copy pose' stuff but that's much less ideal to setup
if i can just figure out how to set up master pose component from cpp i'll be gucci
because i know exactly where i'm setting up the slave components
We do it once in PostInitializeComponents:
HeadMesh->SetMasterPoseComponent(GetMesh());
well jeez that's easy
let me try that
that's funny, i also use the head mesh as the master pose component
i thought i was the only crazy one doing that
the head mesh basically has an invisible body (just the head) but it has the skeleton
ooooooooooooooo
If you wanted head to be master, you'd have it the other way around
But also "because characters", and the way the character movement interacts with the mesh, you probs want the main mesh to be the master
Just because CMC sometimes ticks the pose manually so that it matches up with movement
hahahahah it freaking worked
thank you
so much easier
i can remove entire sections of my code and blueprint now
😄
cool, one bug down
the next thing im gonna set up is an RPC to the server
letting the server know that we movin bruh
so i want to let the server know of the destination that my character wants to move (it's basically just an FVector in the world). am i right to assume that i'll need to keep a property in my player controller that only lives on the server, and then i set up a UFUNCTION(Server) function to change that property?
Hello everyone!
I have a little question regarding OnPostLogin in GameMode
I basically have set up that OnPostLogin players get registered in a Database and it needs to wait for the player to load for some Player Controller Initialization based around the GameMode logic
Here's my wonder
If 2 players join at about the same time, what will OnPostLogin spit out from the NewPlayer if the first player is not loaded yet for example?
I've experienced for example only the last player joining getting proper initialization, any way around it?
Perhaps a loading Queue?
Edit: I may have F up some of my logic, testing new stuff now
Edit 2: Solved
ah crap is it not possible to replicate TOptional? 😦
not possible indeed 😄
😦
TArray is the only template type replication supports
so i need the property to only live on the server. i guess that's just not possible? it would be of type TOptional, but it doesn't need to get replicated to the client
technically, only the movement itself needs to get replicated
and the movement is being performed by the movement component
i'm guessing the movement is really janky because i'm doing some stuff on the server tick. it's probably not a good idea to do stuff on server tick i'm guessing?
i found the problem. i needed to enable Allow Client Side Navigation in the project settings. this is because without it, the client side can't do any predictions and has to constantly snap to what the server is doing
hi, anyone awake?
I need that the server local player is of a type, while the client has yet another one. Is it possible to do so? The game mode allow me to spawn always the same player controller.
you can try overrideAGameModeBase::SpawnPlayerController and do whatever you want
you can also swap them at runtime
I'm trying but I'm failing
Can I do this via BP?
generally you can't do any of that in BP
you could spawn another PC, but there is no way to associate it with a player in blueprints
oh ok make sense why I can't do that
Perfect ty I can try to override SpawnPlayerController then
Also, why it's forced to have a player controller? For example, the server doesn't need a player
What if SpawnPlayerController returns nullptr on server? It will cause troubles or it's totally fine?
Well, seems fine return nullptr
Nope, return nullptr shutdown the execution.
why would the server have a different playercontroller?
i cant seem to see a logical reason why you would need to do that
asymmetrical gameplay would be my guess
why wouldn't it matter if server doesn't have the PC, that one flew right by my head tho
The server doesn't control any actor right? why it need a PC
In an real scenario, (not in editor) the server is just an headless peer where each client is connected to
The Server has all player controllers
yes
Clients have their own. Server still needs them all, one for each client.
Though, it creates one for each client but also one for it self.
A Dedicated Server might not have a local controller, but that's not the same thing.
Exactly, I'm trying to assign an hollow controller to the dedicated server
the server spawns his own local controller?
But there's no local player on a dedicated server so how would that work?
Hmm so I'm probably missing something. On editor, when I start play with 2 clients (one act as server) but it also has a local controller
But it should not have one
Right?
depends if we are talking Dedicated or listen server
ofc listen server will have a playercontroller
Is it possible to spawn a Dedicated server in editor?
is lost and confused rn
bottom one will spawn a dedicated server
middle is listen server (one player is also server)
oh, here the issue then, so I can't have a dedicated server with UI where I can control the settings of each player connected to it.
You can't do that no
I kind of need to do from a client
Yeah, either you have a connected client and build an RCON/Permissions system where clients can change game rules
Or some external app that can communicate with the server
Ok it's much clear now, thanks a lot!
On the subject of replicating TArrays, am I right in assuming that updating an array on client that is static in the sense that the members are not removed, only their values are changed is less bandwidth than replicating a smaller array which is changing indexes all of the time?
As an example, an array of 10 members for the former and an array of two or three for the latter.
has any 1 here messed with steam's inventory? more specificly, dynamic_props ? could really use a hand
@twin juniper if the array size isn't changing then yeah, it probably will be cheaper to change individual elements
With arrays of structs, if you add a new index, the whole struct gets replicated. If you just change one property in a struct just that one property gets replicated. One interesting note is that even when changing a single property, the whole array will resize to match the server's array size, such as if the client removed a bunch of indexes and then got replicated to. The added indexes that weren't part of the replicating properties will be default filled.
@kindred widget Very interesting, thank you for enlightening me. @chrome bay Seems like it, thanks.
Hey guys, can I from game state on remote(server) modify player's local game instance? I want to set some values to their local game instance for caching purposes
you can modify the local game state, or another replicated object
then it can modify the GI
Sorry I meant GameMode, not GameState
I'm overriding FindPlayerStart in order to have dynamic spawn points and while inside the function - I want to to set some values to controller.GetPawn()->GetGameInstance instance
gonna ask again might get lucky this time,
does any 1 have experience with steam backend stuff
i am struggling with dynamic properties
@clear sand GI is not the way to transfer local information into player starts
the timings will be off, for everything
and if you're not doing c++ you have zero tools to get it in execution order you need
alternative is lobby map + client RPCs its information to server, its saved in its PlayerState
then you do seamless travel, the player state will either persist or its data will get copied over when the new one is instantiated
Do you mind if I contact you in PM regarding some details? Would appreciate it
and you have the data, ready, server-side before the pawns are spawned
Im using c++ for coding, but Im struggling to set up correct architecture. Mainly I start my client without connection to server to do login, etc. After that I save login tokens in my game instance, and connection to dedicated server
i was about to take a break, just done with work for the day, so not into long discussions atm
i did have extensive chats about this topic on this channel
I see, no problem, thanks for your input. I think I have some direction to work on
I will give it a try, thanks 👍
basically, tl;dr; version
if you connect to a lobby first
it allows you to setup everything before transferring to game level
if your game level requires clisnts to RPC the data, then you have to manually delay everything until that data arrives, basically overwriting the entire GameMode class
thing is - I dont have lobby, its going to be mmo-like, where locally I do some auth stuff and connect to dedicated only when everything settled
but I have some ideas now
thanks
the login options information is available early enough
its just exceptionally clumsy to handle
multiple pieces of data encoded in a single string... ugh
besides response information, there's 3rd server that handles sessions and other stuff related to game logic, so login actually creates a session on 3rd server and this is the reason why I do this outside of dedicated server before connection to it. Once connection settled - I know I can connect to dedicated server(there's some prelogin things going on as well)
Its not complicated, rather needs a lot of back and forth
Does anyone have experience with Oculus dedicated servers?
anyone have any experience showing a loading screen when the client is connecting? i'm trying to set up a UUserWidget to show on UGameInstance::Init but i still see the weirdness before the server is ready and player is possessed
Has anyone overridden the UControlChannel class to handle async authentication here?
That sounds neat, but I am not sure if there are any major drawbacks to doing it.
"Since UE4 managing auth inside of chain that heads from UControlChannel::ReceivedBunch to UWorld::NotifyControlMessage, it is possible to override its logic and reroute NMT_Join or NMT_Login packages to your custom channel class derived from UControlChannel. You may not close your connection nor sending any data to it and it will remain stall, waiting for your response. Mean while you can do anything asynchronously and than respond to that connection later in way it responds by default."
Hello! I am trying to use a system where it's player hosted servers through steam where players can just join other players sessions, the system works great but there is SO MUCH lag for whoever isn't the host no matter who hosts it...
how do i get two clients to share the same actor present in the level owned by the server, but have different behaviors as if they had their own local copy of that server?
anyone know how to replicate LastUpdateVelocity on a CharacterMovement component? i have an animation blueprint that depends on LastUpdateVelocity, but the animations only work on the local pawn and not on any server pawns
Expose it to your character class and update it on tick and create its own replicated property for it. Or override CMC.
sigh no one really ever answers any of my questions
months just go by. every question I ask is ignored
i have a million questions too bro
the only way youre gonna get answers is with money. and ive offered money and i still dont have many answers
Should I assign a single core to a dedicated server process or two or more cores for unreal? Trying to have a cheap dedicated which is still relatively performant and can serve as many players as possible.. I'm quite new to this
i think 2 is standard
Ok, means I should schedule async tasks mostly after physics probably on the second core
thanks! will try with 2
do replicated properties need to be publicly accessible? as in, not private or protected
no, can be private
is it normal for there to be a lot of corrections when an character is colliding against something?
it depends, usually no
if you're not emulating network conditions, and the obstacle is static..probably shouldn't be seeing corrections
cool thanks. it doesn't affect the gameplay too much so i'll leave it as-is for now
if you are seeing corrections, there could be something amiss with your client prediction
if it gets too wonky i'll send it over
is it generally a bad idea to store replication properties inside of the controller? does it make more sense to move those properties to an actor?
controllers are actors, and a common place to store data that only needs to be seen by the owning client and the server
so do i need to set the controller to bIsReplicated = true?
player controllers should already replicate
you will need to do that for any replicated properties, yes
just note that player controllers only exist on their owning client and the server
other clients will not see them
totally fine
i was moving a lot of these properties over to the unit
but this property in particular makes sense only to the owning client and the server
and no one else
so i'll keep it in the controller
ty @hollow eagle
interestingly, the corrections are happening mostly when i move my mouse and when the character rotates
every 150ms i send a new destination to the server so as to not flood the server needlessly with new destination RPC calls. the rotation is actually determined by the character movement component, and bOrientRotationToMovement is set to true. so i have no idea 
@vague spruce that's a shit community if that's true. I am not at the point of believing that yet. I have been programming for over 15 years, doing all kinds of work, and so far getting basic answer for high level concepts is like pulling teeth. It's ridiculous. Surely someone knows the answer and it would not take long to explain it.
i have yet to get a single person from this community to do (paid) consulting for me, so don't get your hopes up. i have 10+ years
but in general a lot of people here are very very helpful. it's just that some problems are very specific to your implementation
My frustration isn't with those types of questions though. At least then that would make more sense.
My questions recently have been more basic. "Hey, does anyone know why in anim bp, using leg ik suddenly locks the legs inward, starting with ue4.25?" "Works fine in ue 4.24.x" I don't remember the others right now, I would have to search for them and it is late.
i mean, that's pretty ambiguous
it's not ambiguous, it's super specific
too specific for most people to know off the top of their head
and not trivial to test for someone who doesn't already have that environment setup
But it happens in both pre built binaries and source build
With a brand new third person template
Take the default animation bp, slap a leg ik on it, compile in ue 4.26.x, boom, legs lock inwards and the legs stop moving
Well, obviously you have to enter the settings in tbe node
Before compile
I'm not trying to solve your issue, this is the wrong channel regardless. I'm telling you why no one has the answer to those kinds of questions
I’m not sure you’re going to get answers for those problems pretty much anywhere. It’s ambiguous in the sense that there are too many factors at play
Right this is mulriplayer I asked that in animation. I'm just having a bad day. There is no point venting on here.
Thanks for listening to me rang
Rant
game development is incredibly frustrating. i was stuck on a problem today, turns out i was calling Server_Implementation on the client instead of Server
took me hours
i feel you brother
should i just ignore these corrections? my game is running buttery smooth now and it looks great
wow, actually these corrections basically only happen inside of pie. so im gonna move on
friggin pie 
maybe turn on emulate network lag
it really brings out why those problems happen sometimes
good call ill try that a bit later
anyone know how to get both editor windows to keep their height and width? i'm having to resize my window every time
it's buttery smooth now, but for some reason it hitches when the character needs to stop?? very strange
how do you all check if something is running on the client? !HasAuthority()?
GetNetMode() == NM_CLIENT
ty sir
if client created object, it can still have authority
thats a very good call
Remember that no is an answer as well. If your question is something like "hey, does anyone here know why insert pretty specific thing happens?"
If you're getting crickets it probably means that everyone read your question and thought "Nah, no clue". If someone knows off the top of their head, they'll pipe up.
Is there a specific order that blueprints spawn in or is it random? Occasionally ill get errors saying that an actor doesnt exist when i try and reference it in beginplay. Playerstate, playercontroller, character, gamemode, gamestate, gameinstance, savegame are all what i have this problem with.
pretty sure it depends on the loading, if i get your problem, loading time could be random
Hmm. so sometimes the gamestate spawns first and sometimes the gamemode spawns first? Theres no predicting it?
hmm im not sure what the problem is so i dont know what to tell you to be honest
GameMode will always be first since that's server-side only, and the GameMode spawns the GameState
On the client however, you can receive actors in any order
So you have to code around it
GameInstance will always be available. Most commonly you'll have the issue with things like Pawn, PlayerState and GameState
A good way to deal with it, is to create a central event somewhere that all of those actors call (GameInstance or a Subsystem would be a suitable place, since it's always there). Actors can bind to that event, and call some kind of "Setup" function when they have everything they need.
Easier to do in CPP of course
i'm seeing spawned actors appearing and disappearing. the spider is an actor spawned in by the server. any ideas why this could be? i've read online that it's because of RPC spam, but idk
marking the spiders as always relevant seems to work
Most likely the server doesn't know where the player/camera is, so it doesn't know what is relevant to them atm
Oh actually, perhaps the spider is massively offset from it's origin somehow? Or has a tiny relevancy range?
you're onto something. so, the camera is actually 15000 units away
and the fov is at 10
it's to give it an orthographic camera feel
any way to change that?
You can bump it up, but really it'd be better to move the camera closer and use a normal FOV
As otherwise you'll be replicating a lot more than you need to
It might be just me be to be honest, I can't tell that's an FOV of 10. It just looks like a closer camera
But at an FOV of 10 I expect you'll see rendering issues and stuff anyway
it's a trick to get the camera to have an orthographic feel
yea, i've already run into all kinds of stuff
would be great if, you know, shadows worked in orthographic cameras
lmao
i could try a normal camera
let me change it
honestly to me it just looks like a fairly standard FOV that's closer, I wouldn't know the difference unless you'd said
As an alternative, you could also make an engine change so that the relevancy viewpoint is your pawns' location rather than the cameras
And then make the relevancy distance far less than 150M
Actually ignore me you don't need an engine change for that
Just have to override APlayerController::GetPlayerViewPoint()
Maybe just for non-local only and on the Server
!!!! ill check it out
@chrome bay so what i just set the view point to the actor's location?
Yeah just using the pawns location if it has one currently
let's see if that works
Hi guys, i'm experiencing some saturation when the listen server has high framerates
Do these variables even work ?
Does anyone know how to clamp server side net ticks ?
@chrome bay modifying that function breaks the camera unfortunately
oh well, ill figure this out another time
Ultimately you just need to change the FNetViewer::ViewLocation
@tawny mason Run the network profiler and see what's causing it. Sounds like you have RPCs that send every tick or something. IIRC those settings don't affect RPC's
The outrate inrate does not change, it's the packets in and out, so i'm asuming those are saturating my network and not the actual bandwidth
i think they are not clamping my network, the config vars are supposed to be working fine right ?
if i set t.MaxFPS to 60 or 30 the saturation is not there, i assume it could be the rpcs as well, but i dont see any rpc being sent that much
ty by the way @chrome bay
IIRC all those values do is clamp the rate of the network tick clock, I.E. the rate at which it gathers variables for replication. I'm fairly sure they have no effect on things like RPC's, since presumably you want RPC's to be sent asap
ok, i will try to find any rpc being sent every frame or couple of frames but im pretty sure we arent doing that
i'll be back hehe
The profiler will tell you exactly what's being sent and how often
ok i will have another look, not too experienced with multiplayer
thanks again @chrome bay
Tool for displaying network traffic and performance information captured at runtime.
as always thanks for all of your help
Is it just me or is the page this pinned message is linking to broken?
#multiplayer message
All it shows me is a big black box with a button that doesn't work 🤔
https://gyazo.com/57ffa734f9fdb7838425f987010fe28b
I want to replicate the Loc and Rot of an actor (pawn) over rpc's but I have a problem from the client side. I'm using "Switch has Authority". The Server sets the Loc and Rot and replicates as "Multicast" and the Client uses "Run on Server" to set the Loc and Rot. But I think I have a double replication because the movement on the client side is extremely laggy/jittery. Can someone pls help me?
@oblique mountain are you updating a player controlled pawns transform by tick with an RPC ? If that is the case, is it a character ? If not, i would recommend just replicating the actors rotation and rotation with the replication config on the actor class
as @chrome bay said just some messages ago, tick and RPC are not good friends
in the actors default class settings, you can find within the replication category some variables to enable replication of the actors transform
on the other hand, i do not understand what your goal is
You mean like replicate Movement and stuff like that?
Yeah thats probably the reason for the jitter
All you need to do to replicate movement from Server->Client is check "Replicate Movement"
You will get jitter no matter what. Character Movement has smoothing built in to deal with it.
as @chrome bay just said
For any other object, you'll have to implement the smoothing yourself
Usually done by having the root component update instantly, then having the visual components interpolate their relative offsets over time.
So I cannot just say as client a to update the Loc and Rot of this Actor on the Server and all other clients expect client a?
as low as you can get away with
yes you can
but you should not do that with RPC
but using these variables
if you want to make user A set the location of the actor
the only RPC you need is the one from user A to the server
the multicast to all other clients is not necesary
but multicasting every frame is not good either
Just wondering, but a multicast would also destroy the net priority of those replicated actors in this case right?
As in that if you keep calling a multicast that it would be prioritised regardless of whether or not it would have to be prioritised for every client.
Or am I saying something stupid?
But is that not what I have done? If its the Client I'm calling an RPC (Run On Server) to set the Loc and Rot
If I use "Replicate Movement" it only woks from Server to Client so I still manually need to do the replication from the client to the server or am I missing something?
Just a question, but what kind of game do you have Lennard? Because this seems really easily to exploit if you're trying to sync player positions this way, which may or may not matter of course 🙂
Its just a Hide and Seek type game for private use
its so sad that the character class can only use the capsule as collision
this is not correct
and yes it's what you did, but the Server to Clients is not necesary, and the client to server should not happen every frame
given you are using the variables mentioned
Can I use custom collisions with the character class?
2.f is an incredibly low net update rate for characters
Probably want it much higher than that for things that are moving and relying on rep movement
One of the few actors where the default setting makes any kind of sense
Ok but then I have two different methods. The first is the "replicate movement" with smoothing and stuff like that that works only from server to client and the second one is the one over rpc's that just sets the location and rotation. It this correct?
Btw: Thanks for all your answers!
this is correct, my example is not a character 😛
the only reason for using RPC to set a location would be for setting non-client owned objects transform, exp: The server spawns an actor (it's server network owned) a player should be able to set that actors transform, you have to let the server know where to place it.
But don't do it on tick
are you moving it based on the character viewpoint or something ? i would recommend having a desired location variable for example and reading that on server and moving it there, set that variable to whatever you need and whenever it replicates move the objet to that position
Clients shouldn't really be setting the transform of actors they don't own though, that indicates a design issue
true
You should only be sending RPC's to the server with object transforms if it's something the client is controlling movement of (e.g. it's character)
But the character class does a lot of work under the hood to avoid sending RPC's too often
And everything is does send is sent unreliably
this was what i intended to say basically
If it is a character btw, you do that by possessing it and calling AddMovementInput - everything else is done for you
If it's anything else - you've gotta do all that yourself
I was assuming it's not a character
Multiplayer & Blueprint hits a ceiling pretty quickly unfortunately
You can get by with basics, but most of the real sauce is in CPP
I should probably read more about networking and replication stuff
@tawny mason you said that it is not correct that the character class can only use the capsule as collision. Because this was the only reason why I'm not using the character class because I was not able to use something eles than the capsule
you can use whatever collision you put on the character
you will have to support those other colliders and configure correctly the collisions and physics layers but i don't see why you would be stuck with only the capsule
i use multiple colliders on my characters, the capsule is only used for navigation
in my case ofc
character movement only supports an upright capsule though
yes but you can still have other colliders to manage physics, for fitting into a place or something
Does anyone know if there's a way to ping a server to check if its being advertised or not?
Every session starts as being advertised and then gets that set to false once the lobby countdown has ended.
I changed the system from simply joining the first session found ASAP to instead store a list of all available servers.
This brings up the issue though that servers can change that advertised status while players are still viewing them on the server list.
u could have a custom paramater
thats like a boolean
and in find sessions advancd
only find sessions with that boolean being true
in find sessions advanced
Advertised is already a boolean in adv sessions, the issue is that there doesnt appear to be a getter for it, it's only usable during the find sessions, which doesnt help if the server is already found.
If Actor A is spawned and replicated to all clients, and this actor spawns Actor B from within it, will actor B automatically inherit the same replication? Or must it be explicitly replicated
if itll actually spawn and not be a child of that actor, Actor B should be explicitly replicated, im pretty sure
I've created a new ReplicationGraph, and I'm following this as example: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Plugins/Runtime/ReplicationGraph/Source/Public/BasicReplicationGraph.h
I've created a single UReplicationGraphNode_ActorList and added using AddGlobalGraphNode, but the replication is not performed. My character doesn't spawn on the other side.
Consider that in the RouteAddNetworkActorToNodes I'm adding all the actors I receive: GlobalRelevantNode->NotifyAddNetworkActor(actor_info);, but still doesn't work.
Clearly I'm not doing something, though, what? any idea?
It seems the problem, somehow related to this part: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Plugins/Runtime/ReplicationGraph/Source/Private/BasicReplicationGraph.cpp#L23-L53
Any idea why?
If I call HideBoneByName on a replicated skeletal mesh should It hide the bone correctly? I'm trying to use it but it works only on server
The GameInstance is affecting every player or is it being created separately for every player.
Why are you replicating a mesh? As far as you should be concerned, your server has a copy and your client has a copy. Why not hide them both or simply the client version?
Game instance is created when you open the game up, so everyone has their own local instance of it.
Ok got it thanks
It is not replicated.
i see
Hey guys, is there any way of calling server functions on a actor from different players?
I have two characters controlling a pawn but I cannot call the server functions because (I think) it needs an actual owner?
That is correct. The actor cannot make an RPC call unless you call SetOwner on it and set its owner as your character for instance.
3 votes and 3 comments so far on Reddit
Requirements and Caveats: https://docs.unrealengine.com/en-US/InteractiveExperiences/Networking/Actors/RPCs/index.html
Designating function replication across the network
Then what are my options here exactly? 😐
Route through the player controller
Press Spacebar -> RPC to server side PlayerController -> call Jump on TandemCharacter
why is the client1 seeing the client 2 print string and why is the server executing the code aswell
playing as Client
with 2 players
Your options are to call RPCs from the proper actors so either from Character/Player Controller or from the actor after calling SetOwner on it and setting it to a properly owned actor.
if you spawn a replicated actor on the server, can you send that actor back to the client in an RPC?
this doesnt seem to work. In Building Visualization seems to always be null
okay i got it, i gotta put it in a repnotify variable
Is there any replicated ENetRole enum inside of anywhere? I want to skip a server function to prevent clashes between client and server via if(ENetRole == ROLE_AutonomousProxy)
I remember I saw it one day, but couldnt find
How can I join/create session by internet with SteamOnlineSubsystem?
@leaden atlas The generally preferred method for that is to spawn the replicated actor, and then set a replicated pointer to the actor, and do whatever you need to do with it on clients, OnRep.
Playing as a client or playing as a listen server it doesn't matter print string will show on every client when one client does it is that suppose to be or do i need something like hasauthority?
I think you should change the create session to happen when it fails finding sessions not when has finished searching sessions
i tried that idk why it doesn't output than
but my issue is when one client execute this code it outputs the string on every other client
are print strings replicated or something lol
This is an example of an structure of searching, joining and creating a session
And you don't have to open that level when you join a session because when you created the session you alredy are telling to all clients to open that level when they join it
Ohhh i Seeee
this i understand my issue is that when client 1 presses the ready button it creates the session and changes the level and prints the string for itself also for client 2 why is the print string showing on client 2? even tho different client and haven't pressed ready button on that
i will try this
because in your actual structure it will always create a session
try to turn that session into a variable and in -complete if the variable is valid join session and if it's not valid create one
Similar to this one
i low key think you are misunderstanding my problem and i am not being good at explaining haha
I thought you were trying to find sessions and if it fails to create one, but now I'm confused 😅
no lol
when one player joins a session the print screen is shown on every clients screen
😄
Ahhhhhhhhhhh
I think it's because strings are shown to the player screen, but I don't use them frequently so I don't know...
im guessing that they are replicated so eh imma ignore them for now
btw do we have to make our own list of sessionnames or can we make a session with a name ?
I have an actor in my level that generates a maze. I use the gamemode to call the generate maze event, which is multicast. However, I can only see the maze generated on the server. How do I properly replicate this action? What am I doing wrong?
Where is that multicast?
Also in the GameMode?
@dense ocean
Because the GameMode only exists on the Server. You would need to do that in the GameState
oh interesting, yes its in the gamemode
Im having tons of issues, im having trouble trying to replicate damage to everyone
so if someone gets shot the damage is calculated as it should be on the one who got shots side. only one who needs to know their health, but if that player heals, then is shot again, they get killed because the other clients or server still think they have that high of damage.
if that makes sense
so player gets shot and has 10 health
they heal to 100
then shot again they get killed instantly because server or other client still think they have 10 health
Your server should be the only one modifying the actual health values and what happens when they reach 0 (dying etc.). It sounds like your heal isn't happening on the server or you have separate health values between client and server. Make sure server is the only one with the health variable replicated and if it has authority, then make health changes that should replicate down to clients.
see when the projectile hits a player it calls an interface event to the player to deal damage,
the player bp then takes that damage and sets current health
so how would i do this? make a runs on server custom event?
ive looked all on the internet and all examples do line traces for hitscan, not projectiles. and they all keep using the apply damage node, which i think would be better done by calling custom events instead
Sending an RPC to only a specific player only works with client owned actors right?
@thin stratus Thank you! Is gamestate used to handle gameplay events that should be replicated? If not why would you recommend GameState for this case?
I also can't seem to get it work from the gamestate. On begin play for gamestate, i use switch on authority and if authority, I call the multicast event which gets all actors of class (my maze) and tells it to generate
This is the bps in the player, the first event in top left is called from when a projectile hits the player. when shooting the server it calculates correctly but when client is shot, it keeps going back to 12 every time, itll go to 24 but then immediatly back to 12 every time they are hit
Why are you adding damage to current color and then setting current color? You should have a health variable on the server that gets changed by the damage which is set to replicate
because in my game damage isnt taking health its adding color to a player, its strange i know.
but i dont understand
Ok so if Current Color is set to replicate
Then when it changes on the server, that's all you need to do
if i change variable on server, that would change the color on server only wouldnt it?
Delete do damage client and move its logic up to the server node
No.
If the color is set to replicate, it will change for every client
ok let me see
Set it to replicate, change it on the server node, profit.
how the hell does that even work
Replicated properties in UE4 are distributed to all connected clients. That's just how it works.
setting variables through a custom event the runs on server sets the variable on the server does it not?
Yes
so then only the server should be changing
then how does the clients take damage when it isnt called on client
Because clients mirror replicated things
doesnt that mean the client would have the same health as a nother due to it mirroring it?
It means if the server says Player A's health is 90, everyone else see's his health as 90 too without doing anything else but setting it to 90 on the server.
If the client changes Player A's health to 80, the server will backhand the client and put it back to 90 when it goes to change again. The server is your source of truth.
How else would you prevent hacking?
You can't just let the clients do whatever they want, you need the server to make important changes and distribute them out to clients.
i just dont fully understand it, when i call an event of server and say set this variable, the variable is set on the server side not the client unless i call run on owning client
so when i see set current color running through server custom event, i think its just changing the servers color
not the client that needs the color
No. That is the point of marking the variable as "REPLICATED" because it takes care of that process for you
It's UE4 under the hood magic. You change a replicated variable once on the server, it will make sure everyone knows about it.
i thought replicated variables meant its the same for everyone, not in the sense of letting everyone know what it is, but everyones color would be the same because its replicated, which means makes it the same
I don't know how else to explain this to you... yes, if the color is replicated and the color is green, everyone will see the character as green. Which also means, if you change it to red on the server, everyone will see it as red.
One server change, distribution to all clients..
no i understand that now, im just saying what i thought replicated variables meant
Gotcha
i thought it meant if you changed a replicated varible on the server, itd make everyones color that amount,
It does.
i meant everyones personal amount
It just updates the client's local copy of it.
If i have an event that generates a random number and replicate the event to all clients, will all clients have the same random number or a different one from that seed?
I'd test it myself but I'm having a lot of trouble with replication
You replicate the seed itself and then you will get the same number.
Okay thank you
u said it does, i dont think u know what im saying
I don't, but it doesn't really matter. Test what I said and it should work.
it does,
im just trying to specify what i mean so i can fully understand it.
just having it work doesnt mean i know how to implement it unless i understand it u know
I realize that. And I have given very in depth explanations, so I hope that helped.
well as i said u didnt understand what i was trying to tell you, so it made it work but i still dont fully understand it but its fine i suppose.
thanks
So I have a map of items I want to keep replicated across all clients (item id => some item data)
the item data may change sometimes
Try to reread what I wrote. Ask me something specific if you still don't get it.
so every time that happens on the server I have a NMC RPC broadcast those changes alongside with their key
the problem I have now is, when a client connects midway into the game
how do I best send that initial chunk of data to them?
as in, how I do I detect a new player and ONLY send the data to their client?
@steel vault ok so another replication issue then
when shooting the server from client side it does only the 12 damage its supposed to
when anyone shoots a client tho, it does double that amount, there is one server and two clients when testing
Then you are calling the event twice
Where is do damage getting called from?
a projectile
nothing but one thing has collision on it
and the only thing that would react to it on my player is the capsule compnent
called only once when server hit, or when client hit
but double the damage is being done to clients, but not server
Can't really debug your code without seeing or knowing more. If you are only calling the server set event once then it will never do double damage. Print out the damage amount as well
ok ill show the prints
ok here we go
@steel vault client shot server, called only once
server amount of damage
when hitting P
server shot client once, called once, and amount of damage is doubled
sorry forgot the code
this is the coding
that has a code design setup of an unreal tutorial 😦
Seems like dedicated servers don't have SaveGame instances available. Are we supposed to setup manual filesystem OS reading and writing in C++ for configuration persistency? I'm sure there's just another thing I'm not aware.
there is no sense saving a game on dedi itself
how would that work once the game is released? player would have to find a spot on exact same dedi it played on last to continue
My use case is for server configuration - for a listen server, or for standalone, it can be just a trivial savegame that we can use to persist across GameInstances. However for a dedicated server we can't do it that way, so I imagine there's another solution.
its not that hard to manually save stuff in user/appdata/local
Right, so you're saying that we should do manual filesystem OS reading and writing?
i did, did not find the save spot system adequate for anything except roguelike or a platformer at a glance
Right on - I'll look for UE4's filesystem reading and writing interfaces
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
start there
FString UGlobalDefinitions::GetSaveDirectory() const
{
FString Directory = FPaths::Combine(FWindowsPlatformProcess::UserSettingsDir(), TEXT("YourProjectName/Save/"));
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
if (!PlatformFile.DirectoryExists(*Directory))
{
PlatformFile.CreateDirectory(*Directory);
}
return Directory;
}```
this tidbit might also be useful
this returns the User/AppData/Local/ProjectName/Save directory
(on windows, the code is platform agnostic)
can anyone tell my why this is causing it to do double damage to the clients but normal damage to server
even when not being called twice?
Probably it's running both on the server and the clients involved
So the server does it once, and then each client does it to themselves
but its set to only run on server
Good point I'll take another look
Probably the reason is because the clients mistakenly think they're a server for some reason. Is this Dedicated, Listen, or Standalone?
listen
I think if you print IsStandalone IsServer and IsDedicated for everybody you might find that someone thinks they're a server when they're not supposed to be. That'd be the simplest explanation, but I don't know for sure.
how is that even possible
Maybe the Listen Server player thinks they're both a Client and a Server
so do i need an authority check before calling the do damage on server event?
Always a good habit
ill try that i guess
@versed socket noticed a tiny bug in my code there, it should be FPlatformProcess::UserSettingsDir() not FWindowsPlatformProcess to be platform agnostic
@versed socket the authority check worked. what the absolute hell happened?
never ran across this before
your server never did double damage
your clients did damage ontop of the server damage
My guess is that the Listen Server host player probably thinks they're both a client and a server, so when the "client" does Run On Server, it actually works because they also just so happen to be the server anyway
also, please wrap that health (color) setting code in a SetHealth function
as the game develops there are usually dozens of things you need to do that are atomic to health changing
and if you keep stringing them by hand every time you need them, you'll soon want to hurt yourself
oh i know, im just starting thi project so im just getting basics out there
ill organize as i continue
@versed socket thats so damn weird
What I learned when I was new to this was that HasAuthority is something you should always do as a safety precaution
im just surprised it works, because if its remote it doesnt call the do damage event,
which id assume if you were a client shooting someone, then it wouldnt do damage because its not asking the server to do it
but it still works?
that event called from overlap @twin juniper ?
but whatever is hitting exists on both server and client?
the projectile is replicated and only spawned on server side
doesn't matter, if the client handles OnHit separately
and then RPCs the damage
(doesn't matter how the projectile came to be, from replication or not)
yeah the actor projectile replicates, and when client shoots it does a server custom event that spawns projectile
when the projectile hits a player, it calls that do damage interface event
hi guys! quick question, is there a way to know the responsible for an OnRep being called? thanks!
You can't do it like that because the server will call this when it's GameState starts BeginPlay, which is before any client is connected. At least without any modifications.
Try to just use BeginPlay for everyone and cut the Multicast or only call the Multicast when everyone is connected
@hallow acorn wdym? server is responsible because it changed the value of a replicated variable
oh sorry, i meant something like the following... i change the value of a property on server on different functions, what i want to know is from which of them was changed.. when breakpointing OnRep just pops and the call stack doesn't tell the function that changed it but other engine functions