#multiplayer
1 messages ยท Page 265 of 1
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||
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.
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
Hey ๐ I was wondering if anyone could
Can you show your full callstack.
happens in netdriver tick flush
try setting the net.AllowClientRemapCacheObject cvar to true
setting LogNetPackageMap to verbose might give some clues
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
oh is UPSBaseActorPrefabProperties just a UObject? is it set up properly to replicate as a subobject under an actor?
yes
i override IsSupportingNet and using AddSubobjecttolist on actor
how is renaming an object managed ?
for example when chaning outer on server before/after it was replicated to clients
the issue was caused by the fact that the replicated uobjet outer wasnt the same as the object who was managing the subobject list
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
I had similar issues with root motion montages, I fixed this before passing the current animation playback info in FSavedMoves in the CMC and updating montage playback on the server as they come in
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
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
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
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...
You do not want to start a game as SP and then later on move it to MP.
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.
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?
That's just awful
Why?
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
Then dont make a MP game...
If you find that stuff to much to deal with, just make SP experiences.
It's miserable regardless of how much you gaslight me, and anyone will agree on that
But regardless I got my question answered
๐คฆโโ๏ธ
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
The packaging process will tell you in the logs why it failed.
its throwing up an error code and crashing UE
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
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.
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
That sounds like just a single game mechanic, wouldn't be too long to re-work the entire thing.
isnt it that if you wanted MP, you start implementing MP before the rest of the game?
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
Yeah, you don't want to turn single player into mp game, in many casses it's not even possible and require entire re-work.
yeah i understand
alright, so its whenever i try to check, it crashes unreal
when i click refresh platform status
that's just reality?
It's funny how you spiraled instantly from
you know nothing about mp -> you have never shipped a sp game -> you have never used oop before
The gaslighting is crazy
And then the guy below you contradicts your claims by saying buckshot is easy when it's a turn based game
Buckshot is stupidly easy to program, it's the art that probably took the longest
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.
you're talking about the 1v1 sp, which yes it is
Now try the 4 player version, especially with the unreal mp context
Or just multiplayer in general, even in other engine they would use RPCs too. I don't think it's done differently.
Yeah gimme a few hours and it's done? No assets, just gameplay
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
so i read on forums that i need to reverify my UE files, but i havent found an exact method to do so for the source version
lol, try it I'd be curious
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
literary that, 1v1 or 1v4 or 1v9 makes no difference
the moment it's networked, the logic is just different.
I await your few hours unreal mp buckshot
no one needs to do your homework
I'm not wasting time for some random discord user that calls "gaslighting" the second someone says something they don't like

