#multiplayer

1 messages ยท Page 265 of 1

lament flax
#

what engine functions are responsible of spawning replicated actor from server to clients ?

lament flax
#

mh, world subsystems are initialied BEFORE the world creates a net driver

#

so creating the actor in world subsystem init was dumb

#

goodbye files, i wont miss you ||for now||

carmine bobcat
#

Hey ๐Ÿ‘‹ I was wondering if anyone could help me out figuring out replication when using UCharacterMovementComponent::ApplyRootMotionSource.

From the docs, it reads to me like applying a Root Motion Source on a client (autonomous proxy) should lead to the resulting movement replicating somehow to the server, and to other simulated proxies as a result.

When I tested it out, it seems to be the case that the client would apply the root motion, but the server wouldn't, leading to the client being forced back to its original position by the server.

I also tried applying the RootMotionSource on both the client and the server, and in this case both server and client moved, but the movement on the client was choppy, which I assume is due to the positions being out of sync, so I'm not sure this is the right approach either.

I've tried digging into GAS, but I don't really understand it well enough yet to figure out how it supposedly works there.

It's hard for me to get to the bottom of what's wrong when I'm not 100% sure I understand how things are supposed to work. I can definitely share some code/videos if it helps as well.

lament flax
#

still getting an assert on server when trying to replicate a Uobject in a fast array

// fast array entry
USTRUCT()
struct FPSPrefabPropertiesObjectEntry : public FFastArraySerializerItem
{
    GENERATED_BODY()
        
        ...

    UPROPERTY()
    TObjectPtr<UPSBaseActorPrefabProperties> PropsObject;
};

// fast array container holded by replicated actor
    UPROPERTY(Replicated)
    FPSPrefabPropertiesObjectContainer PrefabPropertiesObjectContainer;

// in actor ctor
bReplicates = true;
bReplicateUsingRegisteredSubObjectList = true;

// using AddReplicatedSubObject and giving the UPSBaseActorPrefabProperties
carmine bobcat
#

Hey ๐Ÿ‘‹ I was wondering if anyone could

pseudo wagon
lament flax
tardy fossil
#

setting LogNetPackageMap to verbose might give some clues

lament flax
#

thanks, will do

#

i already done this setup in other projects and didnt had issues, idk if i missed something or if things changed in 5.5

tardy fossil
#

oh is UPSBaseActorPrefabProperties just a UObject? is it set up properly to replicate as a subobject under an actor?

lament flax
#

i override IsSupportingNet and using AddSubobjecttolist on actor

lament flax
#

how is renaming an object managed ?
for example when chaning outer on server before/after it was replicated to clients

lament flax
lament flax
#

so now that i fixed the issue by chaning the outer, PostReplicatedAdd is called on client when i add the entry on server, but my replicated UObject is null (which seems possible since its not atomic^), but the PostReplicatedChange is never called wit ha valid pointer

#

i tried using atomicity with NetSerialize but when its called on client the UObject is also null

#

okay, tested with a simple property and its reped

#

so its an issue on the fast array

gilded vapor
verbal dust
#

Im having an issue with playing a landing animation on server side. I think it might be the on Notify end triggering immediatley instead of when the notify ends but im not sure

#

Theres a bit of delay on client side too. I had it set up to trigger the montage client side and server side but im doing it server side only now to figure out whats going on

lament flax
# lament flax so its an issue on the fast array

tried more stuff, if i reuse this actor member replicated property i dont get the OnRep called on client, so it doesnt seem to be linked to the fast array but an issue linked to the fact the object im assigning was an instanced object from another not replicated actor component

#

so could be because i changed outer before reping (but its not the same compared to the loaded object)

#

tried to duplicate the object with StaticDuplicateObjectEx and replicate as subobject the result, but not working

small wraith
#

Heyo, I have a question.
I want to make a game that has a multiplayer option with identical gameplay to the single player one, but I know multiplayer is miserable in Unreal, replication, rpc, authority and whatnot.

Realistically, how feasible is it to start the project single player only and then eventually turn it into multiplayer? I am assuming it would be borderline miserable because the logic is vastly different but I'd be curious to know if it can be done, just to speed up the prototyping / early stage of the game

#

I know at least it's possible in Godot, I've seen Buckshot Roulette turned to MP a good year after its releaae

fossil spoke
#

but I know multiplayer is miserable in Unreal, replication, rpc, authority and whatnot. that makes no sense. Unreal is by far the easiest and user friendly engine to implement multiplayer in...

fossil spoke
#

You EITHER make a SP game and sell it as SP, OR you make a MP game and sell it as that.

#

You dont just casually convert a SP game into MP.

#

You may as well just rewrite the whole thing.

#

Its much easier to make a MP game into a SP experience than it is the other way around.

small wraith
#

So if I want a game that has sp + mp I have to program it like an mp and sp is just a fake mp with no server?

fossil spoke
#

Yes, essentially.

#

The SP experience would just be like running a Listen Server.

small wraith
#

That's just awful

fossil spoke
#

Why?

small wraith
#

Everything takes 10x to debug, things like hud and screen interaction (clicking on things etc.) is finnicky, not to mention syncing anims etc
I know because I have done it, I have a project like that and I literally gave up because of the endless chase of bugs with rpcs, rep notifies and whatnot

fossil spoke
#

Then dont make a MP game...

#

If you find that stuff to much to deal with, just make SP experiences.

small wraith
#

It's miserable regardless of how much you gaslight me, and anyone will agree on that

#

But regardless I got my question answered

fossil spoke
#

๐Ÿคฆโ€โ™‚๏ธ

bleak hornet
#

so i have server portion for playfab set up, but i dont fully understand how to finish the client side, and on top of the my game isnt packing for some reason

fossil spoke
bleak hornet
#

Assertion failed: (!FPlatformProcess::SupportsMultithreading()) || (!bIsRunning) [File:A:\UnrealEngine\Engine\Source\Runtime\Core\Private\Misc\MonitoredProcess.cpp] [Line: 108]

#

ive restarted unreal, and my pc

#

just got it again

#

its something to do with turnkey as it wont let me install sdk for windows

dark parcel
# small wraith It's miserable regardless of how much you gaslight me, and anyone will agree on ...

I don't agree with this statement, can you find any other Game Engine where it's easier to implement multiplayer?

MP game can be played as SP but not vice versa because both are architecturally different.

Doing multiplayer as not a seasoned developer is miserable to begin with. And depending on the type of the game it gets a lot harder (e.g real time / turn based).

If one never release a single player game, I wouldn't jump to MP.
You will be miserable trying to figure out OOP when there are multiple instances.

verbal ice
#

Buckshot Roulette also isn't a good example of SP -> MP. It's a very simple game to program, so if you were to make it in Unreal in single player, and then port to MP, it also wouldn't be too long

#

But honestly having toyed with different networking solutions in Unity, Unreal takes the crown for the best networking atm

dark parcel
#

That sounds like just a single game mechanic, wouldn't be too long to re-work the entire thing.

bleak hornet
verbal ice
#

You'd implement your game with multiplayer in mind

#

Anything short of a tiny game is going to pretty much need a lot of rewriting to port from SP to MP

dark parcel
bleak hornet
#

alright, so its whenever i try to check, it crashes unreal

#

when i click refresh platform status

dark parcel
small wraith
#

And then the guy below you contradicts your claims by saying buckshot is easy when it's a turn based game

dark parcel
#

Roullete is a single game mechanic

#

you can just re-do that from scratch

verbal ice
#

Buckshot is stupidly easy to program, it's the art that probably took the longest

dark parcel
#

You are just wrong when you said Unreal is miserable and difficult to implement multiplayer when infact it's one of the easiest Engine to implement multiplayer out of the box.

verbal ice
#

There's a lot of learning for Unreal's multiplayer sure

#

Doesn't make it bad though

small wraith
dark parcel
verbal ice
manic bluff
#

Big agree, the way that Unreal handles multiplayer made it 10x easier for me to learn. It's got some quirks and things that you need to understand, but so does literally every game engine when it comes to multiplayer. If you're looking for the shortest and easiest* route, then it's Unreal

bleak hornet
small wraith
#

lol, try it I'd be curious

verbal ice
#

If you make Buckshot with multiplayer in mind, it's literally the same as a 1v1 or 1vX

#

Joins channel full of multiplayer devs
Gets told how you learn how it works and it's really good
Gaslighting
Like, come on

dark parcel
#

literary that, 1v1 or 1v4 or 1v9 makes no difference

#

the moment it's networked, the logic is just different.

small wraith
dark parcel
#

no one needs to do your homework

verbal ice
#

I'm not wasting time for some random discord user that calls "gaslighting" the second someone says something they don't like

small wraith
#

I'd be impressed if you even get the players spawned

dark parcel
#

lmao

manic bluff
#

holy

small wraith
dark parcel
#

this gotta be a troll

verbal ice
#

Cat is that you

manic bluff
small wraith
#

Yeah I'm a troll, whatever
Go make 64player bf6 in blueprints prodigy, y'all so full of yourself is unreal

verbal ice
#

