#multiplayer

1 messages ยท Page 661 of 1

fading birch
#

I would just use a save file

coarse flame
#

Aight, but will that be able to handle alot of olayers and to be able to store world data saving/loading?

fading birch
coarse flame
#

Also wondering bout configs

fading birch
#

that link covers exactly what you're asking

coarse flame
#

Nice thx

#

This saves on server yes?

sinful tree
#

It depends on whether you're running the save/load nodes on the server or on the client.

coarse flame
#

But how do i run then on the server?

#

Bp or c++?

fading birch
#

you'll need to use C++ for that

#

and I would run all the saves on the server

#

and store it there.

coarse flame
#

Alright cheers

unborn trellis
#

Is there a way I can improve this? Essentially I want to have it so If the Red team reaches the score (for testing purposes, set to 2) it displays the text "Red Team Wins", however, if the blue team reaches the score, it displays "Blue Team Wins". But i don't want to have it set up this way as both teams can hit the score limit at the same time and "both win"

rapid bronze
#

You could use bool bGameWon at the start and only exec the code if it's false

Basically when someone wins it sets it to true

unborn trellis
#

I also want to have it so when one team wins, a widget displays saying "team Wins!"

#

i've added a couple more nodes to create this

#

however the problem is, the widget only displays on the server and not both server and client.

unborn trellis
# unborn trellis

I kinda know why it's doing this, it's because of here, it says "Player Index: 0" but i want that to be self for the player controller, but i forgot how to get references ๐Ÿคฆโ€โ™‚๏ธ

paper hinge
#

Hi I am haivng a issue with dedicated server, I opened the port 7777 via nginx from a server to my local machine and I am getting:
Server side.
LogHandshake: SendConnectChallenge. Cookie: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
LogNet: NotifyAcceptingConnection accepted from: *
Client side.
LogHandshake: SendChallengeResponse. Timestamp: *, Cookie: (Same as the server side)

do a need to open more ports for this handshake happens?

paper hinge
unborn trellis
#

into player controller?

paper hinge
#

you can do this comparison inside the player controller so all the players will have this logic or you can store the PlayerState.PlayerId as a list and do it on the server side

unborn trellis
#

so i have this in the PlayerController

#

im calling it here

unborn trellis
#

im new to UE4 as well so i do wanna learn like how to overcome these obstacles for the future

paper hinge
#

change the custom event to replicate

#

I am new here too haha

#

you can change to multicast so if you are running it on the server it will replicate on the clients

#

the showredwins...

unborn trellis
#

i tried all the options and still nothing :/

#

The idea is there, in terms of blueprint, it's just not properly showing on the client side ๐Ÿ˜…

paper hinge
#

if the replication does not work check if that cast to pc_... is working

#

for the clients

#

you can use the debug to check if it is going to the client and where it is failing

unborn trellis
#

So i was testing the custom widget on the Red team. I have a text string to print Blue team wins in text and as you can see it shows on both client and server

#

i just want to display a widget instead of a text string

paper hinge
#

probably you have a has authority before call addScore

unborn trellis
#

ah possibly

#

nope, that didn't work ๐Ÿ˜ญ

paper hinge
#

not there

#

where you call addscore

unborn trellis
#

oh right

paper hinge
#

just check if you have

unborn trellis
#

tried it and still the same :/

paper hinge
#

you probably have something like this hasautority -> addScore

#

this will pass only on the server

unborn trellis
#

thing is i have other blueprint widgets that show on the client

#

for example, when wanting to switch teams

#

lemme try find it lol

#

this is where im having it so when i press Tab in game, this menu shows up

#

im stumped :/

rapid bronze
#

Are you running the score code in GameMode?

unborn trellis
#

No, i've tried the Gamestate, Game Instance, Player Controller and Hud

#

Now i just tried the game mode and the same thing happens, it only shows on the server

#

am i doing the logic wrong?

rapid bronze
#

May wanna try running it on owning client instead

unborn trellis
#

i've tried that

#

it still didn't work

rapid bronze
#

Are the casts going through?

unborn trellis
#

wdym by that?

rapid bronze
#

Are the casts failing or successful?

#

Cause if one fails the code doesn't continue

unborn trellis
#

the casts seem to be working fine

rapid bronze
#

Well, one way you could do it is that you store a PC array after OnPostLogin in GameMode, and when GameState sees that the game ended, it talks back to the GameMode to show the Widget to all players with a For Each Loop through PC Run on Owning Client

unborn trellis
#

how could i do that with blueprints?

winged badger
#

@rapid bronze @unborn trellis that won't work

#

clients don't have PCs except for their own

paper hinge
#

Hi Sinbad I just got that you can not use the player controller for this, but you can use game state

winged badger
#

you do have a PlayerArray in GameState though

#

so you can loop through all PlayerStates

rapid bronze
#

There's the server PC tho and if you run it on owning client it runs client side

#

I do that in OnPostLogin

#

To show Widget only to newly logged PC and only client side

winged badger
#

you also don't need to store the PCs even for that use

#

GetGameMode->GetNumPlayers->For (0 to NumPlayers - 1)->GetPlayerController[Index]->Cast->ClientRPC

#

which is pretty much the only completely safe way to use GetPlayerController[Index]

#

iterating all PCs

unborn trellis
winged badger
#

can be GameMode, less indirection

#

server only

unborn trellis
#

am i leading to believe this is the start of it?

winged badger
#

you do need to connect index from for loop

#

into getplayercontroller

#

aside from that, yes

rapid bronze
#

What am wondering is if you want to show Widget through GameState, you go through PlayerStates but iirc PlayerStates don't have a direct reference to PCs no?

I mean there's Unique Net ID that you can check against

winged badger
#

its GetOwner

#

from PS to get PC

unborn trellis
#

oh like that?

winged badger
#

yes

unborn trellis
#

okay

rapid bronze
#

I completely forgot about that honestly :'D

#

But makes sense

paper hinge
#

if you want to do server to client only you can do on the gamestate like this

unborn trellis
#

i don't know what im doing wrong

paper hinge
#

the add score running on the server and the showAny on multcast

unborn trellis
paper hinge
#

๐Ÿ˜–

rapid bronze
#

You have another GetPlayerController at the end and i think you're running the entire code on the server

paper hinge
rapid bronze
#

So adds them to PC 0 aka first player so the server

#

In this case

paper hinge
#

assuming that the calculation and add score is called by the server

unborn trellis
#

I just deleted everything in the gamestate, starting from scratch

#

So this is my Player Controller

cedar tangle
#

Hi hope someone may be able to advise, I am looking into the multiplayer networking side of unreal engine.

Should I use UE4 or UE5 for starting?

It is only for experimenting, creating development tests but I would like to keep the results for future versions (progressive longer term, probably a git repo).

paper hinge
#

UE4 you will be able to find more docs

#

and plugins

unborn trellis
#

I'm using UE 4.15 for replication and multiplayer

#

im gonna take a break from this and try again another time.

#

If i get stuck, i'll post something on here regarding my issue

paper hinge
#

the problem to use UE5 at the moment is you will never now if you did something wrong or just a bug

cedar tangle
#

I guess the docs would apply form UE4 to UE5, but probably not taking into account any new additions/changes that have been introduced into UE5.

I will use UE4, thanks.

paper hinge
#

any one knows why I am not completing this headshake?

#

open ports 7777 udp and tcp

paper hinge
#

did a direct redirect and worked ๐Ÿ˜„

kindred widget
#

@cedar tangle Even beyond networking, using UE5 for anything more than curiosity right now would be a nail in the foot. It's bound to be buggy. Things that normally work could be entirely broken. I generally avoid PointZero releases and Betas in any development software. However it's also worth noting that supposedly projects will be able to easily port to UE5 eventually. So even things you do now should require minimal effort to switch over later if you really want.

paper hinge
unborn trellis
#

@winged badger @paper hinge @rapid bronze I got it working :D

#

Thanks for all the help you guys gave me.

#

Ill show you the blueprints now so maybe other people may find it useful

#

This is the Player Controller displaying the Blueprint widget on the viewport

#

then with ZIo's help, This is in the GameState

#

Then calling the custom event

#

And there's the proof :D

tawdry marsh
#

hi guys. i moved my files to a new folder. and it messed with the host and i assume join aswell in my multiplayer game. do you know what is wrong ? cant understand what it wants to readjust.

ebon plume
#

Guys. In desperate need of advice.

I'm working on an online FPS Controller prototype. I understand than in most all FPS games, the arm rig is spereate from the 3rd person rig that is being rendered by the other players. I also understand why that is.

My question:

