#multiplayer

1 messages ยท Page 671 of 1

mellow gate
#

I'm not really sure of the final gameplay design for them

rocky stag
#

Yes. I know but I'm worried about my game server CPU performance because I used replicated properties for some sort of fire and forget data using push models instead of reliable rpc's . just worried about replicated property counts because of the iteration count of the replicator. should I ignore the overhead?

empty axle
rocky stag
empty axle
lost inlet
#

uh RPCs are fire and forget

rocky stag
lost inlet
#

the whole point of push model is to forego the property comparison each frame overhead

#

so I would call whatever problem you're describing as completely imaginary

rocky stag
lost inlet
#

you called them that, not me

#

well push model as fire and forget

#

which it isn't

empty axle
#

if you don't have a problem with performance don't do a premature optimization if you are not experienced and can kind of predict where problems might be, it doesn't make sense

rocky stag
#

did you ever had trouble with replicated property count ?

#

Thanks for your guides anyway . I'm gonna take it easy ๐Ÿ˜

quasi tide
#

RPC for fire and forget
Replicated Prop for state changes

rancid flame
#

I have a server function that is called when a player picks up an item, it checks whether they can pick it up and then adds it to their inventory, which is a TArray marked with Replicated.
I want to notify the player's UI that their inventory has changed. I usually do this with a Delegate that the UI subscribes to. The problem is when I call OnInventoryChanged.Broadcast, I think it's doing it on the server, so the client isn't notified.
What's the "correct" way to fix this?

meager spade
#

i actually used a fast array serializer for the inventory

#

it has client side callbacks when an item is added/removed/changed

#

check NetSerialization.h

#

only way when using bog standard TArray, is make it ReplicatedUsing and handle it inside the OnRep_Inventory function.

rancid flame
#

@meager spade Thanks! It's more of a question about how to tell clients that certain stuff has changed on the server. Like I just want to tell the client that owns that inventory component that a specific item has changed. I usually do that with delegates.
I guess I could get the server to do a NetMulticast function, and then that function calls the delegate? it's juts kind of gross

meager spade
#

like i said, FastArraySerializer

#

is your friend

#

@rancid flame its how we do our inventory, its likely also how Fortnite does its inventory

rancid flame
#

@meager spade Thanks, I'll look into this some more then!

#

A separate question: I'm spawning an actor and it's showing up on the Server (when playing as listenclient) but never on clients.
Are there any usual culprits for this?

meager spade
#

is it set to Replicated?

#

Is relevancy good?

rancid flame
#

It was replicates in the Actor settings ๐Ÿคฆ

grizzled flicker
#

if some1 can help me figure this out that'd be amazing

#

client 1 shows proper cape colors/materials. the other clients always show the same color on all 3

#

I attempted a rep notify w/ bool check based on team as well and that just made so all 3 clients showed same color, either red or blue

sinful tree
#

If you have a boolean set up with Rep notify, then on the OnRep function, set the material you want to use.

#

Also make sure you're setting the boolean on the server.

dark edge
#

Do wut

#

U sure about that?

sinful tree
#

That's not how it works currently in BP. You can set a rep notify variable on the client, but it doesn't update the server's value.

#

That's a good question, but I doubt it.. Lemme try :p

#

Yes it does o_o

#

And yeah, if you're not careful, and set the value on the client first, you won't get the repnotify when the server sets it.

#

BUT if you're smart you're not setting replicated variables on a client anyway.

grizzled flicker
#

or is it essentially grabbing the 'local player' node and using that ?

sinful tree
#

The repnotify can then be used to perform whatever actions you want to do when that value is altered. So if you have a boolean called "Blue Team" and all players start with red coloring, then you can make it so it switches the colors to blue if "Blue Team" == true, and red if "Blue Team" == false.

grizzled flicker
#

so this?

sinful tree
charred crane
#

If I spawn a replicating actor on the server, unless i gate its own logic behind a server rpc, it could spawn things on clients through natural spawn calls right?

sinful tree
charred crane
sinful tree
#

It is. What you're trying to do is run an RPC from an actor that the client doesn't own.

charred crane
#

Does an authority switch mean that when the authority section runs, that it's running on the server or that the entity running the logic owns the logic?

#

I had the warning for this section of code, then i added in the authority switch, and the error stopped. Is this the solution or am i masking an issue?

sinful tree
#

An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.

Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe

00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...

โ–ถ Play video
#

Even tick on its own runs on both the client and the server.

#

So when your actor exists on the client, its event tick will play, and it'll start calling that Server RPC. Since the actor is not owned by the client, the RPC fails giving you that message.

charred crane
#

Okay, that makes sense. that 15 seconds was exactly what i needed lol (at least to understand the authority node)

#

Here's another example of a place where there's the warning. I could again throw all of this logic behind an authority switch and it would most likely be resolved, correct?

#

Because both the server and client instances of the pawn overlap with the box?

#

This is a monster spawner, would it even need to replicate?

sinful tree
# charred crane Because both the server and client instances of the pawn overlap with the box?

Correct.
And the monster spawner probably wouldn't need to replicate itself, as the actors it spawns themselves would be replicated.
The other thing is, you shouldn't be using "Run on Server" events unless you're trying to send data from a client to the server, and that's usually only needed to be done on the player controller, the player's character, and possibly player state. One could do it on other "owned" actors, say for example, a Pet AI the player has some control of, or any other AIs that are controlled by the player in some way, like units in an RTS game.

The HasAuthority node is your friend in this case - you usually only want the server to be running code on your actors in your game, not necessarily the client, and definitely not the client telling the server what to do (unless you intend for the player to do so of course!)

charred crane
rancid flame
#

This is a real shot in the dark but I'm seeing something really weird. When I play in editor on a test map, sometimes when a client picks up an item it instantly changes the client back to the project's Game Default Map. Like something bad happened so the server disconnected the client.
Is there somewhere I can set a breakpoint to see what's causing this?

sinful tree
rancid flame
#

I also just read that a UFUNCTION() RPC with WithValidation will kick a client if the validation fails, so maybe it's that

sinful tree
#

Oh yea for sure - if that doesn't return true, it's a boot.

rancid flame
#

OK that's not the kind of validation I was expecting heh, I just thought it wouldn't run the function

woeful pebble
sinful tree
#

Hide current weapon > Swap to new weapon > Set Current Weapon > Show current weapon

woeful pebble
#

i check if the weapon is valid hide the weapon and set the new weapon to my index variable this is off of on rep and then i show my new weapon

#

please help

#

when i set the current weapon with notify it breaks

#

the visibility breaks

#

see i am setting the new weapon's visibility to true once i set the current weapon to my index

sinful tree
#

You didn't have that full path connected in your video.

woeful pebble
#

I know

#

but i do

#

i was showing the tests i did

#

but please help i think this is a bug

#

on event begin play on the server i spawn the second weapon and add it to my array

sinful tree
#

Can you explain what happens or post a video when the full path is connected?

woeful pebble
#

Yes

#

on the server it works perfectly

#

on the client nope

#

if i unhook the set notify of the current weapon it hides the weapon im currently holding but once i hook up the set notify of the current weapon the visibility doesn't change it stays the same

#

did i do something wrong @sinful tree

#

this is what im doing on the on rep of my current weapon @sinful tree

#

this shouldn't be breaking my code

sinful tree
#

Can you show the code that's before this on your First Person Character?

#

Looking for the triggering event

woeful pebble
#

Yes

#

im spawning the default weapon class, primary weapon is being spawned here @sinful tree

#

and i added it to the array

sinful tree
#

What are you doing on the remote path?

woeful pebble
#

hiding the secondary weapon

woeful pebble
#

and all the logic and line tracing works properly the visibility is being broken

sinful tree
#

That's all? Secondary weapon probably wouldn't exist yet as it's further down the spawn weapon server path that you create them - that's probably those errors you're getting (I know that's a separate issue and doesn't really correct the issue you have with hiding).

I'm asking as it may be your references being mixed up somewhere. I was thinking that you possibly were spawning the weapons client side as well as on the server - the Executes on Server and the Has Authority should ensure they are being spawned and being added to the array on the server though.

woeful pebble
#

what do i do man i still don't get it?