Worked on a 100 player game but sure, can do 64

small wraith
#

Circlejerk among yourself, throwaway accounts ftw

verbal ice
#

Bwahahahahaha

dark parcel
#

you won't get far in life with that attitude

verbal ice
#

Don't feed the troll

#

We'll get in trouble

verbal ice
manic bluff
#

so difficult man SadCat

verbal ice
#

I don't get why you'd join a server to ask questions to people with (probably) more experience than you and then start flipping out

#

What's the point

manic bluff
#

bro literally went sicko mode 3 messages in, like what

#

anyway OMEGALUL i got my entertainment for the night

dark parcel
#

This gets confusing, why does all my A.I returns true on IsLocallyControlled?

if (PawnOwner->IsLocallyControlled())
{
    PrimaryComponentTick.SetTickFunctionEnable(true);
}
#

I guess A.I controller counts as well not just PlayerController

verbal ice
#

On the server?

dark parcel
#

well A.I controller only exist on the server

verbal ice
#

guessing it is locally controlled by the server

#

in a sense

dark parcel
#

yeah

#
if (PawnOwner->IsLocallyControlled() && Cast<APlayerController>(PawnOwner->GetController()))
            {
                PrimaryComponentTick.SetTickFunctionEnable(true);
            }

throwing extra check, hopefully does the trick

#

aww damn, the character isn't possesed yet by the player controller by the time the ActorComponent begin play gets called.

quasi tide
#

Awww - I'm surprised no one pinged me when they brought up Godot to try and compare ๐Ÿ˜…

thin stratus
meager aurora
#

Hi, what would you recommend for handling frequently changing replicated variables. In my enemy ai properties like gait are changed quite frequently depending on circumstances and sometimes the changes are picked up sometimes not.

tardy fossil
#

MP in unreal is only miserable if you dunno what you're doing

#

oh whoops i was scrolled up

dark edge
nova wasp
#

having a secondary value to describe the context behind the velocity isn't that weird

#

it's not just a ball rolling around

dark edge
#

But if that value is derived from velocity to begin with then what's the point?

nova wasp
#

sure, if it can be derived from other values it is redundant

meager aurora
proven pagoda
#

Am I stupid here? I'm not used to doing multiplayer in blueprints, but I simply want to destroy this actor and this works for the server but not the client. In C++ I just call a server destroy and it works for my projectiles but this thing doesn't on clients

#

The breakpoint hits it just fine on the client

nova wasp
#

who spawns the projectile?

proven pagoda
#

the projectile ability class spawns the projectile and sends it off

nova wasp
#

I am not really concerned about GAS or whatnot here, I am asking if it is spawned on the client or the server

proven pagoda
#

Server spawns it then

#

just like the server spawns this item class

nova wasp
#

does the rpc just not reach the server?

proven pagoda
#

Correct

nova wasp
#

it might not reach the server if the server has already destroyed it on their side

#

"this works for the server but not the client" does not really describe what isn't working

proven pagoda
#

I put a breakpoint on the Destroy Actor function and the breakpoint does not stop on it

#

I made another event similar to this and just put a print string for hello and that also does not print string

#

I'm not familiar with multiplayer in blueprints is there some setting I'm missing perhaps

nova wasp
#

ah, I forgot

#

multiplayer in blueprints is not any different from C++ in reality except for being extremely limited and onreps also running on the authority

#

does the client own this actor?

#

client->server rpcs must be from something the client owns

#

generally their player controller or possessed pawn

proven pagoda
#

Nothing owns this actor

#

owner is nullptr

nova wasp
#

might be time to read the docs on multiplayer rpcs

#

clients can only send rpcs on things they own

#

you can make a new rpc that includes this item as a parameter of the rpc (but as an rpc on something they own)

proven pagoda
#

Ok but the rpc is being sent from the actor itself to itself

nova wasp
#

read what I said again

#

when I mean "they" I mean the client themself here if that was too ambiguous

#

so for example the client must send rpcs from their player controller, pawn etc

proven pagoda
#

I have the player controller inside this item actor

nova wasp
#

sure

proven pagoda
#

I can just pass the item pointer as a param and call destroy from inside my player controller that's interesting

nova wasp
nova wasp
#

this is a very frustrating aspect of multiplayer but you can help spread the code out with actor components

#

you can add new controller components etc

#

to serve as places to add new rpcs

proven pagoda
#

Well I also have the inventory component from the player controller inside this actor as well

#

I could pass it back into the inventory and do it when I pick up the item

nova wasp
#

that should work as long as it's a replicated actor component

proven pagoda
#

Hmm

#

It is replicated

#

I've never run into this before in multiplayer I'm sorry this is weird I have done so many other things multiplayer and why have I not run into this before

nova wasp
#

one not so great part of this is that other players will never see this inventory

#

as it is on the player controller

#

which only exists between the client and authority

proven pagoda
#

Yeah that's true, but now I can drop items from player to player

#

I'm close to player trading

nova wasp
proven pagoda
#

That's where most of my replication is handled if I look at this project really

#

I didn't put that together

#

hmmm

nova wasp
#

I personally am not a fan of the fact it silently fails I guess

#

like at least in the editor it should just go "lol no" and error log when reading the bunch

#

instead of silently not sending/rejecting

#

(not your code, the way this works in the engine)

proven pagoda
#

That would be nice

#

if it would say

#

hey this didn't send

#

Bro you're a godsend

#

Put it like this in the component

nova wasp
#

pointless trivia: you actually can keep an object alive the server has destroyed through some ways

#

not sure if it's possible in bp

#

to TearOff etc

proven pagoda
#

Back in here just pass this

#

lmao my C++ was old code

#

With the new item destroy

dark parcel
#

PC is the wrong place if the items need to be known by other players.

#

player state is replicated to all, so that's a better candidate.

proven pagoda
#

The item isn't inside the player controller

#

It just exists in the world

#

and is replicated out to them

nova wasp
#

yeah, but when they pick it up it might be interesting for other players to see how many health kits their teammates have or something

#

but if you never need that it's fine to hide it

proven pagoda
#

mmm I'm making an RPG I'm not really looking to share inventory info with other people

nova wasp
#

one thing you can do is have a separate COND_SimulatedOnly replicated thing just for simulated proxies that only need to know about some things and not others

dark parcel
#

So you can't look into some other player profile and check what their equipping?

nova wasp
#

most MMOs I play let you inspect other people

proven pagoda
#

Ok but my equipment list is different than my inventory list

#

so why replicate the entire inventory to inspect equipment

nova wasp
#

okay, if that's something else then I guess it's already done

#

I kinda though they would be the same thing I guess

proven pagoda
#

They communicate sure but no they're independent

dark parcel
#

just keep in mind that client only have their own PC.

proven pagoda
#

I understand

#

I made a leaderboard system for a MOBA once that I displayed live update all players in arena 4 clients what everyone was equipping and unequipping as they bought from shop and gained consumables etc

#

I couldn't do anything with the player controller in it

#

Well actually lmao I collected all player controllers if I look at it and use them in the system

#

what am I doing bro

#

yikes

dark parcel
#

Team's score = Game State

#

player's individual score = Player state

proven pagoda
#

Who said anything about score

#

I'm talking inventory and items equipping and unequipping

dark parcel
#

well you are talking about leaderboard

proven pagoda
#

Ok well I never got to the player score for them they only asked for the items and the GAS stuff really

#

I had to hook it up to everyone's ASC and read it etc

dark parcel
#

unrelated to this convo but I seen enough bad youtube tutorials.

proven pagoda
#

then someone else took it didn't they

dark parcel
#

like Matt Aspald place HP in player controller.

proven pagoda
#

I tried watching them but I can't take them seriously

#

I'm not the best I know I'm not

#

but there's just things that are genuinely what the fk

proven pagoda
#

This item is irrelevant, but the concept is the same. My Equipment Component just handles the currently equipped pieces while my inventory holds the info about all the equipment the player is carrying that's not equipped, but in the end both of them are on the player controller. If I wanted someone else to inspect me and see my equipment, I will need to move that off the player controller to the player state instead, which would be fine I could handle the swap just fine. I was so focused on the specifics that it was this item I missed the bigger picture

frosty helm
#

Is it a good approach to have a state tree only play on the server and then replicate the visuals of the state it is in to the clients?

#

So that the logic is executed on the server, but the particles and animations are played on the clients?

fallen fossil
#

Can subsytems use any rpc? Or all of them are local? ๐Ÿค”

junior timber
#

Trying multiplayer for first time.
I have a widget with textbox and when you type a text and do enter.. It sends an interface to an Actor "WordManager"

The above is simple setup I did to debug a issue.
The variable current word changes in server and clients if I do in server.

But when I do enter in clients. Only it changes in clients. Even though I have set it to run on server

fallen fossil
#

I am thinking in terms of loading game.
How does it work.
If client has some object(game system or some actor component) that holds quests info or just his action history, I would like this to work after loading game / joining multi

fallen fossil
junior timber
#

from actor.

#

if I type a word in client. It is only doing for client
but if I type a word in server, it works for all

fallen fossil
junior timber
#

