#multiplayer

1 messages · Page 122 of 1

dark edge
#

Is Player array not ordered?

thin stratus
#

Nope

dark edge
#

fun

thin stratus
#

It's locally maintained

#

But I'm sure if one spawns a Character with a Replicated Index it should be valid on BeginPlay

queen escarp
#

hmm

thin stratus
#

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

queen escarp
#

exactly

#

maybe an array is better

thin stratus
#

But that is also solvable with a bit of brain

queen escarp
#

and remove index on leave etc ?

#

istead

dark edge
#

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

thin stratus
#

And when needing to know the new index you just take the first empty slot

#

There are a bunch of ways to do this

queen escarp
#

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 ?

thin stratus
#

At this point it's kinda funny that this question still comes up

#

You have been told how this works a gazillion times

queen escarp
#

yupp but struggling with it obviously

thin stratus
#

GameMode is Server-only

#

That's all there is to it

#

You can't get it on the Client

#

No matter what you do

queen escarp
#

yeah so in no way a client can change something on the game mode then really `?

#

absolutley no way

thin stratus
#

At least in regards to directly accessing it

#

You can of course RPC to the Server and then let the Server change something

queen escarp
#

aye

thin stratus
#

But there is no way to directly access the GameMode as a Client since you simply don't have an instance of it

velvet jacinth
#

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.

queen escarp
#

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

thin stratus
#

I would use Character::BeginPlay for all of this

thin stratus
#

I can't quite follow

queen escarp
#

wdym Character thats what im using the player character ?

#

or do u mean the parent class

#

of my class*

thin stratus
#

I mean I would use the BeginPlay method of my Character class

queen escarp
#

yeah but this is for the "update part only" not assign part

thin stratus
#

wdym update?

queen escarp
#

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

thin stratus
#

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.

queen escarp
#

hmm

#

it will set the owner of the widget u mean?

thin stratus
#

No?

queen escarp
#

nevermind ill remove all the updating functions inside thje widget and do it all from the character since that seems to be better'

thin stratus
#

The Owner of the Widget is the local player

#

That's besides the point

thin stratus
#

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

queen escarp
#

yeah i think thats the issue

#

ok so to breake it down simple

thin stratus
#

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

queen escarp
#

ok sure

thin stratus
#

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?

queen escarp
#

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

thin stratus
#

So you actively hide them somewhere?

queen escarp
#

im going to set visible/colapse" was my idea

#

yeah

thin stratus
#

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
queen escarp
#

yepp

thin stratus
#

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.

velvet jacinth
queen escarp
#

ok

#

the player state then maybe * ?

#

game state*

thin stratus
#

They receive that _X based on order they get created it.

velvet jacinth
#

Yea that I know. But the others are the same player controller and character

thin stratus
thin stratus
#

@queen escarp So we use the Character directly. The Event to know, on everyone, that a Character is valid and ready, is BeginPlay

queen escarp
#

ok

thin stratus
#

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

queen escarp
#

yepp

thin stratus
#

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.

queen escarp
#

ok

thin stratus
#

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

queen escarp
#

sure

thin stratus
#

Nasty, freaking BPs

queen escarp
#

imagaine you being a n00b alsop

thin stratus
#

I guess you could make a custom PlayerState variable that you mark OnRep and piggy back of that

queen escarp
#

ok

#

should i just do a Bool and call is "Onrep" and mark for replicate right

thin stratus
#

Something like this essentially

#

Don't have a better idea atm

queen escarp
#

hm ok and that should be in the character bp ?

thin stratus
#

Yeah

queen escarp
#

since thats what were checking

bright fern
#

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?

thin stratus
#

Forgot to rename it

queen escarp
#

ok

thin stratus
#

In the OnRep you can then do something like this

#

Theoretically that should work

#

Still a bit unsure

queen escarp
#

ok but the SET w/Notify is from where what ?

thin stratus
#

Disgusting that we can't have OnRep_PlayerState in BPs

queen escarp
#

i already have a custom player state

thin stratus
#

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

queen escarp
#

i mean

#

i can name it player state * ?

thin stratus
#

Yeah but that's confusing

queen escarp
#

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 ?

thin stratus
#

What?

thin stratus
#

Yeah sure, I would never put the HUD into the Character

queen escarp
#

yeah thats what i mean

#

thats what i did * 😉

thin stratus
#

Mine sits in the PlayerController

#

Okay

queen escarp
#

yeah figured

thin stratus
#

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

velvet jacinth
#

@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.

thin stratus
#

@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

queen escarp
#

ok gimme a few mins setting it up

thin stratus
#

Also you never said who's inventory you are looking at

#

Does each player only look at their own inventory?

velvet jacinth
#

Well from the pictures I've sent it looks right.
Moving items in the inventory of each one seems to work ok.

thin stratus
#

print it

#

Like, the debugging process is something you gotta do

#

I can't do that for you :D

velvet jacinth
#

printing the owner in the drop item function prints server: _1 and client: _1
Looks like the same character but it's not ?

thin stratus
#

Again, _1 doesn't mean anything

#

If you need to know who is who, try getting the PlayerState and printing the PlayerName for example

velvet jacinth
#

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

queen escarp
#

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

thin stratus
#

Yeah cause you have your HUD in the Character

#

Which isn't guaranteed to be valid

#

I would move it to the PlayerController

queen escarp
#

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

queen escarp
#

@thin stratus

thin stratus
#

Can you breakpoint the functions and see where it fails?

#

Cause I didn't test it

queen escarp
#

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

thin stratus
#

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

queen escarp
#

oh¨

#

the top one is unrelated

#

so its accessing none

#

the casting is not failing

#

hmm

nocturne quail
#

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);

hoary spear
near fiber
#

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?

viscid tapir
#

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

queen escarp
#

@hoary spear as player character

thin stratus
# queen escarp <@231467939734355969> 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...

queen escarp
#

Yeah i got it the issue im using the player hud ref all over the whole game basicly :/

willow surge
#

@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.

thin stratus
#

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

thin stratus
#

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

queen escarp
#

Hmmm why would it. Be better in the controller rather then the character ?

thin stratus
#

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

willow surge
near fiber
#

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

thin stratus
#

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

near fiber
#

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 ?

thin stratus
#

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

thin stratus
#

You can of course just tell the Server to move, but it's by faaaar not enough

queen escarp
#

but eXi- question, is the "on rep function" only server called something something ?

fallow kettle
#

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

queen escarp
#

and also the player hud is valid 100% that cant be the problem :/&

near fiber
#

I'll check what I can figure out, thank you!

thin stratus
thin stratus
thin stratus
#

(+- local Splitscreen ones)

fallow kettle
#

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

thin stratus
thin stratus
#

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

fallow kettle
thin stratus
#

So not online at all?

fallow kettle
thin stratus
#

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

fallow kettle
#

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

thin stratus
#

"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

fallow kettle
#

I havent touched the online part just yet

thin stratus
#

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.

fallow kettle
thin stratus
#

Yeah the PostLogin would call for all players who join

#

That's a bit late to suddenly add local players

fallow kettle
#

I just got confused with understanding the diff between using the player controller node and having a custom container

fallow kettle
thin stratus
#

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

fallow kettle
thin stratus
#

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

fallow kettle
thin stratus
#

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

velvet jacinth
#

Hope someone here could reply and try to help with my problem here:
https://forums.unrealengine.com/t/replicating-player-character-rotation/1327505

rocky kestrel
#

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?

candid mulch
#

I copied this code into my custom cmc, and it says that it did not override a base function

muted pewter
#

Does Amazon Gamelift sdk support unreal engine 5.3.1 version?
Or what's the latest supported version of engine?

thin stratus
#

That's a Gamelift question. Better suited for their Discord/Forum

zealous knoll
queen escarp
#

@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*

small grail
#

How did you spawn them?

humble edge
#

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 ...

▶ Play video
pastel fiber
grave widget
#

Can I replicate parameter declared in the interface?

chrome bay
#

Interfaces can't contain UPROPERTY so no

wintry vector
#

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?

queen escarp
#

Hm my widget automaticly are being set to 1080x1920 in the editor when i open them (reversed) ??? why

#

even if i change and save*Ä

upbeat geyser
#

What is the correct way to tell the client to say the server what his location?

unique forge
#

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.

gusty slate
#

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

ocean laurel
#

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

gusty slate
#

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

unique forge
#

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

gusty slate
#

I answered ^ x)

unique forge
#

any tipps? that u can help?

ocean laurel
#

do what he said and make sure all of the events aren't replicated at all so that it's purely running locally

unique forge
#

no replication alright

gusty slate
#

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

unique forge
#

alright

#

ill try

gusty slate
#

And for the future, IF you need something like this replicated (idk why) but, if you do, you have to get the proper Controller

unique forge
#

not the local?

ocean laurel
#

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

gusty slate
#

Exactly

#

each pawn has a controller remember

#

if I remember GetController gets you the owning controller

unique forge
#

made into headblob not replicated

#

deleted the custom event

unique forge
unique forge
#

but player 2 has the same reason as 1

#

when player 2 is running

ocean laurel
unique forge
#

player 1 gets too

ocean laurel
#

put that at the beginning of your headbob

unique forge
#

alright

#

now its like

ocean laurel
#

use your original branches as they were but have this as well before what you had

unique forge
#

when player 1 is running, the shake doesnt happen on player 1, only player 2

ocean laurel
#

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

unique forge
#

now both players dont have the running shake, added on the 2nd branch the is locally controlled

ocean laurel
#

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

unique forge
#

like this?

#

mb the second locally

#

i deleted

gusty slate
#

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

unique forge
gusty slate
#

yeah exactly like your code used to be before

#

Here's the thing

#

even the CameraShake shouldn't be networked

ocean laurel
unique forge
#

ayeeee

#

it worked

#

ty

#

yea

#

added 3rd branch

ocean laurel
#

nice 👍

unique forge
ocean laurel
#

anytime

manic token
#

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?

ocean laurel
#

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

ocean laurel
icy phoenix
#

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.

chrome bay
#

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

icy phoenix
#

ah that might be the problem maybe. How can I ensure I define the actor as the outer?

chrome bay
#

When you're creating them, just use GetOwner() as the object outer

#

IIRC you also need to opt-in to the replicated subobject list

icy phoenix
#

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

chrome bay
#

Instanced will probably have issues I suspect, since you can't change the outer.

icy phoenix
#

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

chrome bay
#

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

icy phoenix
#

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

chrome bay
#

this is an actor right?

icy phoenix
#

actor component

chrome bay
#

It says target is 'Actor'

icy phoenix
#

oh apologies, yes it's my cube actor

chrome bay
#

yeah should be able to just remove it then, just use this as the outer

icy phoenix
#

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?

chrome bay
#

You would do yeah

#

Each instance needs to be added to the list

icy phoenix
#

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 !

hoary spear
limber gyro
#

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?

real ridge
#

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?

real ridge
#

fixed

gloomy axle
serene kestrel
unique forge
#

sometimes it works, then somehow dont work

hoary spear
#

Is this in a pawn?

#

So you can use "GetController" and GetCameraManager

#

@unique forge

wanton cedar
#

when would one want to use fast replication over normal replication?

wanton cedar
slate basin
#

Oh that, no idea

queen escarp
#

im working on my AI, its suppose to choose a random player wich way is preffered ?

slate basin
#

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.

queen escarp
#

hm shouldent this pick a random :/ ?

wanton cedar
#

one of the UE dev talks on fortnites replication mentioned something about this i believe

hoary spear
#

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

fluid prawn
#

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.

serene kestrel
hoary spear
#

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

unkempt current
#

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?

hoary spear
#

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

serene kestrel
hoary spear
#

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 😛

serene kestrel
#

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

hoary spear
#

It very likely could just be a regular pointer ,

#

setup similar to Lyra's inventory, with fragments and definitions etc

hoary spear
pastel fiber
#

If we set bReplicates property of an actor to true, which data members of the actor are replicated?

hoary spear
#

The ones marked for replication

#

The bool is just if the actor should even be considered for replication

winged vault
#

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);
            }
        }
fossil spoke
#

@winged vault Is the Actor/Component marked to Replicate?

winged vault
fossil spoke
#

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.

winged vault
fossil spoke
#

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

hushed rain
#

Is there a way to turn replication on and fire it once on command for a component in a BP?

true olive
#

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.

fossil spoke
hushed rain
#

i think setting it to dormant all and then flushing it before using works though, not sure

short arrow
#

Unless they fixed it for UE5

#

But it was marked as a bug on the site and marked "won't fix" aswell

hushed rain
#

Hmmm, so it's dormant and turns on/off by itself?

short arrow
#

So idk if it makes dormancy less reliable

hushed rain
#

based on changes

short arrow
#

Yeah, but again it's been a few years. Not sure if they backtracked and fixed it

hushed rain
#

interesting, yeah i thought i saw the changes happen even without flushing it. Hopefully it isn't awake but printing dormantl ol

fossil spoke
#

Yes dormancy is how you would handle this.

small grail
# pastel fiber

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.

pseudo kernel
#

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

silent valley
pseudo kernel
#

I find myself really wanting to do something to those kinds of methods

hoary spear
#

In bp theres the nice BlueprintAuthorityOnly or BlueprintCosmetic ufunction specifiers, for blueprintcallable functions

pseudo kernel
#

I'll keep that in mind as I start doing BP networking, currently in C++

hoary spear
#

Doesnt help to much for the c++ side of things tho

velvet jacinth
#

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.

hoary spear
#

Im confused

#

Server rpc?

velvet jacinth
#

Sorry, when pressing B from the server in game the run on owning client doesn't fire

dark parcel
#

why do you need to call server to open a widget?

#

using button press nonetheless

velvet jacinth
#

The button press is for debug and test.
I want to understand and learn how to display a widget locally for each player.

dark parcel
#

just display locally then? No need for any RPC

#

Press B -> Show Widget

#

not like Widget can be replicated

velvet jacinth
#

I saw on YouTube that this is the method. 🤔 very confusing.
You're right

#

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 ?

dark parcel
#

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

velvet jacinth
#

This would show for both the client and the server.
The actor is Replicated

dark parcel
#

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

pseudo kernel
#

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?

velvet jacinth
#

Well, worked as expected. Thank you very much for your help! @dark parcel

sinful tree
# pseudo kernel > If the RPC is being called from server to be executed on a client, only the cl...

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.

pseudo kernel
#

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?

hoary spear
#

Correct

#

Well, you can have the server owned actor invoke a client rpc on the client owned actor

pseudo kernel
woven barn
#

guys i have a dedicated server/gameplay ability system question. is this the right channel?

hoary spear
woven barn
#

thanks

upbeat geyser
#

How to give client owning an actor authority over replication?

hoary spear
#

huh ?

#

SetOwner , if you want to grant ownership to another actor

upbeat geyser
#

For example client is owner of a car, I dont want the server to correct him but vice versa

hoary spear
#

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)?

hoary spear
#

cheaters are welcome then i guess

upbeat geyser
#

Game is not competitive so it isn't a concern so much

tardy fossil
#

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

candid shuttle
#

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?

glad escarp
#

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.

hoary spear
#

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

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

hoary spear
#

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

glad escarp
#

hmmm. ok I can try that.

glad escarp
hoary spear
#

Set the bool before destroying it ? 😅

glad escarp
plain nacelle
candid shuttle
#

is the movement of your second character intentional? I mean the sliding off to the right?

fallen orbit
#

Why components' OnComponentBeginOverlap event only happens in client rather than server?

dark edge
velvet jacinth
#

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?

worthy wasp
#

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?

velvet jacinth
hoary spear
#

Rpc the input?

velvet jacinth
#

Still prints false in the ActorComponent

hoary spear
#

Are you sure the actor logic runs on server ?

velvet jacinth
#

So confusing

#

The get player controller func is just the basic getPlayerController with cast.

hoary spear
#

Ehhhh

#

You cant use that to any reliability in mp

#

Wheres the component?

#

In the player pawn?

velvet jacinth
#

In the player character yes

hoary spear
#

So

#

GetOwner -> cast to pawn -> GetController -> cast to MyPlayerController

#

Generally you cant use any of the "get X" with an index input

velvet jacinth
#

Same problem. still prints false.
No error by the way

hoary spear
#

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 🙂

velvet jacinth
#

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

hoary spear
#

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

velvet jacinth
#

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

glad escarp
hoary spear
velvet jacinth
#

@hoary spear Thank you very much it would take me hours to think about that if it wasn't for you

hoary spear
glad escarp
#

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.

hoary spear
#

Ill stop asking questions now

#

😅

glad escarp
hoary spear
#

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

surreal dragon
#

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?

hoary spear
#

Id test it on two different pc's first, but yes thats what youd do

surreal dragon
#

that easy huh!

hoary spear
#

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

surreal dragon
#

gotcha, thank you

lapis minnow
#

Does anybody know of a way to disable log files being generated when running a dedicated server

nocturne quail
#

how do write if (GetLocalRole() == ROLE_AutonomousProxy) in 4.26?

#

for me GetLocalRole() is undefined

glad escarp
#

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.

hoary spear
#

Clients should prob use onrep

#

On a Replicated mesh variable

#

Set by a server called event on spawn

glad escarp
#

Hmm.. Not sure I follow but I'm gonna read this a few times and do some research.

hoary spear
#

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 🙂

glad escarp
hoary spear
#

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

glad escarp
hoary spear
#

Nice, then we know 🙂

rose turret
#

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

hoary spear
#

Botcontroller (aicontroller?) Wouldnt have a playerstate usually

cosmic yoke
#

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

rose turret
worthy wasp
hoary spear
worthy wasp
#

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.

quaint roost
#

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)

worthy wasp
#

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.

worthy wasp
# hoary spear 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

quasi tide
hoary spear
#

Game show - idk what they use really

quasi tide
#

It's something like, bRequestPlayerState or something like that

hoary spear
#

Just wanted to be precise about it's inheritance

worthy wasp
quasi tide
hoary spear
#

If only ditching bb and going ps was a valid path with bt :p

worthy wasp
#

50+ enemies on screen will crush FPS flat.

quasi tide
#

Well, CMC and skele stuff are super expensive

#

Also animations

worthy wasp
#

take away the AI logic - runs almost full FPS

worthy wasp
hoary spear
#

What ai logic is this

quasi tide
#

I mean, I can get like 300 running around. Soooo

hoary spear
#

I did some custom ai logic and can run ~5k, but its not really that optimized im sure

worthy wasp
hoary spear
#

Ah

#

My mistake lol

worthy wasp
#

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.

hoary spear
#

Ill be going for 50+ when i get to it , using perception

worthy wasp
#

i'm about to make my crowd start utilizing clusters - groups of 5 for 1 AIController/perception

hoary spear
#

But i may cheeze it a little , with a manager amongst them

worthy wasp
#

yah - a manager is like what i'm saying.

hoary spear
#

Yepp

worthy wasp
#

i figure - if i can fraction it by 5 (or more) then it'll be way more performant.

quasi tide
#

It's definitely how Days Gone got their numbers

worthy wasp
#

i thought at first - skeleton/CMC - but nope :/

#

when stripped ... it ran almost full on FPS

quasi tide
#

I'd be interested in the actual profiling numbers.

worthy wasp
#

like how many i'm spawning?

quasi tide
#

No - the UnrealInsights that you used to profile everything.

#

Instead of just turning something off/on

worthy wasp
#

oh man i havent touched profiling yet - :/ Very ill-informed on that topic

hoary spear
#

Its pretty important for optimizing stuff properly

#

Knowing the bottlenecks comes a long way

worthy wasp
#

thansk for the term drop! I've pulled it up and bookmarked it for when i get to this

#

greatly appreciated

grizzled garnet
#

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

serene kestrel
grizzled garnet
#

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

ruby lodge
#

just making sure lol, is this replicated correctly?

#

it should replicate the horn sound

sinful tree
#

Otherwise, that's how you can do it.

glad escarp
#

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.

ruby lodge
sinful tree
ruby lodge
#

but i hope it's not hearable on the entire map lmao

sinful tree
#

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.

ruby lodge
#

hm i see, how do i fix that?

#

i guess thats bad from a cheating pov

sinful tree
#

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.

rose turret
#

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?

nocturne quail
#

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?

ruby lodge
sinful tree
ruby lodge
#

and now you mean the circled nodes on the right should be executed on the server?

fallen orbit
#

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

hoary prairie
#

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 😅

https://streamable.com/fbgasz

sinful tree
hoary prairie
#

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

sinful tree
hoary prairie
hoary prairie
slate basin
#

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?

fossil spoke
#

Search the array?

#

You can setup an ID as a property of the FastArray Element

#

And use that to search for the same one

slate basin
fossil spoke
#

Do not rely on the index

#

Order is not retained

#

On Arrays

slate basin
#

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

fossil spoke
#

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

slate basin
#

yeah I mean have an id on the struct, then use the index for that instead of having 16 bytes guid

fossil spoke
#

An FGuid is unnecessary. An int would be enough.

#

Just increment it and assign it to each element when the server adds one

twin juniper
#

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...

fossil spoke
#

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.

twin juniper
#

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

slate basin
#

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

twin juniper
#

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'

plush crow
#

hi guys, is there a way to set a variable from the host to all clients?

slate basin
plush crow
grand kestrel
#

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

daring arch
#

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?

fossil spoke
#

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.

daring arch
#

Hmmm.

My weapon has a "WeaponMechanism" component.

Is ownership also relayed to ActorComponents?

fossil spoke
#

Well yeah, they are owned by the Weapon

daring arch
#

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

fossil spoke
#

Is the Weapon set to Replicate?

#

The Actor must still have its Replication flag enabled

daring arch
#

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);
fossil spoke
#

If this is called inside a Pawn you probably want CurrentWeapon->SetOwner(this); instead

daring arch
#

This is called inside an ActorComponent for a Pawn

fossil spoke
#

Ah

#

Try just using a direct reference to the Pawn instead

daring arch
#

Uh, how can I do that? I've thought that the only way to get the owning actor of a component was through GetOwner()

fossil spoke
#

Yeah not sure why it would be empty? Unless you are debugging it incorrectly 🤷

daring arch
#

Possibly! lol

fossil spoke
#

Without more information or context Im not sure what else to suggest

daring arch
#

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!

pseudo kernel
#

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?

hollow eagle
#

Only if you want it to.

#

By default no, OnReps are only called for changes.

daring arch
#

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.

hollow eagle
#

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.

daring arch
#

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

hoary spear
#

Sounds like the owner was incorrect after all 😅

pseudo kernel
#

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?

#

I think this is the right method? 👀

pseudo kernel
# short arrow 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.

short arrow
#

goodluck!

nocturne quail
#

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

short arrow
# nocturne quail 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

nocturne quail
shrewd ginkgo
#

I want to make skill for one of The players in my game. He must see other players trough walls. How canI do it

pseudo kernel
#

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?

bright fern
#

Hi everybody,
Do someone know a good tutorial about multiplayer over internet with c++?

pseudo kernel
dire sable
#

Hey there, having the same issue and I wonder if you came up with any solution?

bright fern
#

@pseudo kernel Thank you
Is there free thing?

pseudo kernel
#

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

twin pendant
bright fern
#

@pseudo kernel, thank you so much
I'll have a look at those courses

dire sable
twin pendant
dire sable
#

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

rocky kestrel
#

Hello. Why this not work in multiplayer but singleplayer it works and how I could fix that?

twin pendant
rocky kestrel
#

This not get executed in multiplayer

twin pendant
#

or how do you "register" footsteps?

dire sable
twin pendant
dire sable
#

And it doesn't matter how we leave it, alt+f4, closing the server or exiting via menu

rocky kestrel
twin pendant
torpid girder
#

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

pseudo kernel
ruby lodge
#

Do you mean to have the "is player controller" and "get focal location" nodes also inside the multicast?

torpid girder
dusky yoke
#

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.

stuck cloud
#

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?

queen escarp
#

Hey Got adviced to add some Network Emulation

#

whats a good Default "low" setting for a listen server * ?

hoary spear
#

But you can code it so they can manipulate it

#

But playercontrollers are only replicated to the owning client iirc

stuck cloud
#

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

silent valley
#

(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 ?

sharp vigil
#

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?

silent valley
sharp vigil
silent valley
sharp vigil
#

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.

silent valley
#

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.

sharp vigil
#

I gotcha. Thank you.

ocean laurel
stuck cloud
#

When deactivating splitscreen. How can I switch the view to a different Player Controller?

abstract pike
#

@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... 🤔

hoary spear
#

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

ruby lake
#

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

cosmic yoke
#

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

silent valley
pseudo kernel
cosmic yoke
#

@silent valley so a client RPC for each player controller in that team

cosmic yoke
#

ok i'll try it thanks

ruby lodge
latent basin
#

Hey all what is the command or how do i simulate network lag again?>

#

Cant find the command on google

twilit radish
#

@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.

abstract pike
ruby lodge
#

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

dark edge
#

repnotify

ruby lodge
dark edge
#

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

ruby lodge
#

how do i use a repnotify

dark edge
#

or a late joiner

ruby lodge
#

oh you mean the variable thingy

dark edge
#

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

ruby lodge
#

okay wait

#

i will show you in a sex

#

sec

dark edge
#

no need to show me, using multicast for this is not a good idea

ruby lodge
#

i mean to show how to set it up

ruby lodge
dark edge
#

Yes it'd go like this:

Client:
Input -> RunOnServerEvent

Serverside:
RunOnServerEvent -> set bOpenedRoof

Everywhere:
OnRep_bOpenedRoof -> branch -> play animation

ruby lodge
ruby lodge
#

i guess animating roof also needs to be repnotify then

dark edge
#

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

ruby lodge
#

what do you mean

#

figure what out?

#

the animation is 5 sec long

ruby lodge
#

okay gonna put it back to multicast

#

didn't really understand how to setup the repnotify one and multicast worked so far

dark edge
#

good luck

ruby lodge
#

thanks man!

fathom aspen
glad escarp
#

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:

dark edge
#

smells like get player 0 shenanigans

glad escarp
#

hmmm. I'll try to figure out how to show code. The routing is a bit complex

glad escarp
glad escarp
# dark edge show code

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.

glad escarp
# dark edge show code

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

pseudo kernel
#

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.

quasi tide
#

Don't avoid RPC's arbitrarily.

#

RPC's are great for fire & forget stuff. IE - making a noise.

#

OnReps are for stateful things

pseudo kernel
quasi tide
#

Yup

dark edge
pseudo kernel
#

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?

quasi tide
#

Yeah

pseudo kernel
#

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?

dark edge
#

You might end up with some stuff batched where you get one 20 hp change instead of 5 4 hp changes

last bough
#

Does anyone have any tips or recommendations about deploying a dedicated game server, for a small-medium sized project, on something like AWS?

hoary spear
#

Along with always providing an owner for the spawned actors and widgets !

glad escarp
nocturne quail
#

enabling Substepping is expensive for performance?

ruby lodge
#

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

nocturne quail
#

controller is not yet ready and you attempt to cast it

ruby lodge
#

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

nocturne quail
#

put delay before the cast node

#

always casting on begin play put some delay

ruby lodge
#

why not after it failing?

nocturne quail
#

because it is fully loaded in the delay and you successfully cast it

ruby lodge
#

ah i see okay

ruby lodge
#

the server goes through the code yes, but the client not

#

i tried multiple delays but none worked

nocturne quail
#

player controller only available for

fossil spoke
#

@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.

ruby lodge
fossil spoke
#

Yes and remove OnPossessed

#

OnPossessed is only called by the Server.

ruby lodge
#

okay

ruby lodge
#

and the client doesn't spawn every time

fossil spoke
#

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

ruby lodge