#multiplayer

1 messages · Page 426 of 1

winged badger
#

the override looks sensible for the most part

#

cheap checks first is better

twin juniper
#

hello, if i have an array of objects which are replicated from server to the client

#

changing the attribute in one of the elements of that array won't trigger "on rep notify" call for that array

#

true or false?

winged badger
#

changing something inside the element won't change the pointer, so no, it won't trigger the replication at all iirc

twin juniper
#

makes sense

#

don't like it though

#

i could make it so that the object attributes themselves replicate, but then i run into another set of problems

#

prolly gonna have to go with the RPC, to have a finer control over it

fleet viper
#

@winged badger sorry i dont really understand what you mean by it

tawny parcel
#

I'm getting MaterialInstanceDynamic [npc.mesh.materialinstancedynamic] NOT Supported spammed in my dedicated server's log file. The Material is set during construction script.

Should dynamic materials be set remote only via switch has authority? To add - every time a player joins the game, it will spam this for each npc.

fleet viper
#

Hi so ive setup a simple cast to my player controller and on client side its allright but on server side the cast is failing? Im using the get controller node and its a listen server.

twin juniper
#

@winged badger @thorn yarrow yeah so it didnt work

#

Which is super strange actually

#

Even some of my units which I "own" by calling SetOwner() and then adding them to the array of "UnitsWeOwn"

#

They still go out of relevancy distance.

fluid flower
#

@fleet viper can you post your code/nodes?

thorn yarrow
#

@twin juniper have you tried stepping through IsNetRelevantFor?

twin juniper
#

looks like it is never called

#

@thorn yarrow It is never called on either the structure class or the unit class.

winged badger
#

well, you can always type log lognet veryverbose

#

into your console

#

and see whats going on there step by step

#

warning tho: there will be many many many steps

twin juniper
#

@winged badger like this? -log lognet veryverbose

fleet viper
#

@fluid flower yes ofc wait a sec

#

@fluid flower

fluid flower
#

thanks, tho I can't see where you're checking if its server

#

can you show that part?

#

in any case, odd, controller should be available on server

#

also, when is this event called?

winged badger
#

@twin juniper press tilde and type when the game/editor is running

#

same as if you were tying stat UNIT

fluid flower
#

@fleet viper and how far does the code go on the server, did you set breakpoints or simple print strings to see what part it reaches? perhaps it never gets to the cast on server

fleet viper
#

btw @winged badger how did you mean the logic behind the marker and how not to spawn them for desired clients?

winged badger
#

if you're not using c++ you might be stuck hiding it

#

but even then its not that complicated

#

you have to have TeamIDs to have teams

#

so when you spawn a MarkerBP for a Team, you feed it TeamID at construction

fleet viper
#

@fluid flower it gets to the cast node when i press spot on the client window everything is fine but on the server window it goes to cast failed execution pin

winged badger
#

variable - editable, exposed on spawn, replicated

fleet viper
#

@winged badger does team id also count like an enum TeamA and TeamB?

winged badger
#

sure

fleet viper
#

then i already have an id

winged badger
#

enum is a integer between 0 and 255 behind the hood

fleet viper
#

so but idk how to set it properly up im not really good at c++

winged badger
#

so you spawn it on server, feed it teamID

#

now you need a way to grab the ID of the local PlayerController

fleet viper
#

im atm on it with oz

winged badger
#

so on BeginPlay if TeamID of the Marker doesn't match the TeamID of the local PC

#

you hide it

fleet viper
#

my biggest problem atm is that my server isnt able to get the controller

#

because its a listen server

winged badger
#

dedicated server would actually be trickier

#

i don't like using GetPlayerController[0]

#

but that shoul;d work with listen servers

#

you can also cache the TeamID on GameInstance as soon as its replicated down to clients

#

then you can get the TeamID of local controller without getting the local controller

fleet viper
#

can i even use player controller node? because of the index?

winged badger
#

i am not 100% if there is an edge case or not with seamless travel and listen server where GetPlayerController[0] won't return the local PC

#

but barring that, on listen server, one at index 0 will be local, and on clients one with index 0 will be the only one, so its once again, local

fleet viper
#

will try it

winged badger
#

using it on dedicated server, however

#

where there is no local controller

#

is a good recipe for a disaster 😄

fleet viper
#

heard a lot about it

#

anyway works perfectly

#

you said hide it but can i even be able to not spawn them to not desired players?

winged badger
#

that is net relevancy

#

and you would need to go to c++ for that

#

there is AActor::IsNEtRelevantFor function

#

which you could override so it compares the ID of the marker with ID of the Controller

#

controller being the parameter called RealViewer in that function

#

and use that for net relevancy

fleet viper
#

i guess i have to learn a lot about networking in bps

winged badger
#

if that function returns false, the Actor will not replicate for that Player

#

with listen servers however, even with relavancy

#

you would have to hide it for the host if it belongs to other team

#

as everything exists on the server

fleet viper
#

yeah

#

@winged badger

twin juniper
#

That function seems broken in many ways. It never calls IsNetRelevantFor @winged badger

winged badger
#

show me your function in the header @twin juniper

twin juniper
#

RealViewer = PlayerController... According to the documentation.

winged badger
#

it is

#

did you breakpoint it?

twin juniper
#

@winged badger yeah sorry, I was going to do that earlier but I went out. I'm going to try it now.

copper portal
#

When the host of a match starts the game, they can't see the nametags or score tags of any player including themselves in the first round. After everyone respawns, they can see it. I have printed string to check if the nametag has a null input and it doesnt. This is what I do for my score and nametag: https://gyazo.com/96e41d371c837ff73786594776de8689 and I set the var in event possessed: https://gyazo.com/9c477a04e5c06c3bef79629ccd5b24c4 All that code is done in my character bp and in the widgets, I do this: https://gyazo.com/e066db9c2a7f83706a4bc5008638f60d (the variable is replicated). What should I do to make the host see tags in the first round?

strong abyss
#

@copper portal I am running into the same problem so if you find out let me know and if I find out I will let you know.

copper portal
#

k

copper portal
#

@strong abyss are you using the steam subsystem?

strong abyss
#

Yeah

copper portal
#

@strong abyss ok I just noticed something. When the game starts the tags show up but they get removed for some reason

#

im checking the begin play on my level and so far it may or not be me setting the transform of the location

#

im using paper2d btw

strong abyss
#

I think it has to do with possess node on my end.

twin juniper
#

@winged badger I ended up checking it, looks like it's never called

winged badger
#

time to ask, is the Unit Actor replicated?

twin juniper
#

yea

twin juniper
#

@winged badger maybe this would be a better question. How do I make an actor AlwaysRelevant to it's owner, but other actors follow the natural relevancy rules... NetCullDistanceSquared...etc

winged badger
#

if the owner is the PC

#

you just leave it as is

twin juniper
#

The owner of all units and structures is set to the player who spawned it and it's playercontroller. So if you spawned it, your player controller would be the owner.

#

Does that make sense? @winged badger

winged badger
#
bool AActor::HasNetOwner() const
{
    if (Owner == NULL)
    {
        // all basic AActors are unable to call RPCs without special AActors as their owners (ie APlayerController)
        return false;
    }

    // Find the topmost actor in this owner chain
    AActor* TopOwner = NULL;
    for (TopOwner = Owner; TopOwner->Owner; TopOwner = TopOwner->Owner)
    {
    }

    return TopOwner->HasNetOwner();
}
#

PlayerControllers override that function to just return true

#

and you can also check the Owner

#

make sure

twin juniper
#

@winged badger what would that do though

#

I know it has an owner because right after I spawn the actor I write SetOwner(MyplayerController);

twin juniper
#
bool AUnit::HasNetOwner() const
{
    return Super::HasNetOwner();
}