it is just a simple blueprint actor that I have placed in level.
Wouldn't that mean it creates each instance of that actor? do I have to set up manually for the actor to be owned?

#

I just searched chatgpt.. I'll try to understand it/ Thank you

humble idol
fallen fossil
#

try testing in Player Pawn, it is usually owned and spawned with proper owner.

Or just spawn on server with proper ovner

fallen fossil
# junior timber it is just a simple blueprint actor that I have placed in level. Wouldn't that m...

๐Ÿ‘จโ€๐Ÿซ My Patreon link:
https://www.patreon.com/kekdot
Download Project Files | Premium Tutorials | Courses

๐Ÿ•น๏ธ Get our Game on Steam | The Anomaly Project:
https://store.steampowered.com/app/2960770/The_Anomaly_Project/


๐Ÿง‘๐Ÿปโ€๐Ÿš€Get the project files here on Patreon: https://www.patreon.com/posts/66842088

In this video we...

โ–ถ Play video
junior timber
#

Did watch this to understand the concept. Still confusing.

junior timber
humble idol
junior timber
#

This is literally the only setup I have done.
I am using actor blueprint... As mentioned before the server only owns this actor...
So maybe that is something I need to check

fallen fossil
#

then client can not use it to send data to server

junior timber
#

Yes, wordmanager is calling the RPC.

junior timber
fallen fossil
#

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
#

this explains more in detail

junior timber
#

Yeah, I also watched this video.

fallen fossil
#

6:10 is ownership

shut vigil
#

Hello i just have a quick question

#

Correct me if im wrong

#

Get actors of class affects all actors of that class. for example if i subtracted money from using get actors of class it would subtract money from all of the actors right? and if I subtraced money using a cast node then it would only remove money from that single instance of the actor right?

fluid prawn
#

Quick PlayerState Connecting/Disconnecting wanna make sure its not hersay. But Tracking Player State and Seeding it during PostLogin and removing the player state on disconnect is the correct way?

junior timber
#

get all actors of class will give you an array of that actor in your level.
Get actor of class will only give the first actor of that class in your level.

I think you will need to loop for get all actor of class but also that money variable should be instance variable so that each can have different numbers

shut vigil
junior timber
#

get actor of class will only give you first actor only..
If you have multiple same actors in level... it will not give you all..

it will only do the effect for the first actor

for get actor of all class, it will get all actors and then you need to use for each loop

shut vigil
#

AAAAHH

junior timber
shut vigil
#

oops caps lock

#

nah i get it now

shut vigil
junior timber
#

You have to use RPC to update variable for server and clients

shut vigil
#

RPC what does that stand for?

shut vigil
frosty helm
#

How do I set a variable in my animation blueprint on all the clients from an ability task? I want to set my IsAlive bool to false.

#

Setting the variable from the ability just sets the variable for the server, but I want it to replicate and also set the variable on all the clients as well.

#

If I try to make a custom event with multicast inside my gameplay ability I get this error.

dark edge
frosty helm
shut vigil
#

Hi I am having an issue. I am reprograming some of my code. Specifically picking up items and how that works on multiplayer. I have an even that runs on server that adds a component to the player. But it is not adding the component when doing this on the client player

#

it only works on the server player

#

using mutlicast does not fix anything

#

and making the event that adds the component run on multicast and then callign that event on the sever dfoesnt fgix it as well

#

So basically

#

The server player can pick it up just fine

#

but the client isn't properly

#

even thought It should

dark parcel
dark parcel
#

Iirc theres a gotcha when it comes to run time component.

dark parcel
junior timber
dark parcel
finite kernel
#

That or have a dedicated proxy actor relevant for this system

#

its basically use playercontroller or existing actor as proxy making it massive monolithic mess after some time

#

or have dedicated proxy actor for each system for tidy code

#

In iris a lot of actors are of no issue

#

legacy system nope

dark parcel
#

Well you can turn it into actor component where you can attach it to the pc or character. That way the pc or the character isnt convoluted

finite kernel
#

yes you dont necesarily need to use actor as the proxy, component works just aswell

shut vigil
#

I will ping you when I get back @dark parcel

junior timber
#

Thanks for help. I was able to reroute the message from my widget textbox --> playercontroller ---> actor
as playercontroller is always owned by player

dark parcel
#

@junior timber another thing to note is that client only have their own PC.

#

So if you need to do multicast, that's not the place

#

As client 2 does not have a copy of client 1 PC and vice versa.

junior timber
#

Yeah, first run on server --> then multicast

dark parcel
#

If you need to do MC then attach to your character not player controller.

dark parcel
#

A multicast from the server will only land on the client"s server copy and the client that own it, since client doesn't have a copy of other client player controller.

Check our wizard multiplayer tips and trick pinned in this channel.

#

You will get bug 100% if you play with 2 clients or more.

shut vigil
#

@dark parcel

#

The component is set to replicate and this is what the code looks like

#

The Server player gets the component added to them completely normally

#

the client prints the "Added string but does not seems to have the component

shut vigil
#

@dark parcel (sorry for the ping) I put a print string right after the Add BP Flashlight Component and the Client doesnt even print that string

#

Okay so another update

#

If i make a on server event in my player blueprint and then call THAT in the actor it gives the client the component

junior timber
# shut vigil Okay so another update

https://youtu.be/BJh_R2zCCdk

I watched this 3 part series and it explains a bit better regarding replication.
ownership of actor and all

Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv

Join our community discord!
Discord: https://dis...

โ–ถ Play video
shut vigil
shut vigil
#

but from what i am understand is

#

the reason why it is not working on the client is because the actor i was using to call the server event doesnt own the compononet

dark parcel
#

An actor component is a component you attach to actor.

#

You need to create a new blueprint that derived from actor component.

shut vigil
#

wait okay so

#

wait

#

Ok so

dark parcel
#

Well wait a moment i didnt know it was for a flashlight

shut vigil
#

oh okay

#

Well basically what I want to do is

#

I have actor that I place on the ground and when the player stands in it they can press F to add a component to them

#

but it works on the server player but not hte client

dark parcel
#

Well there seems to be misunderstanding on whats component and what nit

shut vigil
#

okay so

#

This is the actor

#

This is the component

#

the component just handles turning on and off a light that is attached to the player

dark parcel
#

Surely you follow this far?

shut vigil
#

Okay i guess that makes sense

#

then how come the server player can do it?

dark parcel
#

Because server is authority

shut vigil
#

And then how come the exact code that wasnt working in the actor works fine for the client player when its in the player blueprint

dark parcel
shut vigil
#

oooooooooh

dark parcel
#

2 things owned by the client out of the box.

#

The player controller

#

And the player character

shut vigil
#

So the reason why it works only in the player blueprint is because the player is owned by the client but the actor isnt owned by the client?

dark parcel
#

Look into the pinned material in this channel for faster learning. It is compiled beautifuly already.

dark parcel
nocturne quail
dark parcel
#

Only server can call rpc on it.

shut vigil
#

Okay that makes sense

#

and there is no way to make it where calling the event in the actor will give it to the client?

dark parcel
shut vigil
#

there's a node for that right? I cant remember what its called

dark parcel
#

This isnt in anyway recommended, arguably terrible infact.

#

The solution has been given above.

#

Route the rpc to something your client own.

shut vigil
#

so i should just handle the game logic for adding components in the player blueprint and call that event in the actor to make more simple?

dark parcel
#

You route rpc to something the client own. To not convolute youe character we can encapsulate in actor component.

shut vigil
#

but woulldnt it be easier to just make an event like this in the player blueprint and then call this event in the actor?

#

This works completely fine

#

(Item ID is used in the animation blueprint to change animations)

#

The actor already has to cast to the player to change a text blip that says what item you're standing on

dark parcel
#

Works because the character is owned by the client so the client can send server rpc.

shut vigil
#

I know

dark parcel
#

Thats exactly what i mean by routing the rpc

shut vigil
#

Ah

#

Okay

dark parcel
#

But at this point you are convuluting your player character

shut vigil
#

How so?

dark parcel
#

Now is just your flahslight

#

As the game progress will you dump thousanda of code to the character?

#

The character isnt responsible for all those logic.

#

Wycd is wrap the logic inside the actor component then attach it to your character.

shut vigil
#

Well in this case the only thing the character would be responsible is having an event that is called in an actor to give a component

#

thats it

#

The component handles the logic of turning on and off the flashlight

#

how is that convoluting things?

#

Im asking cuz Im not great at unreal engine and I wanna learn

dark parcel
#

The player character shouldn't be responsible to turn flash light on and off.

#

That should be handled by the flashlight

#

Neither it should manage interaction

shut vigil
dark parcel
#

Even when those feature are taken out the character should still work.

#

You can do a better design by separating responsibility by encapsulating.

shut vigil
#

okay but you're missing what i am saying

#

The character isnt handling turning on and off the flashlight

#

A component is

dark parcel
#

Im just trying to help not argue, if you dont want to use actor component. That is your choice.

shut vigil
#

The only thing, that the character would be handling in this case scenario is holding an event that is called somewhere else

#

thats it

