#multiplayer
1 messages · Page 122 of 1
Nope
fun
It's locally maintained
But I'm sure if one spawns a Character with a Replicated Index it should be valid on BeginPlay
hmm
So just having a Replicated Index variable and setting that when the Character is being spawned (manual spawn via override), should be enough to tell the UI which of the 4 widgets teh Character belongs to
But that index is annoying to maintain. Cause if someone leaves, e.g. 3 players connect, player 0 leaves, the 2 others will still be 1 and 2
And the next player that joins needs slot 0 and not 3
But that is also solvable with a bit of brain
I want to knwo why the hell Player array is not replicated and is instead locally maintained
There's so much goofy stuff like that in the engine lol
You could make a fixed 4 size array, just in the GameMode to remember who has what index, and when someone leaves you remove the entry without shrinking it
And when needing to know the new index you just take the first empty slot
There are a bunch of ways to do this
aye
hm so question, casting to game mode as listen server works obvi server --> server but casting from client to game mode and getting a reff dont work
right or am i just ?
At this point it's kinda funny that this question still comes up
You have been told how this works a gazillion times
yupp but struggling with it obviously
GameMode is Server-only
That's all there is to it
You can't get it on the Client
No matter what you do
yeah so in no way a client can change something on the game mode then really `?
absolutley no way
At least in regards to directly accessing it
You can of course RPC to the Server and then let the Server change something
aye
But there is no way to directly access the GameMode as a Client since you simply don't have an instance of it
I can't understand if there's an issue here.
I've set some display names on the inventory widget to identify each player inventory.
The inventoryOwner is the GetOwner from the inventory component ref that the widget has.
I'm on pawn possess by the player controller, I'm spawning and possessing with an AI controller a player character. I need that functionality.
Currently, dropping an item from the client will drop at the server location and vice versa.
hmm okey
so.. hmm ok
aye im not sure how im gonna do this :/
ok firslty
what would i use insated to get an index for the player ?
since this one is only local
I would use Character::BeginPlay for all of this
So in other words, you are unsure why the OwningPlayerPawn is a different one than the InventoryOwner?
I can't quite follow
wdym Character thats what im using the player character ?
or do u mean the parent class
of my class*
I mean I would use the BeginPlay method of my Character class
yeah but this is for the "update part only" not assign part
wdym update?
however i can just change that tho i just thought it was better to keep things seperated
this part is inside the "hero Widget" so its doing all updaing functions in the widget BP
and from the player im only asigning from what character it should get the info from
that was my idea nevertheless
If that's in the Widget
Then that's redundant
Cause the BeginPlay of the individual Character
Will set itself to the matching Widget
And then you can use that Ref to Update the Widget, bind to update delegates etc.
No?
nevermind ill remove all the updating functions inside thje widget and do it all from the character since that seems to be better'
You don't need to
And that is actually worse
You'll need to formulate your questions better if you struggle with any of the directions Adriel and me provided you with
How about we start with "How do I get one of the Characters of my 4 Player Game assigned to one of the Widgets in a local Player's HUD?"
And we leave the updating for after that
ok sure
So one question I have upfront: The 4 Widgets in your UI, are they always there, or do you only add them when a Player joins?
the game is a Max 5 player game the 4x player Ui widget wont be yourself only the other players * and yes will only be visible if there is a player in that slot
they are preplaced added in the UI hud basicly
So you actively hide them somewhere?
Okay, let's assume, for the sake of simplicity that:
- The Widgets are set to COLLAPSED by default
- The Order of the Character and Widgets is currently not needed to be in sync with everyone
yepp
Okay, so you are interested in a Character being Valid and Assignable on all Clients.
The GameMode's PostLogin is only giving you a valid PlayerController, and only on the Server, so let's forget about that for now.
I'm trying to understand if there's any problem with the owners.
It's really confusing to see the same actors as owners on client and server.
Keep in mind that _1 at the end is not indicating "same actor"
They receive that _X based on order they get created it.
Yea that I know. But the others are the same player controller and character
No, if you need something to be Valid, your best bet is to use that something directly.
PlayerController is local, so that will always be _0 and the Client can't have the Servers there
@queen escarp So we use the Character directly. The Event to know, on everyone, that a Character is valid and ready, is BeginPlay
ok
The first Player is the Server, so that's a bit boring of an example, and since you only want to list other players, we ignore this scenario for a second
Let's imagine a second player joins and a Character is spawned
For the ListenServer, BeginPlay of the Client's Character will call
yepp
For the Client, BeginPlay of its own Character, as well as BeginPlay of the Server's Character will call
So at this point we have a good notifier for when a Character is valid. We do have a problem though, since you want to only show the other Players, because we would need to somehow filter the ones that are local.
And on BeginPlay, we don't actually know that yet, cause the Character might not be possessed yet.
ok
In C++ we would have an easy time now, cause we could use OnRep_PlayerState in combination with PossessedBy.
We don't have access to OnRep_PlayerState in BPs
Let me quickly think about what the best alternative is
sure
Nasty, freaking BPs
imagaine you being a n00b alsop
I guess you could make a custom PlayerState variable that you mark OnRep and piggy back of that
hm ok and that should be in the character bp ?
Yeah
since thats what were checking
Hi all,
I'm working on a metaverse based on pixelstreaming and I wondering if someone ever try to run multiple instance of a game on a single server with multiple GPU?
Forgot to rename it
ok
In the OnRep you can then do something like this
Theoretically that should work
Still a bit unsure
ok but the SET w/Notify is from where what ?
Disgusting that we can't have OnRep_PlayerState in BPs
i already have a custom player state
wdym
It's a Variable in the Character with the type of PlayerState
Custom is only cause you can't name it PlayerState
I wonder if that IsLocallyControlled can still fail there hmm
Yeah but that's confusing
aye ok
the casting to player controller
in my case i should cast to "player character" instead right ?
arent we checking if the character is valid not the controller
i mean its the same but ?
What?
Yeah sure, I would never put the HUD into the Character
yeah figured
So from there on
I made some quick widgets
Assumption is:
- HUD Widget with a VerticalBox (VBox_HeroWidgets)
- Hero Widget with a Character Variable
Hero Widget with this Function
That what we will use to set the CHaracter
On IsValid you can also start getting values and binding to Delegates for updating later
The HUD received two functions
Adding and Removing a Character
All they do is go over the Vertical Box Children (your Hero Widgets)
And call Set Character on it
"Add" finds the first empty one and the stops (break)
"Remove" finds the matching one and stops (break)
Ah typo in the function name
Remove not Renove of course
Updated version
@thin stratus I really can't understand that problem.
It feels like my owner/player controller are switched.
The server drops the item at the client location, and the client drops the item att the server location.
In the inventory component drop item function uses GetOwner to get the actor location.
@queen escarp
And then in the OnRep you added you can use those two to add and remove the characters
That's all there is to it
Haven't tested it though
ok gimme a few mins setting it up
There might be more involved here. You should print the Pointers at multiple places to check where it flips them
Also you never said who's inventory you are looking at
Does each player only look at their own inventory?
Well from the pictures I've sent it looks right.
Moving items in the inventory of each one seems to work ok.
print it
Like, the debugging process is something you gotta do
I can't do that for you :D
printing the owner in the drop item function prints server: _1 and client: _1
Looks like the same character but it's not ?
Again, _1 doesn't mean anything
If you need to know who is who, try getting the PlayerState and printing the PlayerName for example
Yea the PlayerState -> GetPlayerName prints 2 different names.
So I guess the problem is the ownership of the component.
Although I just added this actor component to each BP character
hm alright its all set up
nothings happening tho but
hm the ONrep isent fiering even
@thin stratus
ok so the on rep is fering
but im getting errors on the Add/remove
Yeah cause you have your HUD in the Character
Which isn't guaranteed to be valid
I would move it to the PlayerController
oh right since im creating the widget after the possesing is happening`?
ok so the error went away but nothins really happening
hmm so its removing but its not adding i ont think
@thin stratus
ok s
when testing as listen server and 1x client i get
Server:Add
Server:Remove
when only 2x clients test
i get nothing
so something there
if i bypass is locally controlled it fires on clients also but alot of errors
The BP UE shows that you inverted the IsLocallyControlled
That needs to be connected to FALSE
Cause you wanto only call this on other player's character
oh¨
the top one is unrelated
so its accessing none
the casting is not failing
hmm
is this not enough on a chaos vehicle to move on clients?
even this doesn't solved the issue
its mean something else is broken in chaos vehicle component
fixed:
if anyone has this issue, just enable this FPBDRigidsSolver::SetIsDeterministic(1);
Your're using several references there. Which one exactly, is failing
I'm facing a character and pawn interaction issue in my game. I have a character and a boat pawn. The goal is for the character to control and navigate the boat, which has a FloatingPawnMovement component. I've set up an RPC call for the possession, and the camera transition indicates it's working. The boat's movement is also handled by an RPC call using the "Add Movement Input" function. Everything seems to work when the listen server player controls the boat, but client players can possess without being able to move it. I feel I might be missing something basic. Using UE 5.3 and blueprints. Any insights?
Hello ! Does anyone know why PostReplicatedAdd() is getting called 2 times when i'm client ?
// In my add function that triggers this unexpected behavior
Items.Add(ItemInstance);
MarkItemDirty(ItemInstance);
OnItemInstanceAdded(ItemInstance, EvaluatedPrice, ItemInstance.Index);
// Implementation of OnItemInstanceAdded (still incomplete I guess)
void FItemContainer::OnItemInstanceAdded(FItemInstance& Instance, int32 RealPrice, int32 Slot)
{
Owner->OnItemAdded(Instance.Handle, RealPrice, Slot);
}
FFastArraySerializer stuff
everything works but I don't understand why I see 2 paths in PostReplicatedAdd() when I debug it
@hoary spear as player character
I already said:
You should move your UI into the PlayerController.
Because:
Having it in the Character adds yet another replicated Actor into the List of required References.
And:
You can't guarantee that the Character of the Local Player exists yet when this calls. The Accessed None is expected.
You'll solve the issue if you move the UI/Widget into the PlayerController.
If you just ignore this suggestion over and over again, then sure nothing will change...
Yeah i got it the issue im using the player hud ref all over the whole game basicly :/
@thin stratus don’t want to take to much of your time as it seems you’re giving lessons in here now, but any chance you know where this error might come from?
[2023.10.08-14.23.28:844][324]LogNetTraffic: Error: UActorChannel::ProcessBunch: New actor channel received non-open packet. bOpen: 0, bClose: 0, bReliable: 0, bPartial: 0, bPartialInitial: 0, bPartialFinal: 0, ChName: Actor, ChIndex: 11, Closing: 0, OpenedLocally: 0, OpenAcked: 1, NetGUID: 0 [2023.10.08-14.23.28:961][333]LogNetTraffic: Error: UActorChannel::ProcessBunch: New actor channel received non-open packet. bOpen: 0, bClose: 0, bReliable: 0, bPartial: 0, bPartialInitial: 0, bPartialFinal: 0, ChName: Actor, ChIndex: 11, Closing: 0, OpenedLocally: 0, OpenAcked: 1, NetGUID: 0 I can not find any information about this error at all.
Yeah well
I'm not going to give you work around solutions for your previously set up bad code :D
It's already tricky enough to set this up in BPs
That message comes from UActorChannel::ReceiveBunch
Bunch being "a bunch of data".
The UActorChannel handles the Actor. If it receives Bunch and there is no Actor yet, it will initialize everything
And the very first check for that is if Bunch.IsOpen
Hmmm why would it. Be better in the controller rather then the character ?
- PlayerController is valid earlier
- PlayerController remains valid even if the Character gets destroyed
- PlayerController is more "Local". In C++ you could even use the ULocalPlayer.
It's just generally the more logical place
At least for the generic HUD that most games have
@willow surge
// ------------------------------------------------------------
// Initialize client if first time through.
// ------------------------------------------------------------
bool bSpawnedNewActor = false; // If this turns to true, we know an actor was spawned (rather than found)
if( Actor == NULL )
{
if( !Bunch.bOpen )
{
// This absolutely shouldn't happen anymore, since we no longer process packets until channel is fully open early on
UE_LOG(LogNetTraffic, Error, TEXT( "UActorChannel::ProcessBunch: New actor channel received non-open packet. bOpen: %i, bClose: %i, bReliable: %i, bPartial: %i, bPartialInitial: %i, bPartialFinal: %i, ChName: %s, ChIndex: %i, Closing: %i, OpenedLocally: %i, OpenAcked: %i, NetGUID: %s" ), (int)Bunch.bOpen, (int)Bunch.bClose, (int)Bunch.bReliable, (int)Bunch.bPartial, (int)Bunch.bPartialInitial, (int)Bunch.bPartialFinal, *ChName.ToString(), ChIndex, (int)Closing, (int)OpenedLocally, (int)OpenAcked, *ActorNetGUID.ToString() );
return;
}
Seems like you are doing something to your Actor before its channel is fully open
Thanks, Im not doing much / anything breaking that I’m aware of. It’s just the Lyra Game Sample with EOS enabled and PlayFab for the dedicated server. I’ll get on this. Thanks for pointing me in the right direction.
In my UE 5.3 game, I'm having an issue where a character should control a boat pawn with FloatingPawnMovement. While an RPC call handles possession (think it work beacuse of the camera transition) and another manages movement using "Add Movement Input", only the listen server player can fully control the boat. Client players can possess but not move it. I'm probably overlooking something basic? Any advice? I've been googling for 2 days and not sure what I'm doing wrong
You might be overlooking the fact that UE has no proper Multiplayer Movement code for anything but Characters.
Your Pawn Movement is probably not replicated at all, since the MovementComponents for Pawns don't have anything proper set up.
Only the CharacterMovementComponent does
FloatingPawnMovement (I only just registered that you listed it) probably has no Multiplayer capability.
Yeah it's not doing any networking :P
In UE, if you don't have a Character with a CharacterMovementComponent for something Player-Controlled, you have a bad time
Unless you know your sh`t and can code it in C++ yourself
I try to move the boat on tick and that replicates, I check Has Authority and on authority call the add movement input and it moves on both, but that's probably not it? If I use CharacterMovementComponent and call a server RPC to move it on server it should replicate ?
CharacterMovementComponent doesn't need additional RPCs
It has an RPC ServerMove that handles all the stuff in the CMC
There is a lot more than just telling the Server to move
If you just do that you have input lag
For Authority it might move on both because the Actor itself has ReplicateMovement applied
You can of course just tell the Server to move, but it's by faaaar not enough
but eXi- question, is the "on rep function" only server called something something ?
Hey guys!! Am new to multiplayer systems.. so apologies if this is a stupid one...
So basically I am trying to spawn 2 controllers which would possess a pawn each... so am using the game mode to spawn them...
My question is... if its possible to remove the controller that spawns by default and spawn them using a loop coz the problem am facing is that if I try to destroy the initial controller on post login or anywhere... the screen goes black... I tried spawning a controller but didnt work... some suggestions would be great
Thanks
and also the player hud is valid 100% that cant be the problem :/&
I'll check what I can figure out, thank you!
OnRep calls, in Blueprints, for Everyone
I will not repeat myself over and over :P
You should not Destroy or Create PlayerControllers by hand
(+- local Splitscreen ones)
So... if the default controller is on index 0... and I wanted 2 additional controllers... should I simply use the postlogin to spawn them??
Also if thats the case... I have seen alot of the other devs using a custom container to store the refs to those PCs... my query is... whats the point of having the "Get Player Controller" node with an index as an input
I initially thought that there is some sort of containers already made on the engine to deal with them
Why would you manually create those?
^ single player only ?
You can select to start the Game with 2+ Players in the Editor
And in a Real Scenario it would be players joining
Unless there is something about your setup/game that you aren't sharing yet
Coz I want a split screen view
So not online at all?
Yes you are right
The Array that some devs do, which is arguably strange, is for Online
Cause there the GetPlayerController node is less useful
For LocalSplitscreen you can use that Node, yes
And for creating additional players, you can use the "CreatePlayer" node
"Where" is up to your game logic
Aaah!!! That makes sense... actually my end goal is to set everything up in the server but atm am just playing with all these stuffs so that I have a clear idea how these things are working
"The Server", if you have no Online Play, then this is not really a term to use
Splitscreen doesn't have any Client/Server stuff
Everything is in one and the same game
My goal is to make a multiplayer game... so I am exploring how things work on different modes
I havent touched the online part just yet
Right, but then it's still favorable to make sure the terms are correct
And no, you would not create the PlayerControllers in PostLogin then
Usually, if you bring Splitscreen Players into an Online/LAN game, you first create those in the MainMenu
And then have the Main PlayerController join a game
It will tell the Server about the other local PlayerControllers.
Yeah... I just realised that... coz when a player connects to the server they would come with their own version of their controllers which I simply would add to a data container to store the refs... thats how am thinking right now😂😂
Yeah the PostLogin would call for all players who join
That's a bit late to suddenly add local players
I just got confused with understanding the diff between using the player controller node and having a custom container
But thanks alot mate
There is no Array of PlayerControllers by default. If that is your question
The Array is also not really needed. Most of the time the Server doesn't directly iterate PlayerControllers. And if they do, it's mostly via GetAllActorsOfClass.
It's really rare that you need to iterate them
That's one of the rare cases where that Node is actually fine
All these makes sense now!!
I mean.. that's also not true I guess. There is a LocalPlayer Array on the GameInstance
Which is the one that the GetPlayerController node uses
If it can't find anyone with that, it actually uses the PlayerArray (PlayerStates Array) of the GameState
Will eventually find out as I work more on this
It's tricky to learn this without touching C++ I guess
class APlayerController* UGameplayStatics::GetPlayerController(const UObject* WorldContextObject, int32 PlayerIndex)
{
// The order for the player controller iterator is not consistent across map transfer/etc so we don't want to use that index
// 99% of the time people pass in index 0 and want the primary local player controller
// After we've finished iterating the local player controllers, iterate the GameState list to find remote ones in a consistent order
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!World)
{
return nullptr;
}
// Don't use the game instance if the passed in world isn't the primary active world
UGameInstance* GameInstance = World->GetGameInstance();
const bool bUseGameInstance = GameInstance && GameInstance->GetWorld() == World;
int32 Index = 0;
if (bUseGameInstance)
{
const TArray<ULocalPlayer*>& LocalPlayers = GameInstance->GetLocalPlayers();
for (ULocalPlayer* LocalPlayer : LocalPlayers)
{
// Only count local players with an actual PC as part of the indexing
if (APlayerController* PC = LocalPlayer->PlayerController)
{
if (Index == PlayerIndex)
{
return PC;
}
Index++;
}
}
}
// If we have a game state, use the consistent order there to pick up remote player controllers
AGameStateBase* GameState = World->GetGameState();
if (GameState)
{
for (APlayerState* PlayerState : GameState->PlayerArray)
{
// Ignore local player controllers we would have found in the previous pass
APlayerController* PC = PlayerState ? PlayerState->GetPlayerController() : nullptr;
if (PC && !(bUseGameInstance && PC->GetLocalPlayer()))
{
if (Index == PlayerIndex)
{
return PC;
}
Index++;
}
}
}
// Fallback to the old behavior with a raw iterator, but only if we didn't find any potential player controllers with the other methods
if (Index == 0)
{
for (FConstPlayerControllerIterator Iterator = World->GetPlayerControllerIterator(); Iterator; ++Iterator)
{
APlayerController* PlayerController = Iterator->Get();
if (Index == PlayerIndex)
{
return PlayerController;
}
Index++;
}
}
return nullptr;
}
This is the code behind the node
If you can read code, then this should be clear
The Server could theoretically use the node
To get PlayerControllers of other players
But not just via index 0, 1, 2, 3, etc.
Cause it will return local PlayerControllers first (e.g. Server having a Splitscreen friend)
But eventually it will try to find them via the GameState's PlayerArray
Hope someone here could reply and try to help with my problem here:
https://forums.unrealengine.com/t/replicating-player-character-rotation/1327505
Hi everyone, I’m trying for so long to replicate the character rotation on the server and on the client. The goal is to press SHIFT and rotate the character without the other client/server to see it. So if I’m rotating the server, the client shouldn’t see it, and vice versa with the client rotate and the server should’nt be able to see. So t...
What is good fix for network distance culling? I I set visibility (Example: Helmet) too far from other player and then walk to meet that he doesn't see it disabled. Should I make timer every 30 seconds and server event to update?
I copied this code into my custom cmc, and it says that it did not override a base function
Does Amazon Gamelift sdk support unreal engine 5.3.1 version?
Or what's the latest supported version of engine?
That's a Gamelift question. Better suited for their Discord/Forum
Does somebody knows how to open this project at all?
https://github.com/BwdYeti/VectorWarUE4
I end up in a loop of rebuild it, maybe I dont know how to properly open it
@thin stratus Good morning, i did as you said and change the widget so its in the player controller now 🙂 so whenever you got time to continue helping me let me know (if u can)
still getting the same error*
How did you spawn them?
This may help
https://youtu.be/IJtgKMQAxQs
In this tutorial, we will guide you through the process of creating a team indicator system in Unreal Engine. Having a clear visual indicator to identify teammates can greatly enhance the gameplay experience in team-based games. By following along with this video, you will learn how to implement a team indicator that is visible only to specific ...
Can I replicate parameter declared in the interface?
Interfaces can't contain UPROPERTY so no
When I run net mode listen server with two players, one of the screens is just black, the other screen is fine. Anyone know why?
Hm my widget automaticly are being set to 1080x1920 in the editor when i open them (reversed) ??? why
even if i change and save*Ä
What is the correct way to tell the client to say the server what his location?
Hi
um im having a problem with the camera shake
so when player 1 has the running shake effect,so do have the player 2 too but hes not running.
You don't need to use RPCs at all because if I remember correctly velocity is replicated
it's something that you run in the client which means you don't need any RPC call
since you have the headbob running directly in Tick without a check for whether or not you are the local player, it's executing on every player character for all clients, so if one person is running, then all players will have the shake applied
put a branch with "is locally controlled" before your headbob
also idk if youre using it anywhere but delete that random custom event you dont need it
none of those events have to be networked at all btw
The exact reason just so you're careful in the future is you're executing the Headbob on the server and you're fetching GetPlayerController index 0
which means it'll always get the host/first player
i mean like
when 1 player is running rn and he has the shake, no problem at all
but player 2 gets automatically the shake because player 1 is running
I answered ^ x)
do what he said and make sure all of the events aren't replicated at all so that it's purely running locally
no replication alright
Just do a check on the headbob that it's a locally controlled pawn
ie a Client pawn
and remove the replication from the functions
And for the future, IF you need something like this replicated (idk why) but, if you do, you have to get the proper Controller
not the local?
if it were to be replicated then theres no guarantee that it would be the local controller so youd have to make sure it's actually getting the associated controller
Exactly
each pawn has a controller remember
if I remember GetController gets you the owning controller
nono i meant like
like this
but player 2 has the same reason as 1
when player 2 is running
player 1 gets too
put that at the beginning of your headbob
use your original branches as they were but have this as well before what you had
when player 1 is running, the shake doesnt happen on player 1, only player 2
undo what you did so that it's like you had originally after removing the replication, but then add the additional local player check before it
now both players dont have the running shake, added on the 2nd branch the is locally controlled
you dont want to add locally controlled to your existing branches, you want it to be a new addition before your existing logic
so that second branch there would be your first one in the headbob
but have the IsLocallyControlled before it
you want to only execute your headbob code if it is a locally controlled Character
so you check if it's locally controlled
then you do your velocity checks/shakes
on the 2nd branch?
yeah exactly like your code used to be before
Here's the thing
even the CameraShake shouldn't be networked
nice 👍
thank you tho
anytime
Can someone familiar with CMC clarify this for me:
There's a MaxSpeed in FSavedMove_Character, but Im guessing its not actually getting sent each tick, just used for accessing maybe? Is this true?
Thats why we should be making a bWantsToSprint and using a compressed flag for it so we actually have the max speed at the time of the saved move, right?
Is my understanding correct?
But is there not another way for sprinting? I understand needing to use a compressed flag for crouching, cuz of the collision changing, but for sprinting, could we not just do something like multiply the analog input vector that is being sent and is saving as part of each FSavedMove?
now ideally you wouldnt use the start client camera shake youd just use the normal non-replicated shake lol but it works and that's what really matters atm
swap to the legacy shake rather than the client shake to avoid any other potential issues
alr, ty for the tip
What's the correct way (if possible) to replicate a TArray of UObjects? I was able to replicate just UObjects by using AddReplicatedSubObject but the array doesn't work. For now I've defined IsSupportedForNetworking and GetLifetimeReplicatedProps for the UObject and I've set the array as replicated with DOREPLIFETIME_CONDITION(UStatsComponent, Modifiers, COND_OwnerOnly); in the actor component owning this array, but no luck.
Same as you would any other property
TArray<UWhatever*>```
If the array has a size but no objects, that means the objects themselves aren't replicating
Make sure you're using the parent Actor as the object outer, not the component
Not a huge issue, but the outer on clients is always the actor, never the comp
ah that might be the problem maybe. How can I ensure I define the actor as the outer?
When you're creating them, just use GetOwner() as the object outer
IIRC you also need to opt-in to the replicated subobject list
my component has bReplicateUsingRegisteredSubObjectList = true; set, which is also the reason why replicating simply UObjects works, I'm calling AddReplicatedSubObject(MyUObject); in the ReadyForReplication
my array of uobjects is defined like this:
UPROPERTY(ReplicatedUsing = OnRep_Modifiers, EditAnywhere, BlueprintReadWrite, Instanced, meta = (AllowPrivateAccess = "true"))
TArray<class UStatsModifier*> Modifiers;
and Modifiers is simply added to the GetLifetimeReplicatedProps of the component with DOREPLIFETIME_CONDITION(UStatsComponent, Modifiers, COND_OwnerOnly);
Modifiers for the purpose of my tests are added in game by a cube actor I created that when its collision sphere is overlapped it will add the modifier to the character's stats component
so if I understand corretly I should GetOwner() and set it to the object when creating the modifer in BP
Instanced will probably have issues I suspect, since you can't change the outer.
I wanted to use Instanced because I'd like to manually define stats modifiers on the fly in the editor if I needed, but I can probably live without if it's problematic
Last time I tried it, it failed spectacularly because the objects couldn't resolve properly.
But that was a long time ago, I've no idea if it's changed since or if there's a solution
doing this now gives me LogScript: Warning: UGameplayStatics::SpawnObject null outer (this logic is done on the server only)
and the modifier is effectively a nullptr it seems, I only added the IsValid condition now because it crashed the game
this is an actor right?
actor component
It says target is 'Actor'
oh apologies, yes it's my cube actor
yeah should be able to just remove it then, just use this as the outer
so it should probably be the stats component's actor, not the cube
no, still not working. I can see the array replicating null items. I tried removing Instanced , but same issue
do I maybe need to call AddReplicatedSubObject on each array item?
ok I think I managed to get it to work. Basically when I add the instanced modifier to the list I also call AddReplicatedSubObject(Modifier); right before the Modifiers.Add(Modifier);
so I expect I should call RemoveReplicatedSubObject on removal from the array or it'll keep sync a no longer used item
it's all working, thanks a lot @chrome bay !
Isnt the solution to manually Instance Uobjects , like lyra kinda?
in testing with players with low FPS i noticed that the character movement is choppy, likes its not being interpolated properly, is this intended? is there any way to fix it? any tips?
guys I have this in my game state it is called when one of base is destroyed its calling event on all players in game , (second Photo) , print is always printing but my widget is not creating when I try it press K it is created
what can make issue?
fixed
ty, resolved the issue a while ago tho
One thing you could try is increasing the NetworkMaxSmoothUpdateDistance to see if that helps (though this will only help with smoothing out the the translation movement not the rotation choppiness)
just noticed, player 2 is kinda buggy
sometimes it works, then somehow dont work
Is this in a pawn?
So you can use "GetController" and GetCameraManager
@unique forge
when would one want to use fast replication over normal replication?
Haven't seen this option, is this for an array?
Oh that, no idea
im working on my AI, its suppose to choose a random player wich way is preffered ?
Search for fast replication on there, I think that explains it
Multiple GameplayTags can be stored in an FGameplayTagContainer. It is preferable to use a GameplayTagContainer over a TArray<FGameplayTag> since the GameplayTagContainers add some efficiency magic. While tags are standard FNames, they can be efficiently packed together in FGameplayTagContainers for replication if Fast Replication is enabled in the project settings. Fast Replication requires that the server and the clients have the same list of GameplayTags. This generally shouldn't be a problem so you should enable this option.
hm shouldent this pick a random :/ ?
ooooh. that makes sense. so it packages them in cute lil arrays so it saves bandwidth
one of the UE dev talks on fortnites replication mentioned something about this i believe
Does it make sense to have a bpcallable function "BlueprintAuthorityOnly", while still checking if its the server internally? (and calling the respective rpc if not...)
feels like a double up..
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "QuestSystem")
void StartQuest(const TSoftObjectPtr<UQuestBase> Quest);
UFUNCTION(reliable, server, WithValidation)
void Server_StartQuest(const TSoftObjectPtr<UQuestBase>& Quest);
bool Server_StartQuest_Validate(const TSoftObjectPtr<UQuestBase>& Quest);
void Server_StartQuest_Implementation(const TSoftObjectPtr<UQuestBase>& Quest);
While my testing was very limited, it seemed like no client can directly call StartQuest , and its simply ignored
Question, Are Asynchronous Ability tasks replicatable? According to documentation "Ability Tasks are designed to be used in both networked and non-networked environments, although they do not directly update themselves across the network. They generally stay in sync indirectly, since they are created by Gameplay Abilities (which do replicate), and use replicated information, such as player input or networked variables, to determine their execution flow." I assume you can replicate the Async on client and server and then compare result for authority.
It makes sense, but do Clients ever expect to be able to start a quest? If not, then why even have a need for the RPC? If yes, then why the BlueprintAuthorityOnly?
I feel like your latter two questions, invalidate the first statement about it making sense
Its exactly what i had in mind anyways, if they cant call it from client side, then internally checking if its client doesnt make much sense to me
unless there's cases where they would be allowed anyway, because reasons unknown to me
I recently tried to do some physical animation in a multiplayer project and noticed that the animation is out of sync between the server and client. Is there something I can do, plugins, resources, changing settings etc. or is the replication for physics just unreliable and I would have to rework the physics system?
I guess if c++ code try to call it, it makes sense to block it, but then i wouldnt need the rpc anyway. Just toss away if its ever client trying to start a quest
Right, this is why it could make sense if you're exposing some other way for client blueprints to start quests you may still want to call this at the c++ layer
Gotcha. This is gonna be the only way for it to start, so .. I'll keep the bp authority flag there, as it makes it clear for the user
did the same thing, altho cosmetic, for the replicated data ment for clients
Initially I expected this to purely be a 'flair' to the node, and not actually have any behavioural effect what so ever 😛
I'm curious how the TSoftObjectPtr for the quest objects work, are you always just sending CDO's in the RPC's? Or are you replicating down the Objects somehow? In that case you could just pass in a normal UObject pointer no?
Sorry I was thinking of WeakObjectPtr, makes sense to be Soft if you're wanting to avoid the load
It very likely could just be a regular pointer ,
setup similar to Lyra's inventory, with fragments and definitions etc
the load is probably tiny tho. Atleast so far there's no real assets involved
If we set bReplicates property of an actor to true, which data members of the actor are replicated?
The ones marked for replication
The bool is just if the actor should even be considered for replication
I have this niagara system and a multicast event
UPROPERTY(Replicated)
UNiagaraComponent* NiagaraComp = nullptr;
UFUNCTION(NetMulticast, Reliable)
void RPCSpawnTrail(UNiagaraSystem* Trail, FVector start, FVector end);
but the system only spawns on the server irrespective of who is spawning it either it be the client or server.
I am calling it as such
if (StaticData->Trail)
{
if (InOwner->HasAuthority())
{
FVector start = ItemActor->MeshComponent->GetSocketLocation(FName(TEXT("Start")));
FVector end = ItemActor->MeshComponent->GetSocketLocation(FName(TEXT("End")));
RPCSpawnTrail(StaticData->Trail, start, end);
}
}
@winged vault Is the Actor/Component marked to Replicate?
its aUObject class that is stored as such in an actor
UPROPERTY(ReplicatedUsing = OnRep_ItemInstance)
UInventoryItemInstance* ItemInstance = nullptr;
And that actor is replicated
UObjects arent replicated and cannot send RPCs...
Please read the Network Compendium.
Its pinned in this channel.
Its a helpful resource for understanding Replication and RPCs.
I did read that. but I can't figure what to do with this
You would be better off replicating a Struct instead, that represents the "Item".
It needs to be replicated on an Actor
You would also then need a NetOwningConnection Actor to send RPCs
Is there a way to turn replication on and fire it once on command for a component in a BP?
Does anyone know how to replicate Camera pitch? I'm using the General Movement Component plugin and all of the mouse input is done through the movement component.
What exactly are you trying to do?
Basically have a BP actor use as little net/processing as possible while being able to be turned on by players for 1 event
i think setting it to dormant all and then flushing it before using works though, not sure
That should work. But I'm pretty sure dormancy is bugged for blueprints, it'll update regardless of whether you call force net update or not
Unless they fixed it for UE5
But it was marked as a bug on the site and marked "won't fix" aswell
Hmmm, so it's dormant and turns on/off by itself?
So idk if it makes dormancy less reliable
based on changes
Yeah, but again it's been a few years. Not sure if they backtracked and fixed it
interesting, yeah i thought i saw the changes happen even without flushing it. Hopefully it isn't awake but printing dormantl ol
Yes dormancy is how you would handle this.
I'm not sure if it is executed separately on different client (suspected that), means you've got different random points there. The way to solve this is getting the points on the server and replicated it to the client, with On_Rep for the TArray you used for the random position then spawn them.
Would it be "out of convention" to prepend non-rpc methods that should only get called in a certain place with Server and Client?
I find it sometimes hard to know where (I as the programmer) have guaranteed that a method will run
Actually we tend to do that quite a lot, can be useful in complex systems.
Having a convention to always display that information in the same way in the comment can also be useful.
I find myself really wanting to do something to those kinds of methods
In bp theres the nice BlueprintAuthorityOnly or BlueprintCosmetic ufunction specifiers, for blueprintcallable functions
I'll keep that in mind as I start doing BP networking, currently in C++
This method works perfectly when creating a new project using Epic's templates.
Pressing B shows one widget for each player.
In my project it only fire on the client side, and for the server it doesn't call the ClientWidgetTest.
I can't understand what could be the problem here, there's no error or warning on the output log.
Sorry, when pressing B from the server in game the run on owning client doesn't fire
The button press is for debug and test.
I want to understand and learn how to display a widget locally for each player.
just display locally then? No need for any RPC
Press B -> Show Widget
not like Widget can be replicated
I saw on YouTube that this is the method. 🤔 very confusing.
You're right
https://youtu.be/2GYicrkCElA?si=zyHhCfHNv2Zb1fBi
He showed here that this is how you can do it
Hey guys, in today's video, I'm going to be showing you how to replicate user widgets. This means you can display a widget on one players screen, or everyone's screen.
Blueprint Interfaces: https://youtu.be/m90ZkbtPA9s
#Ue4 #UnrealEngine4 #Ue4Tutorial
00:00 - Intro
00:...
So let's say I want to display that widget locally when overlapping and actor.
I understand that it's a bit different from calling like I did.
How can I achieve that? I have an actor with overlaping event working right now
Casting the overlapped actor and calling this function works.
But is there another way maybe adding that widget straight from the collision actor himself ?
Is the overlap detected on server side or locally?
if it's unimportant gameplay element and widget can be shown w/o any check then just detect the overlap locally and show the widget to the owner of the pawn
the way you would do it is the same as you would do it in Single Player
This would show for both the client and the server.
The actor is Replicated
because the overlap happend on every single machine
do a branch that check if the overlapping actor is what the machine posses
or maybe just run an event that create the widget in the controller the overlapping actor posses
If the RPC is being called from server to be executed on a client, only the client who actually owns that Actor will execute the function.
When it says "client who owns the actor" is it talking specifically about the class who implements the RPC itself? What happens if I say, have a reference to a player controlled pawn and want to call an RPC to that client from a server-controlled actor?
Well, worked as expected. Thank you very much for your help! @dark parcel
It's talking about the owning client of the actor. An example would be a player possessed pawn - the server when possessing that pawn would set the owner of the pawn to the client who owns the player controller possessing it.
Whenever you're running a Client RPC, it can only ever execute properly when called from the server and will only execute on the client that owns that actor. If there is no client owner, it won't execute. So if you have a reference to a player controlled pawn and are running on the server, calling a Client RPC on that pawn, then the code will execute on the owning client of that pawn's side only.
If you want other clients to execute it, you either have to multicast from the server (all clients will execute it), modify a replicated w/ notify variable (OnRep) which can then trigger a function when the value changes on a client (which again, can end up firing on all clients) or if you want something to execute only on a specific client, you need to run a client RPC on an actor that that client owns.
This is really helpful, thanks.
So In my current case I have a client player use some object, the object has it's "can I be used" logic happen on the server. In the case where it can't be used, I'm trying to show a message to that specific player, and was trying to use a client RPC on the object.
I guess I assumed it would use the owner of the pawn I passed the function, but I see that's not the case
So I guess for that pattern to happen, I would need to call the client rpc from an actor component or something. Assuming there's no way to call it given their pawn from somewhere else
I see a decent way to achieve this with my current setup, but just want to be sure that there's no way to have a client RPC get called on an actor owned by the server, even if I have say a reference to an actor (like the player's character) which is owned by the client I want to target?
Correct
Well, you can have the server owned actor invoke a client rpc on the client owned actor
Cool, I have everything going though some interaction interface that gets used via an actor component on the player.
I guess I'll move the logic so that the actor component does all the server/client switching and just calls the established methods on the item.
If I avoid doing it on the item, I should be only on the client actor and it should work as I expect
guys i have a dedicated server/gameplay ability system question. is this the right channel?
#gameplay-ability-system probably
thanks
How to give client owning an actor authority over replication?
For example client is owner of a car, I dont want the server to correct him but vice versa
you want the client to have the authority , in a multiplayer game ?
or to dictate the cars location to the server (and thus other clients)?
this one yes
cheaters are welcome then i guess
Game is not competitive so it isn't a concern so much
there is a setting in either the pawn class or the movement controller class that allows for client authorative movement, can't recall it off the top of my head though
My packaged games are somehow unable to find other steam sessions, creating one works perfect and the steam accountData is even fetched correctly. Any idea where I could start looking for, as I haven't changed the session creation/finding Blueprint Scripts since it worked the first time?
Should I rather ask this in #online-subsystems ?
Hello folks. My simple interaction system works like this:
*I run a LookAt sphere trace on a TimerByFunction
*When it finds something that implements the BPI_Interaction interface, it sets that as the CurrentLookAtActor
*When the player pressed the "Interact" key, it checks for the validity of the CurrentLookAtActor (in case the player has looked away) and then sends the "Interact" message to that actor, via the interface.
*The "Interact" message gives the interactible actor a reference to the player character, gets an actor inventory component then calls a SERVER RPC.
*The RPC calls a function that checks for an empty slot and adds the item in question, to the first found slot and sets a bool var to true.
*If it does not find an empty slot, it sets the var to false.
All of this functionality is working except that from the interactible object, when I try to get the bool value, it always returns false. I'm sure it's a replication issue but I'm not sure where the breakage is. I need to check the bool because if the item is equipable, I try to add it to the player hotbar first. And if it can't find an empty slot, I want to then add it to the inventory instead.
Following are the code snippets:
Interact With event ON the interactible actor:
Add Item Server RPC on the Inventory Actor Component:
Add Item Function ON the Inventory Actor Component:
I have tried making that bool replicated and replicating the inventory components in my player character as well. Same result.
I solved this by including a ref to the actor that is attempted added to the inventory
And let the inventory destroy it 😅
With a bool , so its optional
You're instantly checking a local bool value, way before it can even possibly have time to replicate
@glad escarp
hmmm... Ok I'm not sure I can do the same thing with the way I'm handling it but I'll start fiddling
You could also make sure you're interacting server side. Then the actor could just do the regular inventory call and use the bool directly
hmmm. ok I can try that.
Fixed it. You pointed me in the right direction with the object reference idea. I just fed a reference of the interactible object into the inventory comp, used an interface function to set the bool on the object directly from the inventory and then destroyed it from the inventory.
Set the bool before destroying it ? 😅
Right. That's what I said. 😉 Sets the bool directly and then destroys if the add was successful.
Does anyone know why my screen turns black when I am in splitscreen mode? Its so odd.
is the movement of your second character intentional? I mean the sliding off to the right?
Why components' OnComponentBeginOverlap event only happens in client rather than server?
Maybe the overlap didn't happen on server, or maybe it did and you can't tell.
Sounds backwards thats all
An RPC problem:
When I'm executing a skill it is executing on the server. Inside that event logic there's a boolean that I'm getting from the Player Controller, and when I get that boolean, it returns false because this logic runs on the server where the boolean is on the client side.
I'm setting a boolean value in the player controller when the EnhancedInput trigger flow start.
I can't find a way to get the boolean for the owning client. And yes I did tried using RunOnOwningClient, but then the flow doesn't execute on the server at all..
This whole logic is inside an ActorComponent and his owner is the character.
How the hell can I get this bool value for the client where I need the logic on the server?
taking a stab in the dark but i have the same kind of scenario with a listen server setup i'm working on now....
Simple solve (for me anyways) was to ensure that i'm setting this boolean variable as Server auth - which is what it sounds like you should be doing in your case. Then the client will be synced with server-side logic of the said boolean.
Hey guys! Happy wednesday 🙂
I have a Client RPC that i'm executing a delegate broadcast in - but my clients never enact on it.... is this to be expected of any RPC type event? I know that in Server auth - delegates dont happen to Clients... same to be said for any RPC event?
So using HasAuth and settings the bool there?
But the EnhancedInput is triggered on the client so it always be Remote on HasAuth
Rpc the input?
Still prints false in the ActorComponent
Are you sure the actor logic runs on server ?
So confusing
The get player controller func is just the basic getPlayerController with cast.
Ehhhh
You cant use that to any reliability in mp
Wheres the component?
In the player pawn?
In the player character yes
So
GetOwner -> cast to pawn -> GetController -> cast to MyPlayerController
Generally you cant use any of the "get X" with an index input
Same problem. still prints false.
No error by the way
Atleast now we know its the correct controller
Also
General advice is to cast to the most bssic type at all points
So dont cast to your specific char type
Just cast to pawn , as that got a GetController method
Also, your char class has a special controller ref, which doesnt make to much sense
Since pawn knows about its controller 🙂
You're right, by the case here is a bit different.
The character possessed by an AIController, the player controller possess a different pawn.
I need the AIController.
So I fixed the ownership issue and it's working as usual. but I can't get pawn as always
That's why I have a ref to the player controller from the character
Right
So GetController
Already handles that
As its player/ai parent controller
And can be either 🙂
Just means you gotta cast to the correct controller type
So I cast the owner to a pawn, and used GetController, but it returns the AIController which is correct because the PlayerCharacter possesed by it.
I need the PlayerController because there's the logic of the inputs
Ohhh got it. this is so confusing. give me sec
This works. I needed the get the owner of the AIController and then cast
Why? I want to make sure that the item was added to the inventory before I destroy the pickup actor in the world.
I didnt undertsand that the owmer of aicontroller was playercontroller 😆 but nice
@hoary spear Thank you very much it would take me hours to think about that if it wasn't for you
Sure but server side the pickuo can read the bool from the add to inventory function directly..
Right. But I can't handle it all in the component because the player character has two instances of the same component. The inventory component is the same class for the inventory and hotbar so I have to handle the bool, and subsequently the item placement selection, in a different BP. Unless I'm trying to revamp my whole system, which I may eventually do if this one sucks.
I'm not trying to be difficult. I just don't see a different way to do it even from server side, at the moment.
Yeah i get that, i was more thinking along what Tank just commented ^^
You're making it harder for yourself than it needs to be, imo
Say if all I'm aiming to right now is have my friends connect to my session. I have the ability to create sessions, and have the clients join them when testing in the editor. I have my port forwarding all set up and all that jazz. Do I just need to send a build out to my friends to test this?
Id test it on two different pc's first, but yes thats what youd do
that easy huh!
Can be troublesome to find the session if you're using the regular one i guess
Advanced steam sessions helped me out a while back atleast
gotcha, thank you
Does anybody know of a way to disable log files being generated when running a dedicated server
how do write if (GetLocalRole() == ROLE_AutonomousProxy) in 4.26?
for me GetLocalRole() is undefined
Hey all. I've got an issue where I'm spawning an actor base class on server. The class has one exposed/instanced editable variable which get's fed in on construction, then in the construction script it sets the static mesh and a few other things using that struct variable. It works fine if I drag that class into the level, but if I spawn it in, I can't get it to switch from the default mesh. I've tried adding a custom event which I call when I spawn the actor, tried in Construction Script and EventBeginPlay, all to no avail.
Clients should prob use onrep
On a Replicated mesh variable
Set by a server called event on spawn
Hmm.. Not sure I follow but I'm gonna read this a few times and do some research.
Server spawn actor -> invokes a function to set the mesh
The function takes in the mesh and stores it in a replicated mesh variable
The variable is marked "rep notify" and gets a function that is called when its replicated
In this function you can safely grab the variable and be sure its replicated , and set the static mesh of the actor 🙂
ah... ok I will try that. Thanks!
Simple solution. It worked
It might work with the variable exposed on spawn aswell, so long as the actor is spawned from server.. not 100% how that workd behind the scenes
It does. I needed to keep both so I could drop items where I want them in the level and manually set their info variable.
Nice, then we know 🙂
I'm having trouble understanding how AI works in multiplayer
I'm making a "game show" style game that can have human or AI players. I'm tracking everything about a contestant in player state, and I have both a PlayerController and a BotController (custom override of AController) that create/maintain that playerstate
I'm getting stuck understanding how to spawn a BotController, though. it sounds like I should spawn it on the server without replicating the controller to clients (?) but if that's true, how will their PlayerStates sync down
Botcontroller (aicontroller?) Wouldnt have a playerstate usually
hello i have an item struct that i use for my inventory and i want to pass those around, the problem is that i can't send struct pointers as a unique identifier
is using guids the best approach?
this is for rpcs and stuff
it's so much cleaner for me to have one though, otherwise I need a separate class for things like player name, score, etc. and a lot of if-statements ("if bot, show score x. if player, show score y")
is that an anti-pattern?
ACharacter (and any class based off this) has a variable in it for handling AI Bots - which spawns the controller automatically if this is configured this way.....
You could abstract the commonalities if the functionality is very different... or stick with sharing a parent, if that works well for you
you dont spawn controllers - you spawn the class that has this configuration.
as for the Playerstate - thats not part of AIController logic - you'd very much have to manuall;y recreate that logic to get a PS to attach.
is there a callback for "actor entered net relevancy range again"?
in other words: I move my player away from an actor, it gets culled, i move back (callback fired now)
but i dont think you need to - as Ai is spawned from server anyways (or should be - as it is controlled by server)
You could wrap up this information into a struct.
APawn*
sure if you need to drive that far up the chain - but we dont typically make APawn for AI - unless you dont need CMC
Playerstate can be spawned by the ai controller. It's a property of AController
not by default, no
Game show - idk what they use really
It's something like, bRequestPlayerState or something like that
Just wanted to be precise about it's inheritance
this is good to know! but again i've never been in the practice of even using PS on a AI
I don't remember the property name exactly, but AI controllers can 100% have them. And it is allowed. I've never needed them personally though.
If only ditching bb and going ps was a valid path with bt :p
funny you mention that - i'm doing a crowde/horde game atm and it is KILLING my FPS just by the AI alone... with almost no systems inside of it. Only real thing i'm using that is performant heavy is Sight detection
50+ enemies on screen will crush FPS flat.
take away the AI logic - runs almost full FPS
it is not this....
What ai logic is this
I mean, I can get like 300 running around. Soooo
I did some custom ai logic and can run ~5k, but its not really that optimized im sure
AIPerceptionComponent
i have no other Tick events that would crush like this :/
and that component is an overlap event driven as far as I can tell :/
i dont pretend to make heads or tails of it.
Ill be going for 50+ when i get to it , using perception
i'm about to make my crowd start utilizing clusters - groups of 5 for 1 AIController/perception
But i may cheeze it a little , with a manager amongst them
yah - a manager is like what i'm saying.
Yepp
i figure - if i can fraction it by 5 (or more) then it'll be way more performant.
This is a very common optimization technique, as an FYI.
It's definitely how Days Gone got their numbers
yah i figured as much - when i tracked it down to being specifically the AIPerception on them
i thought at first - skeleton/CMC - but nope :/
when stripped ... it ran almost full on FPS
I'd be interested in the actual profiling numbers.
like how many i'm spawning?
No - the UnrealInsights that you used to profile everything.
Instead of just turning something off/on
oh man i havent touched profiling yet - :/ Very ill-informed on that topic
Its pretty important for optimizing stuff properly
Knowing the bottlenecks comes a long way
thansk for the term drop! I've pulled it up and bookmarked it for when i get to this
greatly appreciated
If I add an actor component server side and set it to replicate shouldn't that mean the component should replicate to clients?
nvm actor wasnt replicating
happens to us all haha
yeah but that was just me confirming stuff in bp, now I'm figuring out the real issue which is why some dataasset objects arent replicating
just making sure lol, is this replicated correctly?
it should replicate the horn sound
Not really, but only on account that you're effectively allowing a client to play any sound at any place on the map. You should limit the data the client is sending to the server and the server determines where and what sound to play.
Otherwise, that's how you can do it.
Does accurate replicated physics only work with a static mesh actor? I'm simulating physics on the static mesh component of an actor and no matter the replication settings I check and uncheck on the component and the actor, it always looks really jittery. I usually ends up in the same place for each client but not always.
so you mean no matter where the client is playing the horn sound everyone on the map is going to hear it?
No, what I mean is, you're allowing the client to tell the server where and what sound to play. That means they can technically play whatever sound at any location.
that's what is usually the point of a sound in game i guess? It should play the sound at the location of the player who made it for everyone around him to hear
but i hope it's not hearable on the entire map lmao
But you don't need to have the client tell the server that info. The server should be able to determine what sound to play and where.
Imagine this was a health/damage system. You wouldn't want the client telling the server how much damage they are doing. The server should know how much damage should be applied, otherwise you're allowing a client to say they deal 9999999 damage.
You remove the inputs on the Run On Server event. When you're running on the server, have the server call the multicast with the desired location & sound
There are times when you need to pass information from a client to the server, but this isn't one of them.
ReplicatedUsing question: if I have a replicated UObject* and I don't change what it points to but I change parameters of the UObject, will my outer UObject* OnRep function get called?
using the same keys for character movement input and vehicle movement input is a conflict?
suppose I have one key binding MoveForward which uses the key W , so I move towards the vehicle and start posessing it, and for the vehicle I use the same key w to move forward.
at the time when I posessed the vehicle what was my last Forwad Axis value?
does it effect the vehicle movement even I don't press the w key?
how shall the server get the desired location & sound?
Same way as how you'd get it from the client, except you're doing it on the server instead of the client.
so what i understood is removing the inputs of the HornOnServer
and now you mean the circled nodes on the right should be executed on the server?
In Lan Mode, On my Lister_server host, why is there still a NM_Client? And In this situation the character don't even have a controller
I being stupid again. It's the host's character in the client. Hahahaha
Hey guys, I am working on my FPS game and have setup a rather basic aim offset system. There is a super weird problem I am facing at the moment.
The way I have shooting setup is that, a client fires sends an rpc to the server which then spawns a replicated projectile.
This projectile works fine, you can kill player etc. But when a client is facing down, where their head isn't where it is normally, other clients cannot hit them. When playing as the listen server it seems to work. I can't figure out why its happening and its really critical :D,
Here is a video demonstrating the error, you can see how I can visually see other clients aim offset, but the server sided projectile ignores the hit, but when firing at where their head would be without any aim offset it seems to register an hit.
This makes me believe that the server doesn't know of the aim offset on the clients, but somehow when you're the listen server you can still see the aim offset and even hit them so its got me super confused 😅
You still need to call to the server, but you don't need to pass it inputs. You can have the server read the world location of the actor for the location of the sound and you just select whatever sound you want for actors to play directly in the multicast call.
The aim offset is a replicated variable in the character that is set in tick from the control rotation, I've checked and each characters aim offset variable seems to be replicated perfeclty. And I haven't been able to fix this small issue for 3 months, and its really getting frustrating, and it seems I am just making a idiotic mistake which I can't figure out
If you need anything from me, I will gladly present it. I am mainly trying to learn so if we can find a solution it would be awesome if you can explain it
It's likely because your collisions are not based on the mesh of the actor, but rather the actor itself which is that capsule you see.
I had to check this at the time, but unfortunately not 😅 . Projectile collision class ignores the capsule, and only collides with the mesh.
I also confirmed it at the time by printing the hit comp, it does successfully collide with the mesh. I am just super confused on why the animation visibly changes, yet the projectile still fails to collide unless you're the server....
hey, if you have a FFastArraySerializer, is there a way to call a rpc function that can refer to the same item on the client/server?
i.e I want select an item in the array, then call a server rpc and tell the server what item I'm refering to
FFastArraySerializer don't have the same index on the client/server, so do I need an id on the struct itself?
What are you trying to do?
Search the array?
You can setup an ID as a property of the FastArray Element
And use that to search for the same one
yeah, Idk if I need to use FGUID or just the index of the item on the server as the id itself
that's between the client and the server right? oh actually nvm, it will reorder if I remove something in the middle or add something in the middle for whatever reason
Its not guaranteed across the network at all. It doesnt need to be reordered. Just the fact its replicated means it may not be serialized on a Client in the same order as the Server
yeah I mean have an id on the struct, then use the index for that instead of having 16 bytes guid
An FGuid is unnecessary. An int would be enough.
Just increment it and assign it to each element when the server adds one
Hi guys, quick question, is the Character AddImpulse method replicated? I am working on a slide mechanics and while it works, the initial slide is giving me issues...
What do you mean replicated?
If its called on the Client it wont work, the server will correct you.
If its called on both though, it should work ok.
However a Slide would just be a different movement mode that reduces velocity over time.
I am calling it on server, and the slide is implemented over walking movement mode
it works fine, just the impulse giving me inconsitent results
you could take a look at how Epic did it for unreal tournament, I remember seeing the explosion impulse for player characters being on there
ah, will check it out, thanks!
basically my question arise because if I use : AddImpulse(Velocity.GetSafeNormal2D() * 1000.0f, true); it do nothing, however
Velocity += Velocity.GetSafeNormal2D() * 1000.0f; it 'works'
hi guys, is there a way to set a variable from the host to all clients?
store the variable on gamestate?
this way when the host changes the value of the variable on the game state, any client can get the variable set on the gamestate?
Is there a FVector_NetQuantize for float for easy compression during serialization
Like an FFloat_NetQuantize100
Guess I'll just write my own I'll just use the vectors, they won't cost extra if I don't use the other axes
Quick question- my character (ACharacter) has just picked up a weapon (AActor).
I want to fire Server RPCs on this weapon actor.
Is there any way to transfer the ownership of that weapon to my Player so that I can call Server RPCs on it directly or should I re-route all RPC calls to my PlayerController?
Just call SetOwner on it when its picked up
And pass it the Pawn
An Actor needs an owner hierarchy that leads to a "NetOwningConnection" to be able to call RPCs
So if the Weapon is owned by the Pawn and the Pawn is owned by the PlayerController (which is the NetOwningConnection), then the Weapon can call RPCs because its owned indirectly by the PlayerController.
Hmmm.
My weapon has a "WeaponMechanism" component.
Is ownership also relayed to ActorComponents?
Well yeah, they are owned by the Weapon
I've done SetOwner and it seems like the owner has been changed but my RPC still isn't happening
I must be doing something wrong
Is the Weapon set to Replicate?
The Actor must still have its Replication flag enabled
Yeah- both Actor (weapon) and ActorComponent (hitscanMechanism) are set to Replicate
Huh, this prints empty
(this is from the ActorComponent)
(first GetOwner is to get the Actor and second GetOwner is to get the...new...owner? of the actor?)
This is what I'm doing in my Pawn's "Weapon Handler" ActorComponent, inside a serverside function:
AActor* weaponWielder = GetOwner();
CurrentWeapon->SetOwner(weaponWielder);
If this is called inside a Pawn you probably want CurrentWeapon->SetOwner(this); instead
This is called inside an ActorComponent for a Pawn
Uh, how can I do that? I've thought that the only way to get the owning actor of a component was through GetOwner()
Yeah not sure why it would be empty? Unless you are debugging it incorrectly 🤷
Possibly! lol
Without more information or context Im not sure what else to suggest
Right, I'm probably messing something up- the logic seems to make sense, there's probably something I'm not doing right
I'll give it another check- thanks!
When replication methods are called, is it possible for them to get called even if the value hasn't changed? I.e. let's say I have a UUID replicated by an OnRep method. Assuming the server only ever sets the UUID uniquely, is there any potential for the client to have OnRep called multiple times even if it doesn't change?
So, here's my conclusion:
My Actor's Owner, on the Server, is correct.
My Actor's Owner, on the supposedly owning client, is incorrect.
The server has the right data. The client, however, is unaware that they are the owner.
Are you trying to have the client send an rpc right as the owner gets set?
It's likely that the new ownership has not replicated yet.
Nope- the RPC is only sent a few seconds after.
Huh- "No owning connection for actor"
The server has the right info but the owning client does not. I guess I'll just call SetOwner locally I guess?
lol that made no sense at all but fuck it, it's working now
Sounds like the owner was incorrect after all 😅
Is there an easy way to determine if a player belongs to the current client? I know that player controller returns null for everyone but the player + the server, but what about the case where I want to check if it's not the server's own player for non-headless instances?
Returns whether this Controller is a locally controlled PlayerController.
I think this is the right method? 👀
IsLocallyControlled
This worked perfectly. Learning multiplayer sure has been humbling. I'm making good progress but it's definitely taking a whole new way of thinking compared to before.
oh yeah multiplayer is a drastically big step from single player
goodluck!
finally I have done with this
the whole chaos physics breaking to make it work in a multiplayer game, it was that simple i'm shocked 😄 , curious why on the earth nobody has made a tutorial on this?
well save this picture to save you many days figuring out this system to work with network game, specially dedicated server
input
this looks like you have the right idea, but you're calling a reliable RPC on a ticking event. There is most likely a better way to handle this
totally agree, this is just a work around to make things work, and can be improve for sure 🙂
a small bug fix
I want to make skill for one of The players in my game. He must see other players trough walls. How canI do it
I'm curious about when to use RPC and when to rely on prop replication.
I have a simple start/stop ability system working with networking. Its server authoritative and currently uses prop replication to update start/stop time props, which clients listen to in order to play the actions (with some error tolerance)
I could easily use a multicast to relay the start/stop, but this seems to be working fine.
Is the approach ok?
Hi everybody,
Do someone know a good tutorial about multiplayer over internet with c++?
I like Tom Looman's course but it's pricey. Stephen Ulibarri on Udemy is supposed to be good too.
Hey there, having the same issue and I wonder if you came up with any solution?
@pseudo kernel Thank you
Is there free thing?
Not sure, if price is an issue you can look into Stephen's courses which go on sale really frequently. I think I got his GAS one for $12 which is a steal for how much content it covers
Unfortunately not, we haven't switched to ue 5.3 yet, but i really hope it will fix it for us
@pseudo kernel, thank you so much
I'll have a look at those courses
Welp, thanks anyway, I'll get to you if we will be able to solve it
thanks! On which engine version are you currently?
Exactly 5.2.1
Also with partitioned maps
Also trying to connect as a client on a server
And it does seem like it's not replicating anything to a client
Hello. Why this not work in multiplayer but singleplayer it works and how I could fix that?
like already when connecting or do you also crash when disconnecting?
This not get executed in multiplayer
i guess this is an anim notify event?
or how do you "register" footsteps?
We get the crash when leaving the map
yep alright then it is the same issue as we have
And it doesn't matter how we leave it, alt+f4, closing the server or exiting via menu
I call that anim notify in walking animation always when foot hits ground
then you don't need to call here a rpc since the anim notifies should called on server & client, basically on all machines where the anim is playing, so just make the play sound at location not replicated
Okay thank you!
Hello, I was wondering if something changed how i attach a USkeletalMeshComponent in multiplayer,
NewComp->AttachToComponent(MainCharacterMesh, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true));
NewComp->SetSkinnedAssetAndUpdate(ArmorToAdd->GetArmorMesh());
NewComp->SetLeaderPoseComponent(MainCharacterMesh);
NewComp->bUseBoundsFromLeaderPoseComponent = true;
I am calling this as a multicast and i can see it being executed on both the server and client
what is happening is that it works in single player mode and the attachment is working fine, however in multiplayer the NewComp spawns at 0,0,0 sometimes there is animation replication
Is there a reason you chose to use a multicast for this and not some sort of state replication with an OnRep instead?
About the sound you meant to just select it in the multicast node and not give it through an input. The location also not through an input but how else? How do I make the server read the world location of the actor? Do you have a node setup maybe, thta would be very helpful!
Do you mean to have the "is player controller" and "get focal location" nodes also inside the multicast?
good question, however why would that change how the attachment was working?
Thanks for the reply! Since Im running the code on Event BeginPlay I found that it would still be out of sync, since the client's BeginPlay is run later than the server? The event is run by the server, but still seems to matter when the client loads in? I set the ball to replicate, and the timer is ran by the server. Please correct me if I'm wrong 🙂
To solve it I casted to the gamestate and grabbed GetServerWorldTimeSeconds and ran the timer with an Addition based on that time, which gave me synced & replicated spawning.
Basic question, when I store a list with pointers to all joined player controllers within GameState, will clients be able to access playercontrollers that aren't on the local machine?
Hey Got adviced to add some Network Emulation
whats a good Default "low" setting for a listen server * ?
Not directly
But you can code it so they can manipulate it
But playercontrollers are only replicated to the owning client iirc
Ok cool. I figured it's the better idea to keep track of the player controller pointers within GameMode instead GameState, on the server it should be possible right?
I think I'm then gonna update the GameState from within GameMode with only the relevant bits of information
(c++) In terms of Actor lifecycle.. which function can I override which is as late as possible, but guaranteed to be before replication/onrep events?
PostInitializeComponents ?
Is there a decent resource out there on giving the basics for creating a more performant custom movement component?
or is there usually no need for that with the PawnMovementComponent?
I wouldn't worry about it unless there's a problem
Im focused on creating an RTS and everything I've read so far says CMC is not what you want to use. I'm wondering if pawn movement component has the same constraints.
RTS is a bit different, if you have hundreds of units moving via CMC then it might be a problem.
I'd still suggest working on your game rather than prematurely worrying about optimizing something in a way you don't fully know how you're going to be using it yet.
hmm fair enough, thanks. Still if anyone has any other commentary or resources that have more to say I would love to be directed towards it. I don't think I'm prematurely worrying. It's a valid concern.
CMC is designed to give a good experience for local player with prediction while still being server authoritative and good enough for remote observers. For this it implements a bunch of state and rollback etc.
For an RTS you probably don't want any of that, you need to decide what you actually do need before deciding what a replacement might look like for example.
I gotcha. Thank you.
Yeah, a lot of the time it's not necessary to use RPCs if you have something purely server authoritative that's replicating all required information to clients. Personally I'm a big fan of using RepNotifies for a lot of things when I can, makes things a lot simpler, but rpcs of course have their place.
When deactivating splitscreen. How can I switch the view to a different Player Controller?
@fathom aspen Did something change to seamless travel or persistence with pawns in 5.3? You seem to be the going expert on this and I'm suddenly finding that references to my pawns which used to survive the travel are now left as nullptrs... 🤔
Your options comes down to numbers and how much optimization you've got time to do
Numbers -> how many simultanious controllable agents
Ive heard people using cmc for numbers between 50 and 300, but theres a ton of unknowns with those numbers so take em with a bucket of salt
how do i add mapping context to a client? possesedby? like if (!HasAuthority()) { if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(Cast<APlayerController>(GetController())->GetLocalPlayer())) { Subsystem->AddMappingContext(DefaultMappingContext, 0); } else { UE_LOG(LogTemp, Error, TEXT("Subsystem or local player is invalid.")); } }
its not working
hello is there a built in way to send text chat messages to the team or to everyone? i could use multicast rpc and filter if it should add the message to the UI, but that seems a bit inefficient and unsafe
The client must send the msg to the server, then the server must RPC to each team member individually
Makes sense thanks, in this case the server is authoritative but the actions still get triggered by the OnRep to do some animations and stuff, so it seems to work well
@silent valley so a client RPC for each player controller in that team
yep exactly
ok i'll try it thanks
Is it now correct like this?
Reminder: Is this the correct way to play a sound with a button press at the location of a player for only the people around him to hear?
Hey all what is the command or how do i simulate network lag again?>
Cant find the command on google
@latent basin If you're in the editor you can go to the "Advanced Settings" when clicking on the three dots next to play, from there you can emulate all kind of things if you enable the checkbox.
Thanks alot
Nevermind! It was a casting issue where the pawn was failing to set.
Is this replicated correctly? Client event is set to multicast and server to Run on Server
Everyone should see when the roof opens or not
delete every multicast from your project
repnotify
why though
Because pretty much any usage of it you have would be much better as a repnotify with only a few exceptions
door being open is state, state should be replicated. If you want something to happen when the state changes, use a repnotify
you mean from an optimization pov?
how do i use a repnotify
What happens here if someone is out of relevency range and then comes closer? They didn't get the multicast to open the door, so what do they see?
or a late joiner
oh you mean the variable thingy
I mean they'll see the door shut when it's open on server and clients who got the RPC
just don't use multicasts for state
use repnotify, it's much simpler too
why wouldn't they get it
okay wait
i will show you in a sex
sec
Because they weren't connected or were out of relevency range
no need to show me, using multicast for this is not a good idea
i mean to show how to set it up
do i just set the "OpenedRoof" variable to repnotify and put the OpenRoofOnServer before the branch and delete the client node completely?
Yes it'd go like this:
Client:
Input -> RunOnServerEvent
Serverside:
RunOnServerEvent -> set bOpenedRoof
Everywhere:
OnRep_bOpenedRoof -> branch -> play animation
so like this? Server node is set to RunOnServer and openedRoof is set to repnotify
no
i guess animating roof also needs to be repnotify then
you'll have to do some thinking to deal with the animation time but for now just play the animation
if someone joins late they'll see the animation playing
not just snap to the roof open
but that's a problem to fix later once you've figured this out
so it's wrong like this
okay gonna put it back to multicast
didn't really understand how to setup the repnotify one and multicast worked so far
good luck
thanks man!
Good that you managed it. But pawns don't persist by default at all, so it's on you to do that 
Hey again smart people. So I've got replicated pickup logic functioning just fine. Each client can pick up resources and equipable items and they are added to the inventory and displayed when equipped. However, I have my wires crossed somewhere with the widget functionality. There's an "added item" widget that pops up on the left side of the screen when you pick things up, and the widget hotbar updates when something is picked up. The issue I'm having is that while the pickup functionality works fine on any client, the widgets only work on client 1. In fact, anything I do in any client, happens on Client 1's widgets:
show code
smells like get player 0 shenanigans
hmmm. I'll try to figure out how to show code. The routing is a bit complex
I'm using an interface to directly get my PC from my character so I don't think it's an index problem, though I will start looking to see if that's the case
You were right. It's trying to get the controller at index 0. I haven't set up my spawning system yet so I don't have a way of assigning a player index. I guess I'd better set that up next.
Thanks. Sometimes pointing out the dumb obvious things helps. I need to get out of the habit of using "GetPlayerController" and into the habit of using GetOwner->GetController
Any-one have a good pattern for firing off one time events without RPC, which I'm trying to avoid overusing.
For example if I want an actor to make a noise, I've been using prop rep by replicating down the current game server time.
If on the clients the time is arbitrarily "close enough" + some other constraints, then I also play the noise due to OnRep.
Using the server game time seems to work, but I wonder if there's a better / more established approach here.
Don't avoid RPC's arbitrarily.
RPC's are great for fire & forget stuff. IE - making a noise.
OnReps are for stateful things
Ok yeah this is where I get confused on "best practices" which seem so hard to track down.
So an unreliable multicast RPC is an appropriate solution for doing something ambient, like short term VFX or sounds?
Yup
RPC for transients, RepNotify for state
Cool that's easy enough. Ok so what about another quick example.
Let's say I have a hit flash effect, and health is replicated. On the client I can tell the difference in health and apply the hit flash as a part of the onrep.
In this case, it's a better solution than multicasting it, right?
Yeah
Sweet ty
I guess that makes sense, unreliable multicast can be used when there's already no established state to trigger or react to a quick event
One more question now that everything is starting to make sense.
In general maybe I was confused about being careful on RPC vs Prop Rep.
Maybe it's more correct to be concerned about reliable rpc, where unreliable isn't as much of an issue? Is that where you start to have networking issues by using too many reliable RPC?
Yes, if you're ok with not all hits being flashed
You might end up with some stuff batched where you get one 20 hp change instead of 5 4 hp changes
Does anyone have any tips or recommendations about deploying a dedicated game server, for a small-medium sized project, on something like AWS?
This is a gold habbit for multiplayer !
Along with always providing an owner for the spawned actors and widgets !
Too right. I'm learning that the hard way right now. 😉
enabling Substepping is expensive for performance?
why is this giving me "cast failed" when playing multiplayer? That's in the pawn bp
rip is the string to be printed when the cast fails lol
set 0.3sec delay after begin play
controller is not yet ready and you attempt to cast it
i have the same setup with a character bp and there it works
i put a delay after cast failed and then back to the cast node
why not after it failing?
because it is fully loaded in the delay and you successfully cast it
ah i see okay
it's still not working for the client
the server goes through the code yes, but the client not
i tried multiple delays but none worked
player controller only available for
@ruby lodge You want to use Restart instead of BeginPlay for Pawns.
The PlayerController is ready on the Client when Restart is called for that Pawn.
Obviously except for Simulated Proxy Clients.
so switch beginplay node with "event receive restarted"?
okay
So right now the prints go like (bottom one came first) :
Client 1: Through
Server: Rip
Server: Through
and the client doesn't spawn every time
and the client doesn't spawn every time that sounds like an unrelated issue
Also, without showing code we dont know if you have done what we asked correctly or not
ah haha i see, the rip is apparently a "rip 2" so it comes from the second print here on the right