I am creating a type of robotic character that does not have hands or fingers. All the weapons will be attached in a more modular way directly to the arm of the character. I will be using robotic types of animations and wanted to know if it's still best to create the arms spereate from the full body ?

Doing it this way, I feel like I can do most of the ADS positions / offset through animations rather than creating offsets in Unreal for the arms/weapon.

Any help would be GREATLY appreciated.

tawdry marsh
#

hi guys. i moved my files to a new folder. and it messed with the host and i assume join aswell in my multiplayer game. do you know what is wrong ? cant understand what it wants to readjust.

ebon plume
#

Double post ???

rich ridge
#

I have a little logic related to animation, so I m thinking not to insert it in my anim BP and instead do montage, so just wanted to know if montage is network friendly or not?

#

I do montage in GAS, but this montage animation is going to be played very frequently.

azure hollow
#

hey guys! anyone familiar with PlayFab? I need to send over to PlayFab a structure with my vehicle locations for a ghost replay system. I tried to serialize to JSON but apparently it's not the best solution...can someone help?

sinful tree
coarse flame
#

is c++ a must to be able to store data on server? or can it be done through BP? (Dedicated Server) i kinda messed up and forgot to set it to C++ when creating the project

sinful tree
coarse flame
#

Okey good, but how do i set them so that they are saved to and loaded from the server?

bitter oriole
#

Though doing a game with dedicated servers very strongly implies C++ will be needed

coarse flame
sinful tree
bitter oriole
# coarse flame Can you explain a little more? ๐Ÿ˜„

You only use dedicated servers if you have
A) Large (>5) player counts that prohibit listen server - you'll need to port stuff to C++ if only for performance reasons
and/or
B) Competitive play - you'll need anti cheat, report systems, probably replays, and cleanly implemented multiplayer systems, those will very likely work a lot better in C++

coarse flame
#

Yea, im tryina make a game where you basicly join in a Dedicated Server, and it will handle storing your data, aswell as world data, and hold a larger group of players at once

bitter oriole
#

Yeah, your team of engineers will likely work better with C++ for that

coarse flame
#

Alright, so basicly i need to scrap it, and re-start my project

sinful tree
#

No. You can always prototype in Blueprint.

#

Optimization can come later.

coarse flame
#

Yea, so im currently building with others, and im tryina make it so that you create a character, that data stores in the server with your inventory data, health etc, aswell as the items dropped to ground will store in world data amongst where vehicles have been parked etc

bitter oriole
#

I wish people tried to do less of that, frankly

#

It's ridiculously hard to do and much harder to sell to players

#

But hey, like Datura said, just do a regular save game, assuming a player only stays on that one particular server

coarse flame
#

Yea, that's what made me look into web api and db, cuz if a player decides to change server, not to carry over his stuff

bitter oriole
#

No need for a database if the player is stuck on that one server they started on

#

Just regular ass game saving

coarse flame
#

Yes, but the thing is, if there are 2-3 servers setup, i'd want the player to have the ability to basicly not run same data on server 2 compared to the 3rd and 1st server

bitter oriole
#

Yeah, just do regular game saves

fluid summit
bitter oriole
#

Server side

fluid summit
#

such a conundrum, i'm not sure if keep going with the database setup or check for save game on server side and redo that parts

bitter oriole
#

Of course you can save on server

#

The DB setup needs a DB server, dedis that are 100% owned by you

fluid summit
#

what would be the advantages of a DB vs ServerSide save game that you know of?

#

just passing the data to multiple diferent Servers?

fading birch
#

server side save games would only exist for that server. If you have short lived servers, ie one lobby per server that eventually shuts down, then it's not a good route. A DB is useful for having data that's shared globally, ie Loadouts in Call of Duty

dark edge
#

The only reason you would need some sort of a database for saving stuff is so you can play on one server, then bring the same character to another server, with the servers still being authoritative over inventory etc. If it's like DayZ or Minecraft where every server is basically its own world, server side save games are totally fine.

fading birch
#

If you're doing something like Ark or Valheim, then a server save file is good as the data only pertains to that particular server and is not global.

#

ayy @dark edge

dark edge
#

Honestly if you're new to this stuff, don't go dedicated server unless you have a game design that can very much leverage community hosted servers, like Garry's mod. You are not going to make a competitive multiplayer dedicated server game your first go around, guaranteed.

fading birch
#

..but I did :/

dark edge
#

What's your player count

fluid summit
#

how do save games behave if you want to make changes to the same?

dark edge
#

Oh yeah that's a totally different animal. That probably wouldn't even have a Unreal Engine server on the back end

fluid summit
#

can you change the structure of the save games and not lose them in the process?

bitter oriole
fluid summit
#

yeah, but if it's just doing it for the sake of doing it and learning, everyone should give it a try, knowing that it's going to be freaking tons of work

bitter oriole
#

Having done both

#

Sure, you'll learn to set up a web service and maintain a database, but those aren't exactly mainstay game design skills

#

Then again you might be looking for a job in web services too !

fluid summit
#

yeah, the hacking stuff is going to take quite some time later on, damn it.

fervent spoke
#

hm when i "play as client", the position of my player character only updates on the server 60 times per second, regardless of what net/lan maxtickrate are set to in defaultengine.ini, and regardless of the replication update frequency

more odd, if i set my fps just above 60 (e.g. 61 or 70), the server has an outdated position every other frame. i would have expected most of the frames to agree with the client, with only a fraction being outdated duplicates. instead, it's as if setting my fps to 61 is the same as setting it to 120.

#

maybe i'm just dumb and missing something obvious but i am pretty stumped about what's going on here

fervent spoke
fading birch
fervent spoke
#

^

fading birch
#

yup

fervent spoke
#

i played it

#

i won mice

#

good times

fading birch
#

i still haven't got my free one ๐Ÿ™ƒ

fluid summit
#

i just check it out, that looks nice.

#

you made it alone or with a team?

fading birch
#

small team

#

of 4 people

fluid summit
#

so 30$ x 40k players = 1,200,000

#

not bad after you take out all the taxes and costs

fading birch
#

yeah....

#

the costs were something else entirely xD

#

I won't say anything bad publicly, but poor management decisions caused us to have a very expensive cost system.

#

Which we weren't allowed to fix

#

but was constantly bitched about

#

ยฏ_(ใƒ„)_/ยฏ

fluid summit
#

the beautiful perks of working with a group of people

fading birch
#

oh no, we all wanted to fix it

fluid summit
#

i miss them everyday since i quit my full time job

fading birch
#

it was the boss man

fervent spoke
#

djriff don't be a gremlin

fading birch
#

kekw

#

i got yelled at for posting the leaderboards twice a day lul

#

did it anyway

fervent spoke
#

sounds like a freethinker thing to do

fluid summit
#

what would you call games like clash of clan, travian, etc? (city building + exploring + battles)

#

rpg online?

fervent spoke
#

aren't those strategy games?

#

never played them

fluid summit
#

hmm yeah, tey popup as strategy games, thanks!

fervent spoke
fading birch
#

@thin stratus might know. I've never delved that far into that particular type of issue.

cedar tangle
#

Is it possible to have code/BPs in a server build that is not included in a client build?

For example, code that communicates with another server and would only be relevant to the server build.

I did a quick google, but not sure what I should be looking for.

sinful tree
quiet fjord
#

How many ms should be appropriate for a multiplayer to optimize it

#

I am with netprofile

terse prawn
#

When the server sets the location/rotation of a client's pawn the client does not see it update (Set Actor Location/Rotation nodes). it is using a "Executes on server" event and the pawn is set to replicate.
Why is this happening and how can I fix this?

vagrant lance
#

I have a very odd and rare bug; sometimes the Host loses control when a game starts. They have no control at all - can't move their character or hit Escape to bring up the menu. This is super rare though. Has anyone had similar?

coarse flame
#

Does savegames save automaticly tothe server when the player is connected to one, or does itsave locally?

fading birch
#

depends on who calls it

#

if the server calls it, it's saved on the server

#

if the client does, it's saved locally

coarse flame
#

How do i make sure the server calls it then in bp?

fading birch
#

mark it as a server function

coarse flame
#

Thank you

coarse flame
fading birch
#

read the networking guide in the pins.

coarse flame
#

alrigfht cheers

#

Keep getting graph not editable why is that?

floral crow
#

TLDR; How can I 100% prevent a replicated actor from getting destroyed on a Client?