#

Allof the flashlight logic with the light is handled in a static mesh component that is added to the player

dark parcel
#

Sure and that's not how I will approach my project.

#

Character should handle character logic, nothing else.

shut vigil
#

Well it kinda is character logic

#

Adding components and all that

dark parcel
#

Interaction is on its own, equipment is on its own, inventory at its own, etc.

shut vigil
#

is having the add component event in the character blueprint then having that event called in another actor unoptimized?

#

Like will it cause performance issues?

dark parcel
#

Its not about performance

#

Im not gonna have give me flashlight event in my character bp.

Open door event in my character bp.

Start elevator event in my character bp. And so on. You get the idea.

#

Even if the door were to dissapear from my project I want my character to still work as is.

#

Character shouldn't even know about any flashlight or door.

nocturne quail
#

even if it was a pickup item, add to inventory

meager spade
#

How is that mp?

nocturne vault
meager spade
#

Np

dark edge
#

What specific float are you talking about here

random flicker
#

Hello guys,

I am fighting heavily with UE repilication and seems like it winning.
I have a dumb Character to spawn literally empty.
This under MGF attached to the GameState and the Character is not geting replicated...
I've tried everything GenAI recommended as seems like impossible to fix

dark edge
fossil spoke
#

Also the cull distance is irrelevant if the Actor is marked as AlwaysRelevant.

random flicker
random flicker
dark edge
#

make a C++ template project

#

and look at the code

fossil spoke
#

Or better yet, create a Blueprint of the Character so it has a visual component

#

Spawn that instead

#

So you can visually see it

#

Its very likely there, you just arent seeing it because by default it has no visual representation.

random flicker
#

will try to spawn BP

fossil spoke
#

It doesnt print?

#

It prints once?

#

It prints twice?

random flicker
fossil spoke
#

It doesnt print anything?

#

Not even for the Server?

#

You are running a Listen Server + 1 Client correct?

random flicker
#

I've cached it and now prints log in begin play once

#

by cached I mean have a uprop and store ref

dark parcel
random flicker
dark parcel
#

And your issue that its null? And on whom? The server or the client?

random flicker
dark parcel
#

Setting it on server will do just that. It will not attempt to replicate the value to client unless the property is replicated ( which isnt in your case )

#

You will have to mark it as replicated and use RepNotify if you want callback when the client value changes.

#

The ptr not replicated aside. if you spawn a replicated actor on server, client will eventually get a copy.

random flicker
#

as far as I know you don't need to that for the Character it's automatically replicated

dark parcel
#

Sure but the ptr is not replicated

#

So dont expect the value to be changed on other machines but the one that sets it.

random flicker
#

yea, the problem is that character is not replicated. proprerty was a tweak to have something working

dark parcel
#

And how do you check if its not replicated?

#

Do you have something to represent its visual so u can actually see if clients getting copies?

#

Because your screen shoot of trying to cache the ptr isnt doing much since the ptr is not replicated.

blazing bear
#

does anyone know if the condition in DOREPLIFETIME_CONDITION of a specific variable can be overriden in a child class? Like having COND_None in the parent class, and COND_OwnerOnly in its child.

fossil spoke
#

With an active override

blazing bear
#

Ooo thank youu

fossil spoke
blazing bear
#

Not DOREPLIFETIME_ACTIVE_OVERRIDE ?

fossil spoke
#

No, that was the wrong one sorry.

blazing bear
#

Oh okay, thankss!

ashen plume
#

As a higher level system question, how do games handle responsive item pickup without causing duplication issues? Not sure how survival crafting games do it.

#

Something like counter strike i think just waits for validation during the pickup anim before allowing firing.

dark parcel
#

I would just wait for the server to respond, so delay is a given.

#

There is more headache with predicting pickup.

#

What if someone else actually got the item before you?

#

Do you want to handle taking the candy from the player that think it picked up the item but in reality it didnt?

fossil spoke
#

Sometimes you can "hide" latency and server validation behind animations and other cosmetics

#

So like, if you have to visually "put down" an existing item before the new one is picked up.

#

You can hide the delay of server validation behind the put down of the existing item.

#

So by the time you have to visually switch, you will know if it was successful or not.

#

Sometimes, there just isn't a lot you can do about latency and waiting for the server to confirm your actions.

#

Its all about tradeoffs.

#

Sometimes miss predictions are ok

#

Depends on the game, depends on the system.

lament flax
#

so when you have an actor/actor component that doesnt update variables regularly, i can simple set it to dormant, then when i want to update a variable, i wake it up then update the var (using push model) ?

#

how does dormancy work ? is it replicated to clients from server ?

kindred widget
lament flax
#

so when its dormant, i can change a variable on server then call FlushNetDormancy, this will wake it up, rep var, then make it dormant agin ?

kindred widget
#

@meager spade can probably comment more clearly on it, he's the multiplayer wizard.

meager spade
#

FlushNetDormancy does exactly this

lament flax
#

okay

#

does dormancy affect RPCs ?

#

what happens if a dormant server or client actor tries to RPC to the client/server

#

also, when using DORM_Initial, does it at least rep once before going dormant ?

meager spade
#

dormant stops actor channel

#

so server/client rpcs dont work

#

only multicast

lament flax
#

how do you guys use push model for BP

#

did you exposed a helper static func ?

noble arch
#

Heyyyy guys!
I need some help to think about the architecture of some stuff. I'm doing a mmo RPG like just to gain some XP, but here's my question;
Usually what I do for interactables is that they have a SphereComponent and whenever the players overlap with it, the interactable is removed from its sleeping state so the player can interact with (adding itself to a list of nearby interactable on the player).
But then my best friend ChatGPT told me that it would be better if only the player has a SphereComponent that scan's every few frames for nearby interactables, avoiding too many interactables with sphere collision in the world. It kinda makes sense, but is that the real - best approach ?
Then do I have the player to scan for interactables, but also for ennemies (to show their nameplate for instance)

Can all that be locally ? Or the server needs to control those overlaps ?

exotic wasp
#

if it's a c++ property, just use a setter

#

if it's just bp, I think it's setter handles it

lament flax
#

kay

#

but im referring to pure BPs

#

someone makes a BP, add vars and set them to replicate

exotic wasp
#

there's an engine var

meager spade
#

though i think pure bp props

#

does this automatically

#

but not sure

#

we have very limited replicated bp props

rigid smelt
#

Does anyone know why does the client movement look like that on the listen server? Server moves ok the the client side, client moves ok on the client side. Can that be fixed? If I run 2 clients works just fine on each other, just client on server moves choppy

exotic wasp
#

maybe im blind but I don't see a difference

#

which one is which?

quiet sentinel
#

Same here ๐Ÿ˜‚

rigid smelt
#

left server, client right. when right moves the client instance on the server is choppy af like 24-30fps

#

other way works just fine

#

is the server tick rate 60 and that's the reason? as client runs with more fps? but then even so why the server side server moves properly, because it's locally simulated?

quartz iris
#

Trying to make a planks break on a barricaded door for clients as it only seems to work on the server, what's going wrong here?

quartz iris
fathom wadi
#

Is there a way to disable Tranform replication when server changes the transform of StaticMeshComponent?

opal gyro
#

Hey all, I'm trying to debug a UObject that I create on the server being null on the client even though I think I have the replication setup correct according to the docs. If someone is willing to step through the flow with me in a call and help me out I'd really appreciate it.

#

I'd send pics in here but that would be a LOT of spam

finite kernel
#

fast question, is there any limit to ustruct inheritance depth when the ustruct is used as a replicated property?

random flicker
errant charm
shut vigil
#

how can I make it where the client can interact with code that it dosent own?

exotic wasp
#

evil

shut vigil
#

well like

#

I have a door that I want all players to be able to open

#

Would i have to cast to that door so I can rout it through the client?

opal gyro
#

How are you doing interaction?

shut vigil
#

Blue Print Interface

opal gyro
#

Well if your interaction is triggered on the server (as it should be) you can set a replicated IsOpen bool or something and open the door when that value changes OnRep

kindred widget
# rigid smelt Does anyone know why does the client movement look like that on the listen serve...

Your recording doesn't really show it, likely due to similar FPS as the client updates on the server. But this is a common issue with listenservers and autonomous proxies. The primary issue is that server only ticks animation poses when a client sends new input data. So the animations only update every couple of frames when new data comes from the client. There are some work arounds, you'll have to research them, but from memory they're not that great unless people have found better ones. One was doing some override in CMC that makes the pose tick every frame, but I recall it had some issues.

exotic wasp
#

if your interaction is happening on the server, ownership doesn't matter

shut vigil
#

well

quasi tide
#

Do a server RPC in something that the player owns. In the RPC, pass the object reference that you are trying to interact with. Then on the server, do the normal interface call.

shut vigil
#

it doesnt work on the client @exotic wasp

exotic wasp
#

do what duroxx said

quasi tide
#

No

shut vigil
#

okay so

#

then how

quasi tide
#

Seeing how you are relying on interfaces, on your linetrace, overlap check, or w/e - check if it implements the interact interface

exotic wasp
#

