#multiplayer

1 messages Β· Page 48 of 1

jolly delta
#

is this is call everytime on changing level or only once on login on the server?

sinful tree
bronze mauve
#

Yeah, the old school shooter project from unreal does a lot of iterating over all player controllers and doing something to each of them lol

jolly delta
#

because on my lobby i do that and then store controller on a gameInstance to get it after switching level

bronze mauve
#

Datara is this the BP version of PostLogin?

sinful tree
jolly delta
#

ah

bronze mauve
#

PlayerState might be persistent, but I'm not sure

jolly delta
sinful tree
bronze mauve
#

In the other game mode you could just let the game mode spawn in the players. If you want them all in an array you can store them in PostLogin maybe or if you want to be sure the pawn is possessed by a specific controller you can do something in the character's OnPossess

weak linden
#

@jolly delta I've just realized that my spawning setup wouldn't be applicable to your use case, when your players transition from the lobby to the "game", do you load a new level? If so, do as @bronze mauve suggested, just have a separate game mode for your lobby and game and set the default game mode for the "game" level to the "game" game mode that will spawn using the native way

jolly delta
#

then TopDown level has a different gamemode

sinful tree
bronze mauve
#

Yeah your switching code looks okay.

I'd just let the TopDown spawn players on its own.

Yeah the player states array will already exist for you as well.

#

Loop through that to do custom things like sort them into teams for example

jolly delta
weak linden
# jolly delta this is what i do to switch

Okay, so you can just use the "Default Pawn Class" for that on your TopDown level game mode, If you need more control over the spawn process, you can do something along these lines in the TopDown game mode, my system has a concept of player selectable classes from the game instance, but that part is optional.

EDIT: The 1st screenshot is from my game mode, the second is from my controller, the last is back in the game mode

gray latch
#

I have an issue with a TArray on my client. I add items to the array on server side using "UFUNCTION(Server, Reliable)". This seems to make it so the client side TArray will never be populated, and I am unsure how to query the server side TArray for the client. Any hints?

bronze mauve
weak linden
bronze mauve
#

Replicate the array and only populate it on the server

weak linden
bronze mauve
#

Just remember that the client side array is just a reflection of the server's and you shouldn't add to it client side

bronze mauve
#

I wonder if there is a way to enforce that.

gray latch
weak linden
#

For example

void UEBInventoryComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    // Lifetime variables.
    DOREPLIFETIME(UEBInventoryComponent, InventoryItems);
}
bronze mauve
#

Yeah register it for replication with DOREPLIFETIME

#

Kami beat me to it lol

weak linden
#

2Fast4U kappa

bronze mauve
#

Too fast for... oh forget it

gray latch
#

Ahhh. That actually makes sense! Thanks both. I will test it out and then either cry or smile in just a bit!

bronze mauve
#

So with replication of TArrays... is there any built-in optimization?

If the array has 4 elements and I add a 5th, does the whole array get serialized and replicated down or just the 5th element

#

Smile-crying is acceptable too

weak linden
gray latch
weak linden
gray latch
#

Yes cool thanks. That's what I meant - forgot to specify that my class is an actorcomponent πŸ™‚

#

I have now tried the following: 1) add the replicated TArray to the lifetime replicated props on the base component class, and 2) add the replicated TArray to the lifetime replicated props on the child component class that derives from the base class. In both examples I seem to run into the same issue where the TArray is only updated on the server side, and not the client. What would you recon I did wrong here?

#

I'll be happy to screenshare the code if that is easier!

bronze mauve
weak linden
weak linden
bronze mauve
#

Afaik

#

That FArchive << magic is pretty crazy

#

I didn't know it was overloaded to work both ways based on context

#

Laura told me that yesterday in another channel but I don't think I fully grasped what she said lol

gray latch
#

Basically, the DebugAddWood calls the AddItemOnServer, which calls the AddItem function

weak linden
#

Also, is your PlayerHotbarComponent definitely marked as replicated?

gray latch
#

Oh let me check that last point

#

For the first question, I also look in the editor when adding items. It doesn't update the client's TArray.

jolly delta
#

what is the behaviour of posses ? when i use it it remove my pawn of the clients

gray latch
weak linden
weak linden
jolly delta
bronze mauve
weak linden
bronze mauve
#

Yeah it's confusing, but the player state, player controller, etc. Are all associated with a player. ULocalPlayer I believe?

jolly delta
#

even if this is not exeactly what you tell me to do, for test purpose is this is supposed to work ?

#

because if I remove the possess it spawn the actor on each client as expected but when i add the possess the actor is mission on every clients

native vector
#

idk why but location on client out of sync with server
so im attaching actor to actor on server
client side actors are in different location
there is a way to force transform sync ? or something like that

bronze mauve
#

Replicate movement

#

Is the Actor replicated?

native vector
#

yes

#

delay fixed the problem but i have feeling this is not correct way

#

link func

#

on linked runs

solar stirrup
#

Has anyone here used the General Movement Component plugin from the marketplace? Is it good? Sure looks like it anim_eyes

real ridge
#

guys when i join my game I get instantly kicked after loading map this is what I have in log do you have any idea where can be problem?

real ridge
#

idk why connection is lost it looks like I was kicked by some reason

native vector
#

there is no session to join so u got kicked

real ridge
#

so i don't count it

native vector
#

did u make the session ?

real ridge
#

yea ofc

#

here is my server with session on laptop

#

now from pc i tried again and joined but it is weird

#

sometimes it kick me

#

you can see this is second part of log

#

same as previous saying no sesssion to join

#

which is normal

native vector
#

wrong ip and port on client ? or u missing something else

real ridge
#

nono thats all is ok something in blueprints inside must be wrong or spawnpoints thats why I get kicked sometimes but i dont know what of these

jolly delta
#

is there any reason that force me to add a delay here ?

thin stratus
#

Depends on what is on the left

#

You gotta show all the context/code

native vector
thin stratus
#

Delays as a fix for something are 99% of a time wrong

#

The only times where a Delay for a fix is fine (if it fixes it) is if it's a Frame Delay :D

jolly delta
#

in that case if i do not add this delay my actor disappear

real ridge
#

hmm it's really weird both logs from my games I don't actually understand what's going on even I now don't get kicked from map I don't see each other there

#

hmm

native vector
real ridge
#

packets

#

which are sending server to client

#

gonna debug it maybe I will find solution

thin stratus
#

Loop Executions don't wait for the Delay to end

native vector
#

@real ridge
try to add 2 rpc one form server to all
and other form client to server with print string
and send it every 10s 10 times
if u don't get 1 of then u know u are not connected

thin stratus
#

You will probably get the last iterations PC there all the time.

#

Why are you handling spawning of your Characters by hand anyway?

#

You can just put your Character Class into the GameMode's DefaultPawnClass

#

And override Find/ChoosePlayerStart to return a PlayerStart of your liking

#

That would also remove the need for any shitty delays

#

Cause it calls properly for every player once they are ready

#

UE Multiplayer is all about understanding what Unreal Engine already offers you instead of reinventing the wheel

real ridge
thin stratus
#

You should honestly delete that function and have your GameMode handle this as explained

#

A lot less headache

#

You can even dynamically select a Class for each Player if you override the right functions

#

GameMode has a lot of functions in the Override tab

#

Once you learn this, you'll have a much easier time

real ridge
#

Yes listen exi he is boss

jolly delta
#

i know ahah i am a beginner on unreal and even more on network

real ridge
#

Sometimes I successfully connect to server but sometimes I am one second after joining kicked and this is log what can be problem?

gray latch
#

Is it enough to simply add bReplicates = true; in the constructor for an AActor to obtain the same functionality as ticking the "Replicates" tickbox in an actor's blueprint?

thin stratus
#

@whole grove maybe knows who that was. Wizard maybe?

#

(that Marketplace movement comp)

solar stirrup
#

From the video and tutorials it looks pretty darn good

#

Yeah looks like messages say the same

#

Honestly looks easier to extend than the CMC for custom movement

#

and the possibility to use different shapes is nice as well

bronze mauve
#

That general movement component looks epic

jolly delta
lethal lark
#

The RPC works on the server and the flipbook is visible to other clients, but the function is not executed on the client

bronze mauve
#

But anyways I think you'd want to call the function on the client too

#

Why not just inform the server when the state changes, and have the animations update in tick locally?

lethal lark
#

Thanks, i'll try it

thin stratus
#

I meant if you know the user who looked at it and tested it.

#

But I wasn't clear enough via the phone typed message, sorry

thin stratus
#

I never said that :D stop making up things, this isn't useful

jolly delta
thin stratus
#

The GameMode already handles everything

real ridge
#

guys how I can send here log as txt? I dont want spam whole chat i Have one log to show

bronze mauve
#

Seems like the server really just needs to know the state, and even if the flipbook updates aren't in sync between server and client