const AActor* AUnit::GetNetOwner() const
{
    if (IsValid(GetOwner()))
    {
        return GetOwner();
    }

    return Super::GetNetOwner();
}```
#

I put breakpoints on both of these functions and neither of these are called on the server either.

winged badger
#

don't think engine calls those on its own

#

those are there for if you want to check if RPC can be sent

twin juniper
#

@winged badger i just figured it out the ReplicationGraph plugin messed it up.

#

I tdisabled the replication graph, and now my code works perfectly fine.

winged badger
#

@twin juniper just cheaper checks first

#

you don't need if (UnitsWeOwn.Contains(this)) for example, if you set the owner

#

cheaper to do if (GetOwner() == RealViewer)

#

and effect is the same

twin juniper
#

true

twin juniper
#

Can somebody help me?
I want to implement a network layer for player login, chat, friend list, shop, etc... real time
Can I use GameSparks for it? is there a better product for that?

torn current
#

Heya all! A quick word for anyone interested in using SpatialOS. We wanted to let you know that we have just launched our Game Development Kit for Unreal. This package helps you scale your game’s resources beyond a single server while using Unreal’s familiar workflows and built-in replication features. If you want more information, head over to our blog post (http://bit.ly/2SyqdpZ) for an in-depth technical look at what the GDK can do right now.

Thanks to the invaluable feedback from our community, the SpatialOS GDK for Unreal is now ready to be used for building projects using Unreal Engine. Click through to find out more.

wary willow
#

@torn current Did you all fix up your pricing page? So we can calculate/estimate realistically? Also, are there real-world examples for pricing (current games out in the market using SpatialOS) ?

#

Hmm, quick glance. Guess not.

torn current
#

Hey @wary willow, we're working on clarification around our pricing and should have more info on this in the next few months. This will hopefully also include proper examples and cost projections. We can discuss pricing in more detail with 1:1 conversations, however, where we have more context about your game, if that helps?

wary willow
#

? That's what the other guy said 9 months ago

torn current
#

@wary willow, totally understand it's taking a bit of time to nail down (and I can appreciate the frustration and curiosity around it!) but it's something we want to get right for our devs and therefore worth spending the time on.

#

Very happy to answer any more in-depth question via DM though if I can help further?

summer nova
#

Wait, it works alongside normal unreal networking?

#

thats amazing

#

so i can develop a coop rpg multiplayer and use that to make it into an actual mmo

#

now thats cool as hell

earnest comet
#

What if the said 1000 players were in the same server and in such a small zone though? @torn current

#

Surely a multiserver system would work (Blizzard already proves that with WoW) but their server can contain up to 80 -barely-.

#

80 that is communicating with each other, such as in a big war zone. And WoW is only almost-stable when 40 people are around max.

wary willow
#

Yeah but the thing is..

#

How much money is it costing you

#

And will you be able to monetize your game properly to cover those costs plus other devs costs, plus life costs 😃

#

Look at the ones currently out in the market

#

They are doing very bad financially so far, and most of them got a helping hand by SpatialOS themselves (maybe still are)

earnest comet
#

Well, if you really want a multiserver support for your game, you really need to have the budget to make a big game. 🤔

wary willow
#

How do you budget for something with unknown pricing? 🤔

earnest comet
#

By expecting the worst? x3

wary willow
#

Hah

#

I suppose that's one way to do it.

#

But

#

That's not easy to even do with their current pricing model.

#

Which is my point

#

This is something they keep talking about...but... somehow keep forgetting to do

#

There are four ways to get billed

#

Tech is great. Hands down.

gleaming vector
#

neat

wary willow
#

It's the other part that you have be careful about

gleaming vector
#

the old sdk was kind of hot garbage

#

hopefully the new gdk works well

earnest comet
#

Well, player activity one seems to be the one that makes sense, if you want to make an UBER AMAZING HAX WOW KILLER GUARANTEED MMORPG.

wary willow
#

Right, that's something you can somewhat easily budget for

#

Probably during testing, figure out your max workers

#

But, the sort-of unknown factor really, is what bothers me the most

#

Any/all of those number can easily fluctuate and we don't even know the hard numbers per type

earnest comet
#

I don't think they are wrong about "need to talk private yo" part. They can't really say anything without what you are planning to do.

wary willow
#

That's not true at all

earnest comet
#

Oh.

wary willow
#

We don't even know how much you pay per hour

#

Per GB/hr

gleaming vector
#

well

wary willow
#

per worker

#

etc etc

gleaming vector
#

you probably pay for server load

wary willow
#

Is this on some sort of scale?

gleaming vector
#

so understanding how your server loads whatever container you are using

wary willow
#

If you make more money, do they charge you more?

gleaming vector
#

is a major part of factoring the cost

wary willow
#

Like, those little details...

earnest comet
#

I think that's what they would do, if you choose the "player activity" one, the 4th one.

wary willow
#

And they have real-world examples out there they can at the very least... give us data on

#

How much is it costing Game ABC on Steam to keep running

#

@earnest comet chooose?

#

You pay for all 4

gleaming vector
#

i dont there there is a game on steam running spatial

wary willow
#

There are

earnest comet
#

Waaaaaaaaaaaait a minute.

gleaming vector
#

er, ue4 game on steam

wary willow
#

At least two games

gleaming vector
#

sorryt

earnest comet
#

You gotta be kidding me.

gleaming vector
#

yeah, both on unity

wary willow
#

Well yeah, I don't know about UE4

#

Now you get it @earnest comet ?

#

lol

earnest comet
#

I thought they were options O_O

#

Holy shit I am out.

#

Nope.jpg.

wary willow
#

Hah, nah, you get billed for all four

gleaming vector
#

but, yeah, it's not really priced for low budget indies

wary willow
#

I've tried talking to them a few times about pricing

gleaming vector
#

server hosting is fairly expensive

#

especially at large scale

wary willow
#

Because TBH...if given enough time...any indie with SpatialOS and some scope, can do something amazing with it

earnest comet
#

Excuse me sir while I am opening my wings and flapping my way out of the window and reach the sky, the stars, and hopefully God to ask questions.

#

Yeah, but then, wouldn't a big company handles those server stuff themselves to cut budgets?

wary willow
#

But, if the costs are going to be way above what they can afford, no point

#

Exactly

#

Bigger companies will usually just do their down server arch

#

They are definitely somehow catering for smaller indies though

#

Because there's at least one dude that is solo dev

#

And has a game out

#

(with SpatialOS)

#

But, he's not doing so well financially

gleaming vector
#

i do not think large game companies will do server arch like this

earnest comet
#

Well is there REALLY a point of NOT catering to indies? As we said, a big company will handle those stuff themselves.

wary willow
#

Which is why knowing more information ahead of time is important

gleaming vector
#

MMO-level tech is absurdly expensive to develop

#

Blizzard has probably spent well over 200 million over the entire lifecycle of wow for their server infrastructure

earnest comet
#

Not to mention that they connected servers to each other with uncountable ways.

#

But then, I hope someone uses SpatialOs to make an MMO-ish Dark Souls. 😛

wary willow
#

AFAIK, no "real big studio" is using SpatialOS

#

Mostly small studios (talking 20 or lower on staff)

earnest comet
#

I am sure that would be a good win for those.

#

Until they become big, if ever.

#

Time is money, and all that shizzle.

gleaming vector
#

Midwinter is larger to my knowledge

#

but i haven't really seen much from them

wary willow
#

Clinton Crumper, SCAD grad

#

Lot of good faces there

#

Still, that's only 19 people

#

I wouldn't consider that large

#

Larger than most Indies here probably

bitter oriole
#

Most indies here are never going to need more than one dedicated server

wary willow
#

Eh, depends on project/scope

bitter oriole
#

You'd need a few thousands units sold to fill up a server

#

Realistically, that's not that many people

#

IMHO, people who really do need something like Spatial (as in couldn't work well with base UE) are very, very few

#

I wonder how Rare has been approaching their MP setup, tech-wise. It's an instanced MMO with smooth migration between servers on UE4

wary willow
#

@bitter oriole Sea of Thieves ?

bitter oriole
#

Yeah

#

In terms of handling MP, I think they've got the model right, even though the game is clearly geared toward not meeting people all the time

#

You can play all day long without interruption or loading screens, people come and go smoothly

#

I really wonder how close to the base engine they are

twin juniper
#

Hey

copper portal
#

When the host of a match starts the game, they can't see the nametags or score tags of any player including themselves in the first round. After everyone respawns, they can see it. I have printed string to check if the nametag has a null input and it doesnt. This is what I do for my score and nametag: https://gyazo.com/96e41d371c837ff73786594776de8689 and I set the var in event possessed: https://gyazo.com/9c477a04e5c06c3bef79629ccd5b24c4 All that code is done in my character bp and in the widgets, I do this: https://gyazo.com/e066db9c2a7f83706a4bc5008638f60d (the variable is replicated). What should I do to make the host see tags in the first round?

jade gazelle
#

Does anyone know if it is possible to replicate a “set text” call on a text render component? I have the component itself replicating just fine but when I call “Set Text” on the server it doesn’t replicate down to the clients, they just keep the default text. The only way I’ve been able to do it is with a multicast RPC which works fine, but seems unnecessary

hasty adder
#

Aybe you need a delay in there @copper portal if the name is updating aft3r the first death it's possible the value hasn't replicated yet before the function is called

copper portal
#

@hasty adder good idea

winged badger
#

yuck

#

@jade gazelle its possible to replicate a text variable (with Notify), then call SetText from its OnRep function

#

who is "they" in that story @copper portal ?

#

what creates the widget showing the names/scores, when and how?

hasty adder
#

Name tags tho tbh I get players states and gather the info from@th direct

copper portal
#

@winged badger creation is in the code above and they is the hosts

winged badger
#

creation of the widget is not there

#

nor can i see which BP is it in

copper portal
#

I explained all of it

winged badger
#

nope, you definitely did not

copper portal
#

its a widget and the widget is shown using the widget component in my character bp

winged badger
#

now we're getting somewhere

#

how does it get its context?

copper portal
winged badger
#

so why not push a Character reference into the widget directly

#

and then bind through that reference?

copper portal
#

so u mean like no on rep notify?

winged badger
#

no i mean

copper portal
#

cuz I mean it works in standalone but not when I export to steam

winged badger
#

instead of setting PlayerName

#

you Set a reference to PlayerCharacter

#

then you can access the variables inside the character

copper portal
#

but the rep notify pretty much does that alread

#

y

winged badger
#

and if you are setting it too soon, it won't make a difference because the widget will catch up as soon as the variable changes

#

generally

#

directly updating UI is bad practice

#

you give UI a context

#

and let it take care of itself from there onwards

copper portal
#

ok but then what would I need the rep notify for?

sharp arrow
#

can someone help me im trying to replicate this to all players so in their screens is gona appear the information of the weapon

winged badger
#

you couldn't need it at all

copper portal
#

so I can just delete that?

winged badger
#

the name would still need to be replicated tho

copper portal
#

in what bp

#

character or widget

winged badger
#

and btw, replicated variables inside anything UI related, including HUD do not replicate

copper portal
#

oh

#

so I create a ref var in the widget bp and I cast to it in my character bp and set that var?

winged badger
#

you don't really need a cast

sharp arrow
winged badger
#

you create a variable of your characterBP type

#

and just set it from your characterBP using "Self"

copper portal
#

but I would need to cast to the widget to do that

#

if the var is in the widget

winged badger
#

to the widget yes

copper portal
#

k

winged badger
#

but you would not need to cast the character

#

@sharp arrow what is MainHandWeapon there?

sharp arrow
#

is an actor

winged badger
#

is it replicated?

sharp arrow
#

nop if i do that than the equip/unequip gets al screw

winged badger
#

no replicated variable will replicate if an Actor its a member of is not replicating

sharp arrow
#

is i could replicate it but if i do that and press equip it works but only sometimes

#

lets say if i press replicate

#

ill need to take out the multicast in equip/unequip and the variable nmeeds to be in not replicaated and i do that ops it works better but still has ltos of problems

#

if its replicated the one that is in purple was in multicast and i need to change it to not replicate if not it doesnt work not even a bit but still i get problems that sometimes you can see the player have hes weapon on the hand and sometimes no

copper portal
#

@winged badger i dont think it worked

winged badger
#

widgets are local only, always

#

so you can't really put the setting of the player reference behind an authority switch

copper portal
#

oh

#

lemme test again

winged badger
#

also

#

OnPossessed happens only server side

sharp arrow
#

o whait i think with authority it will work

copper portal
#

begin play then?

winged badger
#

BeginPlay would be far better

copper portal
#

k

sharp arrow
#

yeha it works ty

copper portal
#

@winged badger it still doesnt work

winged badger
#

now that you mention it, i also notice that PlayerName is no longer replicated

copper portal
#

from player state?

#

thats a default var

winged badger
#

but you do have PlayerOnlineName

#

in your characterBP?

#

which is till replicated?

copper portal
#

ye but I dont use that anymore

#

it was just getting set from the player name from player state

#

when I did have it

#

unless I do need to have it

winged badger
#

put it back in and bind to it instead

copper portal
#

k

#

with on rep notifiy?

winged badger
#

no need

copper portal
#

so only regular rep?

winged badger
#

widget will not query it

#

whenever the function is called, which is every tick

#

im off to sleep, gl

copper portal
#

k

haughty burrow
#

i'm trying to get the shortest distance so i can tell an AI go to after whatever is closest

#

does anyone know how to do that?

#

basically i have anywhere from 1-4 survivors, and what i'm trying to do is get all of them and then check to see which is the closest

junior jacinth
#

Hello! I am developing a network game. I had a problem with the identification of the player and accessing him to update his status both on the server and on the client

#

to be exact, I know about replications. But I can not make the desired structure

daring portal
#

hullo everyone! does anybody have good sample projects for couch coop games like gauntlet or helldivers?

#

i'm working on getting a framework for such a game set up, but there are a surprising number of little issues with player spawning, control assignment, etc. i'm not sure how i'm going to make it so it works the same for multiple controllers on a single machine and for networked players

fossil silo
#

Anyone have experience with GameSparks? I'm trying to setup social authentication and am wondering if I have to run a webserver to handle the google/twitch/etc oAuth stuff

#

or is it possible to do just in UE?

foggy wave
#

any good tutorials to create multiplayer?

bitter oriole
#

The Udemy course on UE4 MP

signal marten
foggy wave
#

@signal marten Thanks

signal marten
#

You got it 😃

junior jacinth
vagrant falcon
#

hey guys do you know good c++ multiplayer tutorials ?

junior jacinth
#

it is good to understand how it works in multiplayer

rose egret
#

how do I send my own FUniqueNetIdRepl to GameModeBase::PreLogin?
actully I want to send PlayfabId instead

#

I wanted to use open server:port?id=PlayFabId on client side but maybe there is a better option

jade gazelle
#

@winged badger Set Text —> Rep Notify works perfectly. Actually too perfectly and I’m not understanding how. Even when players log in after the rep notify function has been called they seem to have the correct Set Text info. How is that possible? If they weren’t online when the rep notify fired shouldn’t that event have never happened on their end? Or does it get queued and called when they connect to the server regardless of when the function initially fired?

winged badger
#

when a new player joins the game, the replicated Actors will replicate to them

#

along with any replicated variables inside of them

#

which fires the RepNotify

jade gazelle
#

Right, but with the text render component set to Replicate they don’t receive the correct text on their end. Only if I set it to rep notify.

#

So I’m assuming the rep notify gets fired individually for them on login?

winged badger
#

doesn't matter if TextRenderComponent replicates or not

jade gazelle
#

Well the text render component is a child of the character, which replicates

winged badger
#

as long as its created during construction

jade gazelle
#

So when it is created during construction, it is firing that notify function

winged badger
#

setting something to Replicate doesn't mean that every variable and component is Replicated

jade gazelle
#

I mean I can’t complain, it is working perfectly. I just thought I was going to have to add an additional function to retrieve the text nameplates of characters already on the server at the time of login

winged badger
#

no, if it was created during runtime, and not replicated it would not even exist on clients

#

so new player joins

jade gazelle
#

But they seem to be retrieving the correct info automatically once I set the function in rep notify

winged badger
#

Actors that need to replicate to his Connection are evaluated

#

which is at this point, all of them

#

he receives a bunch, with instructions to spawn an Actor of a correct type, and specific FTransform

#

at this point client will run a construction script for the Actor

#

and create any components that come from the package (inside the Actor asset)

jade gazelle
#

Following so far

winged badger
#

after the Actor is spawned, client will start setting the values of its Replicated variables

#

that it received in that same bunch

#

each time a client receives a replicated variable it sets it on its side, then fires a RepNotify

#

including right after the spawning of the Actor

jade gazelle
#

Ahhhhh I see. I was under the impression that the repnotify was like a multicast in the sense that it fires one time instantaneously and never again

winged badger
#

it fires during intiial Actor replication for all Replicated variables

#

and then whenever the Server sets the variable on his side

#

even if its set to exact same value it had before

#

there is a blueprint caveat that doesn't apply in c++ network code

#

OnRep will also fire on the Server

jade gazelle
#

So what I’m seeing is the first part of that. Even though the server hasn’t set the variable again when the new player joins, it is firing because t is being set locally on their client

winged badger
#

after the variable is set

#

initial Actor replication bunch includes all replicated properties

#

so basically server assumes that client might not know their correct values, and sends them along with instructions on how to spawn the Actor

jade gazelle
#

I think I’m understanding it now. Hadn’t used the rep notify stuff yet but now that I understand it a little better it seems like I will be getting a lot of use out of it

#

Can probably replace a lot of my multi casts

#

Thanks for the primer

winged badger
#

one thing you should keep in mind

#

it raraly causes problems, but...

#

if you set a value of a replicated variable locally on client

#

OnRep will fire

#

its really not intuitive

#

so its hard to debug when it starts causing problems

#

if you don't know that

jade gazelle
#

I’ll keep that in mind but for 99% of what I’m tying to make the server is handing everything and then just passing info down. There’s very little code that happens on the client other than Ui updates

#

Trying to keep it that way unless I absolutely have to do something on client

winged badger
#

if you haven't already ran into it, i do recommend giving Cedrics Compendium a read

jade gazelle
#

I’ve read it a few times now but every time I go over it a understand it better. The first time I read it I was just overwhelmed

#

Good to know that it’s still relevant though because I was worried some of the info may be outdated

#

Regarding the on rep firing locally. Couldn’t you just add a “Switch Has Authority” at the very beginning of the function and only use the authority branch? Then if it fired locally it wouldn’t do anything

winged badger
#

that would stop it from performing its primary purpose

jade gazelle
#

That..... makes sense, hah

winged badger
#

as a callback after replication on clients

#

its generally not a big deal for most use cases

#

and the ReplicatedUsing in c++ doesn't have that... quirk

jade gazelle
#

I’ll keep testing it tonight but for now it works great

#

Was able to completely eliminate some other code once I set it up

drifting plank
#

Hey ! I've a very strange bug !

I have override the TakeDamage function in C++ on my character and it works great.
But the "Event AnyDamage" in the blueprint doesn't work at all.
If the event in C++ works why the bp event doesn't work ?
The damage amount is not 0 and my collision preset is set correctly to "Pawn".

Thanks in advance for your help 😉

winged badger
#

did you call the BlueprintImplementableEvent from your overriden function?

#

also, this is more #cpp stuff

drifting plank
#

Oh

pliant cypress
#

Hi everyone :)

I have problems with replication (I guess) and I'm hoping someone can give me a little push :)
I store all my game data in GameState, which as far as I understand is fully replicated. I try to "channel" some of that data to the PlayerStates, by casting it from my GameMode to all Playerstates in a loop and modifying a variable in all those Playerstates. I have some success, but weirdly it seems that the PlayerStates on the client's side only refresh every 20-40 seconds. So the data definitely goes through, but what I really would like to achieve is to get the correct "up to date" data every time not just sometimes, if that makes sense :)
In my defense I am a game designer by trade with no programming background :p
I read Cedrics Compendium and it didn't help me with this issue so I guess by definition that makes me dumb, but not dumb enough to ask for help when I'm out of my depth :)
Could you please point me in the right direction?

Thank you in advance :)

rose egret
#

@pliant cypress PlayerState.NetUpdateFrequency is 1 by default 😃

#

just set it to 100

pliant cypress
#

@rose egret it is set to 100, still not good :(

rose egret
#

@pliant cypress it depends on your ping and your actors

burnt blade
#

Anyone figure out the replication graph yet?
Documentation is kinda nonexistant and the stream they put out didnt help much

#

I got the general gist of it, but conceptually I'm missing a few things

#

I understand the point of replication graph is to move the replicated actor list building from a per connection build to a mostly universal list building so that connections share lists and they dont have to be built as often. Just confused as to how actors get assigned to spacialized nodes and how those lists are even sent to the client if they are at all

thorn yarrow
#

I have been pokin at it, but not yet. From what I quickly saw, they create a 2d spatialized graph. Which bounds are defined by the world size. (I wonder what it does with World Composition). From there, the ReplicationGraph.cpp converts their loation to a cell position (just a guess from what I remember from the livestream), and from there places it in the bucket associated with that cell. Likely connections are associated with buckets, thus, only actors in their cell/bucket is replicated to them, rest are likely dormant. I am sure they account for overlap som how but not 100% sure how, likely, connections can be associated with multiple buckets (cells). Just afaik, still learning it too. Anyone feel free to correct me. ^^

#

@burnt blade

cunning stirrup
#

Hello, is there a way to know when an actor becomes relevant to a client ? Like an event or something triggered, i've looked around and found nothing.

#

polling AActor::IsNetRelevantFor() doesn't seem right

winged badger
#

that runs server only

#

you could override it to broadcast a delegate, but it would be received only on server

cunning stirrup
#

yeah that's pretty much what I want, that i know when the state changes

winged badger
#

if its a debug thing, you could fire a Client RPC via RealViewer reference

#

so your client PC would be able to Print out which actor became relevant for it when it happens

#

you'd need to cache the relevant state, add the delegate (static would be best)

#

and broadcast it if the relevancy is different then cached state

#

far from elegant, btw

#

if you can override the function that calls IsNetRelevantFor

#

might be considerably less awkward

strong abyss
#

What is the best way to get a HUD element on screen in an online multiplayer game that reacts to the health of an actor?
I am having trouble getting it to work correctly with respawning enabled.
Right now, I have a health component on my pawns that broadcasts an event when the health is changed and have a bloody HUD overlay like in CoD4 that reacts to the event. So I have to bind and unbind the blood widget when the actor is possessed and unpossessed. But the HUD is created in the begin play of the playercontroller, which happens AFTER the possessed event is fired by the player pawn.
I've tried creating and destroying the widget as well, but it seems no matter what I do, I end up with some concurrency problems across the network.

cunning stirrup
#

use UMG

strong abyss
#

I am. Sorry for the confusion, my hud is made of UMG widgets, not the HUD base class.

cunning stirrup
#

ok then use a replicated variable for the health and delete all widget at death, re-add them on player possess

strong abyss
#

On player possesed is called by the server only right? So I need to call a method/event that replicates on the owning client from the on player posses that creates the widgets for the player character?

#

My pawn creates the widget on possession and destroys it on unpossessed.

#

My widget binds to the event on construct and unbinds on deconstruct.

But when the host respawns, the IsValid node where the breakpoint is fails because GetOwningPlayerPawn is returning null.

This doesn't happen when I hit play for the first time, it only happens after the host dies and respawns. The clients all work as expected.

copper portal
#

@winged badger it still doesnt work

merry pebble
#

I have a question from someone, how can i get my live stream video to play when i am streaming on youtube, but on ue4?

#

So like, i stream on youtube live, and i want it to automaticly turn on my screen in level, within ue4

#

lol idk if thats possible, currently. or do i neeed to code something in?

thorn yarrow
#

you might be able to put a media player in the level and have it open a url. You'll have to try it to find out though.

#

otherwise I wouldn't know of anything, that would just work

merry pebble
#

ight

fossil veldt
#

Anyone know how I can pull players IP addresses through Blueprint?

haughty burrow
#

the multiplayer shootout has that i think? at least it shows IP and player pc i think

#

at least from what i recall the server browser showed a bunch of numbers

fossil veldt
#

I will take a look, Cheers

#

Doesn't seem so

#

Looks like there's just ping there

#

Need to grab the Player's external IP address

#

So it can be stored for a host migration system

next warren
#

1.I have a player when he equip weapon it only equipped on server but not on client and also itself

#

2.E.g Rifle is a separate blueprint which has skeletal mesh,socket name,relative transform

#

3.When i try to equip weapon from inventory it spawns an rifle actor and calls event on used which calls equip function (it is in player bp)

#

4.Everything works on server side but not on client side

#

I replicated actor , variables

#

Spawn an rifle actor on server

shut gyro
#

Has anyone had audio problems when trying to do multiplayer games? I noticed that in 3 players or more, various audio streams would get cut out for both local and remote (atteunated sounds). Would ShooterGame's LocalizedSound Cache system fix these problems?

cunning stirrup
#

Is there a way to replicate a variable inside of a UObject ? I'm getting unresolved external symbol errors when trying to set a UProperty as Replicated.

fossil spoke
#

Yes there is but its not supported out of the box.

#

Google it, there are resources that explain how to achieve it.

cunning stirrup
#

yeah i found some but it's very fiddly

#

is there a simpler way to do it ?

fossil spoke
#

No

#

If there was that would be the way they are explaining how to do it lol

cunning stirrup
#

i'm not stuck with a UObject i just need a replicated data container that can also have references in BP

fossil spoke
#

Use an AInfo Actor

cunning stirrup
#

but I don't want it to be an actor or a component

fossil spoke
#

....

cunning stirrup
#

can't a struct do it ?

fossil spoke
#

Sure, but not natively inside an UObject

cunning stirrup
#

ok thanks

fossil spoke
#

AActor is the first object in the heirarchy that supports Replication

#

Out of the box

cunning stirrup
#

I'm getting many errors trying to implement networking for the UObject the manual way

fossil spoke
#

Fix them?

cunning stirrup
#

more like the replication functions that the scripts are supposed to call is not defined

#

from the wiki

fossil spoke
#

Follow the tut man, its all there.

cunning stirrup
#

Is ```cpp
UPROPERTY(Replicated)
uint32 bReplicatedFlag:1;