in this case you could have your interaction be a server rpc

quasi tide
#

If it does, then just send the actor reference itself

quasi tide
#

I don't care

#

That's why I said "or w/e"

#

I don't care how you're getting the actor reference, you do

shut vigil
quasi tide
#

But it doesn't matter for the purpose of this process

exotic wasp
#

yeah

shut vigil
#

okay so

quasi tide
#

The client will just check that the actor reference implements the interface. If it does, do the server rpc and pass the actor reference. Then the server will just call the interface.

#

Now, this is where you can implement some server side checks if you'd like

shut vigil
#

I could call an event in the server in the player blueprint and than have that event called in the bluepriunt for the actor?

opal gyro
#

You should be calling "Interact" in your player or whatever on the server

shut vigil
#

oh shit wait

opal gyro
#

and then you know any interaction stuff in your door is happening on the server

#

And if you want your stuff to be replicated to everyone, it needs to be in a multicast

blazing spruce
#

Dont use multicast use OnRep

opal gyro
#

but for something like a door a better approach would be a repnotify variable, since that would preserve state

opal gyro
shut vigil
quasi tide
#

Am what I'm saying not followable or something?

#

I spelled it out pretty plainly

opal gyro
#

yeah i'm just saying what durox said

quasi tide
#
  1. Client gets a reference to the actor
  2. Client checks if the actor implements the interface
  3. If it does - do a server RPC from the player, that passes a reference to the server RPC function
  4. On the server RPC implementation - just take that actor reference and call the interface function
shut vigil
#

I did it

#

this way the Blueprint interface is called on the server

blazing spruce
#

Thats not it

opal gyro
#

don't multicast

shut vigil
#

but it worked

#

the door opened for both playuers

quasi tide
#

Just because it works, doesn't mean it is right.

#

It could be lying to you

kindred widget
#

Now DC the client and reconnect.

blazing spruce
opal gyro
#

๐Ÿ‘จโ€๐Ÿซ My Patreon link:
https://www.patreon.com/kekdot
Download Project Files | Premium Tutorials | Courses

๐Ÿ•น๏ธ Get our Game on Steam | The Anomaly Project:
https://store.steampowered.com/app/2960770/The_Anomaly_Project/


Part 1 link: https://youtu.be/jtWhd4ugPW0

In this tutorial (PART 2) I explain how you RepNotify works and how...

โ–ถ Play video
shut vigil
#

okay I removed the multicast and it still works

#

I dont understand how it isnt correct if it works?

quasi tide
#

Because when a client connects - it won't show the state that is on the server

#

Which is why you were told to do thing in the onrep

#

Or heck - even if they walk away from the relevancy range and then back in

opal gyro
#

watch that vid i sent, it explains it well

shut vigil
quasi tide
#

Correct

shut vigil
#

would i do it in the interact code

quasi tide
#

In the door

#

When you interact with it

opal gyro
#

the door should have a IsOpen variable that u set on interact

quasi tide
#

You flip the bIsOpened bool or w/e you call it in your door actor

#

Then in the OnRep function that was created for that variable when you flipped it to OnRep style of replication, you write code that happens when the variable's value is updated.

#

If you are in C++, you have to call the OnRep function manually only on the server

shut vigil
#

okay so

#

The door takes a while to open

#

and close

#

should i set it at the end of the timeline?

quasi tide
#

No

opal gyro
#

no you should play the timeline when the variable is changed

shut vigil
#

so i chould call this

#

at this flip flop correct?

#

or am i being dumb

opal gyro
#

all your interact needs to do is change the value of bIsOpen

#

and you don't need any RPCs in the door itself

shut vigil
#

okay so where do i set it to be true or false?

opal gyro
#

OnInteract or whatever ur interface function is called

#

just flip it there

shut vigil
#

this?

#

does toggle state need to be on server?

opal gyro
#

toggle state needs to be onrep like i sent

shut vigil
#

What?

#

Im so lost

opal gyro
shut vigil
#

Like this?

opal gyro
#

no

#

like i just sent

#

just move toggle state from there into the generated OnRep function for your variable

#

the OnRep function is called automatically whenever a change to the variable is received from the server

shut vigil
#

oh it worked

#

huh

#

should I still have this interact blueprint interface called on server?

opal gyro
#

Yeah you p much always want interaction done server-side

shut vigil
#

Ok

#

so

#

Correct me if i misunderstand

#

or lemme just ask why then

#

Why are we doing this?

#

Can we just do a flip flop?

opal gyro
#

the flip flop might not necessarily match the value of the variable

#

that's cleaner anyways

shut vigil
#

okay now one more question

#

For my items

#

I have it where a actor is on the ground and then you do the interact blueprint interfacew and then it calls an event in the player blueprint to add that component on the server

#

like this

#

This is in the player blueprint

#

and is called on the actor whenever you intereact with that actor

#

Is this the proper way to do this?

#

Or can I use rep notify in the actor as well?

#

(the other event called on that even are here btw)

#

@opal gyro

#

I have these events in the player blueprint becaus ethe client doesnt own the actor

opal gyro
#

Well technically you don't need to be doing server RPCs because, remember, we're now only calling the interact interface on the server already so we know that's where that's happening. So anything called off of Interact is happening on the server.

shut vigil
#

so now I can just do all the adding the component to the character in the actor itself?

opal gyro
#

Also kind of gross that you have a function specific to the flashlight in the character class. The flashlight should give itself to the interactor and destroy itself.

#

Yeah you should add an input to your interact function that passes the interacting character to the object.

shut vigil
shut vigil
#

Im gonna do that in a bit cuz this was a headache so

#

Ill get back to you about it

#

thanks tho

#

Netcode is hard lol

opal gyro
#

Just takes practice

#

honestly people make it out to be harder than it is outside of specific stuff

quartz iris
dark edge
#

OnRep_bIsBroken -> do whatever should be done that depends on bIsBroken

#

ez

meager spade
#

also why the execute on server

#

in beginplay

#

especially if this actor is not owned by a client

#

...

#

Beginplay -> HasAuthority -> True -> Build planks, Mark planks array replicated -> Hit -> Server Remove plank -> remove plank -> planks array changes, onrep removes the blanks. ideally though you would want to do planks a lot smarter, ie how client shows/removes them. Personally if there is a fixed number of planks in fixed order, you can be smart and just replicate the plank count and client/server runs determentistic logic based on the plank count

#

this is how i did my zombie's style windows years ago

#

we literally just replicated the board count lol

#

we used multicast for anyone visual to it, to play the board removed/added animation

#

the onrep was purely for late joiners to know how many boards were there without playing visuals

#

though we didnt even need to use the OnRep

#

cause beginplay on client actually set the board count

#

from the server

dark edge
#

I wish OnRep defaulted to including a timestamp or something to let you know the when or why of where that state comes from, you'd be able to do so much with it

lament flax
#

if a component is not set to replicate, but gets loaded at runtime because its placed on a not replicated actor placed in a level/spawned at rutnime.

#

what would GetNetMode return ?

fossil spoke
#

@lament flax The NetMode is determined from the NetDriver, the Actor/Component itself doesnt have anything on it that affects its determination.

#

The World has a reference to the NetDriver

#

Actors access the NetMode through the Worlds NetDriver.

meager spade
#

^

#

Role is dofferent to netmode

#

And serge diff purposes

#

Serve

lament flax
#

so even if not replicated, since the world has a netdriver it would correctly find out if the actor/comp is on server or client

lament flax
#

thanks

#

i guess thats why its more "expensive" to check net mode than role

fossil spoke
#

Ehh, I wouldnt be concerned about the performance overhead of either of those things.

lament flax
#

yeah ik, i just remember being mentioned somewhere

quasi tide
#

I wouldn't really say any are even remotely useful to even think about in terms of "performance"

#

It is literally an int check

lament flax
#

btw, any metrics i should keep in mind when profiling net bandwitch ?
ill soon profile my fragments stuff but i got no clue of what is "good" or "bad" perf-wise

lament flax
#

for role its directly on the actor as a member var, for net mode the driver has to do stuff

quasi tide
#

Move one single component and it is already more expensive than checking the netmode or net role.

fossil spoke
#

Get it as low as you can without sacrificing what you consider necessary to ensure the systems core functionality.

lament flax
#

thats kinda broad

#

whats the 100fps equivalent net-wise ๐Ÿ˜†

fossil spoke
#

Thats bandwidth optimization...

#

In a nutshell

lament flax
#

how many kbps or w/e

fossil spoke
#

0kbps ideally

quasi tide
#

Does it work networked right now?

lament flax
#

when profiling outside networking, you have a target fps

#

here idk what to target (at least as a minimum), would help when trying to make the number smalls

quasi tide
#

I'd handle all of the edge cases of networking before thinking about performance.

lament flax
quasi tide
#

Whatever you're trying to guesstimate

fossil spoke
lament flax
#

i want to see how much it takes in bandwitch when having 500 actors, each with 1 PSC (a component), each PSC has 5-10 replicated props (uobject)

#

totally arbitrary numbers, just trying to max it

#

