#multiplayer
1 messages · Page 139 of 1
If I was to set "gamemode settings" in a lobby map, and then transfer to a map (and have the aforementioned "gamemode settings" be saved through the level transfer (and thus impact how the game starts and is played) how would I accomplish this?
[Using Advanced Sessions Steam for multiplayer rn]
There's a Persistent Data Compendium pinned on this chat that might help you with this and other questions like it
thank you my good sire
Hi everyone, I have been following this youtube tutorial on how to create both server and client builds: https://www.youtube.com/watch?v=DrkG3W8a_ls. I was able to successfully build/package both server and client, but I receive a crash when a client attempts to join the server:
2023.12.30-12.12.59:322][806]LogWindows: Error: === Critical error: ===
[2023.12.30-12.12.59:323][806]LogWindows: Error:
[2023.12.30-12.12.59:323][806]LogWindows: Error: Assertion failed: CurrentApplication.IsValid() [File:C:\GAS Course 5.3\UnrealEngine-release\Engine\Source\Runtime\Slate\Public\Framework\Application\SlateApplication.h] [Line: 255]
There is more to the crash log, so I am attaching it as well. Does anyone know what this error means? Any help would be appreciated, and thank you in advance 🙂
In episode 17 of the UE5 game development series, we'll configure the project to build a dedicated server and standalone client. We'll show how to cook content for each of these configurations, as well as run them both in the debugger and from the command line. We'll then fix a bug that comes about when the client and server tick rates do not ma...
anyone? 😁
im stilling having trouble with this issue. would be glad if any would give the question a shot 😄
In ue4, is playfab the best way to create multiplayer games for modes like team deathmatch and stuff, or should i try steam, or something compeltely different?
Anyone have pointers on how to get behavior trees to play audio? I tried having the creature it's attached to send a multicast event but it doesn't seem to be sending it for some reason.
Looks like that's inside a BT node? Those don't replicate, they can't have RPCs on them.
- Because BT isn't being ran on the client
- Don't design it like this - call a function on your AI that does the multicast
AIController is what runs the BT, via a braincomponent. AIControllers don't exist on the client (at least not from what I recall)
Thanks! I'm a week into this so still figuring things out, so when you say call a function on your AI you mean the actual creature (in this case it's a robot)?
Yes
You can create an interface that you'd put on any AI that will run this node and inside the implementing actor, you'd call a multicast RPC
Or do a component that replicates
Up to you
Yeah interface was what I was imagining in this case to make it more universal. Just to make it crystal clear, BT is never run on the client, therefore if I try to have it do a multicast it essentially does nothing because the other clients do not own the BT
Correct
There may be some setting somewhere where you can do it. But that'd be a very niche thing.
Makes sense, yeah I've learned it's best to play by the normal engine rules to make it happy. Thanks for the info!
Hello all, I'm running into an issue with a simple client server game, i've tested my game on both multiple machines and with network emulation and I get the same results. The issue is that character movement becomes a bit "chunky" once any amount of lag is introduced (25ms with network emulation). I have a simple ACharacter and I'm using the movement component to replicate to the server (I've tried to remove all other processing that might cause hitches). While I expect the lag, I didn't expect the movement to become hitchy, is this an artifact of running in the editor? or something else I'm doing wrong (if it's just the way it is, I get it, I just want to make sure I understand why). Thank you! (I can provide video if that is helpful).
--sigh-- So... I'm rather new to unreal engine multiplayer and I'm struggling with where to put what. I have a vague understanding how to use gamemode, player controllers, characters, etc... but when I want the client to communicate a manually changed nickname from their side to the server, I'm struggling with where to put the logic. I can do it... I've seen some people set variablesin game state since it's persistent until you close the executable and separate on client and server.
But, there's also player state.
My first idea was on the gamemode... on post login, to annouce "player xyz has joined the game!"
and "OnBeginPlay" I'd grab the game instance, and grab those variables. Buuuut I know the server has a game instance, by running "get game instance" in the gamemode of a server, wouldn't I be grabbing the server's game instance and not the client's?
And if I am grabbing the client's game instance, what if I want to access the server's game instance, how do I go about knowing which game instance I'm grabbing?
Essentially when in a multiplayer game... how can I call "get game instance" for clients and also "get game instance" for the server specifically? How are those calls different?
do I need to do custom events that say "only run on server"? or is there a better way?
@gaunt cliff
GameInstance is persistent, not the GameState
GameMode is server only, calling GetAnything there gets the server side version anyway
If you want the Client's GameInstance, you will need to ensure you call GetGameInstance locally
One way of doing that is in the BeginPlay of your PlayerController, limiting the call to local via IsLocallyControlled and a branch
You then need to send a Server RPC in the PlayerController with the Name retrieved from the GameInstance
In the server RPC you can then get the GameMode (since you are now on the server) and call ChangeName with the new name etc
In c++ it would theoretically be a bit simpler as there you could send the name in the connection string which is available in Login and PreLogin (not exposed to BPs)
ahhh that's what i've done for creating widgets, is locally controller -> add to view port...
i knew game state wasn't persistent, so im wondering if i should load variables into player state from game instance, then access the player state from the server, to avoid RPCs?
You can't avoid RPCs
If you think you could then you are still highly misunderstanding this whole multiplayer thing
they can be expensive though, for something as simple as a name, I've setup nametags above player heads using only rep notify
i don't want to completely avoid rpcs
but the player state is automatically replicated right?
Stop thinking about stuff being expensive
🤣
You can't even program multiplayer games yet. And you are using BPs
If you want to be performant you will need C++ anyway
The RPC is required in your situation
You need to send the name to the server
could i load variables into my player state from my controller, or... my gamemode (main menu) then once a player joins, I can access those variables from the replicated player state?
No
i believe you, but could i get some understanding as to why not?
Only the GameInstance survives the joining of the server
So after joining all your PlayerController, PlayerState etc are fresh and new
And to set something in the PlayerState so the server can access it you still need to rpc
ahhh so anything on my client player state won't be in the copied servert player state
Correct
wait... why do they say player states are replicated to all clients?
or does that mean the server sends us player states, not the other way around
That means that a PlayerState of a given player is available to all connected players
Nothing else
Regular replication rules still apply
so it's like the player state object is automatically multicasted to all other players? am i saying/understanding that sort of correctly?
The PlayerState, same as any other replicated Actor when spawned by the server, will be spawned by the client/s too
Connected via a NetGUID
Have you read the compendium already?
I've browsed through it, but haven't extensively studied it no. I will defintely look more through it. I am curious, I followed a tutorial on how to put nametags above player heads and have that replicated to all clients, and the name is set from the client first. Is this using an RPC? I only see the rep notify
in my "onrepname" function
it's accomplishing this, i think without an RPC?
or is it an rpc just without using a custom event?
because im uploading a player name from client to server and then having all players see it?
No you are displaying the default player name in those screenshots
Nothing there says you are uploading stuff
ohhh it's the get player name running on the server, correct?
for context, this is a view from the player character class
without steam running (using advanced sessions plugin) it just displays my computer name with part of the net ID stuck on the end
Yeah that's the default usually
gotcha, I'll dig more through the compendium. I just had this feeling using RPCs all over was the wrong way to do things, like unreal engine had a different built in way to replicate variables to and from the client/server
Multiplayer is wacky to wrap my head around, things in single player were easy because you can put logic anywhere usually, at least on a persistent level
Now... I'm haivng to learn the proper way to do things and where to put certain logic
It's... a lot
but Im very interested in getting it right
the long way if need be
thank you for the insight @thin stratus
Client to Server is almost always server RPC in a client owned actor
Server to client is normal replication of variables
so rep notify and multicasting right?
With OnRep being an optional convenient addition to get notified when the variable replicated
In BP that's more a property changed notify, so it calls for server too and also if the client would Change it locally ( then only on the client though )
C++ it only calls for clients. When the server sets the variable and it replicated
Additionally server can client RPC on a client owned actor to target a player
Or multicast in an actor that is replicated to everyone
Such as GameState, Character, PlayerState and such
Or your own fwiw
I'm very glad I took a few classes in c++ and did quite a bit on my own. It made it a lot easier reading through advanced sessions source files and then to unreal engine's PlayerState header files... finding the declaration .cpp didn't feel straight forward though in visual studio.
I definitely plan to dive into unreal's c++ soon here because it's not alien to me, but I'm greatly enjoying mainly doing blueprints for now. I still have much to learn.
I also found a little tidbit to smack me on the head in terms of security concerns... having a client dictate anything is usually not a good idea
"What do you mean by “send data” then? You can send whatever events or functions you want, at whatever time you want, to the server. How does this not let you send data to the server?"
"Btw: In general, sending data (rather than just UI/events) to the server greatly increases the attack surface for cheaters/hackers. There may be cases where that’s OK, but I’d be very careful about this in any game put up on the internet."
and from another post I found...
"For replicated variables, the server has authority. So for the client to dictate anything you’re pretty much limited (rightfully so) to RPC."
"You really need to be more clear what you’re trying to accomplish with this client-server relationship. The answer to this question is dependent on this."
https://forums.unrealengine.com/t/how-do-you-send-data-from-the-client-to-the-server/14541/7
It’s not exactly clear what you want. Do you want to send things via RPC to the server? That’s in the tutorial. For replicated variables, the server has authority. So for the client to dictate anything you’re pretty much limited (rightfully so) to RPC. You really need to be more clear what you’re trying to accomplish with this client-server re...
How can I debug server when it crashes? Running Launch Seperate Server - true and Run under one process - false
I know it produces logs, but I can't e.g. look up the variables in IDE during debug mode, like with client crashing
attach the debugger to the new process
Hello, often in my multiplayer game the player's character freezes in the current animation frame instead of simulating physics when he dies, anyone knows why?
I'm fairly new to making multiplayer game was curious on what part to start on first i was thinking of making a single player game first then working to make it multiplayer but idk if that is the best approach or not -
Definitely not. Design for multiplayer from the start.
yeah adding multiplayer to a single player design is the kind of thing they make people do in hell
Start with one of the sample projects. Always run in client server, not standalone or listen server. Multiplayer isn’t easy, but adding it later is 10x harder.
That was my first actual paying job. Never again.
Is it reasonable to assume PostNetInit will run after PostInitializeComponents?
dear god the ways you must have suffered
The game is pretty much done, just gotta add multiplayer
That's like what, 10% of the whole game? Ez
how often is the gamestate updated to clients?
Ah ok thanks
No. Only thing you can guarantee is PostNetInit running before BeginPlay and only on dynamically spawned actors
Since PostNetInit never runs on static ones
Hi guys, I have a locked door with a password, when I go to the door and press E, if it's locked, it display a widget asking for the code, you type the code and if the code is correct the widget trigger an event interface to the charactere BP and then, the charactere BP ask the server to unlock the door on the door BP. When the widget trigger the event on the charactere BP It failed due to "no owning connection for actor BP_charactere". Do you have any idea why ?
ask the server to unlock the door on the door BP
This is your problem
Actors not owned by the player can never fire meaningful server RPCs
Move the server RPC to the character and it will work
this is the charactere bp :
The widget is triggering the keypad event, then the charactere BP tries to call a server event to trigger the door unlock. Is that what you meant ? Thanks for your help
no owning connection for actor BP_charactere
Yeah I just realized the spewed error is referencing the character...
...which is weird in your situation since if you as a player able to control your character and move to that spot and press an input, then it means the controller is actually owning your character
So the character in theory should have a net connection
In this situation I would really debug the hell of what's going on in cpp
Yeah and when I pressed M key I look is locally controlled and everything is fine. If I trigger the same event not from "keypad" but from a key pressed it work just fine. But when it pass by the keypad event it failed "not owning connection"
Indeed if it passes the IsLocallyControlled check then it should not fail with that error
Oh I forgot to say, If the server is doing it everything work fine from the keypad to the characterre to the door. The issue is only when I try it white a client
Yeah a server would never get that error
Since the whole logic is local to the server
I had the same code on another project and it worked just fine from the first try, I wanted to rebuild it with the plugin "multiplayer modular lobby", I'm not sure why but maybe the plugin create the issue...
If for example I have Map 1 which uses Map1GameMode which has a Username variable inside it, then the player is transported to Map 2 which has Map2GameMode how would you get the Variable from Map1GameMode during the OnEventPostLogin event please?
When you travel, that game mode actor is destroyed. You can store any variable you want in game instance or savegame object before opening level
Then when the level open, you can read the variable from where you store it (game instance or savegame object)
i have a dash in the CMC that works in the editor but doesnt work in shipping, has any one seen this before?
To add to what has been said, such a variable can always be concatenated to the Options String which gets sent to the server for a joining client. In fact there is already a "Name" option that you can use (look for InitNewPlayer() function for more) @fiery wadi
Ahh ok thanks for the info, I Was storing the username/playername in the GameMode from Map1 but ofc (Lobby Map) GameMode2 couldnt see it I didnt know you could pass through data in the travel info I,ll look at INitNewPlayer() also but I,ll also look at the SaveGame Object too thanks, Just a quick question I would assume a SaveGame Object is a constant over ANY game mode/instance, and the same can be applied with a Game Instance (IE... The Game Instance is the same regardless of the Game Mode when changing Maps)?
SaveGameObject is saved to your disk, hence why it's resilient to travels
However it's going to be local to your player/client, meaning that you will still have to send it to the server
Hey guys, I'm running into an issue with an event not firing. It's a super simple actor which auto recieves input from player. On the server all of the prints fire up normally but on a client, the "Pressed Action1" print string fires but SR and MTC do not. I've also attached the replication settings for this actor. Thank you all in advance.
As you can see on server all of them fire. But on Client, only the Pressed Action1 fires and then it gets stuck
The obvious usual reason for this is that the said Actor is not owned by the player
The flash light actor in your case
Only Actors owned by the player can fire server/client RPCs
If you was to check your output log you would see an error that says: "no owning net connection for actor flash light"
Actors owned by the player are usually: PlayerController, PlayerCharacter, PlayerState
Oh yeah
Okay so in this case, when the flashlight is "equipped" I can set its owner to be the player and it should work okay I assume
Not that I recommend such an approach
Imagine that you need the same thing for your door
Vending machine
Was going to ask about more global stuff like a door yeah
And whatever other thing that might come to your mind
Just route it through the previously said actors
If the player was to own the actor, it means that no two players can "control" the same actor at the same time
So essentially, have an "interact" event that fires on the player and not the actor itself (like the door) that then routes and fires up any relevant event? Like opening the door would be handled via the interact that is housed on the player. Then the multicast would open the door. I have something similar for picking up the flashlight and dropping it which is handled by the player char and they work just fine
Usually you do own the actor, when that actor is a weapon that gets attached to the player for example
Indeed
Awesome! But what about an actor that needs to fire events that never gets interacted? Like say a chest that would just open on its own
Does it need to be routed through something?
No, since it's not instigated by the player, but instead driven by the server
In such an actor you just fire the multicast just fine
Multicasts are excluded from the previous rules
Oh right, because the event fires on the server and then the server tells everyone else
Thank you, that clears up so much!
Good to note though, that the use of multicasts in your case is still questionable
Multicasts have two weaknesses
They don't care for late joining clients, and they don't care for clients that the actor they are fired on is not relevant
Fire a multicast, make a client join, the newly joined client won't see the effect of the multicast
I see I see
That's why you refer to "replicated properties" in such a case
https://vorixo.github.io/devtricks/replicating-tracked-events/ a great related article that I can reference here
Wack
To be honest I would love to be able to assume that BeginPlay fires after replicated properties are received on statically placed actors
Like it's the case for their dynamically spawned counterparts
Is there a PostNetInit equivalent for static actors? Why wouldn't it fire off for static actors?
Not that I need it. Just curious.
Sadly no. It wasn't built to work that way
Basically:
if (Actor && bSpawnedNewActor)
{
SCOPE_CYCLE_COUNTER(Stat_PostNetInit);
Actor->PostNetInit();
}
bool bSpawnedNewActor = false; // If this turns to true, we know an actor was spawned (rather than found)
Guess imma just yolo and remove that additional check and call it a day 
UActorChannel::ProcessBunch
I think part of this decision comes from the fact(?) that the engine isn't capable to guarantee receiving all replicated properties in the initial replication frame for such statically placed actors
But I just can't think of a valid reason as to why the engine won't have such a capability
I wonder if that bug with OnRep still exists, where if you have an OnRep, InstanceEditable boolean (for example) set to TRUE in the BP class, then to FALSE in the Instance.
And then set the Boolean to TRUE on BeginPlay (Server only) that it wouldn't call OnRep for the Client
Goodnesses I'm glad i asked sounds like i almost wasted a lot of time
Dang, I can't recall I ever used InstanceEditable on a repnotify property... so it sounds like the local value is being pulled from the CDO of the archetype rather than the instance 😬
Yus, that was or maybe still is the issue
I think I just solved an enigma I have been chasing for a while now. Basically if you are using streaming volumes or WP, sooner than later you will start getting the following warning in your logs:
LogNet: Warning: UActorChannel::ProcessBunch: SerializeNewActor failed to find/spawn actor. Actor: MyDumbActor
It simply means that a certain Actor that is (1) replicated, and (2) placed in your level, has failed to load. The issue happens when the engine replicates the actor before it had a chance to load, which results in the ActorChannel failing to permanently open, and will remain closed until you force a reload of the owning streamed level. The issue will also have better chances to happen if you introduce lag and packet loss.
It turns out that Epic knows about this issue, and hence why they already implemented a mechanism to protect against it. However it seems that they just never cared to enable the most important piece of the mechanism
#if UE_WITH_IRIS
static bool bShouldServerUseMakingVisibleTransactionRequest = true;
#else
static bool bShouldServerUseMakingVisibleTransactionRequest = false;
#endif
FAutoConsoleVariableRef CVarShouldServerUseMakingVisibleTransactionRequest(
TEXT("LevelStreaming.ShouldServerUseMakingVisibleTransactionRequest"),
bShouldServerUseMakingVisibleTransactionRequest,
TEXT("Whether server should wait for client to acknowledge visibility update before treating streaming levels as visible by the client.\n")
TEXT("0: Disable, 1: Enable"),
ECVF_Default);
Basically the server doesn't wait for the client's Ack, and yolos... what feels weird to me is that they only enabled it for Iris... like wtf
I ran some tests with the CVar enabled and it seems to fix the issue, but I have to yet run more tests.
Pff turns out it doesn't really fix it although that's really what it is meant to be fixing 😮💨
im just ask the question at the sake it sounds dumb..... does my quest system need to be replicated for a multiplayer game thats not sharing the quest with other payers?
It depends™️
Nothing wrong with replicating information if it makes it easier for you.
it will be simple things just to go from starter area to next town or something nothing major just want to add a little interaction
You can do that entirely server side, sure. But the client has to have some way of knowing what quest they're doing and what objectives they have. As well as current progress of said quest.
Is there a way to maintain array order over network?
A replicated array will have the same order on the client as it did on the server
What’s your array property look like?
Not necessarily
A little bit ago, siliex did a good job at explaining how things can fail in a real world scenario
Maybe i will need to use N serialized objects instead of array?
My array is fixed size anyway
A UPROPERTY(Replicated) TArray<AActor*> will have the same order, eventually, BUT since not all the actors will be replicated at the same time it may initially have null entries in it on the client
Or for longer if they're not all relevant to that client, for example
When i reorder array (changel element from index 1 to 2) will it replicate?
Yes
It is not, i`m not sure why :c
Again, what does your property look like? Does it replicate at all?
Humm
This is not the problem
I found the problem
It is UI bug
Looks like i need to call SetListItems again
every time it changes?
You definitely have to do something when it changes, yes
That isn't binding the list view to your array, it's setting the list view up with a copy of your array in it's current state
I see, ty
No, it is replication problem
It is not replicating changes
When i reorder on server this OnRep_Items is not even called
And you have a DOREPLIFETIME for it?
Yes, it works when i change containers
for example
Look
`When i change from slot index 0 to 1 on bag container it change order on server but no client
maybe FFastArraySerializer can fix this bug
Seems unlikely, but maybe it'll help you track down what's really happening. What you've posted so far should be straightforward and should work.
"The tradeoff is you have to mark elements in the array as dirty when game code changes them. List order is also not guaranteed to be preserved between client/server in all cases."
List order is not guaranteed. I think the only way is using RPC
UItemContainer::UItemContainer(const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer){
Items.SetNum(40);
}
void UItemContainer::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const {
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(UItemContainer, Items);
}
UItemInstance* UItemContainer::GetItem(int SlotId) {
if (SlotId >= 0 && SlotId < Items.Num()) {
return Items[SlotId];
}
return nullptr;
}
bool UItemContainer::TrySetItem(int SlotId, UItemInstance* Instance) {
if (SlotId >= 0 && SlotId < Items.Num()) {
Items[SlotId] = Instance;
return true;
}
return false;
}
bool UItemContainer::ReplicateSubobjects(class UActorChannel* Channel, class FOutBunch* Bunch, FReplicationFlags* RepFlags)
{
bool WroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
for (int32 Index = 0; Index < Items.Num(); ++Index) {
WroteSomething |= Channel->ReplicateSubobject(Items[Index], *Bunch, *RepFlags);
}
return WroteSomething;
}
UFUNCTION(BlueprintPure)
TArray<UContainerItemModel*> UItemContainer::GetContainerItems() {
TArray<UContainerItemModel*> Models;
Models.SetNum(Items.Num());
for (int32 Index = 0; Index < Items.Num(); ++Index) {
Models[Index] = NewObject< UContainerItemModel>(this, UContainerItemModel::StaticClass());
Models[Index]->Container = this;
Models[Index]->SlotId = Index;
}
return Models;
}
This is my ItemContainer code
bool UItemContainerBase::TrySwapItem(int SlotId, UItemContainerBase* OtherContainer, int OtherSlotId) {
if (IsValid(OtherContainer)) {
if (OtherContainer == this && SlotId == OtherSlotId)
return false;
UItemInstance* SelfItem = GetItem(SlotId);
UItemInstance* OtherItem = OtherContainer->GetItem(OtherSlotId);
if (TrySetItem(SlotId, OtherItem))
{
if (!OtherContainer->TrySetItem(OtherSlotId, SelfItem)) {
if (!TrySetItem(SlotId, SelfItem)) {
return true;
}
}
}
}
return false;
}
this is the swapper code (called from client and run on server
chat gpt generated
40 items for me, much better
That bit aboutorder not guaranteed seems to be a quote from https://ikrima.dev/ue4guide/networking/network-replication/fast-tarray-replication/ which is not pertinent to simple array replication
But horrifying
no
fast arrays do not guarantee order. But quite frankly that shouldn't matter, just make your own ordering property on your struct
you don't need to worry about the order of the array if that's not what you actually display anyway
I need order to swap items
you don't though
you just swap the values of their "order" property
the actual position of the item in the array is irrelevant
I see
This is what I've done for inventory too - there is no replicated array at all. Items know what container and slot they are in, and the client builds an array from that. The inventory has no replication at all other than existing, basically.
That said, what you were trying to do should work and is simpler to think about initially.
No. No replicated properties in the inventory at all. Only in the items.
Is what I'm done. I'm still suggesting your original array should work.
I tried the 40 things and it is broken, maybe it is another code
I think it is the Outer object not changing
I fixed the bug
bool WroteSomething = Channel->ReplicateSubobject(Equipments, *Bunch, *RepFlags);
Channel->ReplicateSubobject(Bag, *Bunch, *RepFlags);
Replaced this with
bool WroteSomething = Channel->ReplicateSubobject(Equipments, *Bunch, *RepFlags);
WroteSomething |= Channel->ReplicateSubobject(Bag, *Bunch, *RepFlags);
and now it works
It happened again with a client, instead of dropping to the floor his Mesh stayed frozen but it did lost the collision as in the function
I'm starting to think that when a client is playing an animation and he dies, it gets frozen when I execute the simulate physics node.
The function is multicasted and simple. I don't know yet why this happens
@pseudo crest Reliable multicast?
In theory this is all a state and should be handled via OnRep instead of Multicast
It's not reliable but all my friends that are testing with me have low ping and good connection
Oh, I didn't used any OnRep yet, all tutorials I saw where using the RPC-> MC method
Yeah most tutorials also suck
And if they do it and it's important then it should at least be reliable
But OnRep would be better
Well, I think I gonna change to OnRep and test to see if it stop the bug
@thin stratus thank you
I'm trying to replicate BreakConstraint function. I was able to replicate SetContraint.
Can we use playfab dedicated server for multiplayer mobile game only. Android and ios only. With features like matchmaking lobby etc (pubg like).
Does playfab support for both Android and ios?
And any other good service except playfab then please suggest also
You should check that on PlayFabs Website and forum
Hello everyone,
I have a UI that is waiting for a valid player state. I was checking the OnPossessedPawn but sometimes on the client the pawn is changed before the player state is valid. What is the proper way to wait for the player state initialization?
for now the way I do it is like this but I don't like it...
I notice when I run my game as a client->set team ID of player->then retrieve team ID-> I get a default value I coded instead of the one I set.
This is all happening in the beginplay portion of my blueprint. Everything is being executed in sequence.
If I retrieve the team ID after the beginplay event is finished then my team number is the value I set.
Am I just not accounting for latency in this case? Or is there something more going on?
Did you create the teamID variable yourself?
Yes
You can use OnRep function for cases like this
It's on a component. The code works perfectly if I'm the listen server
And you are setting the variable on the server ?
Yes
The code still functions properly if I'm the client and get the value after beginplay has ran through on my BP. So I think my code is correct for client/server
I suggest to use a OnRep Notify function, like this every time the value is changed you can run your code
Yeah that's the thing too. I see it saying the team is changed on client and server with my onrepnotify as well
What is the issue then?
Hang on.. screenshotting..
This is a part of my beginplay. The team ID is set. Then when I go to initialize my HUD I get the team ID. The team ID I'm retrieving is incorrect.
If I take that initialize function out of begin play and manually trigger it retrieves the correct team ID and everything is hunky dory.
Oh so in the intiialize function you need the teamID ?
Yes this will not be replicated directly since it needs time to go to the server and come back, What if you put the Initialize in the OnRep function?
ah good point okay I think I see the path forward. This is due to latency then
Thanks!
Yes 🙂
I'll have to do some on rep in my BP then. My code is mostly in C++ but I do the UI stuff in UMG
appreciate the help
No problem
If we used Amazon gamelift dedicated server. Can we use Amazon online subsystem to connect it?
I was thinking of doing a delegate on the on rep function and it would be triggered if the client was the NETROLE. Not sure how that work in my BP if I was the server.
Is there a clean way to say "OnRep is finished being called on both client and server" so I can continue executing the rest of my BP?
I just wanted to say Happy New Year to all and thanks to all the professionals and people in the "know", Who spend their time helping the rest of us with issues. 🙂
The OnRep function will be called when you change the variable on the server (instantly) and the OnRep on the client will be called when the value gets replicated to the client. So as soon as you receive the OnRep on the client it will already be finished on the server.
My concern was if I had an event where it just triggered on the client being updated but someone was a listen server
like if I had on_rep->event triggered->populate HUD
I am not sure to follow
I want to trigger an event after on_rep is finished. That event will populate my HUD. The only reason I'm having an event to populate my HUD is because the issue I was facing earlier where the client wasn't switching the variable fast enough when beginplay was called
but if I have an event on on_rep in just the client portion of it that wouldn't work for p2p multiplayer right?
Since someone is playing as the listen server
Why not call the HUD initialization directly in the OnRep?
because that code is in my C++ while my HUD initialization is in my blueprint.
I'm not on my computer but can't you override the OnRep function in BP? Or yes you could create a function for this
Great 😉
Why clients cant apply damage to server? Im running it on server
Check if the damaged actor is valid in your RPC
Well yeah, Im not sure I have a RPC
Isnt this running on server thing RPC?
I think I messed something
Where do you call bodyshot and headshot server? These functions are RPC to the server. I think the variable damaged actor will not be valid if you check it in these functions. You likely need to add this as a parameter in your function and pass it when you call the RPC.
Im calling them run on server like this, and its working now after I change them to this, both happening in player bp
Great
Any ideas why T1 Points is 0 when I have 4 Player Start objects with Tag's T1 in the map please
This is done within a Lobby Game Mode, I have a Lobby Map which uses this Game Mode and then a Player chooses a Team to be on T1 or T2 and then the game mode choose a random location out of the T1 or T2 Spawn Points but because theres no T1 spawn points being returned for some reason it cant place an actor in a random location
I tried getting all actors of Player Start then looping through their tags and it output So it;s recognising all the tags for the player starts so not sure why the array is still 0. :S
I decided to loop through all the player starts instead and filter them by their tags as that seemed to be working not sure why the othe way wasnt working
Hi, I've got a spectating system set up so when the player dies they start speccing other players but i want the spectating player to be able to see any post processing effects that happens to the player they're spectating, right now im doing some post process fx when the player gets into low health states for example but the spectating player doesn't see them because I'm only running them on the owning client atm, how can I go about changing it so that the post processing fx are also replicated to any currently spectating players as well?
So when my server spawns an actor, I need to create a widget and then store the actor's ref. on that widget.
For the sake of performance, would it be better to fire off an interface call to the local player's controller and have them create that widget - or create the widget and set variables on the server immediately after actor spawn? Or does it not matter?
I'm trying to rotate my character when pressing 'a' or 'd'
The replication works fine except that my client only rotates with half the speed than the server does.
I printed out the new rotation yaw and it seems like the client is not increasing the yaw value every second function call.
Can someone help me with that?
Log:
LogBlueprintUserMessages: [DefaultMap] Client 0: 0.41667
LogBlueprintUserMessages: [DefaultMap] Client 0: 0.83334
LogBlueprintUserMessages: [DefaultMap] Client 0: 0.83334
LogBlueprintUserMessages: [DefaultMap] Client 0: 1.25001
LogBlueprintUserMessages: [DefaultMap] Client 0: 1.25001
LogBlueprintUserMessages: [DefaultMap] Client 0: 1.66668
LogBlueprintUserMessages: [DefaultMap] Client 0: 1.66668
LogBlueprintUserMessages: [DefaultMap] Client 0: 2.08335
LogBlueprintUserMessages: [DefaultMap] Client 0: 2.08335
LogBlueprintUserMessages: [DefaultMap] Client 0: 2.6293
LogBlueprintUserMessages: [DefaultMap] Client 0: 2.56594
LogBlueprintUserMessages: [DefaultMap] Server: 0.41667
LogBlueprintUserMessages: [DefaultMap] Server: 0.83334
LogBlueprintUserMessages: [DefaultMap] Server: 1.25001
LogBlueprintUserMessages: [DefaultMap] Server: 1.66668
LogBlueprintUserMessages: [DefaultMap] Server: 2.08335
LogBlueprintUserMessages: [DefaultMap] Server: 2.50002
LogBlueprintUserMessages: [DefaultMap] Server: 2.91669
LogBlueprintUserMessages: [DefaultMap] Server: 3.33336
LogBlueprintUserMessages: [DefaultMap] Server: 3.75003
LogBlueprintUserMessages: [DefaultMap] Server: 4.1667
LogBlueprintUserMessages: [DefaultMap] Server: 4.58337
LogBlueprintUserMessages: [DefaultMap] Server: 5.00004
My Code:
void AOceanityPlayerController::TurnShip(const FInputActionValue& Value)
{
float InputAxisValue = Value.Get<float>() * GetWorld()->GetDeltaSeconds() * 100.f * GeneralTurnSpeed;
const FRotator ActorRotation(GetPawn()->GetActorRotation());
const FRotator NewRotation(ActorRotation.Pitch, ActorRotation.Yaw + InputAxisValue, ActorRotation.Roll);
GetPawn()->SetActorRotation(NewRotation);
UKismetSystemLibrary::PrintString(GetWorld(), FString::SanitizeFloat(NewRotation.Yaw));
Server_ReplicateShipRotation(NewRotation);
}
Servers can’t create widgets
I just double-checked and I did gate this behind a "Switch has authority = remote".
So would that mean all of my players are going to try and create this widget? I do have the intended player controller set as the "Owning Player" pin and the logic does work, but I don't want have player B try to create widgets for player A, if it's not needed. Likewise I don't want to be sending interface calls to the controller if it's not needed.
Any client you want the widget to appear on needs to create the widget. Player controllers only exist on the server and the owning client. So if a controller opens the widget, only that client will open it.
Thank you!
I'm having this replication issue where the first time a player picks up an item it's not replicated (client side it's still sitting on table, with empty hand). But after putting it down subsequent pickups are replicated just fine.
After doing some research I'm wondering if this is some net dormancy issue (somehow not detecting the item needs to be replicated the first time it wakes up)
I could try and force replication but wondering if I'm missing some other underlying issues. Shouldn't every time an actor moves it should get replicated?
so i have this code that suppost to move the items around when i press the interact key and it does that but when i try to replicate it is buggy and it only replicates to th client and not back to the server
Hey I just realized that there's a multiplayer chat and have been attempting to fix a problem over in #cpp . Does anyone who understands the UE socket system have a moment to help me with an unintended behavior?
To give context, I am attempting to create a socket for every character that is spawned. These sockets connect to an external python server that generates a unique socket for each one, processing the data, and sending back movement instructions to the character. This works great with a single character, but when I add 2+ characters, my python server sees the unique sockets that were created for each character, but UE abandons all sockets except one. It begins sending all character information through a singular socket and receives all data to that socket.
You’ve only made one static socket. Right at the top. The second client will overwrite the first, etc. You’re losing track of all but the last socket created.
You need socket to be a member of the character or a component or something, not a static variable
OHHHHHHH I think you're right. That is so strange! So even though the class is instantiated independently in each character, it shares the memory for the static socket?
“Static” means there’s only one for the entire application
You're a god send. This is huge and a dumb misunderstanding of how classes work on my end. Thank you!
If you don't mind, do you have any tips on implementing this better? I have this loop hooked up to the onplay
Just check the "Replicates" box in the details panel
but it makes it jitter
Or in the constructor (in C++), set bReplicates = true;
That is something different
You asked how to make it replicate
That is how you make it replicate.
ok
well it jitters but it also doesent replicate from the client to the server
That's because replication only happens from server to client
ok
"it jitters" means jack all without more context
Am I just to magically know what you're doing?
my fault
i have a blueprint that allows me to pick up objects
but i need it to replicate the movement
how would one do this
In a mutliplayer Arena FPS game scenario as a method to prevent Wall Hack cheats is it possible to not send information about other players positions to the client until that client is about to see them? Say there is some method of determining if Player A is going to see player B on the server in 300 ms and only then send the players positions to each other?
That's pretty much how Riot does it with Valorant
I believe from memory the ShooterGame example project has something akin to this.
I could be misremembering though.
Yes, but that's hard
You can't just check if visible, then replicate as that introduces delay
you need to check if about to be visible, which is a much harder problem
Red point online subsystem is good for multiplayer?
It is very good.
U used it bro?
I have and still do.
You are using dedicated server or peer to peer?
I use both
Also Peer 2 Peer is not what you probably think it is.
Your 2 options are Dedicated Server or Listen Server
I have their EOS one. I've only heard good things.
which dedicated server should i use for easy setup with EOS red point?
Oh snap. I also have the Online Susbsystem one. Didn't even know that. lol
Anyone got any ideas on this one? would like to cross it off my list lol
The spectator would need to know the same information in order to emulate the same effects.
How you manage that is up to you I guess.
Personally, something like Health is typically information that everyone might want to know (although this can be untrue for certain games depending on their requirements).
If the Health was replicated to everyone, then the Spectator would have the information on hand to manage playing a PP effect when necessary.
Awesome never thought of it like that, gonna give this a go, cheers!
World->GetNetMode()
It matters a lot what kind of subsystem it is. If it’s a GameInstance subsystem the world and game mode won’t be initialized until after this subsystem.
Siliex is right anyway. Use GetNetMode instead
almost nothing about the world will be ready
subsystems are initialized super early
that's why there's a separate begin play event from the usual initialize function on world subsystems.
but even if the gamemode was ready you still would be doing things the wrong way here, net mode tells you whether you're a server or not.
seeing if there's a gamemode or not is a very roundabout way of getting that same information.
and preprocessor directives for this purpose are strictly wrong, they are evaluated at compile time. The editor cannot change their result, nor can deciding to run a game build in server mode.
Creating subsystems you don’t need isn’t really a big deal by itself either. The existence of one doesn’t have any meaningful cost. So you can just let it create it anyway and later, when everything is initialized, decide if it actually needs to do work or not.
this has nothing to do with cheating
a subsystem existing or not will not do anything about cheating
If you want code that’s only on your dedicated server, you can do that, but the right way is to put it in a separate server only module
just do NetMode != NM_Client...
"authority" is also the wrong term for this
if MAX is passed in then something is very wrong
and you're likely about to crash anyway
you can also do < NM_Client if you really want
but it's the same thing in effect
return !GetWorld()->IsNetMode(NM_Client);
because it's wrong
authority is an abstraction away from client/server, and clients can have authority over some actors
there is no concept of authority over a world
or a subsystem, or whatever
when someone says "the authority" the implied bit is "the authority over this actor"
but that's not what you're checking here. You're just checking if you're a server or not.
don't call GetWorld
that's what the outer is for
const UWorld* World = Outer->GetWorld();
return World && !World->IsNetMode(NM_Client);
the instance of your subsystem that ShouldCreateSubsystem is being called on doesn't have access to the world. That's why Outer is passed in - if the subsystem gets created then that will be the object that owns the subsystem. But until that decision has been made your subsystem isn't "real".
it's not niche
how can you ask a subsystem whether it should be created... if it's already been created? Or the reverse - how can you ask something that doesn't exist whether it should exist?
the object that function is being called on therefore isn't the real subsystem (it's the CDO).
also, the documentation outright says (some) of this
you'd find out by running the code you originally posted
GetWorld would always return nullptr
It’s niche insofar as most of the billions of people in the world don’t know it. However, as an Unreal developer, the idea that CDOs exist outside of any world is a fundamental concept. CDOs for native classes are all constructed during application startup. Running your code with a breakpoint in that method is indeed a great way to learn that. Yes I shouldn’t have said GetWorld, it’s fairly obvious in hindsight why that function is getting passed an Outer to use.
Is there any way to update both the skeletal mesh with animations from code? Right now I have the issue that the skeletal mesh gets updated with the Move RPC server side, which causes me to have a higher net tick rate, but can this be controlled manually and manually ticked?
I just want to manually tick it regardless of what, based on the data in the anim bp, no rollbacks or anything like that
I know this isn’t a play fab support really but I have a few questions. I’m just doing development and I’m wondering if playfab is the best way to go for hosting, or is another type. And if it is, I know it’s free but it tells me to add a credit card. Will I be charged?
No one can answer for you if it's the best way to go for hosting. You'd have to figure out if it fits your requirements of cost, features, reliability, scaling, etc. and compare that with other hosting sites to see what fits you best.
A lot of the features in Playfab are "pay per use" in the free tiers so if you happen to use a feature that they charge separately for, then yeah, you're going to get charged. Going above 150k requests also seems to incur charges, so if you've coded something poorly you could potentially use up those 150k requests quickly depending on how many requests you're making. Finally, 750 compute hours hosting is free per month which is equivalent to having 1 server running 24/7 for 31 days (probably on their "cheapest" tier of server). If you happen to have more than 1 server running or request a more powerful server you could end up using more than those 750 hours and get charged.
Niche is relative.
If you work with these things constantly you find out quickly what is and isnt niche.
Do you think it’s worth it to do playfab. My end is goal is to have a battle royale game mode, and also an other tdm related game mode. I’m mainly looking for a dedicated server hosting that I can use
I wouldn't be able to answer that as I've not used Playfab. Do you actually have a game that is basically ready to actually start being hosted by third parties?
I’m near it. What have you used before?
I only ask as it may not be wise to focus on hosting if you've yet to complete larger portions of your project. It's good to figure it out, but unless you have a game to be hosted, why bother with trying to have it hosted at all.
Personally I've tinkered with Gamelift a bit and Braincloud though not the hosting aspect with Braincloud though they do offer it.
Still, I don't believe figuring out the hosting service you should use is something that anyone can really guide you on - it's heavily dependent on what you're expecting out of a backend service and what you need it to do, and how well you can work with what they offer to meet your goals.
I'm sure there's some barebones hosting service out there that gives you scalable servers, but gives you nothing else, like storage or leaderboards, and they may be dirt cheap, but that may not be what you actually want, and may be more difficult to try and integrate some other third party service to add those additional features.
https://www.youtube.com/watch?v=KPStJGB_tD0how would one make a system like this with blueprints
ive already tryed
i guess im doing something wrong
Mainly right now I’m testing it for development and making sure everything works and lines up. I’m also looking to online store values and thst stuff
im using a physicshandle
How do you save and load players in multiplayer? So I have simple project. I don't have a lobby. I start in editor with 1 server and 1 client. Save the game by iterating over all BP_Character then save their stats and location. When I load i load the save-game, but then what? Also when saving players what else need to be saved?
Heads up that this won't work in editor because of the obscure lifetimes of PIE Worlds. There's a working one here:
https://github.com/TheJamsh/UnrealSnippets/blob/main/Code/World Subsystem/ST_WorldSubsystem.cpp#L65
GetSafeNetMode() being the key part to look at
James, for real you gotta PR that function ❤️ 😄
Honestly it's such a horrible workaround I'd be amazed if they took it. It's borderline pure luck it works 😄
All just down to how the editor splits off game instances for PIE, the whole thing is such a mess
unsurprisingly
I would like to bring your attention to this if you don't mind, maybe you can shed some light or something
Basically if you leave the streaming volume and re-enter it super fast, net startup actors will fail to load on client
Urgh :/
There is a system that is meant to protect against that using transaction IDs with acks and what not but it fails miserably
What I can tell you though is that from last night's investigation is that Iris works flawlessly on 5.3 at least
I wonder if it's some kind of naming collision thing, since those net startup actors will all be identified by their path name
Right. I assume it's just the server not caring really about these pending acks and yoloing replicating that actor
Will have to do more iterations to pinpoint the issue
I remember in HLL we had so many hard to repro issues with map-placed actors replicating (even though we didn't use streaming vols etc) - we ended up making everything dynamic with spawners. We only had a handful of them though, wouldn't have worked on a large scale for sure
But that was like pre 4.25 too
That was a suggestion indeed, but I'm too stubborn to make it work this way.
Yeah definitely not an ideal solution
Yeah dormant initial actors would lose their value for example
At least now I got an incentive to move to Iris xD
Yeah mind you that isn't free of it's own trials and tribulations 😄
Indeed. Gotta evaluate what sucks less
But I feel that Iris is making its way to stability real fast
Fortnite is porting its RG infra to Iris
Yeah FN is gonna be on it asap, got a good hunch that Iris will be out of experimental come 5.4
Whats the best way to get an FPS character? Not true FPS where the real world model is used for the player, but one where the hands and weapons are rendered ontop of the other objects in the scene (so they cant be clipped into the walls) and potentially adding legs/feet to make it so when you look down you can still see your legs and feet?
I've heard about using panini projection, but I also have heard that causes lighting issues
I've heard about using a scene capture to render the actors into a UI layer
I've heard about modifying the engine and adding render layers (so you can render certain objects on-top of other ones, which is sadly not a default feature of UE5...)
Thoughts?
Make the mesh tiny.
Literally the simplest way to do it
If the mesh is contained within the player capsule, no blocking collision will clip though it anyway.
but if anything does get into the mesh it appears insanely large comparitively (as well as the whole receiving light/shadows as well as casting shadows thing)
You need to make the mesh so small that nothing can do that, then just attach it to the camera. FPP mesh doesn't usually cast shadows on anything but itself.
Receiving shadows, well yeah - if the mesh is tiny, it'll be either in or out of shadow usually. Not much you can do about that
Obviously if they need to interact with in-world objects via animation etc accurately, then any kind of reprojection or shrinking is not gonna work
Lots of ways to approach it in general but it depends on the game really. For a generic FPS I'd just be shrinking the arms + attaching to the camera, and using some kind of material FOV reprojection to avoid them looking awful at different environment FOV or on ultrawide screens
why am I getting same player reference? I try to check different players but "target" is always same object
Hello
I'm using console Command "Open"to connect to the server, will this command be available in shipping builds?
Obviously not. OpenLevel does the same more or less
Thank you
I need some help regarding Multiplayer. In the game when the server instance is loaded there are 4 abilites which the player can overlap to take it.
So if a server takes an ability and the client connects at later time. the client does not know if the server (or any other client) has taken any ability already or not..... so what logic do i put where? (Game State, or Player state)
Im trying to learn about multiplayer frameworks, and I nearly understood all about gamemode, gamestate,playerstate, gameinstance, but I have a doubt about a thing in particular.
I'll use the Mario party example: basically you have the board with each position of items, stars, coins, players and each player inventory informations, then at the end of the round you change lever and play there, then the winner info is passed to the board level again, the thing that I dont understand is that as I understood the only frameworks that persists on level change are playerstate and gameinstance but seems not to be safe to store informations there isnt it? Because keeping the informations about item on board position to load again when reopening the board level and when gamemode and gamestate are created again in gameinstance is easily manipulated by client and also gamemode and gamestate are created based on the level.
Where am I wrong?
Is there a way to switch from using EOS to NULL for LAN sessions, if Internet is not available ?
how would you do a function every 30 days in real time? as in, a player uses a certain currency or power but it regenerates every 30 days ?
I think not. It's their duty to ensure that they get the net mode properly
But it's a nice addition regardless
lmao, so when they use the particular variable, i set a timestamp on the server? when you say backend, you mean just on server right? or is there a particular node/function you're saying that does this?
realtime basicaly effects the game, and the server should already know this based on the time
would this require some outside coding ? like a javascript or something basic?
ok dope that makes sense, yea i have one idea, but not efficeint , and yea dont know anything about javascript i just picked one that i knew of lol
I would not eleminate them for this, but instead work my way around it. Something dirty you can always do is destroy the subsystem locally where you don't need it 😄
does this mean it's easily doable?
And answering your question, I think it's just to save yourself some memory that you know you are not gonna use. Also bugs...
dope yes, maybe i'd have it give a couple of calls to regenerate like 2-3 times during this 30 days, but yea that makes snese
For example a client execution path that tries to get the subsystem silently is way worse than crashing to a non existent subsystem
(Where a server was only meant to do so)
Worst case scenario you will get a subsystem that you didn't care about, best case scenario you will crash 😄
Indeed, hence why I wouldn't care about fiddling with it
No, you're good. I actually have a "visual" use case, where I only hold back clients from initializing the world subsystem, but still use the subsystem in a way where I need it on clients
Yeah I wouldn't think so tbh, the only reason I've added it myself is just so I can have server/client only subsystems that might not be relevant to the other etc. Qite a rare case though and is usually MP specific
the functions we call on beginplay don't need to have any Server or Multicast properties?
I mean if I call this function on beginplay,
UFUNCTION(BlueprintCallable, Category = "Component Update")
void UpdateMag(TSubclassOf<class UAccItem> MagAccObject);
does it need to be UFUNCTION(reliable, client) or UFUNCTION(reliable, server) ?
You should never need to call a replicated function on beginplay
Because if teh actor exists on all then beginplay will be called on all
If anything you would change replicated properties on beginplay and that's typical
so calling a non-replicated function on beginplay with if(HasAuthority()) means the function will be treated as it was a UFUNCTION(reliable, server) function?
Kinda. If you call a server rpc on begin play, it might get called twice. Once locally on the server, and once when the real rpc fires on the server
yeah logically
It's just pointless to call rpcs on functions that would end up calling on server and client
That's a rule of thumb to remember when using rpcs
BeginPlay calls functions as reliable or non-reliable?
I'm not sure I understand the question
BeginPlay will reliably call functions if it executed in the first place
bump
Can anybody tell me why when I look from server player to client, bones are hidden, but client player can still see bones on server player.
Also, the bird have a "set simulate physics" node when it die, client can trigger the event but cant see the result, and birds bp looks like this
Can someone please clarify if im thinking correctly about this, If i had a Widget for T1 and T2 to select a character this OnClick would fire to the Controller then the Controller would send the relevant Team choice to the Server(GameMode) to spawm the relevant Charactr Class (T1 or T2) So order of logic Widget->Controller->Server
Guys how can I add the enchanced input in multiplayer? Like this it works only for server, shouldnt begin play run both on server and client? i tried adding a branch with is locally controlled and wasnt working for both
The way I do it is in C++. The PC has a function that gets called by the server when it possess a pawn. AcknowledgePossession. I set up the bindings in that function. Works fine.
Pretty much, yeah. Use the controller as a vessel to talk to the server from the UI.
Is anybody here familiar with GameLift integration & OpenSSL? Trying to build the .dll files for GameLift, but my terminal is throwing an error:
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
I've double-checked my environment variables are set per the readme, but still no luck. Realize this might not be the correct community and I am open to suggestions on where else I can find support.
I mean, your first stop should be on GameLift's forums
Hi, I'm having some issues with replicating post process effects over to spectating players.. when a player dies they'll start spectating the next alive player but if the alive player has some post processing effects on screen, the spectating player cant see them because I'm only running them on owning client, any ideas how i can change this to get it working how i want? I originally was just gonna get the current pp settings of the alive player and apply them to the spectating player when they start spectating them but because im using Set View Target with Blend the spectating player doesn't have a camera to apply the pp settings too since their view target is now the alive player, so i'm a bit lost on how to do it since the spectating player doesn't have their own camera anymore, any ideas?
Im still stuck at this.
Made a new project and copied over a bunch of code so I could have my game use UE 5.3.2 and have Enhanced Input be the default used input system, and my game is getting this error and it has smth to do with calling IsLocallyControlled() in my OnRep, I didn't have this issue at all in my last project and everything works well up until this point, ill give anything else you'd need, thank you for helping
Put print strings in your code. Does the event any damage even run?
Code runs properly, but only for server player.
How far does the code get clientside?
Client character can damage bird and kill it but after dying that ragdoll/Animation code only works for server
Does the multicast make it to the client?
no, only server player can see
You really oughta be using replicated variables and RepNotify though
I wasn't asking what they see, does the multicast event fire on the client?
I guess its because players dont own the bird actor, isnt it?
First off you shouldn't have a run on server event here
detect damage serverside, then set a replicated bool, and in the onrep, set the ragdoll state
you can multicast the ragdolling for now but there should not be a run on server event here, it's redundant. Client can't call it anyways as they don't own the bird.
The run on server event should happen when the client shoots, not when they hit something
I didnt get it, the event happen when actor health is 0, so how can I know actor health is 0 before it hits?
I dont know much about that repnotify nodes
What causes an object to resolve to nullptr randomly during gameplay, after it was initially resolved to a valid pointer? in the debugger its valid, not marked pending kill and registered in actor subobjects list
TSharedPtr<FRepChangedPropertyTracker> UNetDriver::FindOrCreateRepChangedPropertyTracker(UObject* Obj)
{
check(IsServer() || MaySendProperties());
const FObjectKey ObjectKey = Obj;
checkf(ObjectKey.ResolveObjectPtr() != nullptr, TEXT("Unresolveable object %s received in FindOrCreateRepChangedPropertyTracker"), *GetNameSafe(Obj));
return UE::Net::Private::FNetPropertyConditionManager::Get().FindOrCreatePropertyTracker(ObjectKey);
}
my damage code is this btw, and its working when players kill each other, both client and server can see other player dies and ragdolls
but same code dont work on bird actor
I really hate that owner thing...
Because this run on server event is being executed within something the client owns (their pawn)
You shouldn't do it like that though
You don't need the redundant run on server events
Your code is running on server from here on out. The apply damage is only being called on server, so just act as if you're the server from Event Any Damage
I understood that, but I still cant find a way how to let bird actor ragdoll run on server
It already is
assuming the damage function gets called, the code is working serverside
check that first
make SURE the damage function is getting called when a client shoots a bird
Ive also tried adding a post process component to the player and apply the settings to that but its also not working lol any ideas how i can do this properly?
I feel like you're making this WAY more complicated than it has to be
First off, what actually runs the timeline?
I prolly am lmao but thats cause i aint figured out how to do it a better way yet! So every time the player takes damage it checks to see if their health falls between a certain range, if one of those ranges are hit it'll call the respective timelines
For the post processing FX i essentially wanted it so if they hit half health a heartbeat sound starts playing, when they hit quarter health range the heartbeat sound will slow down its BPM and play some post process FX and then same again when they hit low health range, which is working as i have it now but timelines are a bit of a bitch to make sure they account for all possible outcomes lol
But right now i'm trying to figure out how to make sure that the spectating players can see what the alive player sees on screen and hears the heartbeat sounds
You really need some repnotifies I think
And yeah, runs on owning client
spectator isn't owning client
Yeah ik its run on owning client but I'm not too sure on how to change it to make it work for only the alive player and the spectators without replicating it to everyone else
IDK what your current setup looks like in depth but I'd approach this by just driving the FX state by some replicated state (your HP)
So i should do them in my health on rep?
I would. Assuming HP isn't private and you already have it replicated
Then it's just up to the client as to what to do about it
Yeah my health is already set to on rep, so in the on rep function do i then just need to call the range check event from there or is there a better way to determine different ranges?
Is there a way to "know" (listen?) when the server spawns an actor on a client?. (so I can do stuff on the client)
I mean I would map hp to some variable StrawberryJamIntensity and smooth it over time and drive my stuff with that
begin play
void AItemInteractableBaseClass::SetVisiblityForWidget()
{
float Radius = 200.0f;
TArray<FHitResult> Hits;
FCollisionShape Sphere = FCollisionShape::MakeSphere(Radius);
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);
if (GetWorld()->SweepMultiByChannel(Hits, GetActorLocation(), GetActorLocation(), FQuat::Identity, ECC_WorldStatic, Sphere, Params))
{
for (FHitResult Hit : Hits)
{
AActor* HitActor = Hit.GetActor();
ASentinelCharacter* SentinelCharacter = Cast<ASentinelCharacter>(HitActor);
if (SentinelCharacter)
{
InteractWidget->SetVisibility(true);
}
else
{
InteractWidget->SetVisibility(false);
}
}
}
}
guys how i can call this function only locally that this will be changing only for a player that stepped into this item?
oh, duh.
Ooo im not sure what you mean, how do i do that? if I can avoid timelines I will cause making sure they correct for one another when health state is changed is a bit of a bitch! also even if FX are ran through the on rep, how would that then help towards making it visible to spectating players?
When you say over time, are you talking with a timer or using tick or something?
You can even forget the onrep
before calling it check if the player controller is local
IsLocalPlayerController()
Tick / Timer -> map HP to SomeFloat -> Smooth SomeFloat -> drive visuals with it
For instance we have a float representing combat intensity which smoothly interpolates from 0.0 (nothing goin on) to 3.0 (active combat in a boss battle)
and another represnting danger or low hp, which goes 0-1
the 2 combined are used to drive dynamic music mixing
I'm running into a weird timeout issue in my live Steam game. If a player's hardware is lower and loading into a server takes too long, Steam times them out and it fails to connect.
Is there any way to increase the amount of time a client is allowed to connect to a server thanks to the map load time? Or is there another solution here I'm not thinking of (besides better optimizing my load times. I'm working on that as well)
Btw, tl;dr, I have a "board" that keeps track of all my units, and depending on the tile occupied X or Y should happen, that means that the board itself should probably be an actor spawned by the server and fully replicated?, or I can I keep it like a level instance.
like in Stellaris? Where your fleets etc are on an outliner in the UI?
Well its definitely called because bird is still dying for server player, even if client player kills the bird. But client player cant see birds ragdolling/animation change.
not super familiar with that game, but picture a chess game where the pieces move smoothly, and depending on their tile stuff happens.
So like a background sim with actors as a view of it? Or are they just actors in 3d which move on a board in 3d?
second, actors move
enemy actors find each other in the same tile, an encounter (fight) happens
so Im thinking the whole board should be replicated as just another actor
in default engine ini file
[/Script/OnlineSubsystemUtils.IpNetDriver]
DefaultConnectionTimeout=30.0
that might be a quick fix but you need to see whats causing long loads
Yeah the board can be the ONLY thing that's replicated if your system is set up right
Perfect bandaid until I can find a better solution. Thank you!
Every visible actor can just be local, doing stuff based on the board state
right you say that because the board contains the actors
Rather, the board contains the state the actors care about.
Is Chess the closest analogy to what you're making?
chess as in the actors (pieces and units) move in a way they occupy tiles depending on their position. Everything else is not like chess
and there is a board, there is that.
Yeah you won't need to replicate the units at all possibly. Just the game state, in the GameState class. The entire thing can just be data in there if you wanted.
yeh Im already building it that way, setting it up so each "tile" is only data, which contains my entities (pieces or units)
but so far I have the standard spawnActor method for all of them
btw, Im spawning new actors constantly, its not like chess that you start with all the pieces.
Yeah how to architect it is up to you, you could just as easily have some data like an array of units and some logic to spawn/despawn actors based on it
Might be simpler to just use replicated actors per unit though, really depends
Interesting! How would I go about it in my case where I want it so nothing happens until the player is at half health, then at quarter health some PP fx happen, which then gets worse when in low health state, and all goes back to normal when the player heals (provided they're not in quarter or low health states)? would love to see some examples of how to set it up properly in the way you're talking about, find it harder to properly visualise how its set up
map range clamped
Get it to output a float from 0 - MaxState based on hp
looks like 0-2 covers your bases
MapRangeClamped(HP/MaxHP, 0.5, 0, 0, 2)
that'll output a 0 at half hp, a 1 at 1/4 hp, and a 2 at 0 hp
then you can drive whatever with those
Does updating a member variable in a replicated struct send the entire struct to clients or just the piece updated?
Just the piece updated
OnlineSessions and GameSessions are.. different things right?
Where are you getting these terms from thats making you think they are different or the same?
[2024.01.03-05.00.34:495][668]LogOnlineSession: Warning: OSS: Player Can-0EB13FF947C1298F5BD27E93C5E8193B is not part of session (GameSession)
[2024.01.03-05.00.34:495][668]LogOnlineSession: Warning: OSS: Player Can-0EB13FF947C1298F5BD27E93C5E8193B is not part of session (GameSession)
I mean, I want to say they are different things with different purposes. But getting these warning messages makes me think if they are the same thing or supposed to be used together
In this case, "LogOnlineSession" which is what Im guessing your referring to when you mention "OnlineSession", is the OnlineSessionInterface.
So depending on how you want to interpret what youre saying.
Ah, so GameSession is the name of my online session
The answer to your question could be yes and no.
Which is probably coming from NAME_GameSession macro, I believe
I get this upon joining the session, sessionInterface->JoinSession(0, NAME_GameSession, result); this is how I tried to achieve it
Which returns EOnJoinSessionCompleteResult::Success though, so I'm a bit confused
Try breakpointing through the code and try and understand the state the session and the player are in 🤷
Well apparently it was casued by leaving the menu map, not exactly joining to the session. But changing the NAME_GameSession to something else makes the warning go away. I think I need to delve a bit deeper. Thanks for the pointer
I'm having this issue with using IsLocallyControlled in my OnRep where it crashed the game when it's called (it's called at the beginning since i set the health variable in the beginning, the OnRep is called properly when I take away the LocallyControlled check and I never had this issue before, can anyone help? ill provide more of my code if necessary
So I put an Owner check just to see if that existed and it did, it's not registering it to be locallycontrolled tho, at least it's not crashing anymore
@dusty void Always check your pointers before using them.
Yeahhh, it wasn't an issue in my last project somehow, im redoing a project i was on in 5.3.2 just so i could get my defualt movements with the enhanced input system
nvm my editor play settings was set as listen server and it was working for the client but not for the server, idk if that's supposed to be how it is buttttt
also forgot to put UMG in my build.cs file 🫠
Not sure about a few other things but everything at least works now
I'm trying to do a multi sphere trace for objects on an AI during an attack, using the location of a component attached to the character's mesh. The idea is to apply damage when a player overlaps the sphere. However, I'm noticing the server and client are out of sync... the server doesn't seem to update the location beyond the first time it's called. Is there something off about calling this from a tick from an anim notify, or does the game not like updating positions that quickly?
... do I need to make sure the animation is playing on the server too?
@dapper arrow Is that a Listen Server or Dedicated?
Listen server
Is the ListenServer looking at the Monster when it attacks?
In general, you will need to of course play the animation on everyone
Skeletal Mesh Components have a setting that controls when to update bones and tick poses, which is some drop down Enum which name I can't remember.
It's set to only do that when rendered iirc by default
That's why I'm asking if Dedi or Listen and if the Listen is seeing the enemy
Hrmm interesting I'll look at the skeletla mesh settings. This is my current set up where an interface call happens to to the enemy, then it does an RPC up to the server then a multicast to do the animation
That should theoretically not work
The AI is server controlled and owned
The Server RPC should never make it
Unless there is something about this setup that I don't know
I'm probably using the wrong terminology, this is being set down to the actor itself
and not the AI
Yes it's a character with an AIController
Yeah then what I said still counts
You can't perform server RPCs on actors that aren't owned by the specific player that calls it
Also AI are server authoritative. So you shouldn't need to call anything from client side to begin with
The multicast is fine but the server rpc is wrong/redundant
This whole stuff should only be called by the server to begin eith
With*
If you for whatever reason need the client to tell the server the Montage, which I don't know why cause I don't know your game, then you need to do the Server RPC in the player's character, before calling the interface function
I'm still in the early stages of figuring out how the networking works in unreal and where server authorities are, so that makes sense to cut out the RPC there as an unnecessary middle man and keep the multicast so the clients see the animation
this is supposed to really just be a basic, "enemy swings their arm and damages you if you're in the sphere trace"
at a minimum that can just be:
Multicast playing the animation
Your HP should already be replicated
Of course it can get more complex if you want hit effects and not just "number go down"
but start there
Yeah this is just a super basic "you get hit number goes down"
I've got the play montage, then a notify state in the montage that has an event tick to send an interface message to the character enemy to perform a sphere trace
in this case here the client prints out a loc that continuously updates but the server's print doesn't
even with these changes:
Hrm well it looks like getting rid of the RPC and setting the testing to be 2 players with a listen server instead of 2 with a client got it working, so I'm going to chalk it up to a combination of those two things. Thanks for the help!
You said previously you were testing with listen?
You need to opt in to updating bones on dedicated
Ahhh that explains it, my plan is to have there be a listen server on here and not dedicated. I go back and forth between testing with a listen or a dedicated, didn't realize there were more issues between the two
out of curiosity how do you opt in to updating bones on dedicated?
(I'm only a week in to trying to translate single player unreal stuff over a few years to multiplayer)
Option on the skelmesh I'm pretty sure, just search for refresh bones or something like that
Sounds good, thanks!
Where in player controller can I run something but with condition that the object is already replicated?
I want to run something on client after the server already replicate the variables
Or if I can re-word it, when is it safe to run a function when a player joins?
thingking about BeginPlayingState? but I am just guessing at this point
maybe postLogin?
There is no "safe" time. Stuff is replicated at random times. You need to set up a system of checks.
I cant understand why it seems to run on owning client but still only the look works moving and jumping doesnt, even thought seems not to be replicated, dont know how to do it
Somehow I found out that my character BeginPlay runs only on server instead of each client
Hi, anyone here adept at how Unreal character movement works? From the docs it seems like the server does not tick and only replay the received moves to check if it's correct. Neither the server nor client use fixed timestep. And the server does some magic with estimating deltatime since it cant use client's timestamp directly. My confusion is how can it estimate the deltatime correctly? Wont this cause the server and client be out of sync all the time since deltatime is never exact. Whats the reasoning behind this instead of fixed timestep solution (cus then server can assume client update at 60hz and can step the simulation to be in sync)?
Hmm so OnpostLogin is not reliable too... there is no valid controlled pawn yet at the time it's called
@keen thorn https://www.youtube.com/watch?v=urkLwpnAjO0&list=PLXJlkahwiwPmeABEhjwIALvxRSZkzoQpk&ab_channel=delgoodie
https://discord.gg/uQjhcJSsRG
In this video I am introducing a series I will be making which explores the character movement component and how you can extend it in depth.
0:00 Intro
1:00 What is the CMC?
2:00 Do you need a custom CMC?
5:35 What does the CMC provide?
7:10 Outro
can't get this to run only on client which is touching the water. What I noticed only setting water volume is happening on every player - don't know why. When I manually set movement mode to flying for e.x. it works perfectly. How to set water volume only for individual players. Or it is not possible?
This does not answer my question. The guy posted on reddit a while regarding a desync issue caused by server and client deltatime dont match. He did a workaround but still not explain where the server timestamps came from
Sorry for pinging but can you explain this? I mean damage is working serverside but run on server command in bird actor isnt working serverside nor multicasting. I tried it with every variant.
The core issue is i dont get how the server can sync with client or vice versa
I don't think it's the server that sync with client, server is authority. There will always be small desync even in almost perfect network but if it isn't much, you won't really notice it.
When the difference is too big, server will correct client position because server is authority thus the rubber band. I might not catch your question fully, totally new to this my self.
Hopefully someone wise have answer
Thanks i know what u mean, and i also know all this, i just dont know why it was done this way while alot of this would be simplified using fixed timestep update with a timebank
And i also wanna know the technique used to keep the deltatime in sync
How can I run this hide bone node for clients? Client can still see bones in server
make the component, only owner see?
don't even need RPC or multiplayer concept to hide the FPS mesh
I will hide the arms but gun mesh will be visible, gun and arms are merged
So Im using a full FPS arms for first person and its only owner see, but other fps hands bones are invisible and only gun visible, which is attached to a full character models hand
doesn't look invisible to me 0o, I mean what you hightlight should be set to only owner see
If I make it only owner see, gun will also be invisible
As I said, gun and arms are merged skeletal mesh with animations...
the gun shouldn't be the same component imo
Well I know that but Im not a good animator or modeller so Im using a free FPS arms model from sketchfab so
I don't do fps but I think even in the FPS template, you have 1st person Weapon and 3rd person weapon
you basically need two arms FP and TP and 2 weapons FP and TP
Im already doing that
problem is, to show the weapon of one fps arm, I should hide arm bones but weapon bone should be visible
I'm seeing 3 arms
Lemme tell you all meshes
Body in back is a full character named FPSBody, only owner see with arm bones are hidden so player can see FPS arms and that body
FPS Arms is only owner see arms with gun
"Gun" is again an FPS arm but arm meshes are hidden and gun is attached to wrist bone of "mesh", its owner no see
"Mesh" is TPS character people see which is owner no see
So there is 2 characters and 2 fps arms
hmm can't help you here, kinda got confused. I don't think RPC gonna fix your problem though, especially if you have late joiners. It should just be a matter of ticking what owners can or can't see.
but if that route doesn't help then I am not sure what you can try
Well I will probably open arm model in blender and remove everything but gun lol
Im not using animations for it anyways
If that arms comes with a gun and you only want to show gun, totally just get rid off it
deleting the polygon or if you don't care about performance just use a transparent material on the arm
Any reason to not use static mesh then?
a pistol that doesn't slide feels kinda dead tho 😛
Wait, I forgor I can use transparent material on arm
💀
My hours...
throwing it to 3d program and deleting the polygon doesn't take long either
transparent material is kinda heavy but for small game, probably don't matter
Yeah, if you hit F2 or something in pie, you can see material complexity. Anything transparent is always red
I guess it wont do anything bad just for an arm model right?
I wouldn't worry about it. Can always delete the polygon later
moved my issue to: #materials although, it is in a mutliplayer setting, but not exactly the issue im having
if spawning replicated actors should happen on servers, does it mean that destroying actors also should only be executed on servers then they would be destroyed automatically on clients?
in short, yes
Generally speaking, you only want to destroy something you have authority over.
Right, trying to wrap my head aroudn what principle replication as a whole makes sense to apply
There's not a completely strict one-size-fits-all answer because it sort of depends on the usage of the actor, but for 99% of the time this is the rule
btw, can I keep in sync 2 actors even if the original spawning of the actor wasnt triggered by the server?
For example an actor might have been spawned by the Server, replicated, but later torn off. In that case if the Server calls Destroy(), clients won't clean it up
Not really no
Well, you can spawn actors with deterministic names independently, and fool the engine into thinking they are network addressable to sync them together.
Right, Im building something like a RTS game, but simpler, and I have actors that spawn other actors, while at the same time having an array that keeps track of everything and should be in sync somehow, and Im getting into some shady problems.
so if I destroy an actor but the array needs to know, in both server and client, does it mean I should probably let the server take care of that too?
trying to understand what to delegate to the server and what could run on clients
so, for example, every frame my units move, should the position be replicated too?
those are the little things that complicate things
at least for me
If any of that is spawned client-side, then the Server can't destroy anything authoritatively
no, every actor is spawned by the server
but how they move so far is client
but recently I've found a problem where I was disposing (remove from arrays, do other stuff, destroy actor) and it was happening on both server and client
and I was getting errors because the client was trying to access something pending garbage collection
so it made me reconsider some things
Sounds like you were destroying the actors client-side not server-side (or both), but not really sure
yeah, both.
so I should probably in my case.. do something like, when the actor is destroyed then do the stuff.
Yeah, thats the issue then - the client is destroying a replicated actor. The client then receives an update about a replicated actor which no longer exists locally, hence the ensure
so basically on clients (and listen server) listen to the actor destruction, and go from there? or its too late by then
OnPostLogin doesn't guarantee that the controller posses a pawn yet. Should I just run my logic in the pawn's begin play?
If the actor is replicated from the Server, the Server is responsible for destroying it. If the Client destroys a replicated actor they don't have authority over, the engine will panic.
Right, what I mean is, if I need to do stuff before the actor gets destroyed (removing it from arrays, etc) how does the client do that
AcknowledgePossession in the controller is a client RPC that gets called by the server
ty ty
They could listen for the OnDestroyed callback if they need to respond to it somehow
you mean the destroyed event right?
yeah
Could also do something in onposession in the pawn. But that is server side only I believe. I can't remember the pawn specifics. I just do my setup stuff in the acknowledgepossession function
ah ok, then I will use that
btw, actors that are destroyed dont get automatically deleted from arrays right? I need to manually remove them otherwise I would have a null pointer there
Basically I need to tell new player that joins to send their data (Cosmetics and the like)
I guess I could do OnPosses -> Get Controller -> Run a client RPC that does a server RPC? 😄
gonna look at acknowledge possession
I did this in the acknowledgepossession function
ItDepends(TM) - but generally speaking the array value will either be null or garbage
And inside of that just do a server rpc
cheers mate! put me back on track
and I guess putting a "isValid" before each instance of access is garbage code.
The engine will only 'null' it when the object is fully destroyed, if it's a UPROPERTY and if you don't have the pending kill disabled.
Otherwise, it'll just be garbage essentially
If pending kill is disabled and you don't clean it up yourself, it'll never be GC'd AFAIK
Not at all - IsValid() is probably preferable most of the time if you don't control the objects lifetime
You have to null out the references yourself and then it'll be GC'd
^ Yeah this, if PendingKill = disabled
If PendingKill is enabled, the engine will GC it anyway, then set any UPROPERTY references to it to null
I'm not sure what the default is anymore
Default is still the traditional one.
so far Im using BP only, is any of that applicable ?
Allegedly the pendingkill=0 is supposed to become the default in the future.
SInce we're dealing with Arrays in this case, you have to remove the entry yourself regardless
(unless you want the entries to be null)
Right, the problem I had I guess was that in che client my entity was valid, then the server put it to null pending kill
so my removal method did nothing because couldnt find it
something like that
fun stuff
@quasi tide ```cpp
UFUNCTION(reliable, server, WithValidation)
void ServerAcknowledgePossession(class APawn* P);
There is also this, I guess I can use this for the Listen server pawn?
Yeah, BP makes it less easy because any 'pending kill' object is just considered null essentially. In CPP you can still compare the 'dead' object pointer
actually client RPC will work on listen server too right 🤔 . Sorry to bombard with questions, I am just about to start doing MP stuff
But the actor destroy event should fire before the actor actually gets marked as garbage
Just went through Cedric's C++ session management and got to the point where I'd need to work my butt off to expose the session search results to Blueprints, back to advanced sessions plugin for me but I'm glad I went through it so I know what's going on under the hood 😅
does it happen on the same frame?
meaning, the order in which I check matters
it happens immediatelly after the event is broadcast
Hello! Im trying to implement multiplayer for the first time, the camera is ticked replicated but its only showing correctly on the client (right side) not the server (left side) it shows up correctly for a split second when i run the project but then just goes to what you see now. Thanks guys!
even if i set the camera rotation onbeginplay or on tick it just goes back to that same view after a split second
in standalone it works fine
what IS the camera? First off, how is each player getting their pawn?
gamemode default pawn class is the intended pawn, then ive put playerstart in level editor. is that what you mean
the camera is a camera component in the pawn
Hey everyone! So I've got what I'm hoping to be a relatively straightforward replication problem (for those with more replication experience than me) that I'm having a tough time figuring out.
My situation is this:
- There's only ever two players in a session. One is the server (client-server?) that hosts the session, and the other is the client that joins the session.
- Each player has a floating UI (Tablet), which is an actor that follows each player and is set to replicate, but OnlyRelevantToOwner. This actor is supposed to be spawned when hosting/joining a session so that each user can control world properties. This UI controls a lot of functionality in the game, and it uses a widget component, so I don't even want to bother trying to replicate that to other players.
- I've created a "dummy" version of this UI actor (DummyTablet), which is really just a mesh of the UI without any real functionality. The intent of this DummyTablet is for other clients to see where other clients' UIs are, without all of the complexity of actually replicating each client's UI. This DummyTablet actor is currently not set to replicate.
Where I'm at:
- Currently, the session host can see joined client's dummy tablet (and updating transforms) just fine, but the client can't see the host's dummy tablet anywhere. Both the host and client can see their respective Tablet UIs fine as well.
I've attached an image of the current state of the key blueprints for the Tablet UI/DummyTablet UI logic, so hopefully that will help explain exactly what I'm doing at the moment.
First thing to check is that server player is getting a pawn, it looks like they don't have one.
how many player starts?
Show your pawn's code and components
camera stuff will not need to be replicated though, should just work locally
Guyz In multiplayer how can i focus a Actor's Widget component . So I mean how widget component gets inputs from that player only interacted (or focus ) itself.
oh i should get the player controller relevent to the player
I'd start by disconnecting all that and making sure the client and server see the same thing
just disconnect the 2 events
make sure they're all happy and looking through their own cameras
would get controller (self) work as an alternative to get player controller?
yeah will do now
Yeah you did that correctly for the input stuff on begin play
its the same when i unplug it
Then fix that, figure out why your camera isn't being used
you shouldn't have to tweak anything, just add a camera and adjust its position
Is it not being used or is its position not being updated?
when i play it standalone the camera is as i inteded, what would change it when changing to multiplayer
did you disconnect your begin play and input action events?
yeah
Delete camera component and readd, test play, do both screens see the same thing?
adjusted by player start spot location of course
no its still doing the same time, the whole time the server has got the camera right for a split second on start then changed
the same thing*
it works with the new pawn. I guess i can just remake my player that might wokr
yeah you got something borked
thank you for your help mate
just copied and pasted only my components and its not working; so its something to do with them.
it works but only very high up
but my previous pawn (even with all the code unhooked) does not work. Im confused
Hey guys, Im looking for some advice. Im trying to figure out how you do a pubg/fortnite style lobby/server setup.
The way I see it in my head is your lobby is a listen server that people join thru your friends list (I have this working with EOS) then when everyone readies you travel to the dedicated server.
First, is this the correct way to do it?
Second, if so, how do you communicate with the dedicated server that there is a team coming in and these players are on that team?
Do you do that thu playfab/aws? Is there a way to query the dedicated server before joining, getting a team ID to assign the players?
Its difficult to google this as it always just return info on how to setup a dedicated server (which I also already have working)
Any and all input would be appreciated 😄
Not even. Connect to a dedicated server, when X players are ready, teleport everyone into the bus/plane/way your game has them enter the actual map. Profit.
How to not split up team when it joins?
party/group
In UE land, beacons.
I was reading the "lobby" part as the pre-game area where people are just running around goofin' off.
Not the menu part.
But yeah, beacons
It works sometimes? why is this happening? thanks guys
Where is your camera at spawn?
Is the side view the default camera transform or some broken thing?
some broken thing
the camera is in the pawn its default top down like you see when it works
Arnt beacons non visual? Everything I have seen from beacons is just menu stuff
Hi! I am working once again in multiplayer (yey
), and I am experiencing the beautiful world of race conditions on actor initialization - Basically some of our actors (placed on the map) depend on certain other actors (such as controllers etc) to exist (and be replicated) on their BeginPlay functions.
I've read something about controlling when the game starts using game mode or something like that, but not sure if it's the best approach.
Other options I am considering is using a timer to delay the execution of certain functions, but it's not ideal because if the timer ends too soon, we'll have the same crashes, or maybe not using begin play at all and call some substitute function manually. Ideas, recommendations?
Hello everyone I am coming from the #cpp chat. Two users from over there were helping me but they recommended I come here for my question. I am trying to follow Lyra's design pattern. But I am also trying to do a grid based inventory. I am using a fast array serializer to keep track of inventory entries. They hold a pointer to a replicated Uobject iteminstance and then some other data about position, rotation, and count. When the client receives new members from the fast array I instantiate a local array of uobjects for each fast array item because I need them as an array of pointers. Is this a good design decision? It feels weird to have two arrays of the same data basically. I will attach my code too rn
Here is my conversation from the other chat too: #cpp message
So what I'm asking basically is it weird to instantiate a UHInventoryEntryWrapper for every FHInventoryEntry fast array item that the client receives?
What is the different between using a Multicast system to spawn bullets (projectiles) on each client against spawning the projectile in the server and replicating such actor to all clients copying its movement?
Moreover, in this simple projectile setup (image): What do I have to replicate? The base actor and all components or only a part of them?
You're spawning separate instances when multicasting that typically couldn't be referenced over the network without some additional code by making the separate actors net addressable. This is an issue as the server may detect that the projectile hit something and destroy it, but that doesn't mean each client that has their own projectile spawned would detect that same hit and destroy it.
Can someone tell me why this isnt working please. On the client it says the hit mouse is giving accurate x,y coordinates but when i click it it just goes to 0,0
So I've got 2 issues currently, something about replication I guess but after reading through the documents I'm not really understanding
- Animations, I have some animations that I added into a blendspace with a bool that is activated to cause the animation, however it only plays on the screen of the player holding it AND it shows the same animation on all characters
- Its probably a bool again but I have a function to toggle the visability of a spotlight on and off for a flashlight, it does play from the host but not from any clients, none of the different ways I've been trying to get it to work makes it work on the clients
I'm guessing there is something I'm missing on how to replicate over variables
On the details on the variavle have you put replication to RepNotify
Is there a way to “connect” a server object with a client object that were spawned by their own? For example the multicast bullet example but by picking instances from an object pool that each client has.
So the risk of multicast is getting out of sync in clients?
So once I've set them to RepNotify is there anything I do, I've not done RepNotify for anything yet so I don't have anything set up for it in general.
I did just test it and its doing the same thing as it was
Event Tick fires on server and clients.
What you're effectively doing here is having every client set their own value as they'd be getting their own player controller and getting the hit result, but then the server is also running that for the first player controller it knows about and setting the hit result which would replicate and do whatever.
Additionally, the hit result for the mouse cursor can only be captured client side. You'd need to send an RPC to the server with the hit result from the client then have the server set the variable with that result, then the OnRep should be able to do its thing.
I would also recommend against replicating the entire hit result on tick if all you need is the location.
You can look into how to make actors net addressable and that'll show you what is needed to at least make them referenced across the network - If I remember right, it'll require C++ to do. As far as synchronizing them, that's additional work too.
It's not so much a "risk" as even when you spawn a replicated actor they are not entirely synchronized on clients - there is always some latency in multiplayer games. Multicast just means you're having each client run the code separately, and in certain cirumstances that isn't what you actually want to be doing.
I want all the clients to have their own values. But at the moment it doesnt move the compent to the clints hit value it moves it to the origin, which is the servers hit value when im on the client so that might be why. Also might not. Have you got any ways to make it wokr
work
i forgot to include this part
I had to run on owning client. Thanks!
Inputs only run on the client to begin with. If you want others to know the hit result of that click, you'd have to run on the server sending along the hit result that the client generates.
Click > Get Hit result > Send Server RPC > Server Sets Value > OnRep Fires clients can do what they want with the OnRep'd value.
If it's just a one off thing that you don't necessarily need to store a variable for:
Click > Get Hit Result > Send Server RPC > Server Multicasts the value to everyone > Clients that receive the mutlicast do what is needed with the mutlicasted value.
Does (static mesh) component movement not automatically replicate when component replicates is ticked in bp details?
this was so the clients could control their own components but its still not replicating.
which of these steps am i missing; looking at my code?
Hello again!
I’m reading about it but still not getting it.
What is the process for creating an object pool inside a multiplayer environment? The only idea that comes to my mind is to share the exact same actor (object memory actor) between all clients so that everyone pick and return the same actors to the object pool. But then… what with array replication?
As soon as I want to desync that I get messed.
Currently all you've shown is that you're getting a hit result on tick which is attempting to get the local player controller on all instances of the actor and setting the HIt Mouse value, then you've shown a click that is calling a server RPC that then calls the "Clickk" function.
So you have a click.... you're sending a server RPC but you're not sending the hit result to the server through that RPC, and then you're attempting to use the hit result in the Clickk function.
All that is really required to make something net addressable is to make sure that it is deterministically named the same thing on all machines (if you're spawning them in a loop it should be fairly easy) and then calling SetNetAddressable() on them.
But why arent the hit results going to the server? sorry i dont get it could you have a look at the code ive got quickly
each client works individually but the movement doesnt replicate
As I've said... Event tick fires on all clients and the server.
But only the owning client actually can get the hit result.
The server overrides the value set by the clients.
The server doesn't necessarily have the hit result.
Use the click event to send the hit result in through the RPC.
and is there a way to exclude the server from setting those variables
You don't need to be getting the hit result on tick.
ok il try thanks
but by the way, the input action im using is 'triggered' which acts on tick, wont this have the same issue
No because it's not tick and it only fires on the client performing the click.
Click > Send RPC with Hit Result > Server Sets Value
what are the nodes for that called. where do i put that. i dont understand sorry
You're using a click event already.
You already know how to get a hit result.
You know how to create a server RPC (an event marked to send to server). You add an input to that event to pass along the hits result like you would add an input to a function.
You know how to set a variable.
when the server destroys an actor, and consequently the client's actor also gets destroyed and doesn't pass the isValid check, can I then put it into an array or what kind of actions can I do with that object?
If it's not valid on the client (or server for that matter) you can't do anything with it.
it did allow me to remove it from the array it was originally in
but I guess thats it?
If the reference wasn't valid then no, you didn't. If it's not valid that means it's not referencing anything.
I checked and my array indeed stop printing that it had an invalid object inside
only after removal
if I didnt do that it continues to exist inside the array indefinitely for what I see
All that does is remove the first instance of a nullptr from the array. It doesn't mean you're referencing the actual object.
I see, so in this case where the server kills the actor and the clients reacts to it, what would be a good way of handling it?
since both server and client have the reference inside arrays and do stuff.
You can bind to the reference's On Destroyed dispatcher and when that triggers use it to remove it from whatever arrays - it should still be valid at that point.
Problem with that I guess is that I might end up removing it in the middle of an array loop, causing all sort of problems.
usually what I do is to add it to a secondary array, then loop that one.
do I have time for that?
It's unlikely to be a problem. Most things can be thought of being executed instantly, including loops.
And it wouldn't matter anyway - if you have an invalid pointer, you shouldn't be using it within the loop.
do things like timers get deleted when the actor referencing them is destroyed?
I'm not 100% on this one, but I'm fairly certain that is the case.
so I might clear the timers just in case on destroyed too.
not sure about events I listen to, probably the same
@sinful tree i tried to do what you said. It hasnt worked. Ive tried the set variable functions other places too. if i put just the code inside the function it works, just doest replicate. if i use the function it doesnt work at all
I have got the function to work but still it does not replicate
So setting the same name would sync the server and clients actors in the next replicated variable values?
(Ideally you'd probably create a custom structure to contain both the hit location and hit component so they get their onrep fired at the same time)
No. Having matched names and calling SetNetAddressable() is what should link it up, and yes, once that link is established, any replicated values should be sent down from the server.
And something else, when you mean "matched names" you mean object name or any id? Is there a specific method for it?
Object name itself - so like how it displays in the Outliner.
BP_Bullet0
BP_Bullet1
etc...
Oh I see.
Thank you so much for all this help 😢
Unrelated but this screenshot made me realize there are settings for the BP graph lines I want to set now...
When I run on owning client or multicast it works there is no replication. when i run on server it replicates but uses the servers cursor location. is there any way to make it use the clients cursor location
What I've sent should take the client making the click's cursor location and send it to the server and the server is then setting the value which replicates it to others.
If you're calling a "Run On Owning Client" or "Multicast" immediately after setting the values, there is no guarantee that the replicated values have been received on clients by the time these events are called, and that's typically why you use OnReps as it avoids that problem. If you just want to pass it along in the run on owning client or multicast without setting a value, that's fine to do as well.
This is how ive included that. But still when i click it says the location on server is 0,0,0
Hey I’ve tried some multiplayer setup, found a way to make an equipping and equippable input system but im not sure its the right way… anyone can tell me if its fine design side since its SEEMS to work?
I've created a weapon equip system where I have two different classes, one for the first-person weapon (owning client) and one for the third-person weapon(what others see). When I equip a weapon, it triggers a RepNotify equippedWeapon variable that calls an event. This event checks if character's locally controlled, spawns the first-person weapon (which has no logic but is visual), then checks if it has authority. If it has authority, it calls a multicast to spawn the third-person weapon. The third-person weapon class is not visible to the owner through 'owner no see.' In the same multicast, it checks if the character it's locally controlled, and if so, it activates inputs on the weapon, binding the fire events to the player's left-click event dispatcher. Is what I've done correct?
I've also noticed that with this setup, if I set the third-person weapon class to replicate, the inputs no longer work on the clients but only on the server.
Ok you were right thank you so much!
I'm a bit confused by this interface, it sounds to me from descriptions, like Standalone and Listen Server do the same thing? But rationally and from testing it seems that Standalone causes you to open multiple, separate (not networked together) instances of the game? 
The easiest way to start a Multiplayer Game is to set the Number of Players, in the Play Drop-Down Menu, to something higher than 1.
This page is one of the sources that makes it sound like Standalone is still networked
It isn't.
Okay, thank you!
That makes everything that is happening make sense 😛
When I try in Standalone I Just get two wholly separate copies of the game where nothing syncs, that work fine. When I do Listen Server I get a crash that is consistent with my code not being written correctly for multiplayer, which makes sense 😛
Is Pawn BeginPlay too early to access Pawn's PlayerState on Client?
It works fine on Server but I get nullptr on Client 
Objects can seemingly be replicated in random orders.
You can't rely on another object existing in teh begin play of any other object.
Networking, go
so perhaps OnPosssessed is appropriate?
What you can do is when each relevant object begins play, you check if each other relevant object exists. If it has, you do x. If it doesn't, you do nothing.
For a pawn and player state, you'd have to have them both check for each other and trigger the same specific method when they both exist.