#

necessary ?

#

Why is there no simple UReplicatedObject class ?

thin stratus
#

Cause Object Replication requires an AActor

#

That's how it is designed

cunning stirrup
#

and why would you need to have something that can be placed in world when all you need is the data ?

thin stratus
#

There is literally a section "Actor Code For Subobject Support"

#

You can't replicate a UObject without an AActor

cunning stirrup
#

yeah

#

you're right

thin stratus
#

Because it's totally fine to use an AInfo Actor to replicate data if needed.

#

The Data doesn't have to be a class all the time

cunning stirrup
#

but if i'm already using an actor and I just want to send more data though a specific container ?

thin stratus
#

Structs

cunning stirrup
#

structs can't be referenced in BP tho

thin stratus
#

What do you want to achieve then? You can expose your Struct to BPs.

#

BP even support pass by reference for Structs by now

cunning stirrup
#

Basically what I want is to have a class that can store data and directly affect the world, and that can have reference to it

#

the problem with structs is that the reference can't be stored in a variable, as in 4.19.2

#

also they can't trigger any code by themselves

#

AActors have the problem that they are placed in world, so they are subject to culling distances

thin stratus
#

You can mark them as always relevant

#

Otherwise APlayerState, AGameMode and AGameState would suffer from the same

cunning stirrup
#