so this is 5000 replicated uobjects

fossil spoke
#

Well your results will depend entirely on the size of those properties.

#

Its more efficient to send a int32 than an FVector

#

So

lament flax
#

all under one actor, which i assume is 10x better that having it spread across all actors

#

maybe not revelancy wise tho...

#

wherever you are on the map its reped Think_LF

fossil spoke
#

Generally speaking, unless you see saturation issues, I wouldnt worry about bandwidth straight away.

lament flax
#

if the user has a gigantic UObject its his problem

lament flax
#

i never worked on profiling network, just go things "working", using push model and dormancy

fossil spoke
#

I would be optimizing other things instead like CPU usage. Bandwidth is pretty decent these days.

lament flax
#

how do i ease the server CPU

#

i guess low tick time on netdriver tick and replicate actor ?

fossil spoke
#

You mentioned a couple methods already.

#

PushModel and Dormancy are mechanisms to aid in reducing CPU overhead for replicated Actors/Props

lament flax
#

i wish we had dormancy and relevancy per subobject

#

so much power

lament flax
#

instead of having normal arrays on hundreds of comps

#

the only thing "slow" would be itrating the fast array on queries, but i think c++ iterates 10k+ entries quite fast

quartz iris
dark parcel
verbal ice
#

Is there a way to override the behaviour of actor relevancy on the clientside

#

I want an actor that's spawned dynamically to not be destroyed when it becomes irrelevant

#

Somewhat like map loaded actors

fossil spoke
#

@verbal ice I dont think there is.

verbal ice
#

Bummer

#

Engine mod time

fossil spoke
#

@verbal ice The NetDriver has a ShouldClientDestroyActor function

#

Which is called to determine if that given Actor should be removed due to the ActorChannel being closed.

#

Its virtual

#

So you might be able to use that

#

Its called in UActorChannel::CleanUp

verbal ice
#

Ooooh sweet, will take a look

quartz iris
#

It doesn't work for either the server or client now

thin stratus
# quartz iris I tried that but it still doesnt work
  • You shouldn't scatter data that is linked across multiple Arrays.
    • PlankArray and PlankHealth belong together. This should be a Struct with the two properties and then just one Array.
  • Your original code calls the Multicast on BeginPlay. BeginPlay calls for the Server when the Actor is spawned. That doesn't mean the Clients are connected yet, which means the Multicast would not reach anyone.
  • Multicasts are wrong here. This is a state and needs to be handled via RepNotify variables and their OnRep functions.
  • You might be running into a race condition between the boolean bAlreadyBarricaded and PlankArray, as either of them could be replicating delayed.
    • PlankArray would also need to be RepNotify, and you'd need to do the same logic that you do in the OnRep_AlreadyBarricaded function in the OnRep_PlankArray.
      • Potentially a good idea to make a function for this and call that twice instead of duplicating code!
    • I'm not sure what Plank1 to Plank11 are, but if they are Components of the Actor and not runtime spawned, then you don't need to replicate them.
      • You also don't need to replicate the PlankArray then, because the Components already exist locally. Just call SetPlankArray on Server and Client.
      • PlankHealth would need to be replicated still though. If you combine the two into one Array of Struct, then you'd still replicate the whole array I guess, but you don't need to replicate each individual PlankX.
#
  • You are calling too many ServerRPCs. You are already ensuring that you are calling the code on the Server via SwitchHasAuthority.
    • Setup doesn't need to be a ServerRPC.
    • SetPlankArray doesn't need to be a ServerRPC.
    • As previously said, MulticastDestroyPlanks shouldn't be a thing, as this is state and should be done via RepNotifies.
    • Same goes for MulticastDestroyTeamWalls.
    • Destroy1Barricade doesn't need to be ServerRPC either, as Event PointDamage should only call on the Server to begin with.
      • Don't put numbers into function names. This should be called DestroyOneBarricade if at all.
    • The collision, physics, etc. logic in Destroy1Barricade should be handled in an OnRep. This is state! You are only doing it on the Server atm.
normal fulcrum
#

Hey
Can somebody briefly explain, how WP and Relevancy work together?

If I have a player outside of listen server host player range, server will keep the client loaded for sure, and use this data as a streaming source for WP? I need to have enemies around the "distant" players

opal gyro
#