#

@sinful tree

#

im using switch has authority which literally does what you are saying

#

there is def a better way of doing this? how does the shooter game do it

sinful tree
#

The only thing it looks like it could be is your references are likely being lost in the code you've made - you already have a Primary Weapon Ref, and a Secondary Weapon Ref, and you're also using a current weapon ref, then you have your weapon array ref.

Perhaps approach it differently? Like if you know you're swapping to weapon index 1, you know that's your secondary weapon ref, which means you'd want to hide all other weapons and show the secondary weapon. You may not need to use the replicated array at all.

#

(Above just showing that you can hide multiple meshes at once if you ever intend to have more than 2 weapons)

woeful pebble
#

I might try a different method

#

i am looking into the code of the shooter tutorial

sinful tree
#

Like something as simple as changing a "Selected Weapon" variable on the server to do something like this with the onrep

woeful pebble
#

how can the visibility not change?!?

sinful tree
#

I'm doing exactly what you're looking to do, and it works on my end. This spawns the replicated actors on begin play.

Pressing the "2" button swaps the visibility between two without issue using the OnRep function I posted just before this.

meager spade
#

isn't visibility already replicated?

#

it 100% is

#
    UPROPERTY(EditAnywhere, BlueprintReadOnly, ReplicatedUsing=OnRep_Visibility,  Category = Rendering, meta=(AllowPrivateAccess="true"))
    uint8 bVisible:1;```
#

no need for the onrep

#

just have server adjust the visibility

#

@woeful pebble

#

ensure your weapon is "Replicated" also

#

oh and you need to replicate the static mesh component for this to work also

woeful pebble
# meager spade just have server adjust the visibility

never mind the question i asked, i have a variable in my weapon blueprint called "bisequipped" this variable is rep notify in the rep notify function i basically set the visibility of the first person and thirdperson gun. i set the value of this variable in a server event :D

#

i hope i did it correctly cause it was working :D

meager spade
#

sounds good

#

tho personally

#

i prefer the weapons to handle this logic

#

and not put everything in character, so what you did is good.

woeful pebble
#

the weapons? well that variable is in the weapon bp and not character bp

#

thankfully

kindred widget
#

I actually had to override that visibility replication in RS2 to let client handle their own visibility. ๐Ÿ˜„ I didn't know it was replicated until then.

woeful pebble
# meager spade sounds good

setting the visibility on the server doesn't replicate to the owning client sadly basically in the first person view the visibility will not change only in the third person view since it's being called on the server im guessing...

sinful tree
#

You have to set the mesh components to replicate too if you're only setting on server.

meager spade
#

i avoid replicating un-needed components tho

#

and what you did with equipped bool, works well

woeful pebble
#

yeah

meager spade
#

and is similar to how i do weapons.

woeful pebble
#

i saw the shooter tutorial and it basically called the unequip function in the weapon bp

#

when you switch

woeful pebble
#

why does my firstperson gun of the server show up on the client's screen? is it cause of irrelevancy?

#

this only happens sometimes and not all the time?

#

never mind it's cause i wasn't using my rep method that one works very well and will update on every client that joins later

rich dune
#

Anyone here know how to make a rotating door in Multiplayer not lag that hard? I use Component Move to rotate the door and If I rotate them first on the client and multicast it to other clients is smooth on the first client who interacted with the door but all others have a lag on the rotation and it's not smooth.

While testing in editor it's all fine but even with a ping of 4 to a real server the doors is visibly lagging.

Any idea?

bitter oriole
#

In the case of a door, you should replicate the door state alone

#

"open", "closed" - and then animate the door entirely locally

rich dune
#

Ok I'll try that

winged badger
#

@rich dune multicast also doesn't really work well

#

say, im 15k units away when you open door

#

that door is not relevant to me, and i won't get the multicast

#

so my door remains closed

dim flame
#

hmm if I want a weapon to deal damage during parts of an animation through line traces on the server

#

are animnotifies workable?

#

or do I have to use delay?

#

currently doing it with notifies

#

but if server is laggy it doesnt fire the traces

winged badger
#

also, anim notifies tend to be optimized out

#

dedicated server can be made to run them

#

but listen server will not run anim notifies if they are outside what host iis looking at

#

you need montages for that

#

you don't need to use delay, and server is perfectly capable of running traces

dim flame
#

i fixed that part

#

temporarily

#

forcing the server to update bones anyway

#

because my dmg and everything is based on the bones

winged badger
#

listen or dedicated?

dim flame
#

listen

winged badger
#

you have to swap to anim montages

dim flame
#

i am using montages

winged badger
#

k

dim flame
#

the client only sends the run on server when attacking

#

and the server plays the animation multicast

#

and the animnotify on the server gets skipped if its skipping frames

winged badger
#

the way we distinguish them, we'll call then montage notifies, not anim notifies ๐Ÿ˜„

#

because there is a significant difference

dim flame
#

ah

#

sorry

#

bit new to unreal XD

winged badger
#

with listen server

#

the clients CMC is running the TickPose

#

for their pawns

#

so their animations won't tick if the client is slow either

dim flame
#

hmm I guess my problem isnt mp related per say

winged badger
#

as it happens on frames when movement update arrives

dim flame
#

its just fps dependent collision

winged badger
#

CCD?

dim flame
#

im running line traces every tick from a weapon during parts of an animation

#

from the last position of a few points on the weapon to current

#

yeah nvm

#

its my fps dependent collision

#

server client stuff working fine

#

client can lag, server will run the things

winged badger
#

framerate smoothing?

dim flame
#

but server lags and it misses the collisions

winged badger
#

with traces each tick, that shouldn't happen

dim flame
#

if the tick is too big

#

the traces never start...

#

cause it doesnt seem to get the montage notify

#

since its between ticks

#

atleast thats the way it seems to me right now

#

would have to run prediction/sim on the movement to disconnect it from fps I suppose

lost dune
#

Why my character is jittering on movement? I set the max walk speed on client and server with the same value ( and i have no ping)

dim flame
#

when do you run this

#

there might be no pawn?

#

print string on cast failed?

#

or controlled pawn is valid?

#

or print after set

#

with the value

kindred widget
#

@CoolAnswerMe#0294 Do this in the Pawn, not the controller.

dim flame
#

i use onrep variable for this

#

and just change a bool/enum for different movement states

#

and call the movement change in onrep

#

in the pawn

#

hmm

#

is there a way to get the last value of an onrep variable on rep?

#

built in that is

chrome bay
#

Not in Blueprint but yes in C++

#

You just add the type as a parameter

#

In Blueprint you would have to keep a shadow variable

dim flame
#

ah

#

i guess i'll convert part of it to c++

#

ty

chrome bay
#

Also bear in mind BP OnReps aren't really on-rep callbacks. They do dumb things like firing on the Server too, or firing when the client changes something locally

dim flame
#

wait

#

you mean it fires on the client if it changes locally yes?

#

not on the server

chrome bay
#

Yeah, which is terrible

dim flame
#

mm

chrome bay
#

If the server changes the value it will fire on the Server too, though

dim flame
#

no simple way to change default behaviour on that?

chrome bay
#

Not in BP

dim flame
#

no problem working in c++, but havent done much of it for unreal

chrome bay
#

I have no idea why Epic chose to make it work that way (not sure anybody does tbh), but it does

#

But just bear it in mind the logic is a bit more sane in CPP

#

But it may change the implementation slightly

dim flame
#

good

#

dont have to make my own rep functionality then

#

I suppose you could put an auth switch in the onrep function

#

but efficiency :/

#

for the issue with it running on server

raw drift
#

Hello, I'm having trouble with a multiplayer game

I created a function inside a BP like a door or a light that display a widget when you focus on it..problem is, the widget display on everyplayer on the server..

Is there a way to display it only on the player who is looking at it ?

There is an example with a door.

dim flame
#

should be doable with rendering option no?

#

only owner see

dark edge
dim flame
dark edge
dim flame
#

owner of child widget actors for client is client for a possessed pawn afaik?

dark edge
#

The problem is that that logic is being triggered everywhere. Widgets don't replicate anyway.

#

Event On Focus needs to run ONLY on the local client doing the focussing.

dim flame
#

thats why you update it with onrep variable no?

#

or multicast/run on client I guess

#

depending

raw drift
#

On focus is called on even tick like so, on my character

dim flame
#

update the clients version with the new visibility options, or create it on the client based on an onrep variable or run on client/multicast call?

#

hmm, the door could run code after switch auth remote on getting focused, creating widget?

raw drift
#

before sequence ?

dim flame
#

mm

#

and the server could create it with only owner see on auth?

#

maybe

#

there are probably better solutions

#

but that would work for a listening server in my mind

raw drift
#

i'll try

meager spade
#

make your tick do a line trace on if its locally controlled

raw drift
#

Somehow it does work, as player 1 is now the only one who see it, but if player 2 or 3 focus on the door, it still display on player 1

meager spade
#

only*

dim flame
#

yes

#

combine that with kaos suggestion

dim flame
#

or hmm, with that switch

#

you wont need mine I think

raw drift
#

SO SIMPLE !!

#

Can i get you anything? Cofee, 20000โ‚ฌ ?

#

thanks much i've been struggling on this for days

meager spade
#

dang ill take those Euros lol jk,

dim flame
#

deal

#

Kappa

meager spade
#

least ya sorted it now ๐Ÿ˜›

dim flame
#

mm you shouldnt need the on auth switch before sequence

#

with that

raw drift
#

Yes i don't

#

it's working well now

dim flame
#

it will just make you need seperate code for server

#

nice

raw drift
#

this community is really the best

#

others came with extremely complex solutions that don't even work

meager spade
#

years of experience some of us have ๐Ÿ™‚

raw drift
#

Then u might help me for a small thing if u like maths :p

meager spade
#

urgh no ๐Ÿ˜›

#

i try to avoid that

raw drift
#

too bar :

#

bad :p

raw drift
dark edge
dark edge
raw drift
dark edge
#

What you have right now is every character on every client is checking if they are looking at an interactable actor and showing the widget if they are. What you want is that only YOUR locally controlled character on YOUR screen does that, none of the other ones

dim flame
#

just scroll down ๐Ÿ˜‰

rocky topaz
#

I need some advice on how to have smooth wall running/climbing

#

I've been thinking about having volumes that would allow that and the movement component would check if the actor overlaps any of these volumes

#

And then set the current mode to wall running/climbing if it's overlapping and unsets it if doesn't overlap any volume

dark edge
#

The movement component doesn't have to poll for that, just hook into the event overlap for the capsule

rocky topaz
#

But overlapping actors are stored somewhere aren't they?

dark edge
#

Just have an integer that goes up by one on begin overlap with a volume and goes down by one on end overlap with a volume

rocky topaz
dark edge
#

They are but you already have all the info you need to detect when you begin and end overlapping a volume of whatever class you want to filter by, just keep a count of how many you are overlapping

#

On begin overlap, increment the integer, check if it's greater than 0, set while running mode.

#

On end overlap, decrement the integer, check if it's greater than 0, set wall running mode

#

Technically you don't need to check the integer on begin overlap but whatever

rocky topaz
#

Yeah, I see

#

Where would this be done though?

#

On the server? Autonomous proxies? Or both?

#

How can I make it smooth?

dark edge
#

It is not simple, at all. Especially in multiplayer. For single player things are a lot easier

golden nest
#

Hi, does someone know if action inputs executes for both server and client or client only?

lost dune
#

My character movements are still replicated jittered , while i'm having the same character movement on client and server

#

And no ping

#

ping = 30

dark edge
lost dune
#

Just walk around , i think this is a framerate dropdown

#

i have only 17 fps

#

is this normal with a dedicated server working behind?

dark edge
#

Loool

#

Uh

#

Ya that'd be a problem

lost dune
#

is this normal for a simple map with 10 monsters and a character?

dark edge
#

What's your CPU, ram, and GPU?

blazing talon
#

Im trying to add an acceleration penalty to landing. Right now i have a one second timer that starts right when the player lands. i overrode the GetMaxAcceleration() function to use the elapsed time of this timer to use as an alpha to lerp between a acceleration multiplier of 0.2 to 1.0. If the player has just landed, calcvelocity calls getmaxacceleration which returns the max accel multiplied by the lerped penalty multiplier. Any idea why this implementation would cause net corrections?

#
{
    float MaxAccel = MaxGroundAcceleration;

    if(IsSliding())
        MaxAccel = MaxSlideAcceleration;
    if(IsFalling())
        MaxAccel = MaxAirAcceleration;
    if(bEnableLandPenalty && JustLanded() && !IsSliding())
    {
        const float TimeSinceLanded = GetWorld()->GetTimerManager().GetTimerElapsed(LandedHandle);
        if(TimeSinceLanded > KINDA_SMALL_NUMBER && TimeSinceLanded < (1.0f - KINDA_SMALL_NUMBER))
        {
            const float AccelPenalty = FMath::Lerp(LandAccelPenaltyMultiplier, 1.0f, TimeSinceLanded);
            if(AccelPenalty > (KINDA_SMALL_NUMBER + LandAccelPenaltyMultiplier) && AccelPenalty < (1.0f - KINDA_SMALL_NUMBER))
                MaxAccel *= AccelPenalty;
        }    
    }
    return MaxAccel;
}```
lost dune
#