and UActorComponents have to attached to an actor, which makes them harder to access from a component

#

ok

thin stratus
#

It really only hurts your overall work process if you try to avoid Actors here

#
  • you barely can, cause as said, even for Object Replication you need an Actor that actively replicates them
fossil spoke
#

Dont try and fight the architecture honestly, just stick with how the engine wants you to manage it.

#

AActors are required for Replication

#

Use an AActor

cunning stirrup
#

basically what I'm trying to do is to use them to share data about groups of actors that are bundled together

#

I've already got AActors

#

I just need to share the data

#

so structs ?

#

Well anyways thanks a lot for your time

thin stratus
#

Usually you make a Manager Class that manages the Actors.

#

That Manager could be another Actor or a Component

#

The Component would usually be placed on either GameMode or GameState

#

And in their you can keep track of everything, like groups and such

cunning stirrup
#

GameState can have components ?

thin stratus
#

Sure

cunning stirrup
#

Oh

thin stratus
#

Every Actor Class can

cunning stirrup
#

well that simplifies a lot

thin stratus
#

(at least I'm not aware atm of any actor that can't)

fossil spoke
#

Yes every Actor can

cunning stirrup
#

One last question : Do you know of an event that is triggered when an actor becomes relevant to a client ?

#

I've got data that require some heavy computations so using a RepNotify variable isn't really an option wince the data may be modified and discarding all previous computations would be a waste.

fossil spoke
#

BeginPlay is called again when an Actor becomes Relevant again.

cunning stirrup
#

And EndPlay when stop being relevant ?

cunning stirrup
#