The long explanation:

  1. AMyActor is an actor that has both bReplicates and bAlways relevant set to true.
  2. AMyActor::EndPlay has a UE_LOG of Error type when it gets destroyed due to EndPlayReason Destroyed, LevelTransition, or RemovedFromWorld.
  3. I'm spawning a AMyActor instance on the server (from AMyGameMode) and storing a UPROPERTY reference to it in UMyGameInstance ( UPROPERTY() AMyActor* MyActorInstance )
  4. AMyActor sets itself on MyActorInstance on its own BeginPlay ( GetGameInstance<UMyGameInstance>()->MyActorInstance = this; )
  5. On AMyGameMode::GetSeamlessTravelActorList I add the MyActorInstance to the list
void AMyGameMode::GetSeamlessTravelActorList(bool bToTransition, TArray<AActor*>& ActorList)
{
    Super::GetSeamlessTravelActorList(bToTransition, ActorList);

    AActor* MyActorInstance = UGameplayStatics::GetActorOfClass(this, AMyActor::StaticClass());

    if (!IsValid(MyActorInstance))
    {
        UE_LOG(LogPreGame, Fatal, TEXT("Could not find an existing MyActorInstance"));
        return;
    }

    ActorList.Add(MyActorInstance);
}

Expected behavior:
MyActorInstance is never destroyed on a client because nothing tries to destroy it and it is marked as always relevant. I should add that the Fatal log Could not find an existing MyActorInstance never triggers, and that I have print string from the MyActorInstance getting created, so it is safe to assume that the actor is properly spawning.