@dark edge cpu = i5 , ram 32 Go , Gpu = rtx 2060

golden nest
#

What does it mean "Is locally controlled" for a PC?

dim flame
#

directly controlled by the local machine

#

the machine thats running it is also responsible for controller input

golden nest
#

It will return true if i run it on the server player?

dim flame
#

for the server yes

#

if you run it for the server player on a client no

#

or any other player

#

only returns true for a pawn that is controlled by the local machine

golden nest
#

So i have this logic

#

But the server does not spawn the "ProtoBoard"

dim flame
#

hmm

#

any conditions in parent beginplay?

#

but yeah

#

if a player spawns on your server

#

that wont return true

golden nest
#

No conditions neither assosiated logic whit the spawned actor

dim flame
#

cause the player is remote

surreal plaza
#

If I have multiple actors attached to a parent actor, and then move only the parent, does only the parent's transform get replicated, or do all of the children change too?

dim flame
#

that actor is controlled by another machine through a network

#

ergo not locally controlled

#

does it spawn for the servers pawn?

golden nest
#

But each player has it own PC

dim flame
#

yes, with this switch you should get the protoboard for every local machine but they wont replicate to the others, right?

golden nest
#

Yeah, that's what i'm looking for

#

it's true for clients

dim flame
#

oh

golden nest
#

but server does not have it's protoboard

dim flame
#

begin play

#

try adding a delay

#

maybe its being called before controller possess

golden nest
#

Ok

#

I have another problem

dim flame
#

might be better to run it OnPossess

golden nest
#

Will try that

#

Do you mean execute all the logic on the begin player on Possessed?

dim flame
#

make it a function or something and then call it OnPossess in the controller

#

or

#

in the pawn

golden nest
#

Ok

dim flame
#

beginplay can do things too early alot

#

esp with level streaming etc

#

on possess happens later

golden nest
#

The input for "Is local player controller" will be the output of "On possess?

dim flame
#

just make everything after "parent beginplay" run on possess instead

golden nest
#

ok

#

will try

dim flame
#

should work, cause afaik is locally controlled should DEF be true for a pawn controlled directly by the listening server

golden nest
#

That works

dim flame
#

but i've had alot of problems doing things in beginplay

golden nest
#

Thanks โค๏ธ

dim flame
#

no problem

golden nest
pearl jasper
#

Hey guys, does anyone know how can I add a second cursor for local coop?

dark edge
#

GPU is the bottleneck but that's a bad game thread time as well.

lost dune
#

@dark edge thank you that was the corrupted Foliages

#

In advice for everyone DON'T use static meshes as foliage

#

prefer always create a foliage type

dark edge
#

Let me guess they all have translucency as well

#

Overdraw hell

rocky topaz
#

even within the component itself things are often handled differently

eager jolt
#

any ideas?, when the client shoots the host it moves the model of the character but the actor stays in place

meager spade
#

those get actors of class tho ๐Ÿ˜›

eager jolt
#

thx i tried

#