At BeginPlay, are all replicated variables set or is there a delay ?

thin stratus
#

The initial values should be set, but not sure

cunning stirrup
#

BeginPlay is not mentionned in that document

#

ok thanks a lot !

#

Can I make a donation or something ?

#

That saved me so much time

thin stratus
#

Don't worry

cunning stirrup
#

also the Network Compendium should be updated to include that

#

everyone needs to know this

thin stratus
#

What exactly?

cunning stirrup
#

That when an actor becomes relevant BeginPlay is called

thin stratus
#

Yeah, will have to add a good chunk of new info at some point. Sadly barely having time.

cunning stirrup
#

Is there a way to contribute to it ?

thin stratus
#

Nope. Back when I wrote it I didn't plan in contribution.

#

I would need to either rewrite it in GoogleDocs or put it up on some repo

#

but that takes even more time

cunning stirrup
#

yeah...

#

well you can have components and actors that are replicated

#

so that when they are on the server they are also on the clients

#

that's what you use for multiplayer

#

and it works thanks to replication

stray ridge
#

yep that's true but ECS works in more Architectural way of managing things than considering the more object oriented way that components in ue and actors are using

cunning stirrup
#

UE hasn't got an ECS

#

that's a plugin

#

can't say anything about it since i'm not using it / the creator of it

fossil spoke
#

Your better off asking the Author, i doubt anyone here right now would be able to comment on how it works.

cunning stirrup
#

what part of the rep system are you talking about ?

#

replication only copies data from the server to the clients

fossil spoke
#

Go and read the UE4 Replication Documentation.

#

It will explain everything mate.

stray ridge
#

ok just hear me out

cunning stirrup
#

ask the dev of ECS he'll be able to tell

#

here noone knows about that

stray ridge
#

where all the data in clients are manipulated individually but together

#

without the multicast

cunning stirrup
#

can't tell without saying something wrong, my bet is as good as yours here

stray ridge
#

or is it that it already works in the same way

cunning stirrup
#

read the Network Compendium

fossil spoke
#

Read the documentation mate....

stray ridge
#

hence the question

#

😛

cunning stirrup
#

ask the dev

#

or ask directly the question about the replication without comparing it to the ECS

fossil spoke
#

How are we supposed to know how his system works.

cunning stirrup
#

Ask precisely what you want to know using only what is already in Unreal

#

For example : is the replication object-based ?

stray ridge
#

well like i said it more of an design question not a technical object oriented question per say

#

anyways thanks for answering mate

#

I'll try to get a better perspective on both aspects and maybe come with a more refined question.

keen halo
#

Hey all,
So I want to spawn a particle effect on clients close to a projectile hit.
Which option (or other) do you prefer?

Option 1:
Server spawns a replicated actor with desired cull distance .
That actor spawn the particle on clients when replicated - within the cull distance.

Option 2:
The particle is spawned on Multicast.

drifting plank
#

Second seems less expensive

winged badger
#

its not

drifting plank
#

It's more expensive to spawn independtly all particle in each clients than replicates one ? 😮

calm dirge
#

does anyone here have AdvancedSessions for 4.21? or maybe i should ask is it even released?

thin stratus
#

4.21 is still in preview or not?

#

Just wait till it's released. Then the plugin people usually start updating

#

Preview Engine Versions aren't production ready, so most people don't care

#

I never even touch them

calm dirge
#

it isn't in preview, it's released

#

to be frank i accidentally clicked the 4.21 branch instead of the 4.20 one and realised that after it had over half compiled so i thought i will just hang with it, but didn't know advanced sessions for 4.21 isn't out yet...

thin stratus
#

4.21 is not released o.o

calm dirge
#

how come that

thin stratus
#

It's in preview, as I said

calm dirge
#

on github it's just as any other version branch

thin stratus
#

Well, they probably don't mark it there. But they just released preview 4 a few days ago or so

calm dirge
#

and through how many previews does it usually go before it's released?

thin stratus
#

4 is usually quite high already, but nothing stops it from going 5 and 6

#

There are no rules

#

Epic uses the previews to let us find bugs and test stuff.
Then they fix them and at some point release the next preview or release it fully

calm dirge
#

then i'll just wait a few weeks until that plugin is released. i wanted to update our project to the latest version as we're still on 4.19 and it starts to suck

#

thanks

thin stratus
#

Yeah just wait till 4.21 is fully out

#

:P

summer nova
#

@stray ridge ive written an ECS plugin for unreal

#

works like a charm, fast as fuuck

#

but its not worth it

#

you completely lose blueprints, and of course all replication unless you do it yourself

#

and also, the "write back" from the ECS simulation into unreal will bottleneck real fast

#

the overwatch ECS netcode talk is amazing , from gdc paid vault

#

they made sure to have a fully deterministic simulation (much easier to do with ECS) and for prediction they just let the client simulate the game ahead of the server. When there is a mismatch, the client just recalculates the last N frames and lerps beetween the different states

cedar finch
#

Is the "Blueprint Multiplayer" tutorial playlist on Unreal's Youtube channel any good? Seems kinda long and I see a lot of comments saying its not done right. Just curious. I'm trying to setup my pregame lobby and was going to check it out.

balmy kindle
cedar finch
#

@balmy kindle Awesome! Yea i am actually. Thanks

twin juniper
#

Is there a way to make "Network Relevancy" update instantly?

#

https://docs.unrealengine.com/en-US/Gameplay/Networking/Actors/ReplicationFlow
If we look at this, the issue is that every 1 second, relevancy is checked by calling IsNetRelevantFor(). This is fine. However, the part that is an issue is this:

For each sorted actor:

If the connection hasn't loaded the level this actor is in, close the channel (if any), and continue

Every 1 second, determine if actor is relevant to connection by calling AActor::IsNetRelevantFor

If not relevant for 5 seconds, close channel

If relevant and no channel is open, open one now