thin stratus
#

Right, thanks, that's all I wanted to know

bronze mauve
#

Paste it into notepad. That's what I use as my IDE anyway

#

Proof:

real ridge
#

okay I have it @whole grove thanks, guys here I have my log from my dedicated server there are bunch of errors which I have propably need to fix but for some reason I am getting kicked from this server short after joining do you see problem why? I cant find it thanks

bronze mauve
#

dang no red squiggles for my missing semicolon though... 😿

jolly delta
#

@thin stratus

You can just put your Character Class into the GameMode's DefaultPawnClass (edited)
And override Find/ChoosePlayerStart to return a PlayerStart of your liking
That would also remove the need for any shitty delays
Cause it calls properly for every player once they are ready
i do not understand how to do that..

oh wait

digital herald
#

You can just open your game mode Blueprint and set the Default Pawn Class.

fathom aspen
#

But you're WitchCell, so you have ownership rights too

fresh cloud
#

Roxxor so... when the server processes a new player, there's an entire sequence the gamemode does server-side that includes acknowledging and verifying the player is okay to join the server, then it starts an entire sequence starting with InitNewPlayer

#

this includes finding the default pawn (which you can override to decide what pawn they should use), finding a playerstart for them to use, etc.

#

then whenever you need to, you can call a server restart on the player controller that will restart the sequence and find them a new place to spawn, give them a new pawn, etc.

#

it's best to override the functions within the gamemode that already handle it and just add functionality within the existing framework

fathom aspen
#

@solar stirrup TLDR: it's really easy to understand and extend. Also look at the tutorials if you haven't done so, they give you a better picture of the plugin. Honestly best plugin I bought to date. The creator is friendly and helpful too ^^

thin stratus
#

The creator is friendly and helpful too ^^
Hasn't been broken by the Marketplace yet

#

Whatever God bless their soul

fresh cloud
#

oh, exi, i know you probably don't remember but i FIXED MY ISSUES with my custom movement component!

thin stratus
#

Which was that

fresh cloud
#

the one where i was getting issues with like collisions bugging out and stuff? basically have a tank-control style pawn i'm making and i didn't want to use character and cmc because they're really heavy for something this simple

thin stratus
#

The only sad thing about the plugin is that it gives Epic another free card to ignore the problem at hand

solar stirrup
#

Could just hire the dev

#

Like they did for ALS

fathom aspen
#

I grabbed it while at sale (30% off that was iirc)

solar stirrup
#

Damn, missed that sale rip

thin stratus
#

🀑

fresh cloud
#

it turns out i was A) sending the wrong rotation data to the server in every move packet, and B) i was using addyawinput on both the server and client, which was generating inaccurate rotations because it was resolving the rotation at different times

thin stratus
#

Support the poor soul

fresh cloud
#

so now i've fixed the rotation data sending, and fixed it so i read and write directly from the controlrotation on the controller

#

and like EVERYTHING fell into place, it works SO beautifully

solar stirrup
#

True tbh

thin stratus
#

That 400 or whatever it costs doesn't get you far nowadays

solar stirrup
#

Looks very much worth it

fresh cloud
#

i'm so proud of myself LOL, i can't believe i figured it out

thin stratus
#

epic's cut, whatever actual currency they have and taxes

#

They keep little from it

#

And you save a shit ton anyway if you need this

#

Cause you otherwise pay probably something with four zeros to get this done from scratch

#

100,00 of course kappa

#

sigh

jolly delta
#

it work like that πŸ₯‚

thin stratus
#

Yeah that's one way of doing it

#

You can keep that if you want

#

Is there a reason you use a TMap and construct a String?

#

Instead of just an Array and using the Integer as index directly?

jolly delta
thin stratus
#

Fire them

#

joke

jolly delta
#

we are student ahaha x)

fresh cloud
#

the way i do it is i have my own player starts in my maps that contain the data i need, and i have custom functionality in ChoosePlayerStart to pick one for me

thin stratus
#

Yeah that's how one usually does it

jolly delta
#

thank you a lot for your help

fresh cloud
#

mhmm, also remember that uh... restartplayer is a functionality you might want to think about! so for example, when the pawn that the player has runs out of health, you would want to be able to have the player depossess the pawn and have it be destroyed, and then restart the sequence with a new pawn

#

HandleNewStartingPlayer only fires once at the beginning

thin stratus
#

Yus

fresh cloud
#

it's a bit more advanced, had has different functions you'll want to override, but for now that definitely works

thin stratus
#

Gotta figure out how to increment that int then though

#

Think the Choose functions are const? maybe not

jolly delta
#

server travel reset controller data right ?

thin stratus
#

Not always

jolly delta
#

but it is a bad behaviour to trust about it if is is not always ?