Hey folks, trying to figure out why a subobject of mine isn't being replicated to the client. The tricky part is that it's a replicated UObject reference on a replicated UObject, and I'm replicating both as subobjects of an actor component:

    FReplicationFlags* RepFlags)
{
    bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);

    // Recursively gather the subobjects.
    TArray<UObject*> Subobjects = {};

    for (auto& Entry : EquipmentList.Entries)
    {
        if (Entry.EquipmentInstance)
        {
            Subobjects.Add(Entry.EquipmentInstance);
            Subobjects.Append(UAristottleToolboxFunctionLibrary::GatherReplicatedSubobjectsRecursive(Entry.EquipmentInstance));
        }
    }

    for (auto Subobject : Subobjects)
    {
        if (IsValid(Subobject))
        {
            // UE_LOG(LogTemp, Log, TEXT("Replicating %s"), *Subobject->GetName());
            bWroteSomething |= Channel->ReplicateSubobject(Subobject, *Bunch, *RepFlags);
        }
    }

    return bWroteSomething;
}```
The main subobject (the item instance) is replicated just fine, but the dynamically created nested subobject (the inventory container) is never updated on the client (remains null). Here is the code that sets up the container (called on the server):
```UItemInstance* UCompositeInventoryFunctionLibrary::InstantiateItemDefinition(const UItemDefinition* InItemDefinition, UObject* InOuter)
{
    UItemInstance* ItemInstance = nullptr;

    check(InItemDefinition != nullptr);
    check(InOuter != nullptr);

    // Create the instance and set its definition
    ItemInstance = NewObject<UItemInstance>(InOuter, InItemDefinition->ItemInstanceClass);
    ItemInstance->SetItemDefinition(const_cast<UItemDefinition*>(InItemDefinition));

    // Set up the fragments
    for (auto Fragment : InItemDefinition->Fragments)
    {
        if (Fragment)
        {
            Fragment->OnInstanceCreated(ItemInstance);
        }
    }

    return ItemInstance;
}```
And here is OnInstanceCreated (where the nested subobject is being created):
```void UItemFragment_Container::OnInstanceCreated_Implementation(UItemInstance* Instance)
{
    Super::OnInstanceCreated_Implementation(Instance);

    if (!Instance->Implements<UContainerItem>())
    {
        auto ClassName = *Instance->GetClass()->GetDisplayNameText().ToString();
        auto DefName = *Instance->GetItemDefinition()->DisplayName.ToString();
        UE_LOG(LogTemp, Error, TEXT("Item instance %s is not an IContainerItem but definition %s has the container fragment."), ClassName, DefName);
        return;
    }

    // Clone the container and initialize it.
    UInventoryContainer* NewContainer = DuplicateObject<UInventoryContainer>(ContainerTemplate, Instance);
    NewContainer->InitializeContainer();

    // Set the container on the ContainerItem
    IContainerItem::Execute_SetContainer(Instance, NewContainer);
}```
Any help with this would be much appreciated, please lmk if you need to see more. I tried debugging this by doing a Log in the `ReplicateSubobjects` function but it never gets printed. How do you debug something like this?
exotic wasp
#

is there a reason you aren't just using the replicated subobject list?

#

the new method?

opal gyro
#

since I need to gather subobjects recursively (item could have a container which holds its own items and so on), this seemed simpler to set up.

candid pumice
#

hello everyone, I am new. I want to know can I make a peer to peer multiplayer in Unreal 5 without c++ or making any server payment?

quasi tide
#

UE doesn't support Peer to Peer out of the box. It uses a listen server. You can do it in all BP if you want, but you'll be fairly limited in some areas.

summer hinge
#

Hey yall. Does anyone have any advice for a good method of syncing up Level Sequences over the network? Local testing of the "Replicate Playback" checkbox on the LevelSequenceActor is pretty rough. Has anyone found success with any other methods?

quartz iris
blazing spruce
# quartz iris Thank you for the detailed post, is this the correct way of doing it? It seems t...

I would read his response again a couple times mate, he said you shouldn't use multicasts but you're still using one for state changes (PlankArray & PlankHealth).. with the switch has authority you're already making sure your begin play runs on the server so you can just set the plank array directly, because its marked repnotify the OnRep function will get called on both the server and the clients so no need for a multicast

nocturne quail
#

if you want to set it using MC, add a check of has authority, but in your case you don't need MC because you are not using it anywhere except setting a replicated var

empty rune
nocturne quail
#

is this changed in UE5 or its me doing it not the correct way to reference the first argument passed to FText::Format ?

if (ExistingItem->IsStackFull())
{
    return FItemAddResult::AddedNone(Item->GetQuantity(), FText::Format(LOCTEXT("StackFullText", "Couldn't add {ItemName}. Tried adding items to a stack that was full."), Item->ItemDisplayName));
}
LogTextFormatter: Warning: Failed to parse argument "ItemName" as a number (using "0" as a fallback). Please check your format string for errors: "Couldn't add {ItemName}. Tried adding items to a stack that was full.".
nocturne quail
grand axle
# empty rune

Are you trying to sync players bones from control rigs chaos physics sims? if so that would be costly and I don't think UE does that out the box, I could be wrong though don't trust me

empty rune
#

i dunno i followed gorka games tutorial on physics based movement

grand axle
#

I have a question though, Trying to optimize my game for in/out rate for my physics. Is there a way to expose what gets sent through UE? Currently using their experimental Physics tools but there isn't much documentation on that. currently it's not too bad, but I could see it getting wild when I add more physics objects to the scene so I want to limit how much my Scene physics objects send

empty rune
grand axle
empty rune
#

?

grand axle
#

you may have enabled them locally but not to them

empty rune
#

what are you talking about

grand axle
#

are you not using control rig for your physics animations?

empty rune
#

no

grand axle
#

ah than I have no idea

empty rune
# empty rune

i have animations and then im putting physics ontop with simply this code

#

like without that code theres no physics at all

graceful flame
# grand axle I have a question though, Trying to optimize my game for in/out rate for my phys...

You can do the simple stuff to save on performance such as setting a slower tick rate. Can also do some dynamic tick rate adjustments based on distance. I did something similar for my NPCs where the further they are away from the player the slower they tick since they aren't as visible anways. I used the significance manager for that. https://dev.epicgames.com/documentation/en-us/unreal-engine/significance-manager-in-unreal-engine

grand axle
graceful flame
#

Maybe something like a tick rate that slows down with a long tail. So it starts off fast and seems highly responsive when the player first interacts with it then over time it can tick at a slower rate when things more or less come to a stop and settle at their resting spot?

#

But ya anything physics over the network is a pain because its replicating transforms which are a lot, best kept to a minimum whenever possible, or even better just replicate the event to start the physics and then have the physics all clientside if you can get away with it.

#

I'm not sure what the context is here but say for example with an exploding wall its more performant to use repnotify on a single boolean and have all clients run the phyiscs themselves than to replicate each chunk's transform.

#

and say the exploding wall should cause damage to anyone nearby then a simple box collider could be actiavted and applying damage to any player who ventures too close

grand axle
#

I have client side phsysics where need be. it's more I want for example, 30 boxes stacked on one another. I need to limit it's Data sent, Cull floats to doubles and remove Y Coords etc

graceful flame
#

well sphere colliders are cheaper than box colliders so you can start with that but then they might behave like spheres instead of boxes and start rolling around

dark edge
#

how much stuff is replicating

grand axle
#

That statistic was from 10 physcis objects

dark edge
#

what's your replication mode, the old ue4 implementation?

grand axle
#

I think though maybe I can have the tick rate increased based on Angular/Linear velocities length?

dark edge
#

you don't want to change the update rate of physics, just how often it's synced

grand axle
#

This is 5.6 experimental interp and prediction

dark edge
#

I'm sure there's somewhere in there to tune the replication rate

grand axle
#

I'll have a look, I did change the default 100hz to 120 or 144hz for the servers

dark edge
#

so you turned it up

#

is that the tick rate or the rate at which it tries to replicate

grand axle
#

This is for Players

#

Then objects in the world

#

I do see there is a network physics settings component. I wonder if that will work

graceful flame
#

@grand axle have you tried looking at the network profiler yet?

Start the game then use netprofile enable play for a bit then netprofile disable and then you load up the exe and load up the captured data.
UnrealEngine\Engine\Binaries\DotNET\NetworkProfiler.exe

#

Main goal is to reduce waste by avoiding unnecessary replication checks utilizing dormancy, net cull distance squared, net priority, and net update frequency.

#

This week we'll be joined by Ryan Gerleve and Dave Ratti to discuss general server optimization in UE4, as well as techniques and solutions to improve your Actors' performance in a networked environment.

NEWS

Unlocking Breachโ€™s combat with Unreal Engine
https://www.unrealengine.com/en-US/tech-blog/unlocking-breach-s-combat-with-unreal-engin...

โ–ถ Play video
gray blade
#

Assertion failed: MappedClientConnections.Remove(ConstAddrRef) == 1 [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp] [Line: 6918]

I get the above error in my game only when a client disconnects from a lobby after accepting an invite through steam overlay specifically, anyone encounter this before and know whats going on?

grand axle
#

Is this okay or not? Also not sure why but for some reason the camera isn't being set on players some times, even though I set the camera like 5 times

#

Currently stress testing on local, not sure if this will shoot up online with ping yet

random gazelle
#

does anyone know why my client doesnt have pitch camera rotation?

random gazelle
#

as you can see the client is looking straight up but the host cant see that

#

theres no camera pitch for some reason

dark parcel
#

@random gazelle well you would have to translate that to the animation part. E.g the head bone looking up

#

I mean regardless where the player is looking at , its not as if the capsule component rotate along with it.

#

Tldr Your player view looking up or down doesn't rotate the mesh up or down.

#

If you need info of the clients control rotation, its already replicated via getBaseAimRotation.

random gazelle
dark parcel
#

@random gazelle I'm talking about the mesh comp. You can see that the panda is still looking straight. So what is it you want to replicate? Just the flashlight?

random gazelle
#

i want the flashlight and the head to turn where the camera does on client like the host does lol

dark parcel
#

the head doesn't rotate where the camera goes host or not to me

#

you will need to modify the head bone rotation

#

I would attach the flashlight to the modified bone so it rotate along with it.

random gazelle
#

Thereโ€™s no bones bro

dark parcel
#

well you want the panda head to look up or down right?

#

doesn't it have bone?

random gazelle
#

Itโ€™s not a character mesh

dark parcel
#

well my suggestion would be to modify the panda head bone transform and the flashlight just rotate along with it

random gazelle
#

I just made a panda out of static mesh to show you that heโ€™s not facing up

dark parcel
#

ok calm down

#

I wouldn't know

#

I helped you earlier, I mean no harm

#

if you need the info to replicate the pitch

#

it's available on getBaseAimRotation node.

#

the value is basically the control rotation (where the controller is looking at)

kindred widget
#

10 gold says you just need to replace the rotation getter with GetBaseAimRotation.

tardy fossil
#

yea GetBaseAimRotation will fix it

#

cause it auto handles clients using remote pitch

dark parcel
#

rotating the flashlight only gonna feels weird anyway. You would eventually want a character that holds a flashlight and it just roate with it.
Here's my attempt using GetBaseAimRotation, modifying the pelvis. Can easily be a horror game where the player aims a flashlight and instead transforming the flashlight, i can just transfrom the pelvis.

But the idea is the same regardless, you can just apply GetBaseAimRotaiton to your flashlight if you don't want to have a character that look up or down.

#

@tardy fossil copied someone code, is this still relevant?
I had a bug back then because unbeknown to me the value is compressed. So for client side, they have to be re-mapped.
Not sure if still relevant today.

void AAGPlayerCharacter::AimOffset(float DeltaTime)
{
    if (IsLocallyControlled())
        AO_Pitch = GetBaseAimRotation().Pitch;

    if (GetBaseAimRotation().Pitch > 90.f && !IsLocallyControlled())
    {    /** map pitch from [270, 360] to [-90, 0] because of compression */
        const FVector2D InRange(270.f, 360.f);
        const FVector2d OutRange(-90.f, 0.f);
        float L_AO_Pitch = FMath::GetMappedRangeValueClamped(InRange, OutRange, GetBaseAimRotation().Pitch);
        AO_Pitch = FMath::FInterpTo(AO_Pitch, L_AO_Pitch, DeltaTime, 15.0f);
    }
    else
    {
        AO_Pitch = FMath::FInterpTo(AO_Pitch, GetBaseAimRotation().Pitch, DeltaTime, 15.0f);
    }
}
tardy fossil
#

yea that will still happen since remote view pitch is encoded to a uint8 or uint16

#

negatives will just wrap around to be positive

dark parcel
#

๐Ÿ™‡โ€โ™‚๏ธ

nova wasp
#

uint8 is rather extreme amounts of quantization for a rotation, uint16 is fine

#

if you really want you could get weird and have horizontal and vertical be different amounts of bits

#

but I would say just stick with the default short (16) bit quantization for rotation and it will be fine

tardy fossil
#

lol i remember my last game i was replicating pitch AND yaw as a single uint16.. now that was extreme

#

0-512 for yaw and 0-128 for pitch

nova wasp
#

one thing I tried was having the "common areas" use more of the values

#

where it sort of stretches out more in the less used angles

tardy fossil
#

ohhh thats interesting.. like having the center have more precision and the extreme angles have less? i could see that working

nova wasp
#

yep

#

I think it might be easier to just make it relative to the owning pawn transform or something though

#

I prefer to bind the aim rotationa and transform in one struct for networking

#

because that way you do not risk them being randomly sent

#

which is really not important for games that don't have extremely fast movement

last storm
#

Hey, i'm trying to replicate a list of UObject but it doesn't work.
In my ActorComponent which hold this list I:

  • bReplicateUsingRegisteredSubObjectList = true; in the constructor
  • AddReplicatedSubObject(NewAura) when I add to the list,
  • RemoveReplicatedSubObject(OldObject) when removed from the list
  • add List to GetLifetimeReplicatedProps and DOREPLIFETIME
  • set the List as ReplicatedUsing

In my UObject:

  • add GetLifetimeReplicatedProps and DOREPLIFETIME all necessary variables
  • add virtual bool IsSupportedForNetworking() const override { return true; }

Do I miss smth ?

nova wasp
#

also not sure if you are saying it doesn't work, or asking if this is what you need to do

last storm
#

I'm saying that it doesn't work. On client list is always empty

#

even after onrep being called

nova wasp
#

is the object ever created on the client? I am not asking about the replicated list here, but just if the object ever was instantiated on the client from a network bunch

#

also, are you using iris? (I would suggest leaving this for now, it's experimental and will require some extra steps)

last storm
last storm
#

this is how I create then add. it's only called on server

nova wasp
#

does ::MakeAura always create a new instance?

last storm
nova wasp
#

also I can't tell what the list is

#

if it's pushmodel based you should mark it dirty

empty rune
nova wasp
#

for starters if this is ue5 you should have this be a real TObjectPtr but that probably doesn't matter much here

kindred widget
#

Is your actor component set to replicate? Is the actor it's on replicating?

nova wasp
#

also if this list changes often per-element it would be much nicer as a fast array because you can react to individual changes

last storm
kindred widget
#

@last storm You are getting OnRep calls on the client though?

nova wasp
#

I assume the onrep just has empty pointers in the array

last storm
kindred widget
#

Odd. I don't see anything you're missing. I mean for completeness I use the same thing in my inventory system.

protected:
    UPROPERTY(ReplicatedUsing=OnRep_InventoryItems)
    TArray<TObjectPtr<UInventoryItem>> InventoryItems;```