I'd be impressed if you even get the players spawned
lmao
lol, I accept your concession
this gotta be a troll
Cat is that you
players spawning literally works right out the box with unreal multiplayer, just saying
Yeah I'm a troll, whatever
Go make 64player bf6 in blueprints prodigy, y'all so full of yourself is unreal
Worked on a 100 player game but sure, can do 64
Circlejerk among yourself, throwaway accounts ftw
Bwahahahahaha
you won't get far in life with that attitude
me when PC->RestartPlayer() takes hours to write
so difficult man 
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
bro literally went sicko mode 3 messages in, like what
anyway
i got my entertainment for the night
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
On the server?
well A.I controller only exist on the server
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.
Awww - I'm surprised no one pinged me when they brought up Godot to try and compare ๐
Yeah BeginPlay is usually too early for that stuff
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.
MP in unreal is only miserable if you dunno what you're doing
oh whoops i was scrolled up
What is your concern exactly?
Why would gait be replicated? It should be derived from velocity on all machines
having a secondary value to describe the context behind the velocity isn't that weird
it's not just a ball rolling around
But if that value is derived from velocity to begin with then what's the point?
sure, if it can be derived from other values it is redundant
Seems like my issue was fixed by REPNOTIFY_Always
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
who spawns the projectile?
the projectile ability class spawns the projectile and sends it off
I am not really concerned about GAS or whatnot here, I am asking if it is spawned on the client or the server
does the rpc just not reach the server?
Correct
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
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
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
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)
Ok but the rpc is being sent from the actor itself to itself
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
I have the player controller inside this item actor
sure
I can just pass the item pointer as a param and call destroy from inside my player controller that's interesting
yep, that should do it
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
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
that should work as long as it's a replicated actor component
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
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
Yeah that's true, but now I can drop items from player to player
I'm close to player trading
probably because most gameplay code tends to live on the pawn/playerstate/playercontroller etc
That's where most of my replication is handled if I look at this project really
I didn't put that together
hmmm
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)
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
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
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.
The item isn't inside the player controller
It just exists in the world
and is replicated out to them
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
mmm I'm making an RPG I'm not really looking to share inventory info with other people
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
So you can't look into some other player profile and check what their equipping?
most MMOs I play let you inspect other people
Ok but my equipment list is different than my inventory list
so why replicate the entire inventory to inspect equipment
okay, if that's something else then I guess it's already done
I kinda though they would be the same thing I guess
They communicate sure but no they're independent
just keep in mind that client only have their own PC.
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
Who said anything about score
I'm talking inventory and items equipping and unequipping
well you are talking about leaderboard
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
unrelated to this convo but I seen enough bad youtube tutorials.
then someone else took it didn't they
like Matt Aspald place HP in player controller.
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
Pass the item around a little
I've been staring at this for a minute and I understand this differently than I did about an hour ago. Thanks
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
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?
Can subsytems use any rpc? Or all of them are local? ๐ค
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
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
Is this screen from actor or widget?
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
Actor must be owned by client ( something that is owned by thay client in chain) to be allowed to send info to server
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
You're setting CurrentTypedWord locally, sending that value into the server, and then calling a multicast to set CurrentTypedWord to that value on the other clients. You're not not setting it on the server. The only reason it's being set on the server, is when you're playing locally as the server (listenserver).
try testing in Player Pawn, it is usually owned and spawned with proper owner.
Or just spawn on server with proper ovner
๐จโ๐ซ 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...
Did watch this to understand the concept. Still confusing.
Wouldn't multicast set it on server too?
Okay, yeah, you're correct about that. If it's a ListenServer, it's considered a client and also applies.
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
if server owns actor
then client can not use it to send data to server
Yes, wordmanager is calling the RPC.
ok, will need to check into it
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...
this explains more in detail
Yeah, I also watched this video.
6:10 is ownership
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?
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?
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
okay so then, i used get actor of class, and when using a widget it set that widgetr for all of the actors.
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
AAAAHH
I realized I am in multiplayer tab here..
not sure about multiplayer and what your trying to do
so if i wanted a variable to update for every player, i would do a get all actors of class and then do a loop so it applies to every player
You have to use RPC to update variable for server and clients
RPC what does that stand for?
what does rpc stand for?
No you dont
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.
If you're in GAS land shouldn't that be a tag?
I suppose I could do that in this specific scenario, but what if I needed to send a float, how can I send that value to all the clients from an ability?
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
Don't do this, RPC is for a one time event. If you need variable to be sync, mark the variable as replicated.
Is the component marked as replicated?
Iirc theres a gotcha when it comes to run time component.
There can be only one owner at the time so if there are more than one client need to call server rpc, this is not viable.
The workaround is to route the rpc to replicated component that the client own.
You can create a component that is attached to your character or controller then route the rpc there.
Yeah, I watched more than 10 videos to understand this. Found a video that explained it clearly..
Basically, the actor is owned by server. So client cannot call server event on it unless owner changed.
I'll do this in playercontroller.
You should look at the pinned material in this channel.
Exi multiplayer compedium and wizard tips and trick are gold mine.
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
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
yes you dont necesarily need to use actor as the proxy, component works just aswell
I will have to double check that in a bit I am not home
I will ping you when I get back @dark parcel
Thanks for help. I was able to reroute the message from my widget textbox --> playercontroller ---> actor
as playercontroller is always owned by player
@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.
Yeah, first run on server --> then multicast
If you need to do MC then attach to your character not player controller.
If that's whats required dont use Player controller.
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.
@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
@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
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...
so i can't properly replicate giving adding a component when its not in the player blueprint?
Correct me if I'm wrong
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
This is not a component. An actor component is not an actor.
An actor component is a component you attach to actor.
You need to create a new blueprint that derived from actor component.
Well wait a moment i didnt know it was for a flashlight
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
Well there seems to be misunderstanding on whats component and what nit
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
Yes because client cannot send rpc when they dont have ownership of the actor
Surely you follow this far?
Because server is authority
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
Because the player is possessed by the client ! It is owned by the client.
oooooooooh
2 things owned by the client out of the box.
The player controller
And the player character
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?
Look into the pinned material in this channel for faster learning. It is compiled beautifuly already.
Yes the pre placed actor in the level belong to no player.
and the PC in which the game is running ๐คฃ , so 3 items owned by the client
Only server can call rpc on it.
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?
Lets not confuse anyone 
There's a way to call rpc as client. That is by telling the server to give ownership to a specific client.
there's a node for that right? I cant remember what its called
This isnt in anyway recommended, arguably terrible infact.
The solution has been given above.
Route the rpc to something your client own.
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?
You route rpc to something the client own. To not convolute youe character we can encapsulate in actor component.
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
Works because the character is owned by the client so the client can send server rpc.
I know
Thats exactly what i mean by routing the rpc
But at this point you are convuluting your player character
How so?
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.
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
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
The character isn't responsible to turn the flash light on and off I just said that
Even when those feature are taken out the character should still work.
You can do a better design by separating responsibility by encapsulating.
okay but you're missing what i am saying
The character isnt handling turning on and off the flashlight
A component is
Im just trying to help not argue, if you dont want to use actor component. That is your choice.
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
Sure and that's not how I will approach my project.
Character should handle character logic, nothing else.
Interaction is on its own, equipment is on its own, inventory at its own, etc.
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?
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.
you should have an interaction component for interactable items, give this component to any interactable item and bind to an event in character oninteract, then see if item was a flashlight, on/off... if it was as vehicle in/out.. if it was a door open/close
even if it was a pickup item, add to inventory
How is that mp?
Woops! I mistaked it for materials
Np
still a GameplayEffect
What specific float are you talking about here
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
Have you looked at the character the engine gives you with a C++ character template?
What exactly isnt replicated?
Also the cull distance is irrelevant if the Actor is marked as AlwaysRelevant.
So I am using outliner to see if atleast Character appears on the client - nothing there, but on the server I can clearly see a character
let me AI that.. not sure how do that 
don't
make a C++ template project
and look at the code
Ignore the outliner, put a print string in BeginPlay of the Character.
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.
nope, nothing there... werid.
will try to spawn BP
What do you mean nothing?
It doesnt print?
It prints once?
It prints twice?
no UE_Log printed on BeginPlay
It doesnt print anything?
Not even for the Server?
You are running a Listen Server + 1 Client correct?
yes. On even on server, however the server breakpoint is triggered.
Yes, listen server + 1 client
I've cached it and now prints log in begin play once
by cached I mean have a uprop and store ref
Whats actor rep suppose to represent here?
just to store refence, nothing else
And your issue that its null? And on whom? The server or the client?
the ActorRep is not replicated to the client
Yeah the ptr is not marked as replicated.
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.
as far as I know you don't need to that for the Character it's automatically replicated
Sure but the ptr is not replicated
So dont expect the value to be changed on other machines but the one that sets it.
yea, the problem is that character is not replicated. proprerty was a tweak to have something working
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.
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.
You can.
With an active override
Ooo thank youu
RESET_REPLIFETIME_CONDITION
Not DOREPLIFETIME_ACTIVE_OVERRIDE ?
No, that was the wrong one sorry.
Oh okay, thankss!
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.
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?
Depends somewhat on the type of system it is.
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.
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 ?
AFAIK you don't even need to change it's dormancy. A simple FlushNetDormancy call will make it replicate once and then go back to dormant.
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 ?
I think so. That's how we're using it as far as I understand.
@meager spade can probably comment more clearly on it, he's the multiplayer wizard.
yes
FlushNetDormancy does exactly this
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 ?
yes
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 ?
wdym?
if it's a c++ property, just use a setter
if it's just bp, I think it's setter handles it
kay
but im referring to pure BPs
someone makes a BP, add vars and set them to replicate
there's an engine var
there is a helper
though i think pure bp props
does this automatically
but not sure
we have very limited replicated bp props
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
Same here ๐
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?
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?
other half of this code
Is there a way to disable Tranform replication when server changes the transform of StaticMeshComponent?
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
fast question, is there any limit to ustruct inheritance depth when the ustruct is used as a replicated property?
Thanks for helping ๐
Iโve used the outliner to see if actual character is spawned, added logs, break points even tried to cache
Are you sure the plank actor is set to replicated?
how can I make it where the client can interact with code that it dosent own?
evil
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?
How are you doing interaction?
Blue Print Interface
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
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.
huh?
if your interaction is happening on the server, ownership doesn't matter
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.
it doesnt work on the client @exotic wasp
do what duroxx said
should I do that by casting?
No
Seeing how you are relying on interfaces, on your linetrace, overlap check, or w/e - check if it implements the interact interface
in this case you could have your interaction be a server rpc
If it does, then just send the actor reference itself
thers no linetrace
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
server rpc is executes on server right?
But it doesn't matter for the purpose of this process
yeah
okay so
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
I could call an event in the server in the player blueprint and than have that event called in the bluepriunt for the actor?
You should be calling "Interact" in your player or whatever on the server
oh shit wait
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
Dont use multicast use OnRep
but for something like a door a better approach would be a repnotify variable, since that would preserve state
exactly
so i should be calling that blueprint interface on the server?
yeah i'm just saying what durox said
- Client gets a reference to the actor
- Client checks if the actor implements the interface
- If it does - do a server RPC from the player, that passes a reference to the server RPC function
- On the server RPC implementation - just take that actor reference and call the interface function
Thats not it
don't multicast
Now DC the client and reconnect.
you'll come to learn that it working and it being correct are two different things lmao
@shut vigil watch this vid https://www.youtube.com/watch?v=gfXcIF5-CRU&t=490s&pp=ygULa2VrZG90IGRvb3LSBwkJxwkBhyohjO8%3D
๐จโ๐ซ 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...
okay I removed the multicast and it still works
I dont understand how it isnt correct if it works?
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
watch that vid i sent, it explains it well
so your saying if the server player opens the door, and then the client joins. for the client the door would be closeed?
Correct
so where would i do the repnotify
would i do it in the interact code
the door should have a IsOpen variable that u set on interact
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
okay so
The door takes a while to open
and close
should i set it at the end of the timeline?
No
no you should play the timeline when the variable is changed
all your interact needs to do is change the value of bIsOpen
and you don't need any RPCs in the door itself
okay so where do i set it to be true or false?
toggle state needs to be onrep like i sent
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
oh it worked
huh
should I still have this interact blueprint interface called on server?
Yeah you p much always want interaction done server-side
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?
the flip flop might not necessarily match the value of the variable
that's cleaner anyways
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
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.
so now I can just do all the adding the component to the character in the actor itself?
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.
the "other actor" Varibale it from here in the character blueprint
okay
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
Just takes practice
honestly people make it out to be harder than it is outside of specific stuff
anyone help me pls ๐
repnotify
OnRep_bIsBroken -> do whatever should be done that depends on bIsBroken
ez
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
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
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 ?
@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.
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
Yes
Ehh, I wouldnt be concerned about the performance overhead of either of those things.
yeah ik, i just remember being mentioned somewhere
I wouldn't really say any are even remotely useful to even think about in terms of "performance"
It is literally an int check
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
by expenseive i meant epic meant how the value is returned
for role its directly on the actor as a member var, for net mode the driver has to do stuff
Move one single component and it is already more expensive than checking the netmode or net role.
Get it as low as you can without sacrificing what you consider necessary to ensure the systems core functionality.
how many kbps or w/e
0kbps ideally
Does it work networked right now?
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
I'd handle all of the edge cases of networking before thinking about performance.
what ? my prefabs props ?
Whatever you're trying to guesstimate
Its quite literally just getting the amount of data as small as possible.
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
Well your results will depend entirely on the size of those properties.
Its more efficient to send a int32 than an FVector
So
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 
Generally speaking, unless you see saturation issues, I wouldnt worry about bandwidth straight away.
well of course, im just trying to optimize the replication process on my side
if the user has a gigantic UObject its his problem
what would you check for instead ?
i never worked on profiling network, just go things "working", using push model and dormancy
I would be optimizing other things instead like CPU usage. Bandwidth is pretty decent these days.
how do i ease the server CPU
i guess low tick time on netdriver tick and replicate actor ?
You mentioned a couple methods already.
PushModel and Dormancy are mechanisms to aid in reducing CPU overhead for replicated Actors/Props
thats why i also used a single fast array that holds all of my replicated UObjects
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
Why is it not working the way im doing it so i understand what i did wrong
The outliner only shows the server world by default, you can change it but maybe just take matt advice.... give them a cube shape or something just to test.
Im not even sure what you are trying to breakpoint, again as i ve seen from your code, the ptr is not replicated so client one will remain null
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
@verbal ice I dont think there is.
@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
Ooooh sweet, will take a look
I tried that but it still doesnt work
It doesn't work for either the server or client now
- 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
bAlreadyBarricadedandPlankArray, 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_AlreadyBarricadedfunction in theOnRep_PlankArray.- Potentially a good idea to make a function for this and call that twice instead of duplicating code!
- I'm not sure what
Plank1toPlank11are, 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
PlankArraythen, because the Components already exist locally. Just callSetPlankArrayon Server and Client. PlankHealthwould 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 individualPlankX.
- You also don't need to replicate the
- PlankArray would also need to be RepNotify, and you'd need to do the same logic that you do in the
- You are calling too many ServerRPCs. You are already ensuring that you are calling the code on the Server via SwitchHasAuthority.
Setupdoesn't need to be a ServerRPC.SetPlankArraydoesn't need to be a ServerRPC.- As previously said,
MulticastDestroyPlanksshouldn't be a thing, as this is state and should be done via RepNotifies. - Same goes for
MulticastDestroyTeamWalls. Destroy1Barricadedoesn't need to be ServerRPC either, asEvent PointDamageshould only call on the Server to begin with.- Don't put numbers into function names. This should be called
DestroyOneBarricadeif at all.
- Don't put numbers into function names. This should be called
- The collision, physics, etc. logic in
Destroy1Barricadeshould be handled in an OnRep. This is state! You are only doing it on the Server atm.
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
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?
is there a reason you aren't just using the replicated subobject list?
the new method?
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.
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?
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.
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?
Thank you for the detailed post, is this the correct way of doing it? It seems to only work for the server still
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
client should not set the replicated variable, in your MC you are setting it using server+clients, MC calls on all clients and server.
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
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.".
solved using FFormatNamedArguments I hope it has no bad sides
FFormatNamedArguments Args;
Args.Add("ItemName", Item->ItemDisplayName);
return FItemAddResult::AddedNone(Item->GetQuantity(),FText::Format(LOCTEXT("StackFullText", "Couldn't add {ItemName}. Tried adding items to a stack that was full."),Args));
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
i dunno i followed gorka games tutorial on physics based movement
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
the problem is with the physics on it only shows the animations to whoever the moving player is but to other clients it dosnt show the movement, where as without the physics the animation works well in multiplayer
My guess is enabling Chaos control rig sims for clients on their end
?
you may have enabled them locally but not to them
what are you talking about
are you not using control rig for your physics animations?
no
ah than I have no idea
i have animations and then im putting physics ontop with simply this code
like without that code theres no physics at all
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
Distance isn't a thing in my game, everthing is on the one screen. Tick rate maybe might work but then physics objects might not sync as smoothly. I will have to explore that a little more. I wonder if the experimental tools cull like smooth sync does
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
Think rounds or stickfight as the game
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
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
how much state does that represent?
how much stuff is replicating
That statistic was from 10 physcis objects
what's your replication mode, the old ue4 implementation?
I think though maybe I can have the tick rate increased based on Angular/Linear velocities length?
you don't want to change the update rate of physics, just how often it's synced
This is 5.6 experimental interp and prediction
I'm sure there's somewhere in there to tune the replication rate
I'll have a look, I did change the default 100hz to 120 or 144hz for the servers
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
@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...
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?
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
does anyone know why my client doesnt have pitch camera rotation?
Can you elaborate?
as you can see the client is looking straight up but the host cant see that
theres no camera pitch for some reason
@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.
yes it does with the host
proof
@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?
i want the flashlight and the head to turn where the camera does on client like the host does lol
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.
Thereโs no bones bro
Itโs not a character mesh
well my suggestion would be to modify the panda head bone transform and the flashlight just rotate along with it
I just made a panda out of static mesh to show you that heโs not facing up
Thereโs
No
Bone
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)
10 gold says you just need to replace the rotation getter with GetBaseAimRotation.
yea GetBaseAimRotation will fix it
cause it auto handles clients using remote pitch
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);
}
}
yea that will still happen since remote view pitch is encoded to a uint8 or uint16
negatives will just wrap around to be positive
๐โโ๏ธ
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
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
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
ohhh thats interesting.. like having the center have more precision and the extreme angles have less? i could see that working
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
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 constructorAddReplicatedSubObject(NewAura)when I add to the list,RemoveReplicatedSubObject(OldObject)when removed from the list- add List to
GetLifetimeReplicatedPropsandDOREPLIFETIME - set the List as
ReplicatedUsing
In my UObject:
- add
GetLifetimeReplicatedPropsandDOREPLIFETIMEall necessary variables - add
virtual bool IsSupportedForNetworking() const override { return true; }
Do I miss smth ?
did you follow the docs? your setup looks okay from what I can read here but definitely double check https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-uobjects-in-unreal-engine
also not sure if you are saying it doesn't work, or asking if this is what you need to do
I'm saying that it doesn't work. On client list is always empty
even after onrep being called
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)
I don't think so, how can I know that ?
we're not using it
this is how I create then add. it's only called on server
does ::MakeAura always create a new instance?
Yes
for starters if this is ue5 you should have this be a real TObjectPtr but that probably doesn't matter much here
Is your actor component set to replicate? Is the actor it's on replicating?
also if this list changes often per-element it would be much nicer as a fast array because you can react to individual changes
I used to have a TObjectPtr here, but moved to raw pointer to test stuff
@last storm You are getting OnRep calls on the client though?
I assume the onrep just has empty pointers in the array
Yes I do, but OldList always empty, ListAuras always empty
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;
}```
why is this taking the old one by value? you want a const ref here
especially for something as larges as a tarray
I could add const ref tbh, just forgot
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
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;
}```
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?
Ok, smth changed when I added this, now list is replicated. when I add one on the server the list one my client also replicates BUT, the object in the list is null
Can you show the object creation code? The.. MakeAura I think it was?
Too long for discord, but here is the makeaura
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.
so, for exemple, I shoud: NewAura = NewObject<URegenerationAura>(player->auramanager, AAuraManager::StaticClass()); ?
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.
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
Quite likely. ๐ Definitely two very different systems since Unreal has a literal Ownership chain for networking stuff as well.
when I'm doing this, I crash at the second CheckF
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.
Oh, so I just need "UInventoryItem* NewItem = NewObject<UInventoryItem>(this, UAuraObject::StaticClass());
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.
Ok ! thanks !
Hello, do you know if itโs possible to replicate an UObject array in a UObject which is itself in an AActor ?
gonna try that, I'll keep you in touch, thanks alot !
Technically yes. But you should still outer the objects to the owning actor probably. Which means that the actor would replicate the objects, and the array of pointers on the object would just be replicating the pointer pathnames.
@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.
good to know, thanks a lot. Unfortunately, adding outer doesn't replicate the uobject neither
Can you to a lookup? Uhh..
Idk what I need to show haha
TArray<UObject*> Subobjects;
GetObjectsWithOuter(this, Subobjects, true);```
Stick this in your OnRep and breakpoint it. See what ends up in the Subobjects list. If any of the Auras are there.
lemme a second
This is assuming the OnRep is in the manager component, which it should be if that's what you're making the outer.
it is
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
this shows me an aura ! not null !
But now, why is it null in my list then ?
did you mark the list dirty?
when and how should I do that ?
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 ๐ฆ
It shouldn't be OnRepping if nothing was sent though.
oh yeah, and if all else fails you can yell at unreal to make sure the actor is checked with ForceNetUpdate();
true enough but depending on onrep settings it might always send that upon creation
Am gonna be a bit annoying but since I add this, everything seems to work pretty good
Like, List is replicated, object are replicated
fast array would be a good idea though still I think
Wait. The original array now has items?
I think what they mean is they just use that call to find the elements
since I try to GetObjectWithOuter, yes xD
or do you mean that just by searching for them they suddenly appeared in the replicated property you made? that's odd
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.
I'm confused
Searching for them made them suddenly appeared IN THE LIST
if you are hot reloading or live coding it is time to restart the editor
Previously the list was full of nullptr
i'm not
well that is kinda freaky... is something making them wait to resolve until this happens? 
even after deleting the GetObjectWithOuter, they are still here my lil auras
Weird stuff ngl, not gonna pretend this is the first weird behaviour I've ever seen
It won't be the last. Welcome to Unreal Engine.
haha
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);```
Even if you make a second object?
It should be whatever data the client had before the OnRep was called.
Yes, I've tried with 3, and it's always empty
Did you create them with intervals between or all at once?
Interval, they are created with keyboard input so...
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.
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
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.