u know @meager spade xD

meager spade
#

why dont you cache the spawnpoints in the gamemode

eager jolt
#

mans too dumb to know how

meager spade
#

our spawn point bp on begin play just adds it self to the gamemodes cahced player starts array

eager jolt
#

thats cute ngl

#

ive found the host can "death event"people

#

but client's cant do it properly

dark edge
#

Just have a spawn point array, get random

dark edge
eager jolt
#

how would i go about that?

#

@dark edge

#

the spawn points are just for ease because im not an advanced coder

#

this is my first multiplayer game

#

and i just wanna get the mp side of things working

dark edge
#

That's the very basics of a networked game. Find a multiplayer tutorial and start from the beginning.

#

Honestly if you're completely new, I do not suggest trying to do multiplayer right away.

eager jolt
#

ive tried this guy's videos

#

he's said to use custom events then set them to replicate on server

#

ive used UE4 before and made a few games now

#

i got a simple demo level working with MP

#

and ive got a parkour & sliding system working

#

its purely the death that i cant get to replicate properly

dark edge
#

Death should be a thing that happens on the server and is replicated out. A client should never say "that guy died". The server calls the shots on that.

eager jolt
#

should the host also be a player who's playing

dark edge
#

That's a listen server.

eager jolt
#

yh

#

thats the one im doing rn

dark edge
#

That's all sorts of fucky. All of that code should only be happening on the server.

eager jolt
meager spade
#

and you should really do that via the GameMode

eager jolt
#

ive disconnected the two

meager spade
#

the moving to spawn points etc, has no reason to be in the character bp

dark edge
#

The RESULTS (the fact that the character is teleported) are replicated.

eager jolt
#

this screen?

dark edge
#

Honestly it's all screwed up. Start from the beginning.

eager jolt
#

ok

#

so im using a line trace for hitscan shooting

#

when it hits a player

#

it casts to them and tells them to set their replicated variable to dead

dark edge
eager jolt
#

how should i redo this?

#

on every client and server

dark edge
#

Casting is basically checking if a thing is of a certain class.

eager jolt
#

yh

dark edge
#

"Is the hit actor a character?" Is what casting is doing.

eager jolt
#

ok

#

i get that

dark edge
#

The absolute simplest mtiplayer shooter I can think of goes like this.

Client does line trace.
Client tells server "I hit that guy"
(Optional) Server checks to make sure client isn't cheating
Server kills hit guy and respawns him

eager jolt
#

ok

#

ill try that

#

how would i say which guy?

#

should i still use a "cast to"

#

what code should i be running? a custom event?

#

btw i do really appreciate your help ๐Ÿ™‚

dark edge
#

Line trace
Cast hit actor to character class
If it was a character
Tell server (run on server event)

#

Events can have parameters. Make the parameter for the run on server event a Character reference.

eager jolt
#

what input type should i use?

#

ahhh a character ref

#

one of these?

dark edge
#

Yes. Should be reliable too.

#

Things that happen rarely should be reliable. Things that happen all the time (on tick or whatever) should not be.

eager jolt
#

is this how i should get my obj ref?

dark edge
eager jolt
#

im not sure

#

sorry to be difficult ๐Ÿ˜ฆ

#

thats the other side of the line trace

#

i think its working but theres a few hiccups but that might just be the rng of the spawn choser

dark edge
# eager jolt

Why are you replicating that shoot? We're doing client side shooting here

eager jolt
#

ah ive disconnected the shoot from the line trace

dim flame
#

I assume you want to be hitting the capsule?

#

or did you want something more accurate?

charred crane
#

If I want something to be multicast and then after that finishes, have something ONLY run on server, is this the correct way to do it?

meager spade
#

that would cause all clients to run that

#

if thats intentional sure.

quartz smelt
#

Why not just spawn the acid bomb on the server? It looks like the animation would be replicated, but idk Im not to experienced

dawn shore
#

Is there a way to know if other players are playing on the same machine on PIE?

#

for debugging

#

I use Play As Client on the same machine

elder sage
#

I'm still having an issue with my Launch Character node's movement being choppy on the client. I'm fairly sure it's getting corrected by the server, but I don't know how to fix that

#

I'm launching from the server btw

quartz smelt
elder sage
quartz smelt
#

Hm then I'm not sure, sorry man

elder sage
#

can someone tell me why this variable isn't being set to the correct value when the node directly before the custom even is the server setting its value?

charred crane
#

What's required for an actor's movement to be replicated? I have the actor replicated and replicates movement set and it has a movement component. the server is seeing movement but the client isn't.

elder sage
charred crane
#

I've been switching everything to have authority nodes in front of it and now my client enemies wont move. Turns out it was somehow my nav mesh settings got messed up.

quartz smelt
#

Should I replicate line trace if I want them to ignore certain actors with tags? It doesn't work for the clients

clever plinth
#

Is there a good breakdown somewhere of cloud hosting providers that would be suitable for a dedicated server (for internal testing only)? Do people typically use AWS/google cloud or is there something better?

sinful tree
elder sage
dim flame
#

hmmm

#

does restarting a listener server host player do something to its gameinstance variables?

#

nvm i'll just look up the engine code

vivid seal
#

trying to replicate subobjects of a component, I have overridden ReplicateSubobjects() and called ReplicateSubobjectList on a UPROPERTY TArray of object pointers. These objects have overridden IsSupportedForNetworking() to return true, and have GetLifeTimeReplicatedProps() implemented and correctly listing all the replicated properties. The component itself is set to replicate by default in the constructor.

I put a breakpoint in ReplicateSubobjects and it seems to be returning false from ReplicateSubobjectList, any reason this would happen?

vivid seal
#

properties on the component itself are replicating correctly, but my bWroteSomething is just always false when trying to replicate subobjects.
https://gyazo.com/be996ebce02e9ff88094447ba0f53336
Here is the function, I set a breakpoint inside the if(IsValid(Handler) && Handler->GetPredictionID() == 0) block and it hits, but bWroteSomething false after calling ReplicateSubobject there.

peak sentinel
#

Quick question: is it safe to use .AddImpulse() on CMC without caring about custom lag compensation?

#

Can I call it from server while local player moving and not think about anything else?

#

Source code tells its fine but I'm not experienced with CMC deeply so want to be sure

vivid seal
#

if its anything like Launch, you need to do it on the owning client and then the server otherwise you'll get jitter

#

but i would test it in BP and see what happens

peak sentinel
#

Seems like they are very similar

#

Thanks for letting me know

tiny scaffold
#

Hi, Stupid question. I was setting up a text on top of a character, the text sets with the clients index, Server joins and text is set to 0, client joins and text sets to 1 however when the client joints it cannot see the '0' above the server's characters head. if someone could help me that'd be awesome! Thanks

twilit sage
#

Hey guys - any chance someone can point me to a decent direct IP connection tutorial? Im having trouble testing connection to guys overseas using steam. Figured i needed to try it the old fashioned way to see if it guaranteed finding eachothers game

bitter oriole
#

Steam should be disabled for this to work

#

When using Steam you will use sessions instead

twilit sage
#

That simple? Awesome - thanks @bitter oriole๐Ÿ‘

bitter oriole
#

Yeah, just don't use Steam with this

twilit sage
#

Yeah i figured - set onlinesubsystem to null right?

bitter oriole
#

Yeah

twilit sage
#

Cool

twilit sage
#

@bitter oriole hey whats the console command to be the host?

bitter oriole
#

Just start as server

regal flower
#

I'm trying to call multicast RPC from a custom component code on the server. RPC implementation executed on the server but not on the client. Actor is not owned

#

What could be wrong?

bitter oriole
#

Are the actor and component both replicated ?

regal flower
#

Looks like actor is not replicated, as I can see in editor. How can I make it replicated by default in cpp? bReplicated = true in ctor?

bitter oriole
#

SetReplicates

vital canopy
#

Hi Guys, Does anyone know how to spawn a particle spawner on a dedicated server? Or how to replicate it? Ran into a snag :c *try to make muzzle flash particle spawner

bitter oriole
#

Particle system component on your gun, attached to muzzle, activated while firing

#

No replication required other than what's already in your weapon code

charred crane
#