```cpp
UInventoryComponent::UInventoryComponent()
{
    PrimaryComponentTick.bCanEverTick = true;
    SetIsReplicatedByDefault(true);
    
    bReplicateUsingRegisteredSubObjectList = true;

}```
```cpp
void UInventoryComponent::AddItemToInventory(UInventoryItem* ItemToAdd, bool BroadcastChange)
{
    if (IsValid(ItemToAdd) && !InventoryItems.Contains(ItemToAdd))
    {
        InventoryItems.Add(ItemToAdd);
        AddReplicatedSubObject(ItemToAdd);
        
        if (BroadcastChange)
        {
            OnInventoryUpdated.Broadcast();
        }
    }
}```
```cpp
bool UInventoryItem::IsSupportedForNetworking() const
{
    return true;
}```
nova wasp
#

especially for something as larges as a tarray

last storm
#

I could add const ref tbh, just forgot

nova wasp
#

and yeah this list of steps looks fairly complete to me

#

I suspect we are not being shown something

#

I'm wondering if theres a project setting that matters for replicated object list

last storm
#

I'll try after adding this:```bool UAurasManagerComponent::ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags)
{
bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);

if (!ListAuras.IsEmpty())
{
    for (auto Aura : ListAuras)
    {

        bWroteSomething |= Channel->ReplicateSubobject(Aura, *Bunch, *RepFlags);
    }
}

return bWroteSomething;

}```

nova wasp
#

GDefaultUseSubObjectReplicationList can change if this is used by default or not

#

also is bReplicateUsingRegisteredSubObjectList = true in the ctor of the object that OWNS the subobjects? or the subobjects?

last storm
kindred widget
#

Can you show the object creation code? The.. MakeAura I think it was?

last storm
kindred widget
#

For a start, you'll want to set it's outer.

#

EG

UInventoryItem* NewItem = NewObject<UInventoryItem>(this, UInventoryItem::StaticClass());```
#

This is in the component, sets this component as the outer of the InventoryObject.

last storm
#

so, for exemple, I shoud: NewAura = NewObject<URegenerationAura>(player->auramanager, AAuraManager::StaticClass()); ?

kindred widget
#

The second param for class is optional. but yeah. If Player->auramanager is the correct component that will be replicating the object.

#

Unreal uses outer paths for lookups. So it's likely that it can't find the object on the client if it's looking for...
SomeActor.AuraManager.AuraThatGotReplicated, cause it doesn't exist, it was never created with that as the outer.

#

And pointers are replicated that way. They're essentially a pathname over network so that it can be looked back up in the local PCs memory.

last storm
#

I've read UObject need owner for replication, I was confused because you can't set an owner of a uobject, so it was maybe an error and they were talking about outer

kindred widget
#

Quite likely. ๐Ÿ˜„ Definitely two very different systems since Unreal has a literal Ownership chain for networking stuff as well.

last storm
kindred widget
#

Oh

#

I misread your code, no you don't need the second option. That's to specify a specific class for creation.

The <UObjectName> part is a template, it'll autocast the return pointer to that type.

last storm
#

Oh, so I just need "UInventoryItem* NewItem = NewObject<UInventoryItem>(this, UAuraObject::StaticClass());

kindred widget
#

Like.. Say you have
USomeAura
USomeChildAura1
USomeChildAura2

You want to use the return as USomeAura cause you don't care what subtype it is. So you write NewObject<USomeAura>(Outer, USomeChildAura1::StaticClass());

This creates a USomeChildAura1, but passes it back as a USomeAura pointer.

last storm
#

Ok ! thanks !

pliant jungle
#

Hello, do you know if itโ€™s possible to replicate an UObject array in a UObject which is itself in an AActor ?

last storm
kindred widget
#

@last stormSide note to this system that you'll want to be aware of for later. I ran into this fairly early with inventory since a core part is to transfer items between inventories.

You cannot rename the object into another outer. Or.. You can, but the moment the original actor dies, it takes the objects with it.

Like you have ActorA, ActorB. And you rename the object from ActorA to ActorB, two seconds later ActorA is destroyed. ActorA is actually still the one that replicated the objects even though they were renamed. So they'll remain on the host machine, and be destroyed on clients.

So if you end up at a case where you want to transfer Auras from one manager to another, DuplicateObject, don't Rename.

last storm
kindred widget
last storm
kindred widget
#

Stick this in your OnRep and breakpoint it. See what ends up in the Subobjects list. If any of the Auras are there.

last storm
#

lemme a second

kindred widget
#

This is assuming the OnRep is in the manager component, which it should be if that's what you're making the outer.

nova wasp
#

the ctor should also run when created

#

I forgot to say that earlier about seeing if it's created from the network

#

you can breakpoint the ctor

last storm
nova wasp
#

did you mark the list dirty?

last storm
nova wasp
#

using push model replication is a good idea because you are explicit about when things are dirty

#

MARK_PROPERTY_DIRTY_FROM_NAME(ThisClass, MyReplicatedProperty, this)

#

if you are using C++ replication you should probably have these... all over the place

#

even if it's just in a setter

#

it's a bit tedious but in theory the idea is you save on wasting time spam polling for changes on tick (instead this thing declares who has new data to send)

#

in practice things can get polled anyways ๐Ÿ˜ฆ

kindred widget
nova wasp
nova wasp
last storm
#

Like, List is replicated, object are replicated

nova wasp
#

fast array would be a good idea though still I think

kindred widget
#

Wait. The original array now has items?

nova wasp
#

I think what they mean is they just use that call to find the elements

last storm
nova wasp
#

or do you mean that just by searching for them they suddenly appeared in the replicated property you made? that's odd

kindred widget
#

O.o I would remove that and try a rebuild to see if it's working without it. There's no reason that it should cause that to work.

nova wasp
#

I'm confused

last storm
nova wasp
#

if you are hot reloading or live coding it is time to restart the editor

last storm
#

Previously the list was full of nullptr

nova wasp
#

well that is kinda freaky... is something making them wait to resolve until this happens? think

last storm
#

Weird stuff ngl, not gonna pretend this is the first weird behaviour I've ever seen

kindred widget
#

It won't be the last. Welcome to Unreal Engine.

nova wasp
#

machine gods are pleased

#

carry on

last storm
#

Thanks to both of you

#

it will help alot

#

One last thing, why OldList always null ?

    UPROPERTY(ReplicatedUsing = OnRep_ListAuras, VisibleAnywhere)
    TArray<TObjectPtr<UAuraObject>> ListAuras;

    UFUNCTION()
    void OnRep_ListAuras(const TArray<UAuraObject*>& OldList);```
kindred widget
#

Even if you make a second object?

#

It should be whatever data the client had before the OnRep was called.

last storm
kindred widget
#

Did you create them with intervals between or all at once?

last storm
#

Interval, they are created with keyboard input so...

kindred widget
#

That's odd.

#

Your code looks fine. I don't have an easy way to test that atm. Could maybe breakpoint and walk up the callstack to see where that is supposed to be sent from.

last storm
#

IDK at all , idk if this gonna be an issue for me rn but this issue shows up idk if it was normal or not

kindred widget
#

If you get three OnRep breaks, and they incrementally add entries to the array, but the old array is empty, I'd say that either the client is altering the array somewhere, or something is horribly wrong.