thin stratus
#
void AGameMode::HandleSeamlessTravelPlayer(AController*& C)
{
    UE_LOG(LogGameMode, Log, TEXT(">> GameMode::HandleSeamlessTravelPlayer: %s "), *C->GetName());

    APlayerController* PC = Cast<APlayerController>(C);

    UClass* PCClassToSpawn = GetPlayerControllerClassToSpawnForSeamlessTravel(PC);

    if (PC && PC->GetClass() != PCClassToSpawn)
    {
        if (PC->Player != nullptr)
        {
            // We need to spawn a new PlayerController to replace the old one
            APlayerController* const NewPC = SpawnPlayerControllerCommon(PC->IsLocalPlayerController() ? ROLE_SimulatedProxy : ROLE_AutonomousProxy, PC->GetFocalLocation(), PC->GetControlRotation(), PCClassToSpawn);
            if (NewPC == nullptr)
            {
                UE_LOG(LogGameMode, Warning, TEXT("Failed to spawn new PlayerController for %s (old class %s)"), *PC->GetHumanReadableName(), *PC->GetClass()->GetName());
                PC->Destroy();
                return;
            }
            else
            {
                PC->SeamlessTravelTo(NewPC);
                NewPC->SeamlessTravelFrom(PC);
                SwapPlayerControllers(PC, NewPC);
                PC = NewPC;
                C = NewPC;
            }
        }
        else
        {
            PC->Destroy();
        }
    }
#

It depends on the Class your GameMode uses

#

If the previous GameMode uses the same PlayerController class, then it won't recreate it

#

Then it only does this:

    else
    {
        // clear out data that was only for the previous game
        C->PlayerState->Reset();
        // create a new PlayerState and copy over info; this is necessary because the old GameMode may have used a different PlayerState class
        APlayerState* OldPlayerState = C->PlayerState;
        C->InitPlayerState();
        OldPlayerState->SeamlessTravelTo(C->PlayerState);
        // we don"t need the old PlayerState anymore
        //@fixme: need a way to replace PlayerStates that doesn't cause incorrect "player left the game"/"player entered the game" messages
        OldPlayerState->Destroy();
    }
jolly delta
#

oh find my mistake i think, the var is not synced with the server

thin stratus
#

Also, the code might not show it, but in both cases it will call OldPlayerState->SeamlessTravelTo(C->PlayerState);

#

So you always get your CopyProperties call on the PlayerState

#

(also, it's really highly advised to read through some of those classes and learn a bit of c++)

#

cause knowing this is pure gold for UE multiplayer

rose egret
#

can I have BlueprintImplmentable NetMulticast ?

native vector
rose egret
#

no dont give wrong info man

native vector
#

and if u set it on tick it will get worse

rose egret
#

if its not net relevent it wont be casted

#

im using it for some of my events , and its better than Replication in this way

#

its fire and forget event

native vector
fresh cloud
#

yeah, but then remember it's also not uh

#

it only exists for the time that it was fired

#

so if it becomes relevant after it was fired, it won't recreate the multicast

#

thus, on rep variables become invaluable for keeping the state of things consistent

rose egret
#

yea I know, im just using that for some auxiliary events, like player hits a tree and I want the tree to just shake a little on clients

thin stratus
#

Or where does that question come from?

rose egret
#

@thin stratus yea tried it right now, 'error BPimplementable cant be replicated'

thin stratus
#

You can try native

#

But if not, then you'll have to create two events ):

rose egret
#

same error with native, so I have to create seprate func and make my code dirty πŸ™‚

thin stratus
#

:D

rose egret
#

I have to write down all these limitations so that I dont forget it 1 year later

#

πŸ˜„

thin stratus
#

Don't worry

#

I constantly find my own answers to Forum and AnswerHUB questions

rose egret
#

πŸ˜„

cloud stirrup
#

Oh snap not good then I must have messed up before. The hell do I pass info without saving files to disk then….

thin stratus
#

But, even in C++ you have to do that if it's more than the options string can handle

#

You just have better entry points for that in C++

cloud stirrup
#

So you mean to say that I’d have to log in on main menu level then when moving to server level I’d have to re log in… tbh I’m sure that’s what the options string is for atleast where iv seen it mentioned and used it’s like passing an api on connect to client. I get it’s not working though but I do see my options passed to the server. Either way I guess iv not a clue and not doing it the way anyone else would do it. Thanks for the help though. Ok have to go deep to find out how to persist from main menu to server in a reliable way. Without needing steam/epic

hot raven
#

Hey I have a component I'm creating dynamically by class (using AddComponent) then later I'm trying to call a server RPC on it and I get a bunch of errors:

LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: RailgunComponent_C /Game/FirstPerson/Maps/UEDPIE_2_FirstPersonMap.FirstPersonMap:PersistentLevel.PlayerCharacter_C_0.RailgunComponent_C_0 NOT Supported.
LogNet: UNetDriver::TickDispatch: Very long time between ticks. DeltaTime: 50.28, Realtime: 50.31. IpNetDriver_18
LogNetTraffic: Error: ReadContentBlockHeader: Client attempted to create sub-object. Actor: PlayerCharacter_C_1
LogNet: Error: UActorChannel::ReadContentBlockPayload: ReadContentBlockHeader FAILED. Bunch.IsError() == TRUE. Closing connection. RepObj: NULL, Channel: 3
LogNet: Error: UActorChannel::ReceivedBunch: ReadContentBlockPayload FAILED. Bunch.IsError() == TRUE. Closing connection. RepObj: NULL, Channel: 3

Do I need to do something special after dynamically creating this object instance for it to be registered for replication or something? The impression I get is that the FNetGUIDCache::SupportsObject ... NOT Supported warning indicates that the server is not expecting this component to be sending network messages, is that correct?

thin stratus
#

Client Options are passed via the Login methods

#

Where PreLogin and Login give you access to them, and PostLogin does not

#

PostLogin being the only one of the three being exposed to BPs

thin stratus
#

In C++ you usually make sure you only call this on the Server

#

And you have to manually create the object and register it

#

And ensure its stably named

#

AddComponent, if that the BP node that then has the custom Component name in it, is usually only meant for ConstructionScript iirc

jolly delta
#

is client should also be build using sources when server is build ?

lament garnet
#

how do i go about disabling joining to a session without destroying it? there is a getsessionjoinability in agamesession but nothing seems to call it

#

at least thats what my ide says

jolly delta
#

sad :(

dusky yarrow
#

there's the even easier option to give up on online games :)

cloud stirrup
thin stratus
#

Keep in mind that those Login functions only vaguely have something to do with actual "Login"

#

It's not really an authentication thing

#

But yeah, I could imagine that you'd want to send the AccessToken via the Login Option String

#

Honestly, if you plan to do some funky stuff with backend etc. not using C++ is kinda bad

#

Like, BP Multiplayer is just too limited

sly kernel
#

what do I need to do to add coop support to Lyra (preferably without touching C++) ?

cloud stirrup
# thin stratus Keep in mind that those Login functions only vaguely have something to do with a...

so when u say "pre login" you mean just something i did previous to throwing the "open level bp" i see. i thought it was actual bp logic i was to look for even with all other posts using same naming. cheers for the help. im on my way now using a game instance to "store" transient info. like the username set in main menu. then all i will need is a few other things to validate users on joining the server. this will do for my needs. im not making cod.

thin stratus
#

PreLogin is an actual function in the GameMode that does not exist in BPs

cloud stirrup
#

oooooooooooooooh

thin stratus
#

Same as Login and PostLogin

#

Where PostLogin is exposed to BPs

#

And PreLogin as well as Login have the parameter with the Options

#

That's why you would need C++ to use the Options string

#

The Client one that is

cloud stirrup
#

right and just intercept the url and send it out as a hook or do something with it.

#

il look into messing c++ side later i guess. if in i need to.

crisp root
#

I'm having trouble finding reasonable resource requirements for a small VPS to test my dedicated server build. It looks like the Linux dedicated server binary is a few hundred MB, but what about system memory? Could I get by with 2GB to test a few players on my server? Pepega

dark edge
#

2GB can be either way too little or waaaaaaaay too much, depending on what your game does.

crisp root
#

Yeah I was looking at their $12 tier...

#

Thanks for your input.

near granite
#

How can i check if the player controller is 0 index player or not?

#

I want to check if this player is the first join player or not

dark edge
#

Only valid on server of course

#

Everyone is 0 on their own machine

near granite
#

why this is not work well,,,always return true..

dark edge
#

I can't read what language that is but you are probably proceeding before the results of the 0 player search are replicated

elder sable
#

Is it ok to use actor's owner variable to store custom actor ? Or is it engine specific ?

dark edge
#

This occurs instantly.

dark edge
#

owner is important

elder sable
#

Should not be used then ? I have a owner logic and was wondering if i could use that

dark edge
#

Owner can be anything but what are you trying to do here?

elder sable
#

I have an actor that depend of a "owner", so i'm setting it but not sure if it's designed to do that

dark edge
#

Sure you can do that. Owner is used a lot for replication though, just keep that in mind.

#

Keep it in line with the concept of ownership.

elder sable
#

Cool, thanks !

void wyvern
#

how can i replicate the Web-browser and its audio in multiplayer? any ideas?

cloud stirrup
#

i guess here there is no more players left in the world so it cleans up and closes. would it be appropriate on level load putting in a ghost player so its constantly loaded? or is there a bool i can toggle to say never shut down

near granite
#

I don't understand why this is not working well...

I want to detect the player controller is the first player or not!

this code written in the pawn

verbal tendon
#

think of it like this, it's not being executed 2x like you think, but 4x, and twice of that is bad

#

2x assuming 2 players

#

Also delays never solve a problem, they just hide it

magic furnace
cloud stirrup
magic furnace
#

2 for 1, what a win

cloud stirrup
#

its probably a bodge thats going to kill me in about a week but hey ho

#

it works now .

near granite
glossy kettle
#

trust me bro, jane st. told me so

plucky prawn
near granite
plucky prawn
#

That's terrible. Just use locally controlled

near granite
hoary spear
#

Is it ok to pass in actor references to a function that might be rpc'ed ? What would the alternative be?

verbal tendon
hoary spear
#

I may want to destroy that actor (on server side, replicated to clients)

verbal tendon
#

Otherwise as long as the same actor exists on the other side the reference is resolved properly to the local instance. If it doesn't exist it won't resolve

hoary spear
#

depending on if there's more left in the "stack" of it

verbal tendon
#

Then you just destroy it on the server, and if it's properly setup to be replicated it gets destroyed on the clients too

hoary spear
#

Hmm alright, thanks

real ridge
#

Guys how to correctly make HUD? I mean health etc because when I make it on event begin play I am getting errors on server side telling me

[2023.01.01-15.23.02:425][467]LogScript: Warning: Accessed None trying to read property Name
        BPDFCplayer_C /Game/ThirdPerson/Maps/TestMap.TestMap:PersistentLevel.BPDFCplayer_C_2147482485
        Function /Game/ThirdPerson/Blueprints/BPDFCplayer.BPDFCplayer_C:ExecuteUbergraph_BPDFCplayer:0D6C
verbal tendon
#

HUDs dont exist on the server

#

Super simple design:
You have a health variable that replicates with OnRep.
Inside the OnRep you fire a delegate/event: OnHealthChanged.

Your spawned HUD class binds to that event, and when it fires it reads the new health value and changes the display.
Also don't try to spawn UI on the server.

real ridge
#

i got rid of those errors on clients sides by checking is valid

#

but it is not working for dedicated server

dark edge
real ridge
#

on my pawn

#

where to run it

#

beginplay is propably called on server too

weak linden
#

Yes, BeginPlay is executed everywhere

dark edge
#

Show your code

real ridge
real ridge
#

here are showed errors on server created by my widgets

weak linden
#

This is why I typically recommend using the HUD class for managing the creation of your widgets and (where possible) having the widgets themselves handle the relevant logic specific to them instead of the character, controller, or just anywhere/everywhere etc.

I.E a "health bar" widget will get the relevant health value from the owning character (GetOwningPlayerCharacter) etc, etc.

real ridge
grizzled stirrup
#

If a replicated property gets set on a spawned character on the same frame it spawns, how can I guarantee that clients will trigger the OnRep function? Currently it seems like a random chance that it will succeed

#

It's likely a race condition since the OnRep property maybe replicates before the character is fully replicated down itself or something?

#

Is simply delaying the setter of the OnRep property by say 0.5f the solution? (feels a bit incorrect / imprecise to do that)

dark edge
thin stratus
#

@grizzled stirrup I usually do:

void ASomeActor::BeginPlay()
{
  Super::BeginPlay();

  if (SomeCondition)
  {
    OnRep_SomeProperty();
  }
}

void ASomeActor::OnRep_SomeProperty()
{ 
  if (!ActorHasBegunPlay())
  {
    return;
  }
}
#

Cause OnRep can call before BeginPlay

#

And that can cause issues

#

There are functions in UE that silently fail if they are called before BeginPlay

#

Don't ask me why and which

#

I just stuck to this pattern and had no issues

#

Also ensures OnRep is called properly for freshly spawned actors

grizzled stirrup
#

Ah ok thanks! In this case a manager is initializing enemy stats when spawning and the client needs to get these stats to init other stuff so I will likely need to somehow move the manager logic into the enemy itself

#

Great snippet for similar things

#

I've had so many inconsistent OnRep issues likely tied to this problem

thin stratus
#

Yeah it adds a lot of extra code sadly

#

And "SomeCondition" is pretty vague

#

You can ignore that, but in some cases you know if the Variable is actually not default anymore

#

E.g. if you know the boolean is false by default, check if true could be the condition

#

Of if you know a pointer is null by default

#

But just calling it 100% of a time is also fine

dark edge
#

In BP can't you just set the variable and it'll automagically call the onrep since it's not really an onrep?

#

Beginplay -> Set Variable? maybe it needs to change I'm not sure.

thin stratus
#

In BP you have the same problem

dark edge
#

ooh ya true if the modification makes it before you do this you're back to defaults

thin stratus
#

Not sure if BP OnRep is always calling or only on change

#

But yeah I exposed ActorHasBegunPlay to BP for this reason

#

But it's also not like I remember doing this all the time

grizzled stirrup
#

Would an RPC have the same problem btw?

#

(arriving before BeginPlay has been called on client)

#

Say you do

if (AMyCharacter* SpawnedCharacter = SpawnCharacter())
{
  SpawnedCharacter->SomeInitMulticastRPC(SomeStruct);
}
#

In this case it's a one time payload so a reliable RPC in theory would also get the job done but perhaps it also would fail due to the same issue

neon mango
#

If the servers tells an Actor to spawn at location 0,0,0 and then tells the actor to move over time via Add Actor World Offset but movement replication is off.
If there is lag, and client gets the call to spawn the object at some point in the future, where will the object spawn? At (0,0,0) the spawn transform or where the server currently has the object's location?

thin stratus
#

Probably 0,0,0

neon mango
#

Why probably and not exactly?

thin stratus
#

If movement replication is off, then it will never get an additional transform update

grizzled stirrup
thin stratus
#

Actor should have one

grizzled stirrup
#

I guess GetWorld()->HasBegunPlay() works

#

I don't see one for actor

#

A public getter that is

neon mango
#

I'm wondering if I need to create a replicated Vector Location and have client correct the spawned object by moving it on its begin play to where the server should be putting it on intial spawn given that I don't want its movement replicated

#

IDK if this is a bug, intended or an oversight on my part

woven basin
grizzled stirrup
thin stratus
neon mango
#

Oh think I found another bug that may be causing the issue

thin stratus
#

I just know I had issues with this on The Ascent

neon mango
#

Spawning at random lol

#

Server needs to replicate that chance

#

that'll probably cause some discrepancies

#

UE5 dodges this one :p

#

oh wait

#

no

#

If server decides to spawn it, then that gets replicated

#

so that isn't it

grizzled stirrup
#

So when faced with the situation where you need multiple replicated properties to be down before calling a function (say a replicated health component health value as well as an OnRep variable that gets set when a character is spawned), if it can happen a little later than spawn time (only affects cosmetic things on the client), is setting a timer to say 0.5f before calling the function ever a decent way to get around this?

#

I suppose the correct way to do it would be to check in the health component OnRep function if the other variable in the Character has replicated yet and vice versa (calling the function if the check succeeds) but it could get a bit messy if more vars are involved

#

I guess with ping and packet loss there's never any real way to guarantee that all of the vars have replicated yet but a fairly long delay feels like it would catch most cases without spaghettifying the OnRep funcs checking for other replicated property states

#

Another solution would be to make a custom struct (even if it's duplicating data) to hold this initial data that gets replicated once

dark edge
#

Is your stuff failing or just looking goofy for a second?

#

I mean, do your onreps fail in some way without other data or just look dumb, like HP = 200 but MaxHP = 100 etc...

grizzled stirrup
#

Well it was failing before the BeginPlay double check that you and Exi mentioned. Now it works but I realized that I can't guarantee that the HealthComponent health value will replicate down before this property replicates and I need them both at the same time

#

So the hacky 0.5f delay wouldn't change anything visually but just in 99.9% of cases make sure all values are there

dark edge
grizzled stirrup
#

Nah the defaults are fine (even if goofy) it's more that I'd like to initialize the health bar once when the enemy has initialized itself and it requires a few different replicated vars to do so

#

But I suppose I could just do it in a few separate funcs

woven basin
#

You could wrap all the required items into a struct, and replicate that, so you know it all arrives in one.

grizzled stirrup
#

YEah it's likely the best option even if it duplicates data a bit

#

Just nice to have the guarantee

woven basin
#

Then, could you do β€œinitial only” rep, so that the struct comes once with the starting data. Then individual reps after that.

#

I’ve been toying with a β€œstarting payload” struct once idea myself.

#

Once the struct with all data comes, you initial your hud etc and set a bool, then your done.

#

No race conditions. Etc.

neon mango
#

So made a test BP and interestingly enough, the Actor is set to replicate and rep movement, but the spawning isn't happening client side

#

Shouldn't a replicated actor, that is on both client and server be able to spawn other actors for clients if the server version of it is calling the spawns?

grizzled stirrup
#

Depends if the thing it's spawning is replicated

#

A replicated actor spawning non replicated actors on the server won't see anything on the client

neon mango
#

It is a replicated actor, spawning other replicated actors

grizzled stirrup
#

Then yes it will spawn them on client too

neon mango
#

It isn't

#

false it is

#

Something else is occuring

grizzled stirrup
#

An important skill to develop is figuring out why that is

#

Post a log on the client when that actor calls begin play

#

There are some rules regarding owning connections for replicated actors

neon mango
#

It does work I was mistaken

#

I set it up so that it only starts when 3 variables are set on Rep so that I'm sure everything is synced up

#

but I forgot to override those vars when testing

#

It also randomly just stops working

#

not sure why yet

#

stops working as in, stops painting

#

now that I think about it, those on rep should get fired on client

#

IDK why they weren't

#

Does exposing a float to the Spawn Actor not call on Rep?

#

Or is it repped to begin with and then following changes after are replicated?

#

That does not get called

#

From this

#

It would seem

#

I guess it isn't the job of spawn actor to call On Rep for the initial replication

#

Which seems silly? If the goal is for Spawn Actor is to Replicate, then replicate all initial params if they are set to replicate right?

#

It's like I'll have to call an RPC after the spawn to init it and start it

#

rather than use that and begin play

#

I'll give that a shot but seems hacky

neon mango
#

Think I got it pretty decently now

#

Probably need to do some latency testing now... to really see. Gulp

winged badger
#

BP doesnt have a replication callback

#

Its a property changed callback masquerading as replication callback

#

So any time anything chsnges the property, from replication or not

#

OnRep fires in BP

real ridge
#

thanks

lament garnet
#

im trying to send a client to a specific map from the server(like for a kick functionality) but no matter what, the client is sent to the entry map

#

does anybody know where to look?

#

oh well i dont know why i was trying to play with AOnlineSession and AGameSession

#

ill go the easy way

jolly delta
#

anyone that know what can cause this will not work on client side ? this code is in a playerControler

twilit radish
#

Did you specify that player controller to be used in the game mode? πŸ˜„

jolly delta
jolly delta
#

this is my spawn sequence

#

is there anything else to do ?

#

it seems that appear after the server travel

#

update : it appear when we connect to the server

neon mango
#

Did you ever figure this out? I enabled the plugin but it doesn't seem to do anything during PIE.

jolly delta
#

i cant find what i did wrong meh

verbal tendon
# jolly delta i cant find what i did wrong meh

There's a multitude of potential problems: not spawning the actor on the server, input bindings not being setup properly, wrong input mode. You don't provide by far enough context for fruitful help

#

Wrong gamemode, even if the one you have it setup properly, etc... like the list goes on and on.

#

You're going to need to do a little more work on your end and provide better context, debug more. When does it work for you, when doesn't it work? List the differences, share more context

neon mango
#

@jolly delta Have you looked at example projects to see how they spawn players. The ColabViewer template project has lots of networking code and exmpales. Lyra also probably good to look into. I also should probably take my own advice and look at Lyra.

jolly delta
#

but i am not sure if its a good behaviour to do that ?

neon mango
#

Depends

#

are you switching input modes a lot? Maybe going from UI back to game?

#

Then that would be something you have to manage

neon mango
#

Hide the mouse, show the mouse, ex. going to pause menu or not

#

If your game is a top down game where you use the mouse to click but also want to control the player maybe they set the Input mode outside of game by default?

#

Does that break mouse controls for you? More context helps as I have no idea what kind of game you are trying to make

#

or what your goals are

#

There is also a Set Input mode to game and UI as well

jolly delta
#

by adding that is seems that most of my control are work as intend, sometime there is a skip on the mouseclick but not everytime

neon mango
#

There is also a GetPlayerController->Enable Input node

#

And a Disable Input

#

which would let you enable or disable input for certain actors

#

So a few things that can effect input based on where and when you want there to be input or not

jolly delta
neon mango
#

Enable Input to enable input on the actor which will have Input Events

#

Node says "pushes this actor on to the stack of input being handled by a player controller"

#

But this is more #blueprint related than MP related

jolly delta
#

can't i set on the controller after possesing event ?

neon mango
#

The target should be whatever has the Input Events

neon mango
jolly delta
#

is it only when i connect to the server

fathom aspen
#

The solution you figured should be good. I figured that a while ago and it seemed to be an engine bug iirc

verbal tendon
#

generally speaking one place should manage input modes

#

You tell that manager when you want UI input enabled, it keeps track of a counter or some other way, so when all your UI-needing input is gone it switches back to game input

#

And then you just set it by default to be game ingame

#

@jolly delta I'm gonna grab some sleep now but that's somehting you want to eventually look into

#

especially as you add multiple UI-based features to the game

dry pebble
obsidian basin
#

Hey all, got SImpleMoveToActor working in multiplayer (Listen server). However, if I run it - let's say I'm moving Player A. On Player A's machine, their character doesn't animate - just slides to position. However, Player B sees Player A's character animate. This is using the stock TPS character

obsidian basin
#

Also, RepNotify is NOT run on server, right? That's run on the clients after the RPC is finished on teh server?

#

So if I want RepNotify to trigger another RPC, I need to call another one?

twin juniper
#

Variable replication is good for keeping states about your actor. Since a player joining wont receive RPCs sent before they are in the game.

#

I had a question about if its normal to write RPCs with this pattern or is it better to just use a single event. The whole naming thing seems odd to me ya know. Ive seen some programmers prefer this pattern, but I dont understand why.

agile loom
sacred kraken
#

I'm trying to set up input with enhanced input but I am not sure I understand. Where should I call AddMappingContext? And where should I set up the bindings?

#

!HasAuthority?

agile loom
sacred kraken
agile loom
gentle pagoda
#

Which events are triggered during and after seamless travel?
Onswapplayercontrollers are not triggering at my end. Please help.

lament garnet
lament garnet
gentle pagoda
lament garnet
gentle pagoda
#

Is there anything which I can use in BP's.

#

?

lament garnet
#

probably not, multiplayer is not really bp friendly unfortunatelly

thin stratus
#

Cause otherwise the original PC is kept and there is no need to move data over

#

If at all resetting data would be needed

woeful ferry
#

To save actor references I use TSoftObjectPtr and load each and every actor with the same name, so they can get resolved when loading is completed.

But if I want a replicated actor reference, I need it to be a pointer and that can't be saved by SaveGame. So do I save it as a soft object ptr on the server and just resolve it and assign the pointer to the replicated variable on load?

glass anvil
#

How can I set and get stuff from server Game Instance?

sacred kraken
lament garnet
glass anvil
#

@lament garnet Game state will keep date on level change?

lament garnet
#

nope

#

either use seamless travel and implement playerstate::copyproperties

#

or save data to disk before travel

#

then restore

#

what are you trying to do?

sacred kraken
#

Before reading that I just made sure the game instance on the server had the relevant data, and when loading a level and having authority I'd fetch whatever is in there that I need so it replicates to the clients.

glass anvil
#

@lament garnet I have some variables that I use in multiple blueprints that I want to store somewhere else because Game instance is not working on the server and also I have some data that I want to store so I can use it after level change

sacred kraken
#

So the clients would of course have their own game instance, but they wouldn't use it. Only the server would.

glass anvil
#

@sacred kraken How can I tell the server to use it instead of client

sacred kraken
#

@glass anvil HasAuthority(), or when using blueprints using the authority switch.

#

But I would just read the article I sent, it's a bit lengthy but it helps a lot.

glass anvil
#

@sacred kraken So when I cast to GI to set something or get something I will ask for has authority?
I will take a look on the article

sacred kraken
sacred kraken
glass anvil
#

@sacred kraken Okay thanks a lot for the material

sacred kraken
#

Only saying that because I didn't know that until 2 days ago myself

agile loom
lament garnet
agile loom
lament garnet
#

i really have no idea when its the right time to bind inputs.. ive just assumed its when the client acknowledged possession so i went that way

#

so receivestart is better then

sacred kraken
#

I am doing it in BeginPlay

#

I had it in SetupPlayerInputComponent first

#

But now I do the context adding in BeginPlay and the binding of actions in SetupPlayerInputComponent

#

Is that wrong?

#

Event called after a pawn has been restarted, usually by a possession change.
Oh I see. So it works for me because I use PlayerStart and you don't switch pawns

lament garnet
#

i dont think its wrong

#

probably depend on how you setup the game

#

not sure

sacred kraken
#

It depends ℒ️

agile loom
lament garnet
#

thats right, good to know

agile loom
lament garnet
#

yeah the method name was the key for me here πŸ˜†

near granite
#

If Pawn replicate option is checked, The input key also can be replicated to pawn1 of client 2?

agile loom
agile loom
near granite
agile loom
near granite
agile loom
sacred kraken
lament garnet
drowsy meteor
#

Hi guys a simple question, when creating a function that runs on a server or with the properties UFUNCTION(Server, Reliable, WithValidate) , if the function have some parametres , do i put them in the implementation and validate functions too ?

agile loom
agile loom
agile loom
dusky perch
#

Hi, does anyone suddenly have weird replication issues since upgrading from 5.0 to 5.1?

#

Some things just started weirdly not working, and I cannot quite figure out why.

agile loom
dusky perch
#

Hey, did you figure this out?

sacred kraken
lament garnet
#

its a virtual method, you can override it

#

or there is probably a delegate, something like onreceivedrestart

sacred kraken
#

There is a delegate. It's not available for override it seems, so I'll look into how to use delegates. Thanks πŸ™‚

lament garnet
#

ive just assumed sorry, didnt check

#

its a bp delegate so adduniquedynamic

agile loom
sacred kraken
#

ReceiveRestartedDelegate.AddDynamic(this, &APlayerPawn::OnRestarted); I found out I can follow the delegate to see what the signature should look like

#

(Which is void APlayerPawn::OnRestarted(APawn* Pawn))

#

No clue why it receives a pawn though. Is that because it can be bound to from non-pawns?

agile loom
sacred kraken
#

Where do you find that?

#

I ctrl+click but rider gives me cryptic shit

agile loom
lament garnet
#

go to declaration until you end up in engine.h

sacred kraken
#

That's what I do, I think

#

Ctrl+click does that but I end up in the cpp

#

Ah, f10

#

To switch to header file, sorry. I am not stupid, just tired, I swear

#

By default this is called on the server for all pawns and the owning client for player pawns.
Wouldn't I still need to check if I'm the owning client?

#

Because the server doesn't need the mapping, does it?

#

Oh, that's what the IsLocallyControlled is for

#

See, I'll get there. Eventually.

agile loom
sacred kraken
#

So just to triple check:

void APlayerPawn::NotifyRestarted()
{
    PlayerController = Cast<ARockPaperPushPlayerController>(GetController());

    if (!PlayerController->IsLocalController()) return;

    check(InputMapping);

    UEnhancedInputLocalPlayerSubsystem* InputSystem = PlayerController->GetLocalPlayer()->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();

    InputSystem->ClearAllMappings();
    InputSystem->AddMappingContext(InputMapping, 0);
}
#

Oh, I didn't know there was a IsLocallyControlled, that seems much better

#

Isn't NotifyRestarted the right place then?

agile loom
sacred kraken
#

Ah, yes! I stripped that out to not show too much useless cod

agile loom
faint eagle
#

is it possible to replicate actor with custom serialization? i remember you could make custom serialization for simple data types but I can't remember if you can actually do something like FArchive& Arr << MyActor

sacred kraken
chrome bay
agile loom
fossil merlin
faint eagle
chrome bay
#

No, for that you need the package map

#

Then you do Map->SerializeObject

#

But FNetBitWriter should already handle that

#

So as long as you are inside a NetSerialize function, you should be able to do Ar << ObjectRef; just fine

#

It has a horrific operator overload that will do it

#

See FHitResult for an example

faint eagle
#

thx

dusky perch
sacred kraken
#

So I guess I could put all my mapping/binding logic in there

#

Huh, even better

#

It doesn't seem to be called on the server at all

#

So I don't really need the local player check.

Update: Double checked with a standalone server and nope, SetupPlayerInputComponent doesn't even get called. That's super good to know

#

What's the difference between bReplicates vs SetReplicates? As far as I know both work, but SetReplicates seems to be doing a lot more.

#

In fact:

UE_LOG(LogActor, Warning, TEXT("SetReplicates called on non-initialized actor %s. Directly setting bReplicates is the correct procedure for pre-init actors."), *GetName());
#

Weird that I can't do the same with replicating movement

chrome bay
#

In the constructor you should call bReplicates = true

#

It's a fix for actors which have not been fully initialized or even constructed being added to the replication system with the wrong properties.

#

For some reason, Epic "fixed" it by logging an obscure error rather than throwing an asset and/or preventing it from being possible at all

sacred kraken
#

Oh, no I'm not running into this issue. I am just curious why it's inconsistent. I can use a property to enable replication, but need to call a method for the movement replication

chrome bay
#

It's inconsistent because their "fix" is terrible πŸ˜„

#

At runtime you would call SetReplicates

sacred kraken
#

What should be the way to do it then?

chrome bay
#

But in constructor etc. you would need to set bReplicates directly

sacred kraken
#

BeginPlay instead?

quasi tide
chrome bay
#

Yeah it's really really not good

quasi tide
#

Epic - "Let's have 2 different ways to do this"

chrome bay
#

And goes against the entire convention used by the rest of the engine

#

Just UE things

sacred kraken
#

I've only ever seen the boolean way of doing things in all courses and tutorials I've followed lol

#

I still don't know what the "proper" place to put it is

chrome bay
#

Constructor:
bReplicates = true;

Anywhere Else:
SetReplicates(true);

quasi tide
#

Also - welcome back from vacation James πŸ‘‹

chrome bay
#

Has it been quiet here πŸ˜„

sacred kraken
#

But you made it sound like the constructor is a bad place to put it, or did I misunderstand?

quasi tide
#

Not really. Just noticed you were gone for awhile. Could only assume vacation, lol.

chrome bay
sacred kraken
#

Aaaah

chrome bay
#

Setting the bool is fine

sacred kraken
#

Phew, okay πŸ˜„

quasi tide
#

Cedric did a nice explanation of some CMC stuff a few days ago.

chrome bay
#

I just wish they'd fixed it in a way that made any sense

sacred kraken
#

I wouldn't find it weird if I could set the movement replication field in the constructor, too.

#

Then it'd feel consistent for me, a pleb

chrome bay
#

Yeah that's really the issue, both should be behind Set## functions and the engine should handle the case with uninitialized actors a better way

#

Or do what Actor Components do, and have a SetIsReplicatedByDefault function for init time, and SetReplicates for runtime

#

UE is anything but consistent at times πŸ˜„

sacred kraken
#

Another question I have is about binding inputs. I just moved the callback for a Move action to be UFUNCTION(Server, Reliable). It's being called in the _Implementation, but the input is empty. Am I supposed to proxy that input myself? So have a handler that calls another server method with the inputs it actually needs? This would make sense to me, but I want to make sure I understand

chrome bay
#

Without seeing code I couldn't say, but yeah typically if you have to send input to the server - you "accumulate" all input into a struct, and send that to the server in one place at the appropriate time

#

Generally you want to avoid calling RPC's directly from input functions, because they will fire at the tickrate of the client, which might be way too high

#

You usually limit/fix it to something more sensible

#

And also usually send it unreliably

#

CMC does exactly this, batching moves together up to a maximum delta time to reduce the amount of info being sent, but at the cost of slightly more latency

sacred kraken
#

I don't know what cmc is

chrome bay
#

But also to ensure that clients running at 500 FPS don't hammer the server

#

Character Movement Component

sacred kraken
#

Ah

chrome bay
#

Basically the only fully featured network movement in the engine

sacred kraken
#

Got it. And makes sense, I'll make something to batch.

#

I didn't think of that

quasi tide
#

January is the month of the InstancedStruct blog post from Jambax. I can feel it in my bones 😈

sacred kraken
#

Oh, is that the replicates time you can set when using blueprints?

chrome bay
#

oooof we'll see πŸ˜„

sacred kraken
#

Or does that happen automatically when unreliable

chrome bay
#

an no, rep frequency is unrelated to server RPC's

#

All RPC's with exception of unreliable multicasts IIRC will send at whatever rate you call them

#

rep frequency is just for server comparing properties

sacred kraken
#

Oh right, silly (me).

#

I find thinking in multiplayer challenging.

quasi tide
#

Once you get the hang of it, you'll be like, "Ohhh - it totally makes sense". But then you want to get better and you want to learn how to do the more advanced stuff and you curse the Gods on why anyone would ever want networking in their game.

sacred kraken
#

πŸ˜„

#

Well I wanted to make a single player game, but my wife requested me to build something we can play together

#

So now I have to

quasi tide
#

Yup - checks out.

sacred kraken
#

AActor::SetReplicatingMovement just marks the transform fields as replicated then?

#

And any actual changes to the location I should only perform when HasAuthority()

chrome bay
#

Generally speaking yeah

sacred kraken
#

Is Client in UFUNCTION the same as owning client?

#

Since having nothing there should mean client

twin juniper
#

Hi, i need a few infos about reliable/unreliable RPC (actually i have all of them as Reliable and yeah that's not a good way ikr that's why im here), does Unreliable RPC can be dropped and like never be called ? Actually a lot of my RPC are called after client predicting smth (so i want it's RPC to be reliable since i can't predict if it has been dropped)

#

So yeah idk about that

#

Typical example, ActivateSlot predicts the client stuff and then call the server rpc that will do kinda the same stuff but for the server

#

I don't know if this should be Unreliable or Reliable, client did it's stuff, server stuff should also happen, if this rpc is dropped client will just be not synced to server slot

chrome bay
#

Probably reliable

#

unreliable is when you can afford the RPC to be dropped and/or can recover from that

#

Or it doesn't matter ,etc.

quasi tide
#

Unreliable = play on fire vfx
Reliable = pick up key item

twin juniper
sweet spear
#

so what are people using now that steam sessions isn't updated to 5.1?

gloomy tiger
#

Hey there!

I have these AIs in a multiplayer, co-op game. I'm talking about 30-50 AIs simultaneously.

I'm thinking to, instead of destroying the AI when it dies and SpawnActorFromClass when it respawns, make it "despawn" instead; which means, disabling collisions, visibility, etc, and when it's time to respawn it, just make it pristine again as if nothing has happened.

All of this through C++.

Question: does anyone have evidence this approach is smoother (network and cpu-wise) than DestroyActor/SpawnActorFromClass?

bronze mauve
#

Has anyone gotten this breakpoint when starting their project in DebugMode?

quasi tide
gloomy tiger
#

Well, yes. However I wasn't so sure when it comes to multiplayer, and my rationale is b/c some attributes of my AIs are replicated, such as movement speed. Making the AI pristine means resetting this movement speed attribute, which replicates. So I was wondering if it wouldn't end up being the same as SpawnActorFromClass.

#

I mean, I'm pretty confident it wouldn't be exactly the same as SpawnActorFromClass b/c there are more involved than some replicated attributes, but nonetheless I'm just trying to validate whether this would give me, to say the least, an expressive performance impact.

bronze mauve
#

This is the callstack:

near granite
#

Why is my level instance not loading at the location I specify??🀨

quasi tide
#

Don't crosspost, #rules - 7 specifically

twin juniper
twin juniper
#

ActivateSlot is called from input press, so on the client, client runs the activation logic on its own (to predict ui as you don’t want to wait server for that) and then it call the server one ther will do the same but for slot changes logic (unequipping current item and equipping new item)

#

And as the client one is called in an input, the rpc is called in the tick at a certain frequency so player don’t spam rpc by spamming input

#

Input -> Activate slot on client (ui + applying PendingActivationSlot for tick) -> tick detects that there is a pending slot, checking for last time it has been activated, if good call rpc

sacred kraken
#

When a owning client/autonomous proxy pawn calls a Server RPC that changes the location, and both replication and movement replication are turned on... Does the server not replicate movement back to the client that called the rpc?

verbal tendon
#

However much better that it's worth it for you, you need to profile

sweet spear
verbal tendon
#

As with every performance decision - first identify that you have a performance problem, then profile if your solution is comparably better given the change you are making

sweet spear
#

I may implement EOS too

verbal tendon
#

You absolutely can use Steam sessions, but I don't see the rationale when a free solution is available on all platforms

sweet spear
sacred kraken
#

EOS lets you work on all platforms
Is this true? I thought oculus didn't allow it

verbal tendon
#

It also works better than steam sessions for debugging when you are working alone, because you don't need multiple pc/router setups that you do when using steam sessions

sweet spear
#

but I'll check it out later

#

just using what I'm familiar with at the moment, I don't have the time to learn a new system

verbal tendon
#

Sure thing

quasi tide
quasi tide
sweet spear
quasi tide
sweet spear
#

it's a shitty little 3 day old project to test how fun it is

sacred kraken
#

I'm sorry, I know I am not part of this conversation but I thought that you'd pretty much have to use all of them (EOS, steamworks etc) depending on where you publish, if you want your players to have a nice experience.

Is this not the case?

#

I remember reading oculus doesn't even allow your game if it includes steam (trying to find where I read that now)

sweet spear
sacred kraken
#

Hmm okay

sacred kraken
#

What's up with AActor::GetLifetimeReplicatedProps(), my IDE doesn't seem to think it exists. When I try to find it all I can see is:

GENERATE_MEMBER_FUNCTION_CHECK(GetLifetimeReplicatedProps, void, const, TArray<FLifetimeProperty>&)

#

This sounds like it's not a thing to override (like BeginPlay or SetupPlayerInputComponent) but a member function to define which will then magically get picked up

latent heart
#

You need to implement that function on any actor that has replication.

sacred kraken
#

I found that part, I'm just confused why it doesn't seem to exist

latent heart
#

Have you checked what that macro does?

sacred kraken
#

I'm trying to, but I'm not sure if I know how yet.

#

Same as trying to figure out what this does:

#define DOREPLIFETIME(c,v) DOREPLIFETIME_WITH_PARAMS(c,v,FDoRepLifetimeParams())
latent heart
#

right click -> go to definition, or just search for it.

sacred kraken
#

That's the second time today someone said that :p

#

I am doing that

#

The problem is this:

#

aka, I'm not good enough at c++ to figure out what this is doing yet

latent heart
#

That's just a check to see if the function exists. It doens't do anything else.

sacred kraken
#

Maybe it's just rider being goofy then

thin stratus
#

If you have a variable marked as Replicated or similar, it will declare the function in the generated header I guess.

#

For the DOREPLIFETIME macro you need to include UnrealNetwork in your cpp

sacred kraken
sacred kraken
thin stratus
#

You only need to implement it

#

And call super fwiw

#

But not declare it

sacred kraken
#

Found it

thin stratus
#

Unless you don't have a variable marked as replicated

#

And yes, the first is the Class, teh second the property

sacred kraken
#

Sorry, I mean I found the header, but it doesn't have GetLifetimeReplicatedProps in it

thin stratus
#

And you have a variable with UPROPERTY(Replicated) in your header?

sacred kraken
#

Yes, but I was being a bit of a ding dong

#

I needed to build

thin stratus
#

Well just add the implementation, UnrealNetwork and the DOREPLIFETIME and it should compile

sacred kraken
#

It does, yeah

#

I couldn't find GetLifetimeReplicatedProps in the generated header because I had to do a build first. Bit chicken and egg

#

Completely unrelated, DrawDebugString is dope. I've been making widgets to print values for 18 months.

thin stratus
#

PrintString isn't enough?

sacred kraken
#

Not with 30 objects I think

#

Unless it does also follow the objects

#

Then I now learned even more today

thin stratus
#

No it's Log and Top Left Screen

sacred kraken
#

Ah like blueprints

thin stratus
#

If you need it to be on the screen, then yeah

#

But it's still only debug after all

#

Not meant for anything else of course

sacred kraken
#

Yeah.

#

It's useful for stuff like this

#

Printing stuff about the objects, especially when doing multiplayer. Or when you have a lot of AI and need a quick way to see their mode

thin stratus
#

Yus

sacred kraken
#

So I made something to throttle RPCs from my action binding because earlier someone mentioned that I might clog up networking otherwise. But now I have a question:

Is there something built-in I can use to throttle RPC invokations?

#

It seems like the sort of thing that can be made generic

verbal tendon
#

Before you make assumptions about performance you need to verify, how are you determining that your RPCs are a performance issue?

#

Generally speaking RPCs should be used sparingly, and never to a point where they would be a performance issue

#

If you are using RPCs to the point where you are, that's a design flaw in your implementation, not a problem with the RPCs

#

very broadly speaking

#

For example if you are updating your actors position OnTick through an RPC ... the problem is what you are doing, not what you are using to do it (RPCs). Whilst what you are using is also a problem, the real solution is to dig deeper. I hope that makes sense.

real ridge
#

What is best practise when I want add for example replicated Base for planes letΒ΄s say and they will have own health when it will be destroyed it will dissappear for start I just want use 2 big cubes one red one blue, should I use actor or pawn?

#

for this purpose

#

thanks for tips

quasi tide
#

I'm pretty sure that's how the engine does it internally as well. Haven't ever confirmed that though.

jolly delta
#

hey, i need to set a camera to on the top of the right player on client side, but it seems that there is probleme with i. To do that i send an event on client after a onposses (on server)

verbal tendon
hollow eagle
#

I wouldn't jump to unreliable multicasts being performance heavy (they aren't), but yeah it's wasted effort when you only care about the latest value of something.
That said, if the choice is between unreliable multicasts and normal non-push-model replication then it might be a tossup if there's lots of these actors in the world. Though the solution to that is to use push model.

verbal tendon
#

Among other things, there's a vast amount of optimizations that have been built into the replication system for variables that isn't available to RPCs.
It's mostly about patterns in programming. If you get used to just doing everything through RPCs, that's what you end up doing because you know it works.

Rather than using a specific pattern or tool to solve a specific problem

verbal tendon
#

And even better if you don't network the things you don't need to network 🧠

verbal tendon
real ridge
#

when it will be destroyed team who lost base will lose match

proud gust
#

Hello πŸ™‚
What's the best way to connect to a Dedicated Server without using Online-subsystem steam, epic???

at the moment i use the Console command "Open" and it works fine, but idk if this is the correct way.

Thank You πŸ™‚

real ridge
#

πŸ˜„

#

if u are not using sessions

#

I just dont know how I can set this base is for team red and this is for team blue and then when one of them will be destroyed how to know or say which team lost

#

tips?

verbal tendon
verbal tendon
real ridge
jolly delta
#

i do not need to open other port thqn the server port right ?

proud gust
#

@verbal tendon Is it bad to make a direct connection? Would a connection over EOS really be better? What's the difference?

verbal tendon
jolly delta
#

is anyone has an idea how to fix that ? Warning: ServerMove: TimeStamp expired: 134.055450, CurrentTimeStamp: 135.090897, Character: BP_TopDownCharacter_C_2

chrome quest
#

Are chaos vehicles stable in multiplayer? Or do I have to make them kinematic ? (if they rely on physics, haven't checked)

slender forum
#

Hello, any idea why the servertravel command doesnt work in packaged game? It says command not recognized in console. Even lan connection seems to not working, even when its working in standalone :/

native vector
#

i have question about dedicated servers so i know i can connect to dedicated servers using "ExecuteCommand |open [ip]|" but what if it fails to find it ? there is a way to handle it ?

lucid viper
#

Hello!

I bought the following asset: https://www.unrealengine.com/marketplace/en-US/product/pro-hud-pack-v2-navigation-tools
The way this works, is that it takes an actor to set the waypoint marker on your screen, so in my C++ I spawn a temporary actor at the end of my LineTraceSingleByChannel
I only allow one to spawn at a time, so far everything works locally.

I'm trying to figure out a way where I can share my ping markers with other players.
Trying to wrap my head around how I should approach this, I was thinking to create temporary actors for as many players in a team ( 6 for example ).
Not sure yet how I would assign markers for each players in a team yet ...
I would then replicate all those temporary actors to all clients somehow and then force a sync to the hud to display updated markers.
Does this sound about right?

Unreal Engine

A collection of extremely flexible and customizable easy-to-use HUD features from ProHUDV2.

elder sable
#

Hi, if i have an actor that's is owned not controlled by a player, what's the way to check from this actor if it belongs to the local player ?

native vector
elder sable
#

I'm using the playerstate as owner

#

But i think i will just get the player controller from it yep

native vector
#

and also probably u will need use "is local"

elder sable
native vector
#

player controller

elder sable
#

Mhh why ?

native vector
#

try it πŸ™‚

elder sable
#

The actor already has a owner

#

So server side, the clients PC will not be a problem

native vector
#

trail end error is a 20% of programming lul

elder sable
fathom aspen
#

No, just checking it's not null

elder sable
#

Mhh, that's not enough to know if that's the owner πŸ€”

#

Anw it's working comparing with the local PC

fathom aspen
#

It is. It is basically what the engine does to detect if the actor can fire a server/client RPC

elder sable
#

Maybe it's because i don't have set up NetRole yet

fathom aspen
#

Nah, has nothing to do with Roles. But I would have debugged the function and saw what is really happening

#

But if the other method works for you then it works

elder sable
#

Internally it depends on the Owner

#

Maybe it works when using PC as a owner

fathom aspen
#

Doesn't have to be a direct owner

#

But has to be at some point

#

Otherwise the actor isn't owned by the client

elder sable
#

I just don't understand how it could work, since the connection will be valid on the server

#

(In a listen-server context)

#

So you have to check the listen-server PC

#
return GetNetConnection() == GetWorld()->GetFirstPlayerController()->GetNetConnection();

This work

fathom aspen
#

I'm not sure I follow, and the syntax is weird, you don't do that

#

Literally

Connection = Actor->GetNetConnection();
if (Connection)
#

This way you only get true on the autonomous proxy

#

No matter where you call it, it will tell you if the actor is owned by the client

#

If client-side then the current client

#

If server-side then w/e client

elder sable
fathom aspen
#

I'm not implying you have to use any Roles, as they are set for you most of the time (you almost never explicitly set them)

#

What I'm implying though, is if you look at the the one line implementation of that function you should realize that it works

#

You just didn't debug it enough to realize what's going wrong

#

Because of the language barrier I could be understanding you wrong too

elder sable
#

Maybe :p

bronze mauve
#

What's causing this?

graceful flame
#

Inside of GameModeBase I noticed that Event Handle Starting New Player, happens before Event Begin Play. This is problematic for me because I'm setting up references inside of Event Begin Play that the starting new player needs to know about. What should I do?

fathom aspen
#

Event BeginPlay of?

#

GameMode?

elder sable
graceful flame
#

yea

#

The player joins and is assigned to a team using their Player State, but that reference hasn't been setup yet because Event BeginPlay (where I'm setting it up) happens after.

elder sable
#

Why you don't do your logic before beginplay ?

graceful flame
#

I mean GameState reference not player state reference

bronze mauve
elder sable
#

Dunno, but a IsUnique ensure is triggered :p

fathom aspen
#

Also called before BeginPlay is called on GameMode

graceful flame
#

omg know what hahah this blueprint code was like one of the first ones I ever made and is riddled with beginner errors

#

I figured out what was wrong

graceful flame
#

I just casted to the game state because the reference is going to be setup in the next few frames anyways.

hollow eagle
#

You shouldn't replicate it because only the client that a controller represents should have it replicated. An AI controller doesn't have an associated client, so it shouldn't be replicated.

dark edge
#

Why are you trying to replicate an AIController?

elder sable
#
SetRemoteRoleForBackwardsCompat

It's backward for what ? Was it added since Iris ?

hushed rain
#

Is it best to use arrays for something like a possessable/respawnable flying drone like rainbow 6 style? I have an issue where the host possesses the clients drone if the client's drone is destroyed and respawned. I've tried just setting a reference to the drone but the host steals it if the variable gets updated by a client(it gets set on drone spawn).

dark edge
latent heart
#

Sounds like you're spawning stuff on the client.

#

And potentially running server-oriented code on the client

hushed rain
#

I'm spawning on the server and setting every reference on the server, maybe that's why?

hushed rain
#

this is in the soldier character

#

i can repossess my soldiers fine from the drone with no problem

#

if i spawn a drone on client>server>client, the server takes the 2nd clients drone if the server spawned one already

dark edge
#

Why use a bool and not just a DroneActor reference an IsValid checks

hushed rain
#

Yea i tried using isvalid (controlleddrone) but it didnt seem to work

dark edge
#

That's not your problem but it's definetly more elegant

#

not ControlledDrone, MyDrone

hushed rain
#

controlleddrone is basically mydrone

#

just bad naming i guess lol

dark edge
#

You want spawning and possession to be separate right?

hushed rain
#

yeah basically it should spawn 1 and then be able to possess and repossess

dark edge
#

In Character:
SpawnDroneButton -> ServerSpawnDrone
ServerSpawnDrone -> Spawn the drone -> set MyDrone -> set MyDrone.MyCharacter

N -> ServerTryPossessDrone
ServerTryPossessDrone -> if Mydrone is valid -> possess MyDrone

In Drone:
LeaveDroneButton -> ServerTryPossessMyOldBody
ServerTryPossessMyOldBody -> if MyCharacter is valid -> possess MyCharacter

#

Although I'd rather keep the refs in the PlayerController but that's whatever

hushed rain
#

i wonder if set MyDrone.MyCharacter is where im going wrong

dark edge
#

You shouldn't have to set any owners

#

possession sets ownership

hushed rain
#

even if its unpossessed?

#

i had to set ownership for UI stuff because im doing some weird workaround for the scoreboard while possessing a drone

#

its like they all share the "mydrone" variable

hushed rain
north forge
#

Is an actor that's spawned clientside considered to have authority if you're checking from clientside code?

#

I've got a custom anim notify happening from a clientside spawned actor. The Notify function is returning true though when I check HasAuthority on the mesh component that owns it. Doesn't make sense to me that a fully client spawned actor would run anim Notify events server side.

hollow eagle
#

has authority != is the server
Authority means you have authoritative ownership over the actor - you have the last say in everything about it. An actor spawned on a client will be authoritative for that client because it literally doesn't exist anywhere else.

north forge
glossy kettle
#

is custom transport the only way to get good perf out of ue net driver?

high ibex
#

hello, this same issue i am facing .. any solution you got for this ?

elfin atlas
#

sequence bReplicatePlayback server to client success
but client to server not work
Any Idea?

verbal tendon
#

are you logging in using the EOS_DevAuth exe with two different accounts?

#

And does it only not work with dedicated servers or also doesn't work with two packaged games that are clients?

graceful flame
elfin atlas
# graceful flame Use RPC when a client needs to change something on the server.

UDefaultLevelSequenceInstanceData is used to bind game characters and sequence character positions.
The sequence just moves the character and keeps state the position.
keep state works fine on the server, but not on the client.
I want the position to be copied on the client as well, but the position within the sequence is not copied.

graceful flame
#

Have you developed for multiplayer with other areas of your game? Or with other games?

#

If not I recommend having a look at the pinned messages on this channel.

sacred kraken
#

Is it fine to set a replicated field's value on the clients? I know it won't just replicate up, but my thinking is that the server will correct it if it turns out it was wrong. This way I can optimistically render changes so it feels snappier. On a scale from 1 to 5, how wrong am I?

graceful flame
#

I do that too. Your thinking is correct, it does get corrected by the server IF the server disagrees. But if you set the variable client side and also change it to the same value on the server it won’t have anything to disagree about. The trick now is to be careful when you use that because if it’s something like health or stamina you have to see what happens if a cheater were to try and change that value client side every frame. 1 not wrong.

sacred kraken
#

Yeah but, go ahead and change health client side, it will keep getting corrected anyway won't it? This is stuff like stepping on your own grenade

#

Other damage is sent to you from the server I suppose

#

If the server says you died it doesn't matter that you pretend to have full health I guess πŸ˜„

graceful flame
#

Yea apply damage is server side by default and seeing your own cheater health on the hud as full is not doing any harm.

#

But for something like stamina check before a dash can occur is kind of tricky because the check to see if you can dash should happen server side to prevent cheating but that introduces input delay.

#

So I check stamina client side, do the dash if they can then check server side if they have enough energy to dash and also dash on the server. But now if a cheater tries to always have full stamina it creates a problem so I ended up counting a delay between dashes and teleporting back to last update location and setting velocity to 0 if they are dashing at an impossible rate.

high ibex
#

it's the same thing i am facing which @real ridge faced ..

real ridge
#

because I had to set udp TCP port forward to 7777 sometimes 7778 too

#

then I had to get from my provider public ip

high ibex
#

join is success but connection getting timed out and re-directing to base map .. i tried with switching off firewalls but same problem

real ridge
#

okay are Ur up public?

#

first step

#

if no u will get timeout

#

u need ask provider to give u public ip

#

i had to also

high ibex
real ridge
#

if u are on same machine u Can test only via open local ip

high ibex
#

like in aws

real ridge
#

U need public ip anyway for network where is dedicated server running let's say at your home u have laptop and desktop u will run server on desktop and Ur network need public ip, i have no experiences with running this server on Aws so i cant tell you we test only on our networks πŸ˜„

high ibex
#

oh , thanks for clarification and do both builds ( dedicated server, client ) require different defaultengine config files ?

#

artifacts i have setup and i properly edit corresponding artifact between server and client before taking build ..

real ridge
#

no same but u need different Eos settings i mean those codes from Dev portal πŸ˜„ I don't have screenshot here but it is called artifacts

#

when u are packaging client use client artifact as default

#

when server use server artifacts as default

high ibex
real ridge
#

I personally have 2 artifacts just changing name of default on the top

high ibex
real ridge
#

hmm maybe if u will wait 5min I can make screen how my settings are if u want

high ibex
#

one thing is cleared, to use same config files for both server and client

real ridge
real ridge
high ibex
#

ok got it .. thanks

real ridge
#

starts with this are hard I had many problems for example now I cannot join on server on Windows 11 even ports are set properly and everything