I have a volume that loads a streaming level, then that level loads another streaming level into a specific location. Sometimes, one of my 3 clients won't have the second streamed level load. I get the following message in their logs, does anyone know how I might resolve this?:

2021.10.16-23.27.55:574][982]LogSteamSocketsAPI: Warning: SteamSockets API: Warning SteamNetworkingSockets lock held for 6.7ms. (Performance warning.) ServiceThread,PostConnectionStateUpdateForDiagnosticsUI,ThinkPingProbes,P2P ThinkSelectServer,ThinkSelectServer,EnsureDataCenterRoutesValid
This is usually a symptom of a general performance problem such as thread starvation.

crimson valve
#

Is there any system built-in to restart/reset a sub-level in a multiplayer session? Basically I want all the actors in the sublevel to be reset to their initial position (re-loaded?), any deleted ones respawned, and any dynamically spawned ones destroyed...

#

The two approaches I've considered:

  1. Unload and Load the level, making sure it is not just visibility toggled (not actually possible from blueprint it seems). This is what I did in a singleplayer game in the past to reset a sublevel.
  2. Make custom spawner actors for everything to manage the lifecycle, and have them destroy actors and respawn them if Event OnReset is triggered.
#

The use case is like for a shooting gallery where the players will be shooting targets which will explode. After each round I need to reset all the targets.

#

What's the best way to do this?

dawn shore
#

Does anyone know about this? I need to do something different if players on the same machine, for debugging.

Is there a way to know if other players are playing on the same machine on PIE?
for debugging
I use Play As Client on the same machine

wraith thorn
#

I think all my ideas regarding this are only possible with c++...
namely using the device id, local machine name, mac address, something like that, using replication for transmitting that info to the server or other clients and matching, this way you should be able to tell if clients are on the same machine as others

bitter oriole
wraith thorn
#

how so?

bitter oriole
#

Get world type, check for PIE

wraith thorn
#

aight, a lot better than replicating anything here, but also only available in c++ I reckon?

bitter oriole
#

Blueprint only multiplayer isn't really a thing tbh

wraith thorn
bitter oriole
#

Advanced Sessions is a C++ plugin that essentially just exposes existing C++ functionality to Blueprint

wraith thorn
#

well everything is basically C++ exposed to BP, innit?

bitter oriole
#

Using AS means you already need Visual Studio and a W10 SDK

#

Your project is essentially a C++ project right there

wraith thorn
#

but apart from building the plugin, you don't need any custom c++ classes is what I meant

bitter oriole
#

And yes, you may be able to have a simple multiplayer game without additional C++ work but imho if you're doing anything you'll very quickly end up needing some

kindred widget
#

Sessions are also just a very tiny part of multiplayer. BP Only can work, sure, but it has some severe limitations. No FastArrays, limited repcondition. Inability to override a lot of native code that largely drives how gameplay is handled. Some of it isn't just about straight up performance so much as just how organized a tiny amount of C++ can keep your project.

bitter oriole
#

Need something that moves and isn't a Character ? Welcome to writing complex multiplayer code in C++

#

Technically possible to do it in Blueprint but this goes into why territory faster than you can imagine

#

IMHO, anyway

wraith thorn
blazing talon
vivid seal
#

posting again because nobody was around last night to see my question: any idea what would cause ReplicateSubobject to fail? PostNetReceive is never called on the client, and I don't think the object ever even exists on clients (tested by adding an OnRep variable that is never called either)

lost dune
sinful tree
meager spade
#

yeah that is terrible

#

disabling those stuff

grizzled flicker
#

I always thought just the player controller exists on the server and client but does a standard character as well?

sinful tree
# grizzled flicker I always thought just the player controller exists on the server and client but ...

Any replicated actors that are spawned on server can exist on clients - they are "linked" together over the network by a UID, so if you pass a reference of that actor from the client to the server, the server will be able to determine which actor you're actually looking to reference on the server. The relevancy settings and I believe the repgraph determine whether or not that actor exists on any particular client - this is to prevent the server from always replicating all actors to all clients when it's not needed.

#

If you spawn an actor on a client, even if it is replicated, it will only exist on that client.

dawn shore
dawn shore
# bitter oriole Just check if you're running PIE

Isn't that possible for a client on other machine to join a PIE multiplayer game. I don't use that approach now, but if that is possible I think I would use it in the future because it seems convenient.

#

may not. correct me if i am wrong

rough jolt
#

anybody know how to improve this replication code for lights (engine thruster) so they won't flicker for clients?

bitter oriole
dawn shore
#

Then checking PIE seems ok

woeful pebble
#

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000

what does this error mean and why is it always with the client window?

bitter oriole
#

Debug it

woeful pebble
# bitter oriole Debug it

i sort of found out that when i don't have authority im doing TWO server events every .1 seconds and so i just put those two events into one event and luckily fixed it. yes this was entirely my fault

bitter oriole
#

No I mean when you have crashes, debug it through VS

#

EXCEPTION_ACCESS_VIOLATION is the easiest error to fix

woeful pebble
#

im guessing there's a limit on how fast you can do a server event and how many you can do

bitter oriole
#

Or it's pure coincidence and you still have the crash

woeful pebble
kindred widget
#

Do you have any C++ code? Cause it's kinda rare to get that crash in blueprint.

woeful pebble
#

I don't seriously

#

other than one empty c++ class i created so i had a .sln file

kindred widget
#

Yeah. That's a lot of guesswork without debugging to find what function is actually crashing.

novel siren
#

hey. Probably an obvious error but I've never had this happen in replicated projects before so I might be missing something. This project is C++ based, using client-host model.

What I am trying to do:
GameState calculates a value . GameState passes this to the player controllers for all players. The PlayerController passes the info to a UMG widget.
This is done in a C++ mostly (the widgets are spawned in via derived blueprints)

What is happening:
The information is being passed the host player. Any other other player has a widget show up but does not get the data. While debugging it appeared the GameState could see the correct PlayerController. The PlayerController could not see its own widget however.

#

What could I have overlooked/missed?

woeful pebble
woeful pebble
novel siren
novel siren
woeful pebble
#

i think you have to

#

for example you can only cast to your hud class on the player controller with get HUD only on owning client events

#

not on server events? or perhaps you have a has authority/is server check?

novel siren
#

I think that might be the issue too. I think I set up my client RPC incorrectly

#

I am about to re-factor the code and see if that resolves the issue, give me a few minutes and I can update

woeful pebble
#

because the host is technically the server and anybody who joins the host's server is considered the client

#

at least i think that's how it works

novel siren
#

That is my understanding too but god knows I probably have it wrong ๐Ÿ˜‰

#

I honestly think I am not replicating the events correctly. Let me just try to see if this change I have in mind resolves the issue

kindred widget
#

@novel sirenOut of curiosity. What is creating the widget? What event?

novel siren
#

got it working

#

I had the wrong part of the chain replicating on the client

#

and @kindred widget the local player controller

kindred widget
#

On a side note. It's often best to move any widget based logic to HUD. Your replicated logic can get the local HUD to get widgets or do things. This enforces the idea that it's client only. Less issues with it being the server or client version of the controller since HUD only exists on the client.

novel siren
#

Fair point. I thought of that but in this case I decided to bypass that route. My rationale was in this case that the players interaction with this particular widget has a replicated effect (e.g., pause the match)

#

(to be clear the replicated events do not occur in the widget for obvious reasons, I am not an idiot)

#

(they just call replicated events in other classes)

kindred widget
#

Sounds like an RPC in playercontroller. Widget gets local player controller, calls that rpc. Widget binds to a delegate in GameState that gets called when the Paused state changes, and updates it's own UI based on that change.

novel siren
#

I haven't implemented those events yet

#

just the rational for why I went past the UHUD and straight into UMG for this

kindred widget
#

I'm just saying that it shouldn't really matter what holds the widget. Widget should be able to be added from anywhere to function with no inputs from anywhere else for the use of pausing the game. You can easily get local player controller via GameInstance, and GameState also has a global getter.

novel siren
#

oh yeah, that I realised which is why I was confused by my bug. I just had replicated the wrong event (mostly cause in my pseudocode for this I had one function to do what I wanted, instead of two like I ended up with)