Actual behavior:
On rare occasions (1/50 games I'd say), a client will print the Error log about MyActorInstance getting destroyed, and then that client ends up crashing after trying to access the MyActorInstance. This seems to only happen immediately after doing a seamless travel to a different map.

So now, how do I ensure 100% that MyActorInstance is never ever destroyed?

fading birch
#

nothing special should be needed. Just need to drop a breakpoint and it should be fine.

blazing socket
#

How can I check in the PlayerState whether it's local or remote?

#

GetRemoteRole() == ENetRole::ROLE_AutonomousProxy ?

fading birch
#

what are you checking for?

#

authority or?

#

show where you're calling it

#

breakpoint the if(!HasAuthority() and see what the role is.

#

you want it to RPC yes?

#

I would structure it like this then:


void ASideScrollerRPGCharacter::JumpInput()
{
    if (!bWasWallSliding)
    {
        Super::Jump();
    }
    else
    {
      LauncherCharacterRPC();        
    }
}

void ASideScrollerRPGCharacter::Server_LaunchCharacterRPC_Implementation()
{
    LauncherCharacterRPC();
}

void LauncherCharacterRPC()
{
  if(GetLocalRole() < ROLE_Authority)
  {
    Server_LaunchCharcterRPC();
    return;
  }

  /* BREAKPOINT */ LaunchCharacter(FVector(0.f, GetActorForwardVector().Y * -800.f, 3600.f), true, true);
  AddActorLocalRotation(FRotator(0.0f, 180.f, 0.0f));
  bWasLaunched = true;
}```
#

1s let me see what that does, i don't use that function really

#

ah

#

yeah you can just use that

#

does the same thing GetLocalRole() == ROLE_Authority

fading birch
#

try making LaunchCharacterRPC a net multicast function

#

i would remove the has authority check

#

you probably need to do this through the CMC

#

yeah, that's needed for this kind of stuff

#

I don't know of any resources for CMC sorry. I just read what it did and extended it as I could.

#

I ended up modifying the CMC in engine as extending it wasn't enough.

cedar tangle
#

what is a CMC class?

vivid seal
#

messing with CMC custom movement replication is probably the least fun thing to do in unreal lol

twin juniper
vivid seal
#

to be honest i thought launch just worked by default with CMC replication like jump does (though in that case it'd be called from the client, not the server?). If not, you'll have to extend CMC and mess with SavedMoves to add some kind of bWantsLaunch flag so that launches are part of corrections and replays like everything else. there's detailed tutorials online but to be honest they're all a huge pain.

vivid seal
#

of course it doesnt lol

eternal canyon
#

because then u would be sending a vector over the network

#

allowing the client to cheat

#

as they could modify how much they want to be launched

vivid seal
#

yeah one thing i never got with CMC extension is where do you put verification? there are some custom movement types where you'd probably need some kind of client input to be added to your packets, and i get how to add that, but i'm not sure in what function you would add logic for sanity checking that stuff before it gets executed on the server. i made a google doc mapping out what order everything gets called on both client and server a while back but so much stuff is called in multiple places and i wasn't sure what was the standard approach, since every tutorial just kind of ignores that part of setting things up

eternal canyon
#

you just have a CanDoThisFunction in the CMC

#

and call it everytime the action is performed

cedar tangle
#

Actually is very interesting you say "before it gets executed on the server" must be a way of check before hand.

raw quarry
#

When I have two server instances running on the same machine with different processes, ServerTravel doesn't seem to be working on the second server:
GetWorld()->ServerTravel(nextMapPath, false, false);

#

for the first server it works properly, and the second one it opens the map on the clients, but it opens it locally and not connected to the server anymore

#

only difference I can think of is that the second server opened gets an incremented port number since the first server is using 7777 by default already

fading birch
#

what port is each server using?

raw quarry
#

7777 and 7778

#

do I need to use an absolute path? Maybe relative path is getting screwed up somehow

fading birch
#

how are you connecting to each server?

raw quarry
#

the initial connection is done by launching the client application with command line arguments

fading birch
#

And those would be?

raw quarry
#

@fading birch i.e.
game.exe <Server IP>:<port>?PlayerSessionId=<Session_token>

fading birch
#

If you're using sessions why not just find the session and connect to it?

raw quarry
#

not sure what you mean

#

I'm not using Unreal's session system

lusty sky
#

why you calling LaunchCharacterRPC recursively ?

#

LaunchCharacterRPC
{
!hasAuthority();
Server_LaunchCharacterRPC();
}

and the Server_LaunchCharacterRPC() is calling LaunchCharacterRPC()

#

Oh Did it work for you?

#

Try to run the game inside the editor (not a new PIE window) with this option checked

peak sentinel
#

I'm adding Impulse to a client pawn in CMC (as server), but since server-side correction is enabled, client velocity does not change. Can I somehow find a workaround for both not disabling server-side correction and adding impulse?

peak sentinel
#

Alright, found it

devout egret
#

Hey yโ€™all! Iโ€™ve hit a snag with the networked CMC Iโ€™ve been working on. Iโ€™ve run out of custom compressed movement flags. Since 2 of them have been reserved and we only have access to 4. I was wondering if thereโ€™s a feasible way to increase the available number without messing too much with the source code. Thanks for your help!

#

Iโ€™ve also heard it is possible to increase the number of compressed flags since 4.26 but havenโ€™t found any guides on what to do/override or code examples

polar wing
#

@devout egret There's been a pretty substantial rework of that system to allow for exactly that use case! There's a new NetworkMoveData class you can extend in a similar manner to FSavedMoves. Doc here: https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/CharacterMovementComponent/

But I also found a great free resource that actually has some examples of how this is used in practice: https://www.unrealengine.com/marketplace/en-US/item/50527885258c47f79ec1ebcc5e00e868

In the past, you had to do some rewrites to achieve that, or do some bit-shifting stuff like the Unreal Tournament UE4 source code. Let me know if that helps! It definitely made my life easier.

cedar tangle
#

Am I correct in thinking that a Game Mode Event Graph, with a branch check of Is Server, should only execute on the server. As I see it, what seems to happen in the Game Mode BP replicates to all other clients also.

Is it down to replication that makes the print string show on all connected clients?

Actually, I think this is the intentional behavior for print string as it displays โ€œServer:โ€ in front of the message. I will test printing from a reference that is inside a class to see if that works as I expect it to. If so then that answers my own question.

rough kestrel
#

has anybody used Photon with UE4? Just trying to see the viability for our project.

rough kestrel
cedar tangle
rough kestrel
cedar tangle
rough kestrel
cedar tangle
rough kestrel
# cedar tangle That looks like that I have been Google'ing for. Thank you again.

Hello guys, in this video I will explain the GameMode Class, GameState Class, PlayerState Class, and Player Controller Class within Unreal Engine 4. I will explain the practical uses of these classes and how you can implement them in your multiplayer game. To move forward, you must understand what role each of these classes play in your multipla...

โ–ถ Play video
cedar tangle
#

But obviously did not get to vid 3 ha ๐Ÿ˜† .

rough kestrel
devout egret
plucky prawn
#

is using delay in blueprints really the way to "make sure" that networked stuff is available? my PlayerController's BeingPlay is run before the server even has the PlayerState setup and id like a more proper way than just waiting an arbitrary amount of time hoping its ready after

#

i guess i could tick also but both of these sound like hacks

meager spade
#

No

#

You should use appropriate call backs. Delays/timers are not the best way. Sometimes they can be OK if used properly. But not the best way.

fluid summit
plucky prawn
#

but which event? is there one built into the engine? or am i supposed to make my own?

fluid summit
#

with eventDispatcher you can make your own event notifications and run code on notif

plucky prawn
#

yes i understand but this does not help me. i dont know when the player is really ready (ie has its player state created on the server) so using an event dispatcher does not help me. if there isnt such an event available out of the box then i can understand how this would help me

#

so the player state exists in PlayerController.BeginPlay and its the correct class (im using a custom PlayerState blueprint), however the custom data is not ready/copied from seamless travel. using a delay of a few seconds "fixes" this

fading birch
#

the player state is ready when it's owner is set

#

There isn't really an event that you can call to check that from BP afaik. You'll need to use code and override it

charred crane
#

My goal with this logic is to make a widget that appears to everyone, if I run this on server, will it replicate that widget because it's a component or no?

plucky prawn
thin stratus
#

Widgets aren't replicated

#

And components that are spawned runtime don't change that fact

charred crane
#

Oh a 3d widget can be replicated can't it...

fading birch
#

that's when the player state is initially replicated

charred crane
#

I did something on my last project that had replicated health bars

thin stratus
#

You replicate the events that create the ui

#

And you replicate the data the ui should show

#

And that's it

plucky prawn
fading birch
#

OnRep_PlayerState is in AController which is when the controller has it's playerstate replicated

charred crane
#

Hmm. I want to make an arrow indicator over a players head when they're targeted by an ability, and I want all players to see it. Perhaps it's easier to just make an actor with an arrow on it.

thin stratus
#

Maybe yeah

charred crane
#

Thanks

plucky prawn
fading birch
#

GenericPlayerInitialization may be better

#

it handles both PostLogin and HandleMatchHasStarted

plucky prawn
fading birch
#

np

lavish dagger
#

Anyone knows a good tutorial or reference on how to replicate projectiles in C++? I tried some google searches but no luck.

violet sentinel
#

or do shenanigans like UT do

lavish dagger
eternal canyon
#

just set he projectile to replicated if u dont want it to be predicted if u do u have to do the magic that UT does

#

and call the spawn function on the server

#

there are so many things wrong with using a multicast in that situation

violet sentinel
#

in my case using replicated actors as projectiles was impossible because by time the client received the replication projectile would already hit or fly far away

#

and many many other problems in close distance

#

so just use them as visual fx and real proj in server only

#

plus crazy 900 RPM weapons which i still detest

lavish dagger
#

I tried setting replication on my projectile but it doesn't seem to spawn when using multiplayer. I have the below setup:

    bReplicates = true;
    bAlwaysRelevant = true;
    InitialLifeSpan = 20.0f;
violet sentinel
#

are you spawning then on server? are they fast?

lavish dagger
# violet sentinel are you spawning then on server? are they fast?

I'm trying to spawn them on the server. idk if i'm doing this right:

bool ASWeapon::ServerFireProjectile_Validate()
{
    return true;
}

void ASWeapon::ServerFireProjectile_Implementation()
{
    //StartFire();

    FRotator MFRot = GetMuzzleDirection().Rotation();
    FActorSpawnParameters SpawnParams;
    SpawnParams.Owner = this;
    SpawnParams.Instigator = GetInstigator();

    AGrottoProjectile* Arrow = GetWorld()->SpawnActor<AGrottoProjectile>(ProjectileClass, GetMuzzleLocation(), MFRot, SpawnParams);
    Arrow->CharSpawner = GetPawnOwner();

}
#

in my .h:

    UFUNCTION(Reliable, Server, WithValidation)
    void ServerFireProjectile();
    void ServerFireProjectile_Implementation();
    bool ServerFireProjectile_Validate();
violet sentinel
#

get rid of this in header
void ServerFireProjectile_Implementation();
bool ServerFireProjectile_Validate();

#

you must never have them, they're generated by uht

ebon plume
#

Would this be a decent approach to managing inventory for BR style game:

Inventory System for character using ENUM.
Setting defaults at runtime.
Character Interacts with weapon BP loot.
Add to the inventory and attach the weapon BP to characters socket.
Manage visibility/etc (Current selected weapon/etc)

I have been told just to pre-place all the weapons on the character and enable/disable as needed (upon interacting etc.) ----- but...

I do not want to do this because I want the weapons to hold the same values (ammo in clip, etc.) and be persistent. Although its possible to pass those values to the player than picks the weapon up. I feel like there's no point in doing this.

Would this be considered a good approach in general ?

violet sentinel
#

Inventory System for character using ENUM.
what do you mean by enum? inventory slot type ?

ebon plume
#

Yeah, assigning the variables upon interaction with BP

violet sentinel
#

eh, you can. if you have very limited amount of items. i'd prefer data assets 1 asset per item

#

blueprintable enum can have only 256 values, br game would have way more than that

ebon plume
#

Where can i read up on Data assets

violet sentinel
#

google, they're just data holding uobjects/primaryassets

#

there are bunch of various inventory systems demos out there some would work in mp

ebon plume
#

Cannot find the one i created in the Variable Type

violet sentinel
#

UPROPERTY(EditAnywhere, BlueprintReadWrite) UItemDataAsset* ItemType;

ebon plume
#

Do data assets need to be # included ?

ebon plume
#

LOL nvm, fixed it

upbeat heron
#

I have a strange problem, I'm trying to test the multiplayer inside my editor by setting players as 2 and "Play as listen server".

Why does the client also have it's own GameMode object?
It is causing some strange bugs to occur.

rich locust
#

this..

#

try unticking run under one process

upbeat heron
#

Hmm, It still seems to behave as if there is multiple gamemodes running

rich locust
#

editor debugging is not perfect at all times

#

but

#

Im not sure about gamemode part

#

server only has it but uidk

upbeat heron
#

the client is printing things that originate from the gamemode

thin stratus
#

@spring tangle Please use the Job Board for this.

fluid summit
#

Hi! i'm having some troubles with the default server map on a dedicated server.
I'm running the editor on standalone as a client.
For some reason the server is not opening the default server's map, but rather the map i'm currently using in the editor, is this normal?
Do i have any other way to test the server with it's default map that's not packaging the server?

fading birch
#

yes. Create a shortcut of your .uproject file after Target add -server -log

fluid summit
#

oh didn't knew about that one, thanks!

fading birch
#

you can do the same thing to launch a client by replacing -server with -game

fluid summit
fading birch
#

ah ok

#

do you know where your engine is installed?

fluid summit
#

i'm using source version of 4.26

fading birch
#

ok perfect

fluid summit
#

<Delete it and never come back>
Ok...wait what?

fading birch
#
YOURENGINEDIRECTORY\Engine\Binaries\Win64\UE4Editor.exe "FULLPATHTOYOURPROJECT/PROJECT.uproject" -server -log ```
#

fill those all caps words in

#

and replace the Target of your shortcut with that

fluid summit
#

okey, so it would be like this

#

D:\UnrealEngine-4.26\Engine\Binaries\Win64\UE4Editor.exe "D:\UE4EngineProjects\CultPathMain.uproject" -server -log

fading birch
#

yes

fluid summit
#

i'm not sure about \CultPathMain.uproject" -
shouldn't it be \CulPathMain\CultPathMain.uproject ?

fading birch
#

full path

#

udpated my stuff above to be more clear

fluid summit
#

oh that makes sense

#

love you, it works

#

the one for the client also comes in handy

#

yeeeeeeeeees my setup works

#

damn it was hard to get an entry map for the user and one default for the server

karmic briar
#

hey guys i wanna ask is there any guide to adding steam for my project on 4.27?

#

i wanna try to do it again and the goals for it long term to use it alongside EOS

#

and i wanna use it for multiplayer "matchmaking"/"world search"

#

think of my use case for steam is similiar to valheim

vivid seal
#

do you guys find yourselves having values that are separately calculated on client and server (not replicated) even though ideally they should be synchronized? I'm knee deep in spaghetti code with fast arrays representing values of uobjects inside of uobjects and i'm about ready to just not replicate this stuff at all and instead try to enforce that the same code is called on both client and server (the worst case is client cheats or i mess up somewhere, and then the client just mispredicts stuff)

mossy kindle
#

Hey guys, why is the character loading correctly for the server but not for the client? The left screen is server and right one is the client. I am using a savegame to save the character and then load it on begin play

thin stratus
mossy kindle
#

You mean the custom events or the variables?

thin stratus
#

The variables

#

You said you load a savegame

mossy kindle
#

They are replicated

thin stratus
#

Where , how, when?

#

:D no one here can help you without info about the code

mossy kindle
#

There is another level, where the player sets up their character

#

After that is done, there is a Widget for saving it, when it saves it to the save game

thin stratus
#

On each client?

#

How do you send the selection to the server?

#

Is that level Multiplayer?

mossy kindle
#

Nope

#

That level is singleplayer

thin stratus
#

And how do you send the server the data then?

mossy kindle
#

And then the player joins the multiplayer level

mossy kindle
thin stratus
#

The data should just be some struct with info about the character

mossy kindle
#

Its it not a struct

thin stratus
#

You can send that via an RPC for all it matters

mossy kindle
#

The meshes are stored in seprate variables

#

So do you think it might be the problem?

thin stratus
#

No. But you have to send the data to the server via an RPC after connecting

#

And then the server has to set some RepNotify variable with the data

mossy kindle
#

Its like this for every piece of mesh

thin stratus
#

So everyone gets the change

#

Yeah that's pretty wrong

#

There is no reason to mark those variables as replicated

#

The data can't replicate like this anyway

mossy kindle
#

The player cannot change the character mesh once its on the multiplayer. Do i still need repnotify?

thin stratus
#

Yes

#

On PostLogin you can send a Client RPC to ask the Client for their character data.

#

Which can then load the data and send a RPC back with that data

#

Then the server can spawn the character and set the data on the character as a RepNotify variable

#

In the OnRep function you an apply the changes then

#

That's why filling it into a struct is good/necessary

#

Just keep in mind that players can cheat how they look like in a setup like this

mossy kindle
#

its not a professional game

#

It's my first multiplayer game

#

Am i on the right track?

thin stratus
#

Well that's saving stuff. Not the part that is important

mossy kindle
#

I mean is it saved correctly or i need to do some rpc stuff here too

mossy kindle
#

Ok

#

So i did the rest of the thing

mossy kindle
#

How do i do this part

mossy kindle
twin juniper
#

Hey Guys was just wondering if anyone could help me with this engine-ini error im getting i currently have built a dedicated server for my game and its telling me that my default material name is not defined in my Engine.ini file for the server causing it to crash

Heres the log [2021.09.05-08.06.20:822][ 0]LogUObjectGlobals:Error: Can't find 'engine-ini:/Script/Engine.Engine.DefaultDeferredDecalMaterialName' in configuration file section=/Script/Engine.Engine key=DefaultDeferredDecalMaterialName

It gives a similar error for DefaultLightFunctions and others im assuming i have to fill the Engine.ini with default values for these categories but im not sure how to do it anyways any help would be apperciated

keen thorn
#

Hi, anyone tried to implement network prediction using the NetworkPrediction plugin yet? very curious

twin juniper
#

What's the correct way to set continuously changing variables that drive blendspaces in multiplayer?

mossy kindle
#

Tick?

rich locust
#

no way

#

for example

#

character movement is has built-in replication

#

so you can get the values from there if you like to do stuff such as walk/run

#

for others

#

you need to be subtle

#

if you put on tick you will have problems

#

try to work with what you already have

twin juniper
#

What problems? Other than inefficiency. I don't plan to have it on tick but I want to do it on tick for now to test. I would imagine it would work but be very choppy or reduce framerates, but doesn't seem to function at all.

#

It's not walk/run it is a maggot npc and the variable controls how much it is bent depending on the distance of the nearest enemy player it detects.

rich locust
#

think about it this way

#

can you absolutely cannot do it on client

#

for example lets say physics

#

if you know what vector you are going to impulse and start location

#

you dont need to replicate the movement at all

#

you just apply the same thing on the client as well

#

not everything needs to be replicated

#

you dont need to replicate things to do that

#

I dont know what you mean by bent

#

but you can check the distance on the client

#

it doesnt have to be on the server unless necessary

#

because lets say your Maggot sees Player A as nearest, it is the same for the player B locally

twin juniper
#

i do check the distance on client

#

the maggot bends via animation blueprint

#

i need all players to see it

rich locust
#

all players should be able to see it

#

even without server

#

because all players know each other`s location already

twin juniper
#

yes that is true because players move via movement component which auto replicates

#

the maggot is an AI that has a trigger that tells it if an enemy is near, then bends towards that enemy depending on the distance

#

but if i want the maggot to bend, i need to set a variable in the animation blueprint, and afaik I need to set this variable on server

rich locust
#

no you dont

#

server already gives everyone player locations

#

use that instead

#

and set the variable on everyone locally

#

how can I explain with my mediocre english let me try

#

Maggot is on 0,0 (Coords)
Player A is on 1,0
Player B is on 2,0

Player B already knows A is closer to maggot because it has both of their location therefore can use this

#

so no server needed

twin juniper
#

yeah my setup is very different to what you are imagining.

#

I lied about the 'nearest enemy' thing to make things simple to explain, there is no distance comparison

#

But thanks for trying to help.

thin stratus
#

The idea stays the same though. If you have data available on Clients, use that instead of replicating even more.

twin juniper
#

I should go into more detail because I'm probably confusing people. Pretty much I have some maggot NPCs, they are hostile to some players and friendly to others. They have a trigger box around them, as soon as a player enters, they check if that player is hostile and if so, 'lock on' to that player as long as that player is in range (even if another hostile player comes near the NPC; only once the 'locked on' target moves out of the trigger volume, the maggot is then able to lock on to other targets that approach). The maggot BP has a variable that controls how much it is bent (via an animation blueprint) depending on how far away (while still in range) this 'locked on' target is.

I managed to get it all to work via checking the distance of the 'locked on' target (on tick, but probably will change later to every 0.1 secs or so for performance) in the maggot BP, setting a variable on server and then setting the variable in the maggot anim BP, on all clients, via a multicast. I imagine this is quite inefficient and I'm doing this kind of thing a lot over my project, what worries me is that it is a continuous variable so it will be changing often (unlike some of the other instances I do this, which is just occasionally when players press certain attacks).

rich locust
#

what you can do is then, you can make the "locked-on target" replicated

#

then use this

#

because these targets still exist on everyone

#

tick on server but only set it if it is different than the last time

#

you can use tick as long as you are not filling it with rpcs, replicated stuff changing etc

twin juniper
#

the locked on target is replicated

rich locust
#

if let the players know only when the target gets changed you can still go with the original

#

its not inefficient per say

#

you dont need to constantly Set it

#

check if it is different than before before setting it

#

if you dont try setting it constantly you wont have problem

#

server can tick just like clients no problemo

twin juniper
#

but i still need to set the variable in my animation blueprint and I don't think I can set that in client

rich locust
#

why not

#

you have the target

#

actor

#

and the maggot

#

just recalculate the distance

vivid seal
#

You can and should be setting animbp variables on the client

twin juniper
#

oh you're right I can just do that

#

thanks

fallen escarp
#

Hi everyone. I need some help, I'm not entirely sure what is causing problems I'm experiencing with really, really basic replication. So, I'm running server and client commands, but, the item is not really replicating movement induced by physics correctly, there is a difference in how the physics plays out.
I'm running Server command event, then a multicast afterwards which does actual item spawn.
I have item spawn BP ticked "replicate movement", but it's not exact.
The game is about sorting boxes in tandem so I'm really into making it 1:1 across clients.

twilit radish
#

Are you spawning the cubes locally on the client(s) through the multicast?

#

Because if so I would just let them replicate with the server saying where they should be exactly, but that doesn't necessarily have to be a good solution depending on what you plan to do with it.

fluid summit
#

Hi! i'm having some troubles forwarding ports so someone else can connect to my dedicated server over the internet.
is anyone familiar with the topic?

#

this is what i'm doing atm

#

The server ip address is my "Temporary IPv6 Address"

fallen escarp
rich locust
#

you dont use get player controller

#

ever in mp

twilit radish
# fallen escarp This is how: (SR_ is server, CL_ is client multicast)

That indeed spawns them locally for all players, like I said I'm not sure what you plan to do with it but currently the issue is that the server doesn't say where the cube(s) should be because the server doesn't know about the cube(s) that clients have. Which means that any small change / imperfection could already cause different results for players which then could be again different for someone else. I would say you should just spawn them on the server and let them replicate to clients with the correct position / rotation so that the server still has authority over them, but that could give different 'issues' when you for example want to interact with them through physics or something else based on client actions.

fleet viper
#

I srsly dont understand this, im trying to store my controller for my recoil component in this variable, which is later used to add pitch and yaw. The server does store the controller and on client side no controller is stored eg. null. I just dont know anymore how to get the controller associated with this pawn on client side anymore

twilit radish
#

Is it null for the pawn that is controlled by the player playing on that device, or is it someone else's pawn? Player controllers are not replicated to other clients other than their own.

fleet viper
#

just trying to get the controller thats possessing that character

twilit radish
twilit radish
#

Then I assume it's either called too early to the point where the controller has not possessed the pawn yet or something else is wrong.

#

What are you doing with that variable when it's supposedly set?

fleet viper
#

ok i did some further testing, it is now set on the client which is good, but it still cant retrive the value in the component

#

which is very weird since the component should work on the client since the character owns the component

fleet viper
fleet viper
#

and yes its the whole time not valid

twilit radish
#

Did you check if it does get set but simply doesn't apply the rotation?

#

Or does the print string run?

fleet viper
#

print string runs

#

on client and server

#

so for both sides its not set

#

weird eh๐Ÿ˜

#

ok i might have found the mistake but not sure, the function that adds the actual recoil is just a function and all the values im printing out (to modify the recoil) are all just server sided

twilit radish
#

Where do you run AddPitchAndYaw from?

fleet viper
#

from tick directly

#

but

#

the values that are added are all coming in from a seperate function

fallen escarp
fleet viper
fallen escarp
fleet viper
#

i got it working

twilit radish
fleet viper
#

thank you so much for helping me, the problem was that the added recoil was only server sided@twilit radish

fallen escarp
#

(Transform includes location, rotation and scale)

twilit radish
steady musk
#

Hi guys. I know I can launch dedicated server with some parameters like /Game/Maps/BattleMaps/Arena_Map -log But can I use custom parameters when launching dedicated server? And if so - how can I read it?

fallen escarp
twilit radish
#

I'm not sure what your tutorial plans to do, but it was spawning them locally for each client which most likely gives different results especially over time. Which can be fine but that again depends on what you plan to do with it ๐Ÿคทโ€โ™€๏ธ

fallen escarp
twilit radish
#

I'm also still pretty new to this, also haven't done much in terms of learning for a while now so I was trying to get slowly back into it xD

#

But it has a steep learning curve if you ask me, quite a few complex topics and things to keep in mind etc. ๐Ÿ˜›

fluid summit
#

Anyone familiar with portforwarding? i'm not sure i'm doing it correctly so people can join my dedicated server

twilit radish
#

I have port forwarded before yes, but in my experience people always have different software for it build into their routers (if at all). Most of those companies have forums though, you may be better off searching on the internet for such places.

twin juniper
#

Is Windows Server Core (command line only) ideal for dedicated server deployments, or is it typical to also install the desktop experience (GUI) ?

fluid summit
#

is this okey?

#

and for the people to connect, i give them my public IPV4

#

wich i'm getting from here

lost inlet
fluid summit
#

you can get some really cheap Linux VM with linode

twin juniper
#

Iโ€™m more comfortable with Linux for servers, I was just getting the impression Windows was recommended.

lost inlet
#

by whom and for what?

twin juniper
#

Thatโ€™s a load off.

#

The docs and google search didnโ€™t seem to mention Linux much.

fluid summit
#

BillGates- Yeah yeah, got with windows.

lost inlet
#

we don't ship a linux client, but 100% of our official matchmaking servers are hosted on linux servers across bare metal and cloud

twin juniper
#

Perfect

#

Thanks for the info!

fallen escarp
#

Is it better to use custom events marked with "Server", "Multicast" or "ByOwner" or use SwitchAuthority and direct BP actions?

fluid summit
#

the switch authority works after you started the action, in order to run on the server you need to do so with the replication on the event

fallen escarp
#

So, it seems that if I call the event (marked as server) while using switch authority Server, it works on both, server and client. If I do is with "remote" it works only if clients instigate it, but not server machine.

fluid summit
#

If you call an event (run on server) it will run the event on the server and than replicate it on the client.
If inside the event you have switch authority (Server, for example) the code following will only run on the server

#

the event is fired on both, but inside the event you say "hey, only run the following if you are remote/authority"

spark stag
#

are development client builds supposed to work with shipping server builds?

fluid summit
quiet fjord
#

how much is the ms recommendation for multiplayer that I am optimizing and I do not know the values โ€‹โ€‹in which to move

#

can someone clarify for me

lost inlet
#

?

lapis zinc
#

for some reason this isnt replicating

#

it only works for server

sullen kernel
#

Any suggestions for which function to override in AGameModeBase to bind to delegates on a newly spawned player?

violet sentinel
#

but if you need after actual pawn spawn it will be a bit later, just open source

meager spade
#

@fallen escarp The advice you got given is not accurate

#

Run on server - This event is ran on the server. Normal client will not run anything from this node.

#

Run on Owning Client - If called from server, will run the event on the owning client. If called from owning client, will just run like normal.

#

NetMulticast - Has to be called on server, and will run the event on all clients.

twilit radish
#

Just wondering, is it possible to connect to a listen server through both LAN and an online system? Or can you really only have one or the other?

#

As in, some clients join from LAN, while others join from lets say Steam.

grizzled stirrup
#

Is it still a thing that if you want to use Steam leaderboards through the generic OSS interface calls such as ReadLeaderboardsAroundRank, you have to create a matching stat in Steamworks for each leaderboard type that matches the leaderboard name?

#

When using the Steam API directly, it was possible to just grab the values from the leaderboards without needing them defined as stats

#

Is this just the way the interface is implemented and making stats is the only way around it?

lost inlet
lost inlet
grizzled stirrup
#

I have it retrieving the names and correct ranks

#

But the score comes back -1

#

There are some old posts about needing to implement the scores as stats if using the OSS interfaces

#

Just was seeing if anyone knew if it's still the case

lost inlet
#

Well you seem to understand the Steam API so why wouldnโ€™t you check the implementation?

grizzled stirrup
#

I'm trying, as far as I can see, the UE interface doesn't make use of the delegate that gets returned from Steam after fetching a leaderboard but it's quite hard to track with slow intellisense

lost inlet
#

Steam callbacks donโ€™t run in the game thread so thereโ€™s a bit of boilerplate for getting the result

grizzled stirrup
#

Yeah that's the thing it hops around quite a bit

#

I think that it's just getting the rank and name directly but for some reason checking if a user has a stat matching the name of the leaderboard

#

Rather than fetching the score directly

#

Perhaps to allow for multiple stats per entry as they pass in null for the details array which is what Steam uses to store more than one value per entry

#

Looks like that is indeed the case OnlineLeaderboardInterfaceSteam.cpp line 1005

#
                // Only take the rank from here (stats grabs the actual ranked value)
                UserRow->Rank = LeaderboardEntry.m_nGlobalRank;
lost inlet
#

Pretty much all the async task implementations are in the same cpp file

grizzled stirrup
#

Yeah it's just tricky for me to see what calls when

#

Ok so after a bit more reading the code it looks like the actual "score" associated with each entry does indeed have to be a separate stat if using the OSS interfaces

#

So rather than writing to a leaderboard directly, you are writing a stat to a steam user, then writing that stat to a leaderboard entry. Then when reading a leaderboard, you are retrieving a stat matching the leaderboard name

#

A bit confusing but it seems like that's how it's set up

grand stratus
#

guys what happens if i created a run on server rpc in UI graph editor

#

does it only run for the server

#

or all the clients

grizzled stirrup
#

What does the RPC do exactly?

grand stratus
#

okay

grizzled stirrup
#

Mostly you only create UI on the client so it wouldn't run at all on any clients

grand stratus
#

i passed a player state aray

#

to the Widget

#

then i used a server rpc to type cast each element

#

cause it fails to type cast if i did not do that

#

idk why

grizzled stirrup
#

PlayerState is a replicated array so it's available on the server and client

grand stratus
#

yeah i know

#

i passed the player state

#

to the widget for each player

grizzled stirrup
#

Firstly you should retrieve the PlayerArray variable from the GameState, not pass it to the UI

grand stratus
#

i got the player state array from server and created a wifget for each player and i passed this array to it

grand stratus
#

i got my player state array from the game state

#

and then i got all actor of scene

#

with player controller

grizzled stirrup
#

Ok well there's no need for any RPCs if you just get the PlayerArray directly in the widget from the GameState and not pass anything in

#

PlayerArray lives on both client and server

grand stratus
#

and for each element i create a widget for each player controller

#

how can i get the player array in widget

#

if iam client

grizzled stirrup
#

Get the GameState and retrieve the PlayerArray there

#

GameState is replicated

#

As is PlayerArray

#

So clients can get all the info there

grand stratus
#

really

#

i thought widget dont have anyrealtion with game state

grizzled stirrup
#

There is a GetGameState node in BP, even though it has no relation to the widget, you can use it to get data

grand stratus
#

so game state is replicated for each client

#

if i cast it does it fails

#

?

#

also the client dont have the aother player states right?

grizzled stirrup
#

All clients can access other player PlayerStates via the PlayerArray variable held in the GameState

grand stratus
#

so if iam a client not a server and i get game state then cast it then got the player state and got each element then cast it

#

no problem will arise right>

grizzled stirrup
#

Yes that is fine

#

That's what GameState / PlayerState are there for

#

To query data about other players / the game

grand stratus
#

but why sometime

#

i get cast failee

#

failed

shy kelp
#

is there any way to replicate about a hundred AI Pawns without any network lag?

grand stratus
#

when i cast player state array element

shy kelp
#

because currently, im getting a lot

grizzled stirrup
#

That's the main bandwidth killer

shy kelp
#

hmm

#

can i do that with basic C++ knowledge, dont know too much

#

ykw, ill just learn the terms as i go ๐Ÿคทโ€โ™‚๏ธ

grizzled stirrup
#

In short, without custom work it'd be very hard to have 100 pawns running around in a close proximity

#

CMC code is very dense and difficult

#

You'd have to know what you are doing to write a new one

grand stratus
#

let me try that @grizzled stirrup i will not use any replication inside the widget and test if it works

#

btw

shy kelp
#

yea i can see that lmao, im having to limit cull distance severely as of now

grand stratus
#

btw if here the target was a client player actor that i got from the server

#

does this function runs on the client player actor right

grizzled stirrup
#

Ok this is very bad for many reasons

#

You have to be careful about how much data you send, when you use RPCs etc.

#

What you are doing here is sending the entire PlayerArray down as data to the client when they already have access to it via the GameState

peak sentinel
#

I didnt read the above but if whatever you're doing %99.99 of the time you dont even need to send player controller

grand stratus
#

yeah yeah if this works i will remove the player state and players state

peak sentinel
#

Server already only one who can access playercontrollers except the owning client

grizzled stirrup
#

I'm not sure why you even need an RPC in the first place: No. of imposters could be derived from the amount of players in the PlayerState array and your player controller / player state are local

#

So why not just run this logic locally on begin play of the PC?

#

Clientside

grand stratus
#

cant do it on event begin play

grizzled stirrup
#

Another important part of gameState is the namespace that gets replicated down for match events

#

Make use of that

#

So when MatchStarted replicates down

#

you can react to it

grand stratus
#

also the no of imposters happens to be in game mode

grizzled stirrup
#

Make it a replicated variable in the GS

#

An OnRep one

#

And if that's the critical info you need before running this logic

#

Run it then

#

Rather than using an RPC

grizzled stirrup
#

FName MatchState;

#

MatchState variable found in the GameState

grand stratus
#

what does it hold?

grizzled stirrup
#

Time to do some googling ๐Ÿ™‚

grand stratus
#

yeah

#

that what i did when i asked

#

hahaha

#

but lets assume that to do an rpc

#

if i did it like i showed u above

#

the target is the one going to runs it , yes?

#

i mean if i got this client player controller from the server and passed it to the target

#

the target will be the client one not the server player controller

grizzled stirrup
#

Yes

grand stratus
#

ok

#

thanks

vague spruce
#

Hi, I was told to ask this question here. Iโ€™ve got a bunch of AI actors on my level that have a health bar and I only want to show the health bar if the player has selected one of these characters. Iโ€™ve already come up with a solution, and thatโ€™s to store the selected actor on my player actor.

However, is there a better place to store this info? The tricky part is that these AI actors need to know if the local player has selected them in order to do some UI work. This info wonโ€™t need to be replicated

grizzled stirrup
#

Why not a simple bool? bIsSelected ?

vague spruce
#

gotcha, and i set that bool on the selected units?

grizzled stirrup
#

Yes, clientside

vague spruce
#

let me throw another curveball

#

let's say that i want to show all of the health bars if the player presses Ctrl

#

where would i store this bool?

#

on the player controller?

grizzled stirrup
#

No each AI will have its own bool

#

So you'd simply be setting it to true on all when pressing Ctrl

vague spruce
#

hmmmmmmmm

#

yea idk about that one lol

#

but i definitely like your bIsSelected idea

#

i'm gonna set that bool directly on the "units" client-side as i'm calling them for now

grizzled stirrup
vague spruce
#

yeah it's gonna be bIsHovered

#

for the Ctrl idea, does it make sense for these actors to be looking at the GetFirstPlayerController() and then checking a bool?

grizzled stirrup
#

You also don't necessarily even need a bool if you correctly show and hide the Ui at the correct times

vague spruce
#

@grizzled stirrup this is very true. i was going to do this on tick

grizzled stirrup
#

Why?

#

Just do it once

vague spruce
#

basically just check if bIsHovered

grizzled stirrup
#

No need, just show the UI once when you press Ctrl, then hide it again whenever you let go or press ctrl again

#

Or however your controls work

vague spruce
#

so the problem is that the health bars are stored on the actor

#

i guess i should just make the health bars public?

#

feels weird

grizzled stirrup
#

No make a function on the AI

#

public

vague spruce
#

gotcha

grizzled stirrup
#

That then will hide or show the UI

#

other actors won't need to know about the healthbar

vague spruce
#

yeah that's an interesting idea

#

and then what, when i select another actor how would i know to deselect the previous? do i keep a pointer?

grizzled stirrup
#

You also could make the AI subscribe to a delegate that the player broadcasts when pressing CTRL

#

that way there isn't any direct communication

grizzled stirrup
#

And is actually way cleaner

#

Because you won't need to get all AI from the PC

vague spruce
#

this is a fantastic idea

#

yeah, i didn't really like having to iterate on all of my actors from the PC

#

i REALLY like the delegate idea

#

i think im gonna do that

grizzled stirrup
vague spruce
#

delegates are bad?

grizzled stirrup
#

No

#

Looping oer all actors

vague spruce
#

right right

grand stratus
#

@grizzled stirrup it did not work

vague spruce
#

i have another question, but i guess i'll give it up for @grand stratus lol

#

thanks @grizzled stirrup

#

super helpful

#

i guess now that i have you i'll just ask

#

i've got some agro tables designed right now and they're working

grand stratus
vague spruce
#

but it feels fucking off. like, should i be storing agro tables on the game mode? probably not i think??

#

is there another unreal entity where the agro tables would be?

grizzled stirrup
#

What is an agro table?

vague spruce
#

yeah i have like multiple players and shit

#

and they generate threat

#

and some players are more threatening than others

#

so i have a agro table, or a threat table

#

that keeps track of who is the most important

#

and the AIs then use this threat table

grizzled stirrup
# grand stratus

Have you set your GM to use the BP_Amogus class for the player state?

grizzled stirrup
grand stratus
#

from prject settings u mean @grizzled stirrup

grizzled stirrup
#

You could also just do it per AI

vague spruce
#

it should live on the server though

#

got it

#

yeah i probably just need to have it per AI

grizzled stirrup
#

GameMode is only on server plus you can easily gate a level manger to only run things on server

#

Also AI Controllers only live on server

grizzled stirrup
vague spruce
#

i can't remember why the hell i added this functionality on the game mode... there has to be a reason

grand stratus
#

let me check

vague spruce
#

now that i think of it, this freaking sucks. i'm gonna change this. thanks @grizzled stirrup , back to coding!

grand stratus
#

u mean this right

grizzled stirrup
#

Yeah that's correct so it should iterate through playerstates, log to verify

grand stratus
#

casting fails

#

so i log when it fails

#

it fails

#

@grizzled stirrup game state fails in cast

#

btw as i said this happens on client side and in user widget BP

twin juniper
#

Hi, how would you do a "position correction ogic" for pickups ? Like i'm dropping two items and i want them stack on top of each other and instead second pickup move to a defined distance from the first pickup

#

Im thinking about sphere traces to get all pickups in the player field and then get their position and take the one that will be close from the pickup dropping pos ?

#

But what if there is another pickup close from it, a third one ๐Ÿค”

tacit bough
#

I'm trying to get basic movement replication working. I'm trying it out with crouching. It's working when the player is the server but nothing happens when they'r the client.
What am I missing here?

thin stratus
#

Iirc crouch is already replicated through the CMC

#

You don't need all of this

#

It doesn't work for your client because you are executing it only on the server

#

The CMC replicates it through the flags it sends to the server each frame. So setting it on the server for the client is pointless and wrong

#

@tacit bough

thin stratus
#

Or you step into cpp and craft yourself a callback for when the GameState is available

tacit bough
hoary apex
#

anyone know of an open source implementation of a master server (Server browser) for UE4 i'm using one from the marketplace i got a while back but it isn't written great i've had to hack and slash to get it to even work, it has no external IP detection so servers report the NAT IP if not public, also the plugin itself only supports IPs for exxample the master server connection is hard coded to the IP which i think is bad since that could change.. I know there was an old github project that used python to acomplish this but it is brokken for 4.26 just wondering if anyone knows of anything i don't

bitter oriole
#

"Hi I'm a server he's my IP and map and player count"

#

"Hi I'm a client what's the server list"

#

"Hey here's the server list"

thin stratus
#

Yeah the biggest code part is the handling of settings, player sessions, player count etc.

elfin sail
#

/Source/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/GarbageCollection.cpp] [Line: 885] Invalid object in GC: 0x00067f6f00067f6f, ReferencingObject: PlayerCharacterController /Game/AlWathba/levels/TourdeFrance/UEDPIE_0_TourDeFrance.TourDeFrance:PersistentLevel.PlayerCharacterController_0, ReferencingObjectClass: Class /Script/PhotonDemoParticle.PlayerCharacterController, Property Name: MyGameController, Offset: 1640, TokenIndex: 42

tacit bough
elfin sail
#

my game controller collected by gc after 4 5 seconds

#

any idea why

bitter oriole
#

No other live object owned it through UPROPERTY

elfin sail
#

yes its UPROPERTY

#

is it replace by default playercontroller ? i think

bitter oriole
#

That's not really a thing

#

How did you set up your player cotnroller class ?

elfin sail
#

in G mode ?

#

this property

#
UPROPERTY()
        class UMyGameController* MyGameController;
thin stratus
#

Why do you use an extra class/pointer though?

bitter oriole
#

You change the player controller class in game mode settings

thin stratus
#

Is this a PlayerController?

bitter oriole
#

So show the line in your game mode constructor

thin stratus
#

What you are doing there seems wrong. You don't need a pointer to the PlayerController

#

The GameMode has a class variable for it and spawns it for new players

bitter oriole
#

All you need to change the PC class is one line in GameMode's constructor

thin stratus
#

That is automated

elfin sail
#

i am working on it in between

bitter oriole
#

Look : the only line you need is in GameMode's constructor

elfin sail
#

no think i found it

#

its related to game instance

bitter oriole
#

No, it is not

elfin sail
#

        MyGameInstance = ((UMyGameInstance*)World->GetGameInstance());
        if (GetLocalRole() == ROLE_AutonomousProxy)
        {
            MyGameController = MyGameInstance->myGameController;
            HardwarePlayerPower = 0;
            HardwarePlayerRPM = 0;
            HardwarePlayerBPM = 0;
        }
#

and change my game instance

#

like it is test game instance

bitter oriole
#

Okay, I have no idea what you're doing here so I'll leave it up

elfin sail
#

okay thank you

lapis zinc
#

is the server supposed to jitter from the clients view?

#

like in the editor

elfin sail
#

yes it will do

bitter oriole
#

Better test in standalone

elfin sail
bitter oriole
#

No

elfin sail
#

you have to write code to sync

#

or lerp kind of solution

bitter oriole
#

It happens because you have multiple PIE viewports and the ones you don't focus simply run at low framerate

#

Don't test your multiplayer code in PIE

elfin sail
#

it's not just related to frame rate

#

you sync data is one the major reason for jitter

bitter oriole
#

No shit

elfin sail
#

okay

meager spade
#

PIE jitter is a known issue

#

we never rely on PIE testing, always do standalone, proper internet tests.

bitter oriole
#

PIE is just not a serious test case for multiplayer in any scenario

meager spade
#

PIE is strange sometimes..

elfin sail
#

i was having the same issue but i solve it with syncting script

meager spade
#

if it was a player, then its likely rubber banding due to corrections

chrome bay
#

Also in editor sometimes the extremely high framerate can cause banding too because the saved move buffer on CMC overflows

meager spade
#

^

bitter oriole
#

The point is that PIE will create an insane amount of rubber banding that has no relationship with reality

#

So just don't do PIE

#

Use standalone and test carefully there

meager spade
#

Use pie to make sure things work, but never rely on it. Real world testing is the only way.

#

you can do it with LAN and multiple pc's, just setup a way to create some latency.

bitter oriole
#

Or just use standalone with packet lag ini settings and you have 95% of real world issues

meager spade
#

i still don't trust that, cause we have seen stuff we could not produce with any packet lag/packet loss in editor

#

and only happened in live testing

bitter oriole
#

Yeah, of course

meager spade
#

Replication races/connection issues, urgh, those were fun days debugging.

elfin sail
#

by the way it never worked for me until I use lerp or sync algo some kind

bitter oriole
#

Just start with a serious setup in standalone with 50 pkt lag (which means like 130 ping) and you can safely develop your multiplayer code in a decent real-world approximation, without PIE bullshit, and with a joining scenario that's more likely to happen

#

No shit you need to lerp stuff

meager spade
#

BTW, the ability to hot join into a running pie session, is good for rapid testing your stuff is working

#

shame not many people know how to turn on the "Add Client" button in UE4

elfin sail
#

it's rubber bending happen when cross the player

meager spade
#

see ^ point proven ๐Ÿ˜›

peak sentinel
meager spade
#

editor settings -> experimental -> Late join iirc

peak sentinel
#

Found it, thaks

meager spade
#

ye

#

then you can late join clients into a pie session

#

good for testing those OnRep's/states.

peak sentinel
#

Yeah, very useful

chrome bay
#

OMG wut

meager spade
#

has some issues, like randomly can crash, etc (might be fixed in 4.26+) but 4.25 has some quirks, but overall, its fine.

chrome bay
#

I never knew about that ๐Ÿ˜„

meager spade
#

.. ๐Ÿ˜›

#

when i found it, it changed everything

#

honestly, when working on a multiplayer game, its so handy

#

making sure the client generated the same procedural map

#

was the big use case for it

chrome bay
#

Yeah can see how it would be useful for that for sure

meager spade
#

even making sure the world state after things have been destroyed/blown up is correct.

peak sentinel
azure hollow
#

how to compress a struct of location and rotation into binary data? I need to send this to the server

#

tried with JSON but it's way too heavy and I don't think it's the right solution

chrome bay
#

Well JSON is always going to be the worst way to send anything because it'll be strings

#

When you say server do you mean a UE4 server instance or something else like a MySQL etc?

#

If a UE4 server, just send it as a parameter of an RPC

azure hollow
#

sorry I mean Playfab backend...we use that one to store data

#

it's my first time with networking and compressing data

chrome bay
#

Oh no idea in that case RE playfab

azure hollow
#

but the struct serialization it's something I have to do in ue4 so...any way to do it?

bitter oriole
#

Unreal has struct serialization built-in for USTRUCTs

azure hollow
#

any doc I can read? first time with this topic

chrome bay
#

You just need an FArchive of some kind to actually put the data in

azure hollow
#

well I'm more confused than before now haha

bitter oriole
#

Assuming USTRUCT, UPROPERTY

grizzled stirrup
#

I'm having the same issue, did you ever find a solution without having to directly use the Steam API?

#

I got a test variable / leaderboard to write but setting up a new one identically nothing happens

#

Did you ever find a solution to this without using the SteamAPI directly?

grizzled stirrup
#

Ah it's annoying because I had it working perfectly using the Steam API but I'm moving back to only use generic interfaces.

#

Weirdly it works fine every time when calling it from the PC on begin play

#

But not in a session

#

I'm thinking that the SessionName passed into the LeaderboardsInterface->WriteLeaderboards func may be messing with it

brazen sluice
#

Hello, is there a way to increase the size of the reliable RPC buffer

bitter oriole
#

Please don't multipost

brazen sluice
#

I was literally asked to ask here ^^'

bitter oriole
#

Ah, right, nevermind then

brazen sluice
#

no problem

azure hollow
brazen sluice
#

Im guessing ServerMovedPack and ServerUpdateCAmera are UE stuff I dont have control over

bitter oriole
azure hollow
#

it's ok in c++ I just don't understand how to place this

bitter oriole
#

You asked for how to serialize a struct into binary so I take it you have a struct, and binary output

azure hollow
#

I just need to compress this struct and send over to playfab ๐Ÿ™‚ I can't understand exactly how it to move the struct into bin

bitter oriole
#

That part is the code I gave you, the variable Output is an archive storing the data

azure hollow
#

ah ok great

#

thanks

grand stratus
thin stratus
#

Yes and no

#

Yes it make not have replicated yet

#

and no, this is should never be fixed via delays

#

Nothing in Multiplayer should

grand stratus
#

Then what should i do

#

How i check the i have the game state now? For client

bitter oriole
#

You can simply check that it's valid

#

Or you can have each value in the game state have an invalid default value, and don't do anything until each value is not invalid

grand stratus
#

okay