If at any point this connection is saturated```

We do NOT want a 5 second setup. Is there a way to change this timer to also be every 1 second? How do we change the network relevancy timers?
thorn yarrow
#

Force Net Update can be called on any actor

#

@twin juniper

twin juniper
#

@thorn yarrow But is there a way to actually change the timer?

copper portal
#

@winged badger u here?

thorn yarrow
#

Sure, but wouldn't advise

#

brb

twin juniper
#

How?

thorn yarrow
#

thats how you do it per actor

thorn yarrow
#

NetPriority = 1 = 1/1 = every second
NetPriority = 2 = 1/2 = every half second and so on @twin juniper

twin juniper
#

@thorn yarrow I have netpriority set to 3

thorn yarrow
#

okay

#

should update 3 times as fast, but again, not advised lol. if you want to dynamically change it, do that but would not suggest updating all your units 3 times a second all the time hehe

winged badger
#

that is NetUpdateFrequency

#

NetPriority comes into play when there is more traffic then the capacity to relay it

thorn yarrow
#

"An Actor with a priority of 2.0 will be updated exactly twice as frequently as an Actor with priority 1.0."

#

seems it accomplishes ths same thing but sure

#

its just implicity vs explicity

winged badger
#

the Actor with NetUpdateFrequency of 3 will be considered for replication 3 times per second, basically

copper portal
#

Zlo, the problem still occurs. Ive also tried putting the cast and setting the ref in a run on owning client event but it still doesnt work

winged badger
#

the idea behind giving UMG context is that once it has a reference, it can query all information it needs by itself

#

the pattern also allows for completely changing the UI without altering the underlying game code

#

you display the name via a bound function, correct?

copper portal
#

what do you mean by 'query all information it needs by itself'

#

yes]

winged badger
#

it querries the information (PlayerName) every tick

copper portal
#

k

winged badger
#

if you want the UI to respond to some event, instead of querying it constantly, you use event dispatchers

#

the Pawn has a dispatcher, and calls it when something significant changes

#

and UI binds an event to that dispatcher, so it gets executed whenever Pawn calls it

#

now, WidgetDisplay components are a bit of special use case, in that the Actor owning them can reference the UI by default

#

in general, its best not to have your core code have any knowledge that the UI even exists

copper portal
#

so if casting to the widget and setting the pawn var dont work, then I have to use event dispatchers?

winged badger
#

you'd still need the pawn var to bind

#

you can have the widget display the pawn's displayname instead

#

to make sure the reference is set correctly

#

also when setting up a UI for the first time, you should have part of it clearly visible, no matter if it has context or binds correctly

#

you really don't want to go debugging the name, if you are not sure UI is even visible or in the right spot

copper portal
#

well how can I make this work into the code that I have

winged badger
#

when your WidgetDisplay has a Pawn refernce

#

and shows whatever is in PlayerName variable over Pawn's head

#

then you are done with the widget part, it works fine

#

then it becomes a matter of making sure that the PlayerName is current and correct

copper portal
#

well why does it work when the player is recreated?

winged badger
#

if there was exactly one way to recreate a player, i could answer that

copper portal
#

I use spawnactor

winged badger
#

but the playercontroller and playerstate are already around at that point?

copper portal
#

ye

winged badger
#

dunno if you can pull OnRep_PlayerState in BP

copper portal
#

only if u create a playerstate var

winged badger
#

that is unfortunate

#

since you already have it

copper portal
#

?

#

have what

#

if the host gets recreated when the respawn happens and the nametags show, couldn't I just trigger that respawn event again?

winged badger
#

got any code in that project?

copper portal
#

only bp

winged badger
#

where is your replicated name variable again?

copper portal
#

character bp @winged badger

winged badger
#

and it gets set when?

cunning stirrup
#

at BeginPlay just check for IsLocallyControlled

#

when you spawn the actor it'll get fired

winged badger
#

the way i understand it its a name tag on widget display component that isn't supposed to be only local

cunning stirrup
#

widget are only local yeah

winged badger
#

i mean, other players should see the name too

#

so

cunning stirrup
#

dunno didn't read everything above

winged badger
#

IsLocallyControlled would be counter productive

cunning stirrup
#

check if it's not locally controlled then

copper portal
#

@winged badger begin play

winged badger
#

BeginPlay of?

copper portal
#

@winged badger charcter

#

character*

winged badger
#

and you don't have accessed null?

#

or have IsValid check for PS?

#

because on Characters BeginPlay PS won't be ready

#

not even on server

solar halo
winged badger
#

@solar halo you might get different results for that question asked in #multiplayer and anywhere else

solar halo
#

Where should I ask that then?

winged badger
#

difference being that PlayerState can (and by default does) persist after player loses connection

#

so for a multiplayer game, it has certain advantages

#

that other options do not

solar halo
#

I usually do PS myself, but I'm just curious what people choose and why.

winged badger
#

if you drop connection and rejoin, your PS is waiting for you

#

along with the Inventory

#

so results here will be biased towards the PS

solar halo
#

I should've probably put in the question Multiplayer.

versed socket
#

@solar halo The only reason to put those in the PS or the Character is if other people in the multiplayer server should have a reason to access whatever stuff you have in your inventory at any time. In my opinion, there's no much reason for that so I'd recommend just putting it in the PC and then if somebody needs to access it, you can have a serverside function/event in the PS to get another player's stuff.

solar halo
#

@versed socket What's your reasoning behind Controller?

versed socket
#

@solar halo The PC exists only on the server and on specific client. The player's inventory should only be relevant to those two in particular.

The PS & Character exist for everybody. If you make the inventory replicate through there, then not only does it add extra stuff to send over the network from the server to share with everybody else in the game but it also makes it so that anybody can see your inventory at all times directly. So why do it that way when you can just ask the server to tell you what's in a player's inventory? To me, it makes more sense for the server to tell you rather than to ask the other client directly.

winged badger
#

@versed socket bOnlyRelevantToOwner would address that consideration

#

sorry i mean,COND_OWNERONLY

rose egret
#

how do I sent my own UniqueNetId to server ? :(((

robust wind
#

Hey I hope someone could help me.
I setted up my lobby and menu stuff as I planned to but I want to disable join even if there are spots left for players when the players travel from lobby to game

#

And just can't find much information on how to do that the only thing I find is that it's impossible on BP

rose egret
#

AGameModeBase::PreLogin

#

@robust wind

robust wind
#

Thx

low obsidian
#

Hi Guys, I have a sprint system with a variable CurrentSpeed being replicated. When I call StartSprinting, it calls SetSprinting(bool sprinting) and it will set the CurrentMoveSpeed variable on the server. After calling SetSprinting on the client, I check the value of CurrentMoveSpeed and it is still the default value. But when I call StopSprinting and do the similar logic, it gets the stamina boost. Does this happen because it doesn't wait for the server to execute the code so it just sets it to the value of the variable at the time of execution?

ocean dust
#

Hello, all. What does bReplicateMovement = true for APawn actually do? I have set my custom Pawn to bReplicates = true; bReplicateMovement = true, set its DefaultSceneRoot and SkeletalMesh to bReplicates = true, but it still does not update on clients. What am I missing?

low obsidian
#

After that, check the blueprint to make sure that Replicate Movement is true

#

@ocean dust UE wont set the checkbox to true if the blueprint is already created.

ocean dust
#

These are my settings atm

#

My projectiles replicate correctly with very similar settings. But the Projectiles use a ProjectileMovement component, which I'm guessing is a major difference

#

As my custom Pawns use physics forces to move them around

meager spade
#

do you have a CMC on the pawn @ocean dust ?

#

pawns wont replicate movement by default, you will need to handle replicating a standard pawn

copper portal
#

is it ok to use get player controller with an index of 0 in game instance?

ocean dust
#

@meager spade No, it's a custom Pawn class

#

Then what is the point of the "Replicate Movement" boolean?

#

What is that supposed to do?

meager spade
#

nothing for a standard pawn

#

well it does cant remember off top of my head

ocean dust
#

Well, fantastic. Do you have any links handy for movement replication for custom Pawns?

#

Thanks for the heads up all the same

meager spade
#

i think it just enabled the CMC to replicate movement

ocean dust
#

Why would that be on APawn and not on CMC?

#

Then again, given what I've learned about UE4, that's not so surprising

meager spade
#

cause you dont need to use a CMC, any movement component can handle it

#

like ProjectileMovementComponent etc

#

and its not on APawn its on AActor

ocean dust
#

Why wouldn't that be on UMovementComponent, then?

#

And have those components inherit that?

meager spade
#

APawn is derived from AActor

#

and its AActor that has the replication settings

ocean dust
#

Yeah, understood

meager spade
#

cause the settings are not just for movement

ocean dust
#

Still doesn't make sense why it's a boolean on AActor that does nothing

#

Unless a MovementComponent is attached

#

which seems like it defeats the purpose of the Component-based approach

#

But I digress

#

thanks for the info

meager spade
#

yeah so you will need a custom movement component for the pawn

#

or one of the premade ones

ocean dust
#

Sigh. Alright. Any links for such a thing?

#

Otherwise, I'll start digging through the docs/code

meager spade
#

not sure if UPawnMovementComponent does replication

#

but looks like a good start to maybe replicate the movement

#

for most characters i just use ACharacter even for AI

#

but i know in the near future, i will be writing a custom movemement component for AI, because CMC is so bloated, 100+ AI and the bottleneck is the CMC

ocean dust
#

Yeah I'm learning that UE4 has a very specific and rigid expectation of how their game systems are meant to work

#

and if you stray from that structure, nothing works

meager spade
#

yeah, trying to fight the engine will only dig you a deeper hole into the void

ocean dust
#

Starting to make me think I made a mistake picking UE4 for my game

meager spade
#

well, UE4 is a good engine, i mean there are other engines out there, but UE4 can do basically anything you like but its a bit of a learning curve and its also learning how what and why things do what they do. Don't even get me started on the AI Percepetion system and the fights i had implementing new senses 😄

ocean dust
#

Yeah. I guess my thoughts are: I picked UE4 for its built-in replication and multiplayer abilities. But I'm learning that what I'm looking to do for my game does not fit with what UE4 was designed around, which means I need to implement most of the things I need.

#

I feel like if I have to jump through those hoops, put in all the effort to extend replication to other systems, learn how things work in UE4, why they don't work for my situation, and then crowbar them into place to work correctly

meager spade
#

what are you trying to do with APawn?

ocean dust
#

that I might be able to spend my efforts more productively on an engine like Unity

tribal ingot
#

hello active people im new to the discord where do i go for help with getting leaderboards to work for anroid ue4

ocean dust
#

Where the plugins are meant to be generic and the system as a whole is smaller and simpler

#

The APawn I'm trying to build has a few requirements:
1 Not a humanoid character
2 Moved by physics forces
3 Animated (but only a little, nothing big)
4 Replicated location and rotation
5 Attached static meshes
6 Can be spawned/respawned as a part of player death without destroying the PlayerController that owns it

#

As far as I have come to understand, #1 already screws what UE4 assumes

#

#4 is not done automatically, no matter how many checkboxes I click on

#

And it seems that #2 is going to require a lot of client prediction which is also not done out-of-the-box

#

I ran into other fun problems like "AActor is the root of replication by default"

tribal ingot
#

u need a blueprint making for that?

ocean dust
#

Which means replicating things like Inventory items is stupid difficult and one has to go write their own UObject base class that supports replication

#

Assuming your Inventory items don't need a transform, gravity settings, scene components, etc. that comes along with the hugely-complex-but-somehow-still-lacking AActor class

#

</rant>

gloomy flint
#

If anyone with a more intimate knowledge of replication in UE4 could help me out real quick that'd be cool. I have two players connecting to my game right now: Player 1 as the server, and Player 2 as a client. From the Player Character owned by the client's Controller (P2), I want to call a custom event located in the Player Character owned by the server's Player Controller (P1). Currently, the event runs only in the client's version of Player 1, but Player 1 does not receive the call server-side. Switching the event's replication mode to Run on Server produces a "No owning connection for actor" error, which I assume stems from the fact that the client's Player Controller does not have ownership over Player 1. Am I understanding this correctly? And how can I fix this? I feel like it's something simple I'm overlooking.

gloomy flint
ocean dust
#

@gloomy flint P1 is not accessible by P2

#

your arrow from P2 to P1 is not possible

#

Clients cannot talk to each other

#

they must go through the server

#

You would want to create an event for P2 -> Server -> P1

gloomy flint
#

Hm, okay. How would I go about doing that other than what I have, since P1 is the server?

ocean dust
#

You would create a Run On Server event that P2 can call

#

That will then forward the message on to P1

#

The Server has a reference to both Player Controllers

#

Each Client has a reference to its OWN Player Controller

#

But the Clients do not have access to other Client's Player Controllers

#

So your graph is incorrect

gloomy flint
#

Okay, makes sense. Where would that Run on Server event typically be located, blueprint-wise?

ocean dust
#

It would probably be in the PlayerController, such that the P2(CLIENT) calls a Run on Server event on itself

#

That event will be dispatched to the server

#

Then the server can look up the other player controller

#

and send a Run on Owning Client event to the P1 PC

#

(or just a regular event, if you're expecting P1 to be a listen server)

gloomy flint
#

Aha, okay, that was the issue. I had to set the custom event in P1's code to be Run on Owning Client

#

Thank you so much! I knew I was just mixed up somewhere.

ocean dust
#

Where SendMessageToPC is the event that is intended to run something on another PlayerController, but it actually is replicated to the server

#

Then the server-side forwards that message to the other PC

gloomy flint
#

Gotcha. Thanks a bunch

ocean dust
#

👍

hollow patrol
ocean dust
#

Ok, so my Projectiles replicate correctly while my other Actors do not. HOWEVER it doesn't seem like ProjectileMovementComponent actually does any replication. I'm guessing the Projectiles only appear to replicate correctly because their ProjectileMovementComponent state is being set correctly when they are spawned, and it happens to "play out" the same on both client and server (but not actually synced)?

copper portal
#

@winged badger

#

what should I do?

ocean dust
#

@hollow patrol Is another process already using that port?

#

Maybe an old instance of the dedicated server is still running?

fringe dove
#

hmm, when was NAT holepunching added? from 4.21 preview 4:

Fixed! UE-65576 STUN and TURN servers needs start scripts for first time users

sharp pagoda
#

I thought holepunching was subsystem-specific?

solar flower
#

How can I call events from Player controlled pawns only if they're the locally controlled pawn?

sharp pagoda
#

Client RPC @solar flower

solar flower
#

Can't get this to run on the Server

sharp pagoda
#

Show me what's before the branch

solar flower
#

BeginPlay()

#

This is in the Player Pawn

sharp pagoda
#

That's happening because the controller hasn't possessed the pawn at that point

#

You need to run that after being possessed

#

For the client, you use OnRep_Controller, for the server you use OnPossessed

solar flower
#

It's working for all clients

#

Just not the server pawn

sharp pagoda
#

It might be working in your tests, but in a real scenario it won't. Check the validity of the controller to see if you even have one when you are the server

solar flower
next warren
#

For multiplayer shooting "projectile is best or line trace is best "give some suggestions

#

For network bandwidth

#

For rifle gun,m416 like

bitter oriole
#

Only line trace can work with realistic bullets

next warren
#

Line trace make more bandwidth or projectile actor

ember jasper
#

Hello there !

I'm back with the problem we didn't resolve last time : LAN VOIP !

My colleague and I have been trying to establish VOIP from an empty project, adding everything you could have tell us previous time, without success.

Now the time urges as our project reaches the end and we REALLY need this functionality.

First of all, we tried ShooterGame VOIP which works fine !
Then we implemented our VOIP as follows :

In the PlayerController :

#

This is what we think to be the minimum requirement to establish voice communication.
(We also tried with DefaultPlatformService=Steam without success either)

versed socket
#

@ember jasper When you figure this out I absolutely want to know too

ember jasper
#

@versed socket Ahah, if we find it out, after all the time we've been searching for the answer, not only you will have your answer but we'll really consider making a proper video to not let anyone stuck into this again.
It'd be a real shame if we had to use a 3rd party VOIP software because we didn't manage to make it work on UE4.

proper olive
#

Can anyone shed some light on this? When clients log in, there's some bugs that can arise before they get all the replicated data loaded in. I Managed to put a Get Players Array on the Game State, if it's > 0 then wait until it is, before allowing the player to load in. I also made a widget to access the Players Array and when I look at it as the Server, while the Client is logging in and loading data, it looks like a lot of the Server's variables are getting set on to the Client's Player State until they get their data loaded and then it shows them as the Player State default values that I've given it.... here's a screenshot:

#

^ that's what it looks like on the server when a client is logging in and not loaded yet

#

1 is server's character name, but the client is showing 0 for name even tho the other stats are all coming from the same Player Info struct I put on the player state

#

it actually still has that data until the player overwrites it with signing in to a character so maybe it's getting set in my save game or something

copper portal
#

@winged badger r u able to help me?

mighty rover
#

Is there a standard way to shoot a ping to a specific IP address in UE4?

versed socket
mighty rover
#

I got HTTP requests already sending to get public IP (using a public web service that simply returns your IP in a string, and I crawl the page to get that response). I'm trying to fake nat punchthrough via mobile on cellular networks in my p2p game by using GameSparks matchmaking and cloud code to send host the client IP and essentially let GameSparks do the handshake

#

would an HTTP request work in the same way for verifying client IP?

#

"verifying" in the loosest term possible lol

#

essentially all I'm wanting to do is send a quick ping of sorts to the client from the host to initiate some sort of basic communication between devices, then see if I can let GameSparks do the rest.

#

thinking about how nat/network works, a ping wouldn't give me that anyways. Nevermind

mighty rover
#

just need my host to try to send an outbound connection somehow to the client IP so it fails so that the reverse connection will be accepted.

thin stratus
#

@ember jasper The strange part is, that it's really not much work to get this working

#

Did you consider making an empty project and trying it in there first, to make sure it's not something random in yours?

#

And yes, I know ShooterGame worked for you, but to recreate it, it's maybe better to get rid of everything and just get voice to work first.

#

I only ever implemented this once and iirc I only added some cpp code to the PlayerController to start and stop talking

#
  • the usual ini stuff
gloomy flint
#

I have these custom events being called from a client pawn to a listen server pawn. They were working just fine but all of a sudden decided not to... I haven't changed anything about them or the two pawns' replication settings. Any ideas on where to poke around to get it to work again?

finite moat
#

happen to me before i think it was not the blueprint, i just restarted the unreal and the steamvr driver

gloomy flint
#

Always a good thing to try haha, I'll reboot it just in case. 😂

#

Unfortunately nothing 😦

ember jasper
#

Hey @thin stratus !
I'm glad to have you there once more ^^

Making an empty project is exactly what we've been doing here.
The only difference is : we didn't go through cpp.
We believe the only requirement in the PlayerController is the Sessions management and as illustrated above we implemented it in blueprint.
And the connection is correctly established.
But no voice communication.

Maybe we've been missing something that is implemented in cpp and not in our Blueprint ..? We're on 4.19.

thin stratus
#

Can't say anything about the Engine Version being at fault. The project is def not on 4.19 so it might be, but welp

#
;; EXTRA LOGS START

[Core.Log]
LogNet=verbose
LogOnline=verbose
LogVoice=verbose

;; EXTRA LOGS END

;; VOICE IMPLEMENTATION START

[Voice] 
bEnabled=true

[/Script/Engine.GameSession]
bRequiresPushToTalk=true

;; VOICE IMPLEMENTATION END

;; STEAM IMPLEMENTATION START

[OnlineSubsystem]
PollingIntervalInMs=20  
;DefaultPlatformService=Null
DefaultPlatformService=Steam  
VoiceNotificationDelta=0.2  
bHasVoiceEnabled=true

[OnlineSubsystemSteam]
bEnabled=true  
SteamDevAppId=XXX
SteamAppId=XXX
GameServerQueryPort=27015  
bRelaunchInSteam=false  
GameVersion=1.0.0.0  
bVACEnabled=1  
bAllowP2PPacketRelay=true  
P2PConnectionTimeout=90  
; This is to prevent subsystem from reading other achievements that may be defined in parent .ini
Achievement_0_Id=""

[/Script/Engine.Engine]
!NetDriverDefinitions=ClearArray
;+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"  

;; STEAM IMPLEMENTATION END
#

That's all I have in the Ini

#

And I only have a modified JoinSession Node cause we passed the VR device name over

#

Otherwise it should be the default nodes

#

And in the PC

void ASomePlayerController::K2_StartTalking()
{
    bool bUsesPushToTalk;
    GConfig->GetBool(TEXT("/Script/Engine.GameSession"), TEXT("bRequiresPushToTalk"), bUsesPushToTalk, GGameIni);

    if (bUsesPushToTalk)
    {
        StartTalking();
    }
}

void ASomePlayerController::K2_StopTalking()
{
    bool bUsesPushToTalk;
    GConfig->GetBool(TEXT("/Script/Engine.GameSession"), TEXT("bRequiresPushToTalk"), bUsesPushToTalk, GGameIni);

    if (bUsesPushToTalk)
    {
        StopTalking();
    }
}
#

(we have PTT)

#

Then some more "Mute/Unmute" functions

#

As well as the PlayerState exposing a "OnTalkStateChanged" event

#

But that is all just extras

#

90% sure that's all I did

#

It worked locally with 2 PCs over Steam.

#

Never tested it online though

ember jasper
#

Thank you very much cedric_eXi ! The only notable difference here is the use of "StartTalking" and "StopTalking" where we've been using "StartNetworkVoice" and "StopNetworkVoice" in Blueprint, which are both calling StartTalking and StopTalking in cpp as shown here from the Engine :

finite moat
#

@gloomy flint just noticed isn't it Run On Server if you want it to run on server and called from client

ember jasper
#

We also are not using Steam OnlineSubSystem.
We'll proceed with some testing based on your exhaustive information, trying to implement VOIP through cpp this time, and come back to you to report whatever result we had.

Thanks again !

stable kindle
#

Hi guys i have a quick question abot the COND_InitialOnly and Deffered spawning. Would calling a deffered spawn delay sending the initial properties

jolly siren
#

Does anyone know the proper way to destroy a replicated actor in BeginPlay? This is causing them not to get destroyed on clients. I guess deleting them on the server before they replicate to the clients causes them not to get destroyed on the clients. Trying to avoid using a hacky delay.

#
void AFPSGunPickupZone::BeginPlay() {
    Super::BeginPlay(); 

    if (Role == ROLE_Authority) {
        // Destroy the gun pickup zones if pickups are disabled
        AFPSGameMode* GM = Cast<AFPSGameMode>(GetWorld()->GetAuthGameMode());
        if (GM && !GM->GameVariant.SpawnPickups) {
            Destroy();
        }
    }
}
stable kindle
#

The ideal case would be to not have them spawn at all if at all possible

jolly siren
#

Right, they are placed in the editor tho in this case

stable kindle
#

@jolly siren perhaps you could put them in a sublevel and check in the level blue print before loading the sublevel

#

That way they are never loaded

#

The level blueprint could check game mode and then load up the sublevel with the pickups etc

jolly siren
#

That is a good idea jespersbane

stable kindle
#

@jolly siren Thanks ^_^

jolly siren
#

Couldn't I also set bNetLoadOnClient to false?

#

Or will placed map actors not replicate on initial creation?

stable kindle
#

they would not load up on the clients at all afiak

jolly siren
#

ah okay, yeah I think you are right. Was hoping they would replicate instead of loading, so in that case they just wouldn't replicate over if destroyed on the server. But I don't think that is the case.

covert flame
#

Hey guys, this is my first question here and I am looking for some basic multiplayer advice. Our multiplayer project has the possibility to spawn as different roles, there is a VR role which results in a "VR_Character" being spawned. And there is an observer role which is a pawn type atm. as both are VR-controller, both c++ classes replicate their transform in tick. starting a listen server and being spawned as the VR character role, i can see the observer pawn moving around etc. but unfortunately not the other way round. The observer does not see the character. There are 2 playerstates that the observers sees and I checked that the server and client transforms for the observer is the same. Atm i am more confused about where to look. Is this a character or observer problem? I did not check any more details except there are 2 playerstates that the observer sees. but not if he gets the correct VR-Char transforms or something. Any help would be appreciated

swift topaz
#

Any clue where the hard cap for replicated objects is located? The cap is set to ~10,000 roughly, but I'd like to know what manages it.

slim holly
#

you don goofed if you go anywhere near that limit

swift topaz
#

Unless you plan on making your own run-time levels for people to modify? 😉

bitter oriole
#

Still a terrible idea

#

You can't replicate that much, period, it won't work

#

@swift topaz If you're doing runtime levels you should have the level components un-networked, spawned locally based on a common information

#

Send a map file over the network once, parse it, spawn everything

swift topaz
#

One of the main issues with that is the interactive component. Replication is still required if you have objects you need to properly update. Say opening doors, turning lights on and off, opening chests. All these elements still need to exist on all machines. Especially if you try to move things around like a bookcase and you want everyone to see the state it's in.

winged badger
#

send a random seed, generate the same map on every machine is always nice

#

and if number of types of objects is limited, you could have a manager actor/component handle their "replication"

swift topaz
#

There's no procedural generation either. The map is being created by a player for other players to interact with.

winged badger
#

looked at FFastArraySerialization?

#

it will replicate structs in an array, but only ones that were added/changed/removed, and it can fire client side notifications

swift topaz
#

have not looked at that, will have to look into it

winged badger
#

NetworkSerialization.h has a lot of comments explaining how it works, and an example of how to implement it

slim holly
#

guys you don't need to replicate every switch or doorknob, only the action that activates it

#

sending single multicast boolean is much cheaper than replicating door animation to all clients

winged badger
#

replicating a state in above mentioned struct works too, and it doesn't leave late joiners in invalid state

ocean dust
#

Hello, all. Another day, another multiplayer problem. I have changed my entire Pawn structure to use SkeletalMeshes as their root scene component, and that seems to properly allow my NPCs to replicate their location correctly. However, my player-driven Pawns are not properly replicated to clients. What's weird I can see that they are moving on the server based on where their particle effects are playing on the clients, but the skeletal meshes and actor locations REFUSE to change on the client(s). To reiterate: my NPC Pawns are moving and replicating correctly as far as I can tell. My Player Pawns are not updating their positions on clients and I am struggling to figure out why. I have set Replicates, Replicate Movement, Always Relevant, and Never Dormant, and several other settings for the Player Pawns, but still nothing works

#

What's extra weird is I've also set up some debug printing of the Player Pawn's location. And it reports that the Pawn is in 2 different places over the course of a few frames: the location that is has been driven to, and a location very close to 0,0,0

winged badger
#

i do think CMC prefers a capsule

ocean dust
#

I am not using a CMC

swift topaz
#

correct me if I'm wrong, but when a player attempts to place down a door that other players can interact with, that door should be server spawned so that you can do/see the interactions from every player client, does that not require the door to be replicated?

slim holly
#

not necessarily

#

you can also multicast the event that spawned the door

swift topaz
#

do go on, cause you just blew my mind

winged badger
#

you can simulate the door

#

you just need a way to reference it afterwards

ocean dust
#

You can broadcast a message that says "I placed a door here"

#

Without having the door itself replicated

winged badger
#

now with Actors loaded from a package, that is easier

slim holly
#

you know, shit gets really weird when you start optimizing network bandwidth

winged badger
#

as they can be referenced over network, non replicated, out of the box

slim holly
#

but, it is expensive

winged badger
#

you can't send a pointer to a door inside a Multicast event later, and say OpenThisDoor

#

that is the drawback

slim holly
#

assuming there are <250 doors, tag-em

#

sorry, less than 4 million doors

#

getting generous and using integer

winged badger
#

you can use above mentioned FFastArraySerialization to keep them in sync - trivial example, you have TSubclass<ADoor>, FTransform and bools bOpen and bLocked

#

inside the FFastArraySerializerItem struct

#

its callback for Added spawns a door at the right Transform in the right state

#

and its callbacks for change... well, change the state

#

downside is that you would probably need a separate custom serialization for each group of Actors

slim holly
#

unless it's just an actor

winged badger
#

upside is that your struct could store a pointer to actual Actor in its added callback, which would solve referencing non-replicated dynamically added Actors over network for you

#

yeah, but then you have to account for every state every Actor can have

#

in single struct

swift topaz
#

Thanks for the information, looks like we'll have to re-structure the way actors get created and exist in the world.

ocean dust
#

OK, more info

#

I changed the settings to 2 clients. The non-owning client gets the updated position for P1

#

But P1's client does not

#

How is that even POSSIBLE?

covert flame
#

no one an opinion to my question? 😄

winged badger
#

what do you use for movement component again @ocean dust

ocean dust
#

Nothing

winged badger
#

ReplicatesMovement might avoid sending updates to owning client

ocean dust
#

But it sends them to other clients? That seems....weird

winged badger
#

its usually assumed that owning client has a fair idea on how to simulate it

#

CMC won't replicate stuff like Velocity to the Owner to save bandwidth, for example

#

if that pattern holds...

#

well, that and it might cause a jitter in the simulation as well

ocean dust
#

Well, I tried using a Multicast event to sync the transform

#

and it still didn't work

#

this is the strangest thing I've seen so far

calm hound
#

@covert flame - Unfortunately you're going to have to put more effort into it than that. Your description is very subjective, and you really haven't provided much details, code, blueprints, etc. Replication is a very complex subject, and posting with just a result leaves no one with any real data.

ocean dust
#

Is it possible for a dedicated server or listen client to load more than one level at a time?

#

In other words, have players connected to each other but in different levels?

covert flame
#

@calm hound Well, hmm I see. I thought that it would be good enough to give hints if I tell you my obersavtions but one character seeing the pawn but not vice-versa but sure, gotta check more data anyway 😃

swift topaz
#

Only one dedicated server per map is possible @ocean dust all players exist on the same server, ergo same map. You can server travel everyone to other maps (borderlands style), but if you want to jump to a completely separate server, then a diff dedicated server needs to be launched which will take care of the other map.

ocean dust
#

Well damn. I want to enable players to go into different areas independently of one another. Is that even possible in UE4?

#

Also, thanks for the info

swift topaz
#

afaik, not out of the box, you would need to spin up one server per map and then direct players from one server to the other, passing relevant information via connect options.

ocean dust
#

Is it possible to spin up a dedicated server of the game on a player's computer and also have a client run without making that player a listen server?

#

In other words, can I run a dedicated server on my computer and play with my friends on that dedicated server on the same computer without having to run command line programs or jump through crazy hoops to get the server set up?

swift topaz
#

You can run a dedicated server on your machine and have people connect to it the same way as a listen server, yes.

ocean dust
#

What are the nodes for starting/stopping a dedicated server? Is this possible in BP?

#

Or in C++?

swift topaz
#

You just need to build the dedicated server, just means you need to get engine source code and compile so that you can create dedicated server builds. Then all you gotta do is launch the server executable and you're done.