#

and I replicated the wrong one of the two... >.>

kindred widget
#

Haha. I feel you. I just converted a slider widget to C++.. Took me half an hour of trying to figure out why it was getting wrong values. Don't use direct gets when there is a getter function specified. ๐Ÿ˜„

novel siren
#

At least not in 4.25+

#

pre 4.25 you could get away with it to some extent (if memory serves)

kindred widget
#

In this case, the slider UWidget doesn't update it's value. That is just used for default setting. I was getting the default. The getter, gets the actual value from the UWidget's internal slider. Slate, man.. Slate.

novel siren
#

There is a reason I hate doing UMG in C++

kindred widget
#

I'm starting to love it. It's just very quirky.

novel siren
#

in terms of BP:
UMG
Interfaces (I am just not a fan of UE4's API for interfaces in C++. So much easier to deal with in BP)

#

you want to hear me swear like a banshee at something? Give me UMG work to do - especially on the graph side of it. Want me to just kill someone? Ask me to do a widget tree in C++

winged badger
#

and add an interface to the widget ๐Ÿ˜„

novel siren
#

oddly

#

Already done

#

That was part of the issue today

winged badger
#

c++ interfaces are full of caveats

#

but blueprint is oh so much worse

#

when you find yourself debugging a packaged game only bugs

novel siren
#

See I have an easier time seeing interface related bugs in BP, not in C++. Other bugs? Usually better in C++ for me.

winged badger
#

then you'll find yourself rewriting those into c++ where they belong

novel siren
#

I still do them in C++ for the paid work I do but man I do prefer them in BP, if they are done right.

winged badger
#

can't debug blueprints without the editor running

novel siren
#

true

#

no standalones or cmd line runs

exotic spindle
#

Just started getting into Networking again - If I have a server owned actor, that replicates to the clients, and the clients are supposed to call a Server RPC function on said actor - Is there any way on the server to determine which client send the request? Idea being a permission system that's server authoritive.

#

Kind of out of the loop for years, with networking, so might be thinking about this completely wrong

winged badger
#

yeah, no

#

you have a No owning connection for <insert actor> warnings in the logs

#

every time you try that

#

client has to own the Actor to RPC through it

novel siren
#

welll in theory you could still debug blueprints... the fancy noob way ๐Ÿ˜„ (print strings!)

#

(I will go punish myself for my bad joke)

winged badger
#

good

#

๐Ÿ˜„

kindred widget
#

@exotic spindle Clients can't call a ServerRPC on a Server Owned Actor. If this is the case of like opening a door. You need to interact with it via the pawn or controller. So like line trace on the client, take the hit actor, send that through an RPC to server as an actor pointer. Call an interface on it on the server. Interface function in the door can set it's state on the server then replicate to clients that the door is opening.

#

In this same case, your server can do permission checks after the RPC before and/or after calling the interface function on the door.

novel siren
#

While folks are here I have more general question....

exotic spindle
#

@kindred widget Ah, yeah right, I start to remember. I'm still in the rough planing stage of this endeavour. Thanks for clearing that up.

novel siren
#

So the game I am contracted on is an RTS game (and no it is not violating OOP like my series if you recognise my name) - the camera pawn itself is replicated but the movement is not replicated. The rationale behind this decision was: 1) players can individually set their own cameras speeds 2) even if 1 wasn't true, and the player upped their speed to move across the map faster, it would not give them any benefit as there will be other ways to jump the camera around 3) the other players can never see each other's cameras. Given this set up would you still not replicate movement itself or would you still replicate the movement? (The only reason I can think to do so in this case, especially due to 3 is due to cheating, but again 1 and 2 address that)

kindred widget
#

I assume this is like a Starcraft camera setup?

novel siren
#

yes

#

I have argued this back and forth with myself for days now

small stratus
#

I'm pretty much new to multiplayer as a whole, but does anyone know how I can use media players / sound with multiplayer support? sorry if I'm interrupting anything

kindred widget
#

Doesn't really need to be replicated at all I don't think. There's no reason for it. It's all local interaction and view. The most you'd ever need to replicate is the position if you wanted other players to see where someone else is looking at on a minimap or something. But that would be client updating the server of it's own state and skipping owner replication.

#

As far as cheating. Let them hack the camera all they want. Visual state of things should remain the same and be affected by authoritive replication elsewhere.

novel siren
#

That was my original thought

novel siren
#

@kindred widget thanks for confirming I was not going batshit.

kindred widget
#

You may be. But not about that. ๐Ÿ˜„

novel siren
#

I mean I am well past bat shit, let's be fair

kindred widget
# small stratus I'm pretty much new to multiplayer as a whole, but does anyone know how I can us...

You usually do this locally based on replicated stuff. This is an exceptionally complicated question because there are a lot of edge cases and different implementations based on what you need to do. For instance, your players finish a boss fight and you want a cinematic to play. You replicate or RPC a simple value through somewhere like GameState. You use this value to look up which cinematic to play and play it all locally. The only networking being the lookup data for what it is you want to play.

novel siren
#

but Fog of War, hiding units, all the other visual stuff is handled elsewhere and replicated so that if they hack the camera it won't matter. And there will be a mini-map and hot keys to jump to various spots already.

#

oh @small stratus he is right, I was thinking of simple sounds (like music and footsteps) not more major events

small stratus
#

What I'm trying to do is get a video to play through all clients, with sound

#

sounds simple but it could be a lot harder I wouldn't really know

#

multiplayer aint my thing

kindred widget
#

Start simple. Make a non parameter multicast. Call that multicast where you want them to see the video. Set the video hard coded to one video. Then send that multicast from the server.

#

This will play the video locally for everyone.

novel siren
#

sighs yay time to refactor code.... cause I am an idiot and forgot that I didn't pass that value cries

kindred widget
#

After that, you can start branching out. Add a parameter to the multicast that's a GameplayTag or Integer, or Enum, whatever you prefer to handle your data. Then switch on that to select other videos.

small stratus
#

That makes a lot more sense than just playing the video. Thanks a lot, I'll give it a shot

small stratus
#

So I've managed to replicate the media player, but how could I replicate the sound? Any ideas

#

hm. When I package the project, it isn't working. But when I play as a listen server with 2 clients, it plays on both clients

twin juniper
#

Hello everyone.I am playing a camera shake on my anim montage.But when it is playing it is playing on all clients instead of one client.How can I stop it.I am playing it on fire animation

kindred widget
small stratus
#

I am using the media player

#

And I will try this out

small stratus
#

Not sure how to fix this

waxen umbra
#

I have an issue where UGameplayStatics::SpawnSoundAttached causes a warning on a listen server when there is at least one client connected.

LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: AudioComponent /Game/Maps/UEDPIE_0_Develop.Develop:PersistentLevel.GBP_AIActor_2.AudioComponent_0 NOT Supported.```
#

There's no issue on a dedicated server with several clients or a listen server with just the host.

#

I'm a bit confused since I'm playing sounds the exact same way in other places with no errors, but this actor in particular seems to cause the error when spawning the sound.

tame trail
#

is it possible to pass variables around from one client to another? I need to keep track of who is currently rolling the dice and im not sure how to tell the clients who is rolling and who isn't. Can client transfer data like this?

waxen umbra
#

Probably need to go Client1->Server->Client2

#

So some server call that tells the server what client you want to send a message, then the server can send the message to that client. Even if it would be possible to do it directly it would not be safe

tame trail
#

if it wouldn't be safe, how else would I do it

waxen umbra
#

The way I said :p

#

That way you can validate it on the server and make sure one client doesn't use it to crash another client

tame trail
#

alright

#

thank you

twin juniper
#

Hi guys, i'm an indie dev learning UE!
Do you recommend using **AWS Gamelift **for multiplayer FPS titles?
(Example: Counter Strike)

1-What is your experience, is it cheap?
2-What tips you would give?

tame trail
#

I like playfab

bitter oriole
#

If you're learning Unreal I would very strongly suggest cooperative games with no servers, too

#

Well technically I would recommend singleplayer

#

But hey

#

Turn based is so underrated, you can essentially not do any actual multiplayer code, and you have like 80% of the value of a multiplayer game

#

Makes anticheat a lot easier too

viscid monolith
#

Hi, i set all the things for replication on actor, but it's value doesn't replicate. Here is example: I have 3 players, one is server, other 2 are clients. I made so when i press a F key, replicated value increases for 1. But it changes only on one side and never replicates

#

I increase time by this function

#

Which is just this

bitter oriole
#

Replication is server to client, not the other way around, so check that first

viscid monolith
#

Yes, i know it

bitter oriole
#

So you're only changing Minutes and Days on the server, right ?

viscid monolith
#

Yes, i even have GetLocalRole to Authority only

#

and i tried this function as RPC Server

#

Results are the same

bitter oriole
#

How is TickTime called ? Did you confirm it's called ?

#

Did you override BeginPlay or something ?

viscid monolith
#

It's called from a Timer, that i run from BeginPlay.

#

Yeah, i just noticed

#

But the function should apply only on server i guess

#

yep, already fixed

bitter oriole
#

I also see no initialisation value for those variables in constructor

#

Anyway, I don't see any error in the code here

viscid monolith
#

Im just very lucky for issues that has no reason to appear

#

added initialized values in constructor and made BeginPlay Authority Only. The same

bitter oriole
#

Need to see the rets of the code

viscid monolith
#

I forgot about debugging, so im gonna look what is ever happening on different sides

#

On client it's still 0, so it's not issues with how i get the value to print.

#

And actor seems like the one for all sides

#

code for this actor

bitter oriole
#

Where's the log ?

viscid monolith
#

What log?

#

The one that prints messages on the screen?

bitter oriole
viscid monolith
#

In BP. Just gets actor from world and displays data

#

I thought it's not reliable, so i checked with debugger

#

it's the same

bitter oriole
#

How is the world manager spawned

viscid monolith
#

I dragged it to the world in editor

bitter oriole
#

Check that it's replicated in the details panel

viscid monolith
#

Right

#

It's not

bitter oriole
#

There's your problem

viscid monolith
#

Damn, it was too stupid, thanks!

#

Now it works

charred crane
#

I have a 3D widget component attached to an actor. On that actor's beginplay, I want to give the component a reference to its owner. How can I get it to have a valid reference on clients?

twin juniper
#

hello, i have a weird bug with Run on Server event, i marked it as reliable, the actor have player authority, but it triggers just once on server, if i call the same event second time, after some frames it doesn't called on server

#

any ideia why this happens?

twin juniper
pure hearth
#

Hey guys how do i replicate a sound or play at location for all players? in C++

violet sentinel
#

that is common case

jaunty onyx
#

Hello,

I'v a Jog_Stop animation in my AB. This animation uses root motion. My character does a little step forward in this animation. But I know how not recommended root motion is for multiplayer games.
What alternative do I have to make this little step forward without root motion ?
Is root motion this bad in Animation blueprint (for multiplayer)?

Thanks ๐Ÿ™‚

rare pulsar
elder sage
rare pulsar
elder sage
rare pulsar
elder sage
pure hearth
rare pulsar
elder sage
#

Or, for example, your client could be writing to a blackboard that the server is ignoring because it has authority over the client

novel siren
#

I return, again!

This project is an RTS, client-host approach. I am trying to set up my sun rotation. To do this I use an actor. This actor is made in C++ and is replicated. The rotation event is a multicast event (because it was not replicating without NetMulticast). What happens changes slightly:

  • In stand alone - works fine.
  • In listen server with just host - works fine.
  • Running dedicated server (just to see) OR listen server with more than just the host - the directional light vanishes...
#

I am a bit lost as to why that might happen - again probably missed something obvious (though not as bad as earlier where I placed my RPC in the wrong spot... twice)

sinful tree
#

Also, maybe instead of replicating with an RPC, you use a replicated variable with a RepNotify that can then change the position as needed?

novel siren
#

including the host, yes

#

didn't think of RepNotify, I will try that tomorrow (or after I eat)

charred crane
#

Anyone have experience with widget components? I'm really struggling with getting ai health bars to replicate properly.

unreal epoch
#

So I have a player character with a movement system that correctly replicates. I am working on a drone pawn class with a floating pawn movement component. For some reason the movement is only done on the client and not the server.

#

The pawn is replicated and the box "replicate movement" is checked

#

this is the look input, i was mainly looking at it since it was the same functions used by the player

#

but this is the movememt for the drone

sinful tree
charred crane
meager spade
#

what movement component does the drone have?

charred crane
#

I have tried having the custom event have varying replication states but it never quite works.

unreal epoch
#

a floatingpawnmovement

#

@meager spade

meager spade
#

yeah that has no built in movement replication iirc

#

nor smoothing)

#

@charred crane you can not replicate widgets

unreal epoch
#

does character movement component include flying @meager spade ?

meager spade
#

and why is a HasAuthority branch, running a server rpc @charred crane

#

@unreal epoch yes

#

set its movement to flying

unreal epoch
#

ok, then perhaps I will just make it a character instead of a pawn

charred crane
meager spade
#

if you go pawn, you will have to put in smoothing and stuff for the movement

#

if you ever get it working without, it would just be skipping/jumping when moving

#

you can not replicate WidgetComponent @charred crane

#

UI is all local, it should not/ can not be replicated

charred crane
meager spade
#

because your logic is wrong

#

you need to create the health bar locally

#

and update it via events/tick

#

when it takes damage/gets healed.

charred crane
#

The widget component is part of the bp

#

its not local

meager spade
#

so why are you doing a server rpc?

#

to set the owner ref

charred crane
#

because i'm trying to figure out how to do it

meager spade
#

owner should be set on beginplay

#

before the HasAuthority check

charred crane
#

Why before rather than after?

meager spade
#

and turn off replication on widget component

#

because it needs to be done locally @charred crane, and you don't need to gate it.

unreal epoch
#

@meager spade how do I change the movement to flying instead of walking? it is a function or can I change a default variable?

meager spade
#

CharacterMovementComponet -> Set Movement Mode

unreal epoch
#

oh found it

charred crane
#

The other day I think Datura helped me realize that most of my logic needed to be behind authority switches, so that's what I've been doing. The only logic I don't want on the server is UI, anim, vfx, sfx, user input, etc, right?

meager spade
#

ui never spawns/runs on server

#

if its dedicated

#

if its dedicated server

#

then yes you can do it off the remote role

#

if its listen server you have to be more careful.

charred crane
#

but p2p the host wouldn't see it, right?

meager spade
#

correct

#

host is server

#

thats why you need to do it before that node

charred crane
#

I have another problem. I'm testing in PIE using the dedicated server checkbox. My melee attack relies on the animation of the swinging sword overlapping with an enemy to deal damage. I have the below logic. the client triggers this, but the server doesn't. When testing in a packaged game using the steam subsystem and a p2p connection, it works.

#

Here's my attack logic

#

I guess my question is: why does this fail with a dedicated server and succeed with a p2p?

meager spade
#

you need to tell your skeletal mesh to run animations

#

on server

#

@charred crane

charred crane
#

Server Attack calls a server rpc which calls a multicast rpc to run that third image

#

the third image has the animation in it

meager spade
#

your server is not running animations on dedicated server.

#

which is why its not working

charred crane
#

you mean like dedicated servers just dont do animations?

meager spade
#

correct.

#

by default anyway

charred crane
#

blast these dedicated servers lol

meager spade
#

you can make them do it

#

go to the skeletal mesh

#

component on the character

charred crane
#

ya

meager spade
#

set VisibilityBasedAnimTick to AlwaysTickPoseAndRefreshBones

charred crane
#

sure enough, that does it. Thanks again!

#

is that a relevant perf hit in general?

#

it's only gonna be on a max of 4 entities in my game, but just curious for future stuff.

charred crane
#

I'm trying to get a placed static mesh to replicate its visibility and collision status. The entity in which this logic is located is not replicated.

#

When EventBeginEvent is triggered, the collision is enabled, but the door visibility does not change for clients. it remains invisible.

meager spade
#

is the door replicated?

charred crane
#

its a placed static mesh, so I'm not sure how to replicate it other than using the SetReplicates node as you see in the first image

meager spade
#

it looks like an actor

#

so you can set it replicated

#

oh wait

#

your doing a multicast

#

what actor is this in?

charred crane
#

ignore

meager spade
#

then multicast wont work

#

the actor needs to exist on all clients

charred crane
#

the door actor exists inside the level

meager spade
#

for multicast to work

#

no this actor

#

not the door

charred crane
#

oh, yeah that doesn't replicate.

#

ok

meager spade
#

for multicast to work

#

the actor calling the multicast must be replicated

charred crane
#

ok that makes sense, this logic was from before i made this not replicate

#

there's no need for authority switches in an actor that doesn't replicate is there?

#

because wherever it's spawned, it'll be the authority?

meager spade
#

right

#

a non replicated actor will always be authority

#

a client spawning an actor, will have Authority role

#

Authority is who has authority over that actor

charred crane
#

right

meager spade
#

for replicated actors, the server has authority cause only server can replicate actors.

charred crane
#

A static mesh that's placed in a level is naturally replicated, so I shouldn't need the SetReplicates function either

meager spade
#

its not replicated

#

it exists on both client and server, but that is not replication

#

that is cause its in the map

#

if it needs to replicate stuff then it needs to be set as replicated

#

at that point, the server will take ownership of it

charred crane
#

Will SetReplicates retroactively remove the client side version of a placed actor like that?

meager spade
#

and replicate it via its name (if we want to get technical)

#

no

#

setting it to replicate, the server will adjust the role add it to replicated actors list, and send that to all clients

#

clients then grab the id of that actor, and map it to the actor in the world

#

(for pre-placed map actors)

#

Spawned replicated actors is slighly different, as server willt ell clients to spawn that actor

eternal canyon
#

hey kaos

#

i have another pun based on ur name

#

spooktrum skript

charred crane
#

Ok here's my new logic. It works on dedicated server but not p2p

#

Wait, it's not working because the boss ref is invalid. disregard.

dim flame
#

how come you are setting them to replicates on begin play instead of in class settings?

charred crane
#

Because it's not a class, it's a static mesh that is placed in the world.

dim flame
#

or collision

#

hmm not a class

#

nice wording ue ๐Ÿ˜‰

charred crane
#

I mean, it is a class, but not like a bp object

dim flame
#

well okay that explains it

charred crane
#

Also, I just realized that the object all this logic is in is placed in the world, so I have two instances. I need that to be 1 instance i guess, so it has to replicate so that it doesn't fire off logic I don't want to happen, right @meager spade ?

charred crane
#

by the gods, i've solved it

hollow portal
#

yo so I'm having an issue with connecting to an IP on android
you can host a server fine but can not connect.

rare pulsar
#

How would I go about doing that

novel siren
#

@sinful tree RepNotify worked kind of. I had to force the notification to go through. And it takes a couple of seconds (more than 5 but no idea how much more than 5) for it activate. (I know it is at least 5 because I have a built in delay for something unrelated that is 5 seconds and that went off before the sun began rotating)

sinful tree
novel siren
#

The client wasn't (I remember reading about who sets it determines if it fires)

#

so I had to force it to fire for all

unreal gate
#

Can't seem to get the client side to function while server side is working normally. Haven't changed anything, excepting taking away some VR stuff. From the pre-built top down package. Anyone else gotten similar issue?

#

In the event graph for movement etc it still firing and looks identical for both client and server. But the client wont move.

rare pulsar
#

So run the event that tells it to move from the server rather than client?

tacit flume
#

anyone here by any chance ever implemented backfill tickets with playfab in blueprint in ue4 in a p2p game?

rare pulsar
#

Thats the event that is used for movement of the ai

rare pulsar
#

Yeah the template i am using was initially meant for single player, I'm attempting to convert it to multi

mellow drift
rare pulsar
mellow drift
mellow drift
slim harbor
#

Hello. I am new around here, I apologize that English is not my main language. If it is not a suitable channel to ask this, I am sorry. In a multiplayer if for example I have 100 players in the same game, how do I assign a camera / point of view to each one? I can't find any mention in the forum or youtube about this.

slim harbor
#

I go search onto this. Thanks Lorash โค๏ธ

woeful pebble
#

does anyone know where to look for simple AI that roams and around and chases the nearest player in multiplayer?

#

im using pawn sensing and behavior trees and it keeps getting stuck near my second player which is the client

#

How can i make the ai find the closest player?

rare pulsar
#

Ok im having a weird issue, im using spawning volumes that were in this template and i have the items that are spawned being replicated but the 2nd player is only able to see the ones that are in its initial view when it was spawned rather than all the others which are spawned

#

This is where it is spawned

#

both the spawning volumes and the items are replicated and the event called to spawn the items runs on the server

meager spade
# rare pulsar Would it matter where it is called from?

It does matter, the Run on Server/Run on Client needs to be on an Actor that is owned by an owning connection (PlayerController) via SetOwner. Multicast must be used on a replicated actor, but does not need to be owned by anyone.

#

just to clear up mis-advice

rare pulsar
winged badger
#

there is an illuminati eye

#

you can use it to expand a menu which lets you select which world is the outliner showing

#

(client/server...)

#

use it, figure out if you have invisible actors on clients, or you don't have actors at all

rare pulsar
sinful tree
rare pulsar
sinful tree
rare pulsar
sinful tree
#

What event are they firing off of?

rare pulsar
sinful tree
#

Don't do this. The server has its own begin play.

winged badger
#

think of the replicated actors are fully separate and independent instances, which they are

#

the only think thats special about them is
A - server can set replicated variables, that get propagated to clients, with optionally having a callback when changed
B - those actors can send RPCs (to another instance of the Actor on another machine, that happens to have same NetGUID, but is in no way the same instance)

#

so every engine function/event that would normally run on server "on its own" runs on clients as well

#

that very much includes BeginPlay, Tick, Collisions.... and many other things

rare pulsar
winged badger
#

depends on the scope

#

where you'd put it

#

you can put a branch IsServer there and just call the spawn event

#

not ideal for every use-case

rare pulsar
#

They are placed in the level as fixed points where the resource can spawn

winged badger
#

but it will always run only on server

#

you can just pre-place them on the level if they are "fixed"

#

but even if you want to randomize those each time the game starts

#

those
A - do not need to be actors, it can just be an array of vectors
B - most certainly don't need to be rerplicated

rare pulsar
#

probably didnt explain that as well as i could of, the script is running on a spawning area for a type of resource, so they are predefined areas that the resources can spawn at random positions when the game starts and then there is a timer that will regenerate on when they spawn it will place the actor into the world for the corresponding resource type

novel siren
#

I will have to look out and see what has happened to him.

#

So weird question, and one I feel I should know the answer to. With Replicated elements in a USTRUCT, used for a data table, where the heck do you do the DOREPLIFETIME bit? Also if I am doing my data-table in the editor but the struct is in C++, do I need do do anything special for replication? (I found very little info on replication and structs/data tables and want to ensure I missed nothing before I forge ahead with my code)

rare pulsar
sinful tree
rare pulsar
sinful tree
#

There are other factors that go into relevancy... I know distance for sure is one. The idea again is that relevancy is a means of trying to limit the amount of network traffic you're sending and receiving. If the actor is not relevant, then it usually gets culled (ie. the actor no longer exists on the client) until it becomes relevant again and the server will begin replicating it again. If you're not really changing anything on the actors, then marking as always relevant probably won't cause any harm (just a guess).

#

If you intend to add more mechanics on to these actors, like it looks like you're dealing with trees and rocks, so maybe you'll have a resource collection system on them in the future... Then you probably don't want to have them always relevant since they will be changing when someone goes and harvests from them.

rare pulsar
blazing spruce
#

Hi, someone replied to me the other day but I cant find it, what's the best way to make it so when the host presses the start button for the lobby screen, the buttons disable for all clients?

sinful tree
twin juniper
#

Hi i have made a multiplayer listen server player list and added 4 players for testing. So only the Server and client itself comes up. So if i'm client 1. Client 1 and Server name comes up and rest as undefined. If i am client 2. Only client 2 and Server comes up rest is undefined. Etc etc. What is the cause? I use player state to get the player list thanks help appreciated.

rare pulsar