#multiplayer

1 messages Β· Page 193 of 1

tired current
#

if a player joins late since the value is replicated it should be fine yea?

#

there is problems with it getting out of sync but not too often.. What would the ideal way to do this be? or is how im doing it okay

dark edge
tired current
#

Thank you πŸ™‚

fossil veldt
#

What's the current best way to stream large amounts of largeish data items (~32KB) to specific clients without requiring Iris?

#

Is UChannel the way to go?

fossil spoke
#

Might help?

fossil veldt
#

Ah I appreciate it but I don't like to do it with RPCs honestly

#

I wanted a more robust solution

#

It is quite incredible how long the engine has existed and nobody still seems to have figured out a proper solution to this

fossil spoke
#

Use a Socket?

fossil veldt
#

eh but then I can't do any sort of decent load balancing

#

ima be sending ALOT of data

#

I honestly might just use UChannel

nova wasp
#

UDataStream

#

UDataStreamChannel *

fossil veldt
#

that's Iris

nova wasp
#

be fancy with Iris

#

will this actually help? of course not but it's new so it's cool

fossil veldt
#

ahah

#

It is annoying because it would be great but I feel like none of this new fancy stuff is actually usable at this point

nova wasp
#

I am not sure what is required to make a raw data channel work from scratch

#

like, which parts does unreal hide from me that I would have to implement

fossil veldt
#

Only one way to find out

#

Seems like there's a map on net driver

nova wasp
#

I have made my own datachannel but it sucked because I had to make engine changes

fossil veldt
#

yea

#

ima see if I can find a way to just layer on a custom data streaming UChannel

nova wasp
#

UReplicationSystem::InitDataStreams should include a for loop that goes over your new ones but no dice

#

for example
UNetTokenDataStream final : public UDataStream

#

is how iris sends exports across I think

#

personally I am hoping to get away with RPCs

#

I pray

fossil veldt
#

Oh cool NetDriver just constructs UChannels from config

tired current
#

Is there anyway to call a method and only have it execute on the client?

fossil spoke
#

You can also check the NetMode

#

if(IsNetMode(NM_Client))

tired current
#

thank you

#

and if I wanted to call a server authoritative method would it just be HasAuthority?

fossil spoke
#

Yes

#

You can also do

#

if(GetNetMode() < NM_Client)

nova wasp
fossil spoke
#

A Listen Server isnt a Client

tired current
#

That is true, out of curiosity how would I deal with it if I wanted something to happen only on the clients and on then only on the client host as well in a listen-server setting

nova wasp
#

it depends on the context

fossil spoke
#

if(!IsNetMode(NM_DedicatedServer))

nova wasp
#

AController::IsLocalController returns basically that

tired current
#

if i wanted to play a sound when a player pressed a button but only for that player

fossil spoke
nova wasp
fossil spoke
#

BP has a macro called CanExecuteCosmeticEvents which does the same thing.

#

Its helpful, similar to HasAuthority in BP.

nova wasp
#

the important thing: ROLES are defined PER ACTOR that is replicated

NET MODES are global for the world (generally speaking, replays and replay playback mess with this a bit)

#

I guess per net driver more accurately

#

which there is generally one of per world (?)

fossil spoke
#

There can be multiple net drivers

#

If you record replays, then there is a separate net driver for that.

nova wasp
#

ah yeah, actors define NetDriverName

tired current
#

what is a net driver? dont think i came accross that in the compendium

nova wasp
#

it's the core netcode manager that handles the actual packets going up and down

woven basin
# fossil veldt Only one way to find out

Check out our website:
https://hraqe.pro/
linkedin:
https://www.linkedin.com/company/90669236/

You can find full project code here:
https://github.com/hraqe-pro/TCPTutorial/tree/master

1:02 - Required dependencies and required variables
2:17 - TcpListener descriptions
2:45 - Function general description
3:44 - Client connection server side fun...

β–Ά Play video
fossil spoke
#

Its not something you would normally be exposed to.

tired current
#

yea okay

fossil spoke
#

Its quite low level

tired current
#

thanks for sharing the vid tho as I am curous in general

nova wasp
#

it's not really a big concern most of the time for gameplay code

#

with Iris you do kind of have to grab it indirectly to change actor replication properties sometimes but even then it's mostly "just call these static utils"

woven basin
twin juniper
woven basin
#

This info is from the Voxel Plugin discord - because its one of the few places where you need to send large amounts of raw data - so the topic comes up a bit over there.

nova wasp
#

the problem is the parts that are missing are very tough to figure out

woven basin
nova wasp
#

subtle differences in rpc and onrep order

woven basin
nova wasp
#

a lot of iris is bending over backwards to make it seamless but it's still going to do things weirdly

woven basin
#

Currently RPC order is garunteed when reliable on the same actor channel - is that different in Iris?

nova wasp
#

iris has no actor channels

#

this is the core part of iris that receives bunches

#

this thing is getting hammered with changes that affect deserialization orders to this day

woven basin
#

kk - thanks mate - I'll look into all this a bit more today. I've got a source build of the engine that I'm going to switch over to Iris this week, so its very timely for me

woven basin
nova wasp
#

Fixed bitstream error that could occur if total size of a batch exceeded 2^20 bits

tired current
#

So I am trying to play a sound only on the clients

if (IsNetMode(NM_Client)) {
    UGameaplayStatics::PlaySoundAtLocation(sound, GetActorLocation());
}

but the sound doesn't play on server or client.. I am calling from Pawn class which is possessed by player controller so should have Client mode

fossil spoke
#

Its best when submitting code in Discord to post the entire function scope.

tired current
#
{
    if (OtherActor->HasTag("Enemy") && Character) {
        Character->TargetHit();
    }
}```

that other method is just the targetHit method
fossil spoke
#

And does the function even get called?

tired current
#

yes

#

if I dont use the netmode if statement it is just called on server

#

would it need to be an rpc?

#

that would be weird

fossil spoke
#

What PIE settings are you using?

tired current
#

listen server

fossil spoke
#

...

#

A Listen Server is not a Client

tired current
#

ah would the second payer not be a client?

fossil spoke
#

You didnt say you had a second client.

tired current
#

apologies

fossil spoke
#

Thats why I asked what settings you were using

#

Important to answer specific questions with specific answers.

tired current
#

ahh yes Listen server and 2 players

fossil spoke
#

Ok cool.

tired current
#

i didnt touch advanced settings

fossil spoke
#

Where are you binding the BeginOverlap?

tired current
#

begin play

fossil spoke
#

Does BeginOverlap get called on the Clients at all?

tired current
#

no.. that is probobly my issue lol. Thank you.

#

I guess I should RPC it then

fossil spoke
#

No

tired current
#

ah

fossil spoke
#

Stop going to RPC as the first answer

#

RPC should be your last choice

#

Not your first

#

Overlaps can occur on both the Client and Server

#

Therefore you need to work out why the Overlap isnt happening on the Client

#

Think about why something isnt happening.

#

Investigate why its not happening.

#

Understand why its not happening.

#

Then you can reason about an appropriate solution to the problem.

#

Stop jumping straight to an answer without understanding the problem.

tired current
#

I think my replication settings look good

#

good advice thank you

#

I will do some more research

fossil spoke
#

Good luck

fossil veldt
fossil veldt
#

the part where it splits it up works great - but NPP is broken / sussy with it and I don't have time to go fix / PR the engine atm

#

and I don't much like using the features that are exclusive to Iris because it means I can't turn it off if I need

silk nexus
#

I've been trying to figure out how to display a game state variable in the client HUD. I've tried using a dispatcher to update a client-side variable as well. For some reason, the above blueprint tries to access none when executed on the client. I feel like it's obvious, but I'm blind to it after staring at it for so long.

Can anyone tell me why this is throwing the tried to access none error?

nova wasp
#

show the gamemode

short arrow
sinful tree
silk nexus
tired current
#

Clarifying question: if I am calling a netmulticast RPC on an actor owned by the server, in a listen server, will the event fire twice for the client host?

modest crater
fossil spoke
#

Its literally in the name

#

Listen SERVER.

tired current
#

yea okay

#

sorry am just trying to wrap my head around everything and understand how it works. Am new to networking.

modest crater
#

matt, not sure if you seen or not but uextm got his pr merged #cpp message to fix the issue with TInstancedStructs in arrays and the issue with the base struct meta thing, might be finally able to update that note on your genericItemization plugin when it gets fixed

fossil spoke
#

Yeah I havent had much time to continue development on the plugin.

#

Ive just been making sure it compiles with latest.

modest crater
#

Yeah it gets a bit like that with needing to maintain released stuff, I also think they are moving the plugin to the engine modules instead too

charred island
#

network newbie here who is having trouble googling how to get started converting my project to multiplayer:

how would one go about replicating things like thumbstick input? in my case, I have a space sim where player input controls thrust to move/rotate the ship. naively trying to use the "replicates movement" setting results in the clients stuttering back to the original orientation. should I be sending the stick axis values from the clients to the server and having the server replicate the thrusted position/orientation back to the clients? is this robust to latency? am I completely off track?

modest crater
# charred island network newbie here who is having trouble googling how to get started converting...

buffered inputs is one way of going about but its older and not used with unreal, instead it replicates the things those inputs drive in the form of flags (like bSprint, bJump or bCrouch, just one off things that are binary) and then values like your velocity, acceleration, even your pitch/yaw get replicated automatically.

I would worry less about the character movement being networked (since its already implemented) and more on what else you do care about like

  • State - for example health, it would be a replicated float, its state needs to be maintained and replicated

  • Event - for example shooting a weapon, its a once off sound and VFX event we want to run on clients but its not persistent (I know about "burst combo" techiques but just keep it simple and general)

tardy fossil
#

i heard that some projectile prediction systems actually rewinds EVERYONES position temporarily on the server while it moves the projectile.. seems like a real easy solution but it also seems very hard on performance.. anyone ever try something like this?

woven basin
#

yep - server side rewind

chrome bay
#

The trick is to not move the players at all

woven basin
#

If your looking for a way to do it - I can highly recommend Unreal Engine 5 C++ Multiplayer Shooter Course - he covers the topic in great detail and by the end you'd have a full working version.

#

and yeah - its more about hitbox captures over frames from memory

#

been 1-2 years since I did the course - cant remember the specifics

chrome bay
#

Ignore players and trace against simulated capsule positions instead. Also keep in mind this is a massive hueristic, trying to make it too perfect is just throwing performance away for literally zero gain

woven basin
#

probably depends how competitive/accurate you want it to be

chrome bay
#

The issue is you're not trying to estimate what happened on the Server, you're trying to estimate what happened on the shooting client at that time, which the Server can never know with 100% accuracy

#

Unless ofc you have a perfectly lockstep game (which I doubt)

tardy fossil
#

yeah.. the way i do it now is have the client send an RPC when it detects a hit and the server does it thing with rewinding the hit player based on ping ect.. i was thinking server side move might be more accurate since the clients RPC can take a variable amount of time to arrive.. but like Jambax said, the game isn't lockstep so trying to get a 100% accurate hit prediction system is probably a waste of energy

chrome bay
#

well also all other players are being updated on your client at variable times

woven basin
# tardy fossil yeah.. the way i do it now is have the client send an RPC when it detects a hit ...

The client shouldnt be telling the server about a 'hit'.

The client should ask the server that it wants to shoot. The server checks ammo, is stunned, is reloading etc - and if allowed, the server "shoots". The server then decides/rewinds and determins if any hits occured, and if so, broadcasts to each client the hit.

The client firing can do prediction on the firing, for local animation, but the actual projectile is spawned on server. You could also do local hit prediction, but that creates issues if the local client "predicites" it hit someone, creating a blood splatter, but the server doesnt calculate that.

chrome bay
#

I disagree, client should send the hit - but server should just validate it

woven basin
#

But the client A might not have the right location of the other client B?

#

why would the client decide a hit?

#

the server handles the shoot? it can decide the hit?

chrome bay
#

Because otherwise they'd miss all the time, your local client would have to account for lead time

tardy fossil
#

yeah the projectiles are spawned locally, so it could look like a hit on the client but miss on the server

woven basin
woven basin
chrome bay
#

Once the hit gets to the server, you try to work out "roughly" where all players were on the shooters' client at that time, then resimulate/validate the hit locally based on that info

#

IDK how that course says to do it but that's how we/I did it on HLL at least, minus the gory details

tardy fossil
#

thats basically exactly how i've got mine set up haha

woven basin
chrome bay
#

Just hitscan everything, so much easier πŸ˜„

woven basin
#

haha - yeah

chrome bay
#

the complexity vs the actual difference to gameplay is borderline depressing

tardy fossil
#

yeah.. all my projectiles are slow moving tribes style projectiles lol

chrome bay
#

yeah, I guess our case was just bullets

tardy fossil
#

which is why it also has to be spawned locally, or else theres a very noticable delay

woven basin
#

so the local prediction makes it "feel" instant

#

otherwise your client shoots from a slightly different lcoation to the server, so the predicted projectile doesnt fully match the server generated one. You just create different issues...

#

KaosSpectrum spoke a few times in here how that is how the did it that way as well

meager spade
#

yeah predicted projectiles is fine but over a certain ping, it falls apart

#

sometimes its easier just to smoke and mirror it client side

#

iirc games like overwatch spawn a dummy projectile client side, and the server side projectile never goes to the client, but the server projectile is the one that decides what got hit

#

but i could be wrong, but that seems right to what i heard

scenic cradle
#

how to get the client camera's pitch rotation to server?

tired current
#

is the camera component replicated and is the actor its on replicated?

scenic cradle
#

I m doing this now, its working too, is it good?

quasi tide
#

Make it unreliable

tired current
#

Can someone give some insight on if I am using RPC’s the wrong way in this scenario please:

I have a method called on a player controller, which calls a server RPC with a validation check. Then that server RPC calls a client RPC to then play an animation.

The idea is that the server is being used to validate this action happening but then it needs to replicate back to clients.

I tried it a few ways and found that even with no RPC’s it still executes on both server and client, but I am thinking this way that the server validates it. I also need the client RPC to go back to clients as if it just plays anim on server rpc then the clients don’t receive.

#

Also Possibly related:

Would someone be able to clarify if my understanding of Invoked from Client vs Invoked from Server is accurate please?

My understanding is that invoking from client means some processing happened on the clients machine like an overlap event of a projectile spawned by a player pawn or a sound played by a client player pawn firing a gun and that is calling an RPC.

scenic cradle
#

ou so there is no need for it to processed in order?

quasi tide
# scenic cradle why?

Because IA_Look is pretty much called on tick and you don't want reliable RPCs to be called so frequently. Unreliable may drop a packet, but it doesn't matter - it is being sent so frequently, it'll have an updated one in no time.

scenic cradle
#

ou oki

quasi tide
#

Too many reliable RPCs fills up the buffer and could lead to people being kicked.

scenic cradle
#

thanks

sinful tree
# tired current Can someone give some insight on if I am using RPC’s the wrong way in this scena...

RPCs are used as a means to communicate between the server and clients.
Server RPCs are used to have a client request the server to do something. These can only be sent to the server if executed on a client owned actor, or if they are called while already executing on the server.
Client RPCs are used to have the server request the owning client to do something. These will only be sent to the client that owns the actor. If there is no owner, then it will not be sent to any clients.
Multicasts are used to have the server tell all clients to do something.

One thing to keep in mind with RPCs and Multicasts is that they are not stateful. They are "fire and forget" so if you happen to say, play a looping animation on a multicast, and someone joins the game later and comes across your character that should be playing that looping animation, it would not be playing that animation on their end as they weren't present when that multicast was sent. If you need something to retain state, then you use an OnRep variable and its associated function to then execute what is needed.

Some events, like the overlaps you were mentioning, can happen in more than one place as each copy of the game would have their own instances of those actors spawned and each instance of the game can locally detect said overlaps or trigger those events without any network communication happening. So if I move my replicated actor into an overlap on my copy of the game, my copy of the game would detect that overlap and meanwhile, my location is being sent to the server, and the server then moves my character to that location on its copy and then it too would detect that overlap, and finally, because the server is replicating my location to all other clients, then my character's location is replicated out to all other clients, and then they too detect that I overlapped --- All this happened without my game telling the server that I overlapped or the server telling anyone else that I overlapped.

tired current
#

Thank you for this very in depth explanation!

quasi tide
#

At this point, I think Datura just has a template they copy paste and change around a bit to make it more aligned with the users question.

tired current
shadow aurora
#

Had a weird situation the last day or two where GEs are not removing for like 8-9s after the server removes them while I'm in PIE. I don't believe I have network lag simulating either. Any thoughts?

sinful tree
tired current
#

i see that makes sense

quasi tide
#

You could also have the trigger box only exist on the server and not on the client at all. That's how I handle those things personally.

sinful tree
#

That's another thing to keep in mind, each time you mark an event as a Server RPC, that's a potential way for clients to tell the server to do it. It's like leaving a door open allowing someone to potentially utilize it even if you never have any events that run on a client that call to it, it's still left open - that means someone with enough know-how could potentially "spoof" a call to that RPC and make the server execute it, so don't just mark everything as "Run On Server" just to indicate that it's something you want executing on the server.

tired current
quasi tide
#

On the actor, turn off "Net load on client"

charred island
# modest crater buffered inputs is one way of going about but its older and not used with unreal...

I understand how that would work well for booleans like sprint/crouch, but I'm talking specifically about continuous analog inputs.

In my case character movement isn't working automatically. I have the values from my flight-stick(s) continuously adjusting thruster outputs on the ship, which works locally. When I try to network it, any attempted movement is snapped back to the original position/orientation.

zenith osprey
#

Has anyone had it where you spawn an actor set the ownership etc all correctly (least to my knowledge) but it doesn't work at first glance till you tab out and select it in the Outliner.

In my context this is spawning a FPWeapon and TPWeapon. And at first the player can see both weapons even though the visibility settings (OwnerNoSee and OnlyOwnerSee) are set correctly. But if I "tab" out and select the item in the outliner the visibility then fixes itself. Is this some weird replication ownership bug or? Cause the ownership has to be set correctly since just selecting the weapons in the outliner fixes them somehow. But trying to resolve why I need to select them in the outliner in the first place.

If needed this is my code in the items.

HEADER

class GAME_API AItem : public AActor
{
    GENERATED_BODY()

public:
    // Sets default values for this actor's properties
    AItem();

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Replicated)
    USkeletalMeshComponent* SkeletalMeshComponent;

    UPROPERTY(Replicated)
    bool bFPItem;

    UFUNCTION(Server, Reliable)
    void SetupMeshOnServer(bool bIsFPItem);

    UFUNCTION(NetMulticast, Reliable)
    void SetupMesh(bool bIsFpItem);

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public:
    // Called every frame
    virtual void Tick(float DeltaTime) override;
};

CPP

void AItem::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    DOREPLIFETIME(AItem, SkeletalMeshComponent);
    DOREPLIFETIME(AItem, bFPItem);
}

void AItem::SetupMeshOnServer_Implementation(bool bIsFPItem)
{
    if (HasAuthority())
    {
        SetupMesh(bIsFPItem);
    }
}

void AItem::SetupMesh_Implementation(bool bIsFPItem)
{
    if (bFPItem == true)
    {
        SkeletalMeshComponent->bOnlyOwnerSee = true;
        SkeletalMeshComponent->CastShadow = false;
    }
    else SkeletalMeshComponent->bOwnerNoSee = true;

    FString RoleString = HasAuthority() ? TEXT("Server") : TEXT("Client");

    UE_LOG(LogTemp, Log, TEXT("[%s] : Set Actor Visibility"), *RoleString);

    // Print to Screen
    if (GEngine)
    {
        FString ScreenMessage = FString::Printf(TEXT("[%s] : Set Actor Visibility"), *RoleString);
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, ScreenMessage) ;
    }
}

// Called when the game starts or when spawned
void AItem::BeginPlay()
{
    Super::BeginPlay();

    // Check if we are on the server
    if (HasAuthority())
    {
        SetupMeshOnServer(bFPItem);
    }
}
gritty warren
#

I have a super simple question (sorry everyone above me, I cannot help)

I have a widget that is on the client only. When I click the widget button, I want to call a function that runs on the server that takes in a GameplayEffect Class.

What should I do? This sounds so simple, but I've had a ton of issues getting this to work via GAS, so now I'm looking for any method

sinful tree
#

Easiest way would likely be to make a Component that is attached to your PlayerController that handles whatever this widget is supposed to control. Then it's just a matter of from within the wiget get the owning player, get component by class from that reference, call the RPC.

gritty warren
#

thank you!!

#

that makes a lot of sense

kindred widget
# zenith osprey Has anyone had it where you spawn an actor set the ownership etc all correctly (...

That has almost nothing to do with ownership. The correlation of the Owner in each name is misleading here. OwnerNoSee OnlyOwnerSee are shitty names that should actually read as ViewTargetNoSee, OnlyViewTargetSee, or similar. Because they are only related to the "owner" via a loose concept that it's "usually" the owner who sees them because the owner's view target is the one set on the pawn.

In reality those values work based on the viewer. EG if you're spectating another player and you've got them set as a view target, you would see their OnlyOwnerSee and not see their OwnerNoSee even though you as the spectating player do not have ownership over said pawn/actor.

As far as why selecting them in the outliner fixes it, I've no idea initially.

quasi tide
#

Owner is probably the most overused/overloaded term in UE's dictionary.

copper raft
#

heyy guys, i made a procedural aim offset, how can i replicate it? i tried a lot of methods but when move mouse up and down in multiplayer mode, my hands are stuttering

zenith osprey
#

overall obviously it doesnt work but everything is set correctly

lusty yarrow
#

Hey, how expensive is sending an array of actor pointers through an rpc as opposed to looping through the array and sending each actor pointer as a separate rpc? Which is preferred?

sinful tree
lusty yarrow
# sinful tree Sending an RPC for each individual actor would probably be worse on account that...

Actor "selection" system. Need to clear a player's array of selected actors at some point. Theres multiple facets to this because I've also got some primordial client prediction going on which would mean I need to save the array so I can at a later point rollback on it should the clearing not go through. Already have the single actor selection setup with rpcs so i figured I could just do the same logic as when single selecting only that I'm sending multiple rpcs through, in case of failure on an actor I can always roll back just that one actor.

#

Multiple rpcs feels more malleable than sending a whole array through at least with what I've got setup so far.

sinful tree
#

This is for like an RTS style selection system?

lusty yarrow
#

Yes

proven pagoda
#

I set up a host migration system that if my listen server host disconnects, it will auto rehost. My issue is persistence. When it rehosts my player gets destroyed along with the player state. Any pointer on which class I could save player data on that survives more than the player state that is replicated?

#

All my important player info is on the player state yikes

sinful tree
# lusty yarrow Yes

I'd think client prediction wouldn't be an issue with something like this as selecting units can be done entirely client side without impacting gameplay.
On the server end, yes, it can matter what units they have selected, however, you probably don't need to have the server be the authority over what units they have selected, only over what actions are taken with the selected units.

To that, I'm not sure I'd have the selected units as a state of some kind. You could just as easily allow a client to pass through the array of selected actors when issuing a command and having the server filter out invalid units at that point. Once a reference is passed across the network it's generally very small to reference it, if I remember right it's only like 4 bytes, and in which case, if you had 100 units selected, that would only be 400 bytes of data to send in that RPC which is next to nothing in the grand scheme of things.

lusty yarrow
# sinful tree I'd think client prediction wouldn't be an issue with something like this as sel...

Server isn't the authority, both client and server hold a local list of "selected" actors and each actor keeps track of the player who selected it by uid. The only authority the server has is telling the client if what he selected is available for selection or not, if its not then just rollback. So in a way, clearing the selection wouldn't require validation due to the fact that we're already doing that during the initial selection of each actor, which is why I preferred the single actor rpc for each element in the array. Both selected actor arrays are kept in sync but not replicated.

lusty yarrow
#

the uid itself is replicated.

fossil spoke
#

Before the Aim Offset is queried.

copper raft
sinful tree
# lusty yarrow Server isn't the authority, both client and server hold a local list of "selecte...

"Client Prediction" insinuates server authority. It's a means of saying that you're allowing the client to do something before the server allows it, and if the server doesn't like it, then the client must adhere to what the server wants (ie. the server is the authority). Selecting a unit "predictively" means you're allowing the client to select a unit before the server OKs it, and rolling it back if they don't - but again, this isn't something that is strictly tied to gameplay or latency in the first place - the server shouldn't really care about what is selected, only what actions a player is allowed to take with the units it has selected. For example, you wouldn't want a client to be able to tell the server to move an actor that is supposed to be controlled by an enemy.

The actors themselves also shouldn't care about whether they are selected or not. The client can maintain an array locally of all selected actors. You can do checks client side to ensure they're not selecting actors they're not supposed to. When they issue a command, you pass that array to the server, and the server then loops through the array, checks if the client should've been able to issue a command with the selected actor, and if not, does nothing, otherwise, perform the action for that actor.

dark parcel
copper raft
copper raft
#

πŸ˜΅β€πŸ’«

copper raft
dark parcel
# copper raft do i need to use this for aim offset?

I dunnoe, depend on what you need, I can't do math. For my use case I just need the character to bend up and down for free aiming.

Iirc only use the get base aim rotation. (Got to remap it for non locally controller characters because of compression)

fossil spoke
copper raft
copper raft
fossil spoke
#

Probably because you are using the wrong terminology.

#

You dont need to replicate the Aim Offset

#

No one has ever needed to replicate an Aim Offset

#

You need to smooth the aiming.

copper raft
copper raft
fossil spoke
#

I dont know your setup or what to recommend. You are better to re-ask the question in #animation

#

Without using the phrase "replicate"

#

Because that isnt the issue

copper raft
dark parcel
#

He only have the problem in networked environment tho, isn't that multiplayer issue. A video probably help.

dark parcel
#

Of the stuttering?

#

Show what happend in single player and multiplayer

copper raft
#

is like this guy

#

he has same problem

#

looks like this

dark parcel
#

K so u already have the problem in single playee

#

That's not even multiplayer issue then

copper raft
#

how i said this problem is only for multiplayer

dark parcel
copper raft
dark parcel
#

Well I don't know that. I suggest taking a video of what you have and post it, maybe someone knows if it's network problem or not.

I'm going b to bed, gl

copper raft
dark parcel
#

Computers can't send data fast enough to show a smooth motion over the network

copper raft
#

so now is ok?

#

it should be like that?

dark parcel
#

If it work then I guess? I'm new my self. The problem I see is that you should interpolate to smooth the motion for proxies characters

dark parcel
dark parcel
#

Interp from current roll, target is w.e u have atm

copper raft
copper vale
#

does anyone know of a plugin or something that exposes icmp to blueprints?

#

i need to fix 9999 ping issue with Steam πŸ˜…

lusty aspen
#

does anyone know how GetWorld()->GetFirstPlayerController() behaves over multiplayer. If there is 4 players on 4 different systems, would the first player controller be the local player for each of those systems? or is it always ordered the same for everyone, and the listen server would be the first player controller?

woven basin
charred island
#

I have code for controlling a spaceship's orientation based on enhanced input axes for pitch/yaw/roll. it calculates thrust values and then applies them, which works fine on a standalone. what would be the best way to make this work over the network? should I move the input processing to the PlayerController class and then have the client version send the input data to the server version of the PlayerController?

devout sonnet
#

Actor replication for a 2 player rock paper scissors game. The options are displayed on 3d cards. The server spawns the 6 cards and places them in front of the players. Having spawned from the server, the host can see all the options. But those aren't being replicated to the client. I'm not sure how to set up an RPC to tell the client about the options. I've tried setting the created actors as replicated variables, I've tried doing RPC to set variables on the player controller.. any advice?

fossil spoke
#

If the Server calls a Server RPC, it just calls it as if it was a regular function.

fossil spoke
devout sonnet
#

Yeah, if you want, I have the project spelled out in this Google doc

devout sonnet
devout sonnet
fossil spoke
#

Create an Enumeration asset

#

Which contains your card types

#

Rock, Paper, Scissors

devout sonnet
#

Yup did that

fossil spoke
#

Create a replicated property in the Card actor

#

That will be the type

#

Set it to Expose on Spawn

devout sonnet
#

And I have the variable of that enum set on spawn.

fossil spoke
#

Spawn the Card on the Server, set each to the appropriate type

#

Make sure the CardType property is RepNotify

#

Override the RepNotify function

#

Which is where you would set the mesh/materials

#

For the card type.

#

If you follow all of that, it should work.

#

If it doesnt, you have done something wrong.

devout sonnet
keen marlin
#

Hello. I wonder if other players can see if another player is playing a short animation. I'm making TurnInPlace for a multiplayer game. It's done inside the Animaton Blueprint of the Character that the players control. . Looking forward to your help, thank you

lost inlet
#

Nothing about the ABP is replicated

keen marlin
#

Do you mean variables?

lost inlet
#

What

#

Also all that is replicated through other means

keen marlin
thin stratus
#

Any data inside the AnimBP doesn't support replication, so if there is anything directly set on it from outside or it produces any kind of animation state from data that is not replicated, it would not really sync up between players

#

But, that said, the data doesn't only need to be in the character. It just has to replicate somewhere where it makes sense.

rustic sable
#

if a sword is spawned on the server, its overlaps also being on the server, how does it know its position when swung with a montage on the client?
It's working correctly just wondering how the server knows about the position changes

tardy fossil
#

the server plays the montage too

dark parcel
#

Everyone have copies of the sword

#

The overlap happend respective to each machine

#

It's not like you are sharing a world with anyone, you have your own.

#

Multiplayer is about synchronising your world so you have an experience that make it seems like you are seeing the same thing

#

Ofc if you don't want care about the overlap that happend on client machine, just filter it with switch has authority

#

So when the overlap happend in a client machine, it simply do nothing

rustic sable
#

well I just did a authority check and since the weapon is spawned on the server, and bind also happens on the server the overlap is server only.
It makes more sense if the montage plays server side (which I didn't think it did) otherwise it seems the position is replicated up which doesnt make sense

dark parcel
#

Wdym by if the montage play server side

#

It will just play if you call play montage node, if you don't call it on client, then it won't play the montage there

#

If the weapon is a replicated actor, a copy will be made for clients

rustic sable
dark parcel
#

If you add switch has authority you simply filtering, what code runs on client what code runs on server

tardy fossil
#

i think he was just wondering how the swords hitbox moves on the server when the montage is playing on the client

dark parcel
#

Client playing montage won't move anything on the server machine

rustic sable
dark parcel
#

The server won't even know the client is playing a montage

rustic sable
#

right exactly so is a dedi server playing the montage for the purpose of positioning or no?

dark parcel
#

I think you must try to pin this in your head. Every player have their own instance of the game

rustic sable
#

It's not a question of that

tardy fossil
dark parcel
#

You can play a montage on client but that will only happend in the client machine.

At the same time you can tell server via server rpc. Hey make my character in your machine to play this montage I'm playing.

#

Then each machine will play the montage, respective to when they get the play montage call.

So what position matter is up to you to decide.

#

If you only care about the hit box in the server version then you can just check the anim notify that happend on the server.

#

So in a sense the client play the montage ahead just for visual, but all gameplay element only matter in the server.

Not saying that's what you should do, but just my 2 cent trying to illustrate

lament flax
#

what happens if a same UObject is getting replicated as a subobject by many actors/comp ?

woeful ferry
#

But it'll still be replicated through the actor that owns the subobject

lament flax
#

okay thanks

worthy knot
#

are physics constraints replicable for late joiners ?

ancient adder
#

Does anyone know how to cache/get the exportNetGuids from PackageMap and reapply/set them?

I'm serializing properties and one of them is UScriptStruct*, I'm caching the writer before or after sending it incase of a packetloss
When packet is lost I send the cached writer instead of serializing again but UScriptStruct* is null on client side
After debugging it seems I need to send netguids or something so it can resolve UScriptStruct* on client side, been looking into PackageMapClient for sometime with no luck

chrome bay
#

What do you mean "reapply" them?

#

But yes, objects are addressed over the network by a numeric ID which each connection independently agrees on

ancient adder
#

Add them to the PackageMap when sending cached writer so they can be sent to the client, hope that makes sense

chrome bay
#

I'm extra confused by sending the cached writer

#

Maybe I'm not following something here, might need to see code

#

You don't need to do anything special to handle packet loss, the engine covers all of that for you

ancient adder
#

This is where I serialize and cache the writer

FBitWriter TempWriter = FNetBitWriter(Map, 1024);

// Serialize properties including UScriptStruct* . <- Important comment

FSerializedState SerializedState;
SerializedState.Writer = TempWriter;
SerializedStatesMap.Add(Somekey, SerializedState);

DeltaParams->Writer->SerializeBits(SerializedState.Writer.GetData(), SerializedState.Writer.GetNumBits());
return true;```

And in case of packetloss I get the cached writer which is where I'm facing issues, client cannot resolve the property `UScriptStruct*`
```cpp
auto SerializedState = SerializedStatesMap.Find(Somekey);

DeltaParams->Writer->SerializeBits(SerializedState.Writer.GetData(), SerializedState.Writer.GetNumBits());
return true;```
ancient adder
chrome bay
#

That sounds like a code issue tbh. Packetloss is inherently handled for property replication already. Perhaps your code isn't resilient to the lossy changes of replication?

#

You're not guaranteed to get every state, just the eventual state - but that's true to all replicated properties

#

Re the GUID's, I don't know what you can do here or why it would fail. FNetworkGUID's are acked and agreed upon independently of individual packets being read in. If you had to do this, I would just reserialize it

ancient adder
ancient adder
kindred oyster
#

Hey, is it possible to add a player in editor multiplayer tests on runtime?

limber gyro
#

are u looking for this?

chrome bay
#

yeah but you need to enable it in defaultengine.ini or summin. One sec

kindred oyster
#

yeah but on runtime, I want to do some tests for later joining players

chrome bay
#

If you search "create player" in the console it should find the command, but there is also an option you can enable to show the button in editor

limber gyro
#

since you are testing late connects i assume u might be interested in reconnects as well

chrome bay
#

tbf it's essentially the same thing as far as networking is concerned

#

Reconnect means all new objects and data

kindred oyster
#

Yeah this comes in later, actually I read about multicasts and want to test about different behaviors. Yesterday I learned that my actually implementation isnt good

#

I actually don't know if my game will get a multiplayer, it is a nice to have. So I want to setup stuff to be prepared for that

#

Its a cozy game, play with 1 or 2 maybe 3 friends coop

#

some basic stuff actually is to understand how things should be done (item pickup, harvest stones and trees / harvestables)

chrome bay
#

The general rule to follow is:

Persistent State = Replicated Property
One-Off/Transient Event = RPC

#

If you are modifying game state through RPCs, then yeah that will not survive join-in-progress/reconnect etc - but it also won't likely survive in the same session either when you consider things like relevancy.

kindred oyster
#

so

#

Harvestables (stones, trees) are replicated -> server destroy event are auto replicated ?

chrome bay
#

Yeah, that is inherently replicated (if the actor itself replicates)

kindred oyster
#

if I set a new tree its also replicated

#

because it is persistent

chrome bay
#

Yeah, if those actors are replicated those changes will propagate to the clients when they join

oak flower
#

This message appears to me in the log all the time, and it's causing hitches in my game, but it's not even multiplayer, how do I deactivate this feature?

chrome bay
#

Ancient bug that's never been fixed

oak flower
#

thanksssssssss ^^

oak flower
#

ancient bug from an ancient engine (4.27.2)

chrome bay
#

honestly might still be an issue now, though I haven't seen it for some time so maybe they eventually snubbed it

#

but yeah, it's like a hitch every half second or so - extremely annoying

kindred oyster
#

but for my case I didn't get it (I have a Player Character Component that checks for overlapping Items the nearest Item is selected (actually I destroy it on server with multicast)

#

This is the article

#

the Example show a very static example

#

in my case I have a param (reference of item)

#

or Should the Item Actor have a bool (bActorDestroyed) that I set via Interface from my BP and destroy itself on notify

chrome bay
#

Destroying a replicated actor is implicitly handled, so you don't need to add anything special

#

Assuming you mean the literal "DestroyActor" call

#

And not a game-centric destroy thing

kindred oyster
#

ok, so my example is bad for the OnRep stuff πŸ™‚

woven basin
#

And you literally add late joiners anytime

kindred oyster
#

Thanks1

twin juniper
#

Does RepNotify work in plain classes?

lament flax
#

lets say im in a widget (so client side), and i want to call a server RPC on a component, the owner of the component has authority

is it the same to do :
In Widget : MyComp->CallServerRPC;
and
InWidget : MyComp->SomeInternalMethod
In MyComp::SomeInternalMethod: CallServerRPC;

chrome bay
twin juniper
#

maybe I do need to create my entire Networking System

lament flax
chrome bay
#

Unreals networking is centered entirely arounds UObject and UPROPERTY, none of which "works" in a native class

lament flax
chrome bay
#

Rebuilding networking to avoid using UObjects is quite insane

lament flax
#

remaking whole unreal networking is insane work

twin juniper
lament flax
#

or Actor/Comp

twin juniper
lament flax
#

did you added it as subobject in an actor/comp ?

#

uobject arent replicated by default

twin juniper
#

it's in a struct in an actor component on the character so I think ye

#

never used subobject

chrome bay
#

Actor Component would be replicated

#

But not UObjects indeed

twin juniper
#

Can this be in a struct from an actor component ?

chrome bay
#

yeah, but in that case the struct itself should be replicated. Replicated inside a USTRUCT is not needed

twin juniper
#

so I can skip this step?

chrome bay
#

The UObject instance itself still needs to be a replicated subobject regardless

twin juniper
#

After creating the UObject itself, I'mn trying to replicate it but it can't find the variable (prob since it's private):

            CurrentWearableItem = NewObject<UStaticMeshComponent>(OwnerActor);
            CurrentWearableItem->bReplicateUsingRegisteredSubObjectList
chrome bay
#

bReplicateUsingRegisteredSubObjectList is a property of the owning actor not the object you create

#

Just read through the guide more carefully

#

Actually, hold that thought

chrome bay
#

It's an Actor Component, so you don't need to do anything - just mark the component as replicated

lament flax
#

all instructions are there

chrome bay
#

You also need to register the component

twin juniper
#

the Component works fine, it is in a UObject tho and the RepNotify doesn't trigger

twin juniper
#

.h

    UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
    TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;

    UFUNCTION()
    void OnRep_WearableMeshComponent();

    void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
    virtual bool IsSupportedForNetworking() const override { return true; }

.cpp

void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    // Add any replicated properties here
    DOREPLIFETIME(UWearables, CurrentWearableMeshComponent)
}```
#

You tutorial and all other says to set the Object to be replicated on the actor, but the problem is, that I could have tons of these object (not just 1)

chrome bay
#

And what is UWearables?

twin juniper
#

derived from UObject

chrome bay
#

Okay, so when you create that object, you need to call AddReplicatedSubObject to whatever owns it

#

Presumably the actor

twin juniper
#

it's an actor component here

chrome bay
#

And that actor (or component) needs bReplicateUsingRegisteredSubObjectList to be true

#

AND, both the actor and component need to be replicated

#

Also make sure you're only creating all this server side

twin juniper
chrome bay
#

Well something must create and own it surely? Where's the NewObject call?

twin juniper
#
CurrentWearableItem = NewObject<UStaticMeshComponent>(OwnerActor);
```ye
chrome bay
#

Yeah okay, so in this case you can do OwnerActor->AddReplicatedSubobject(CurrentWearableItem)

twin juniper
#

would that work considering that the bReplicateUsingRegisteredSubObjectList was set to true in an actor component from that actor?

chrome bay
#

no

#

Whatever UObject is replicating the object needs that flag

twin juniper
#

okk, I'll just find the component by class

#

Strange, the RepNotifyStill don't work

worthy knot
#

Does anyone have any experience replicating physics constraint components?

twin juniper
#

ActorComponent:

    SetIsReplicatedByDefault(true);
    bReplicateUsingRegisteredSubObjectList = true;

Wearable.cpp

CurrentWearableItem = NewObject<UStaticMeshComponent>(OwnerActor->FindComponentByClass<UInventoryComponent>());
OwnerActor->FindComponentByClass<UInventoryComponent>()->AddReplicatedSubObject(CurrentWearableMeshComponent);

void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    // Add any replicated properties here
    DOREPLIFETIME(UWearables, CurrentWearableMeshComponent)
}

Wearable.h

    UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
    TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;

    UFUNCTION()
    void OnRep_WearableMeshComponent();

    void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
    virtual bool IsSupportedForNetworking() const override { return true; }
chrome bay
#

AddReplicatedSubObject(CurrentWearableMeshComponent); that doesn't look right. It's the UWearable that needs to be the replicated subobject

chrome bay
#

If the mesh component is a replicated component, it'll replicate already - don't need to do anything there. The problem you have is that UWearable is not replicated, so that pointer never populates

twin juniper
#

'this' would be good, since it's the pointer for this class

#

I want to avoid replicating the component entirely, so just using a RepNotify to Spawn on the client as well without replication

chrome bay
#

Realistically that needs to be a replicated subobject of whatever owns it, and only setup once

#

If you don't replicate the component then that pointer can't populate and you won't get a rep notify

#

If you don't need the mesh component to be replicated don't bother, just use a bool or something instead i.e. "bWantsMeshes" or whatever

twin juniper
#

I think it's because I'm creating a new object of StaticMeshComponent, but not the UObject class

kindred oyster
#

πŸ™‚ oh man Multiplayer will drive me crazy

twin juniper
#

I have no clue no more

twin juniper
#

I'm not sure if this is important information, but the UObject (UWearable) is actually stored in the Item Struct (This struct is not derived from anything) at run time. Every time you add an item, it's created. Should I mark it as ReplicatedSubObject on the constructor of that struct?

UPROPERTY()
TObjectPtr<UWearable> WearableItem;
``` @chrome bay
kindred oyster
#

OMG Nothing seems to work πŸ₯²

charred island
#

anyone have any experience with resimulation? I have enabled it on my physics-controlled pawns, and it 'works', but it doesn't seem to be correcting the pawn positions when the simulation drifts

twin juniper
#

I'm not sure if, since this struct is NOT derived from UObject, Can his members still be replicated using UObject and RepNotifies? Or do I have to derive it to UObject as well

kindred oyster
#

Maybe someone give me a tip how I can handle this stuff?

#

this is my no multiplayer solution

#

I hit a "stone"

#

I spawn particles, then I loop some item actors to pick up

#

remove the niagara component

#

and destroy the actor (the big stone I hit)

#

the lootable Item Actors are set to replicated, so my first thought was to do this stuff on a server event

#

but this doesnt work

#

Next thought was to split up visual stuff and "hard" stuff (niagara are visuals so they can be done with multicast)

#

I dont need final solution, some tips will be cool

dark edge
# kindred oyster

Serverside:
Event Do The Thing -> call multicast TheThingIsHappeningShowCosmetics -> loop -> spawn replicated actors

Everywhere:
TheThingIsHappeningShowCosmetics -> show cosmetics

#

you also should be able to fire and forget a niagara system

#

assuming it's set up right

lament flax
#

i got a fast array which contains a ref to the component who is containing the fast array.
in a fast array item PostReplicated[...], how can i check if it was called on "client side" of the owner ?

example :
i got Listen Server (Comp Instance 0), Client 1 (Comp Instance 1) and Client 2 (Comp Instance 2)
each of them changes some items values on server

  • if PostReplicatedChange gets called on Client 2 (Comp Instance 2), but its a change on Comp Instance 1 items, fail check
  • if PostReplicatedChange gets called on Client 1 (Comp Instance 1), and its a change made on Comp Instance 1, check suceed
limber gyro
#

i need to pass an array to a character that is being spawned and possesed, im thinking about doing "SpawnActorDeferred" to pass the value, or is there any better/more correct way?

karmic gust
#

Anyone have any experience dealing with connection time outs in hosting lobbies?

#

We're working on connecting but when we try it just times out, already had to do a bunch of unusual steps to just get the lobbies to show up properly.

twin juniper
#

This is exactly what I want:
https://stackoverflow.com/questions/72525905/how-to-replicate-uobject-inside-ustruct

but I replicate the Struct like this on the ActorComponent:

DOREPLIFETIME_CONDITION(UInventoryComponent, ItemsArray, COND_OwnerOnly)
```The UObject inside the struct doesn't get replicated... How to make it replicate and use RepNotify?
lament flax
#

show UObject code and the code in the comp you are using to make it reped

twin juniper
# lament flax show UObject code and the code in the comp you are using to make it reped

This is the struct:

USTRUCT(BlueprintType)
struct FItem
{
    GENERATED_BODY()

    UPROPERTY(EditAnywhere)
    TObjectPtr<UWearables> WearableItem;
};

This is the Wearable class that should be replicated once the item is created:

UCLASS(BlueprintType)
class UWearables : public UObject
{
    GENERATED_BODY()

public:
    UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
    TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;

    UFUNCTION()
    void OnRep_WearableMeshComponent();

    void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
    virtual bool IsSupportedForNetworking() const override { return true; }
};```
I need to make it replicated to use a RepNotify, because at the moment, the RepNotify NEVER triggers
lament flax
#

this isnt enough

#

show how you create your UObject

twin juniper
#

in the Wearable.cpp, I've got this too:

void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    // Add any replicated properties here
    DOREPLIFETIME(UWearables, CurrentWearableMeshComponent)
}```UObject replication is weird
twin juniper
lament flax
#

the one you want to rep

twin juniper
#

I want to replicate the UstaticMeshcomponent which is inside a UObject...

lament flax
#

then you want to rep UWearables

twin juniper
#
FItem(UItemsDataAsset* CurrentDA) : ItemDataAsset( CurrentDA ), WearableItem( nullptr )
{
    for (auto EffectType : CurrentDA->GetAdvancedEffects())
    {
        if (UWearables* CurrentWearable = Cast<UWearables>(EffectType))
        {
            // Assigning the UObject
            WearableItem = CurrentWearable;
        }
    }
}
```This is where I *create* the UObject @lament flax
lament flax
#

yeah you missed some steps

twin juniper
#

What step?

lament flax
#

mostly at Registered Subobjects List

twin juniper
#

this is different

#

completly

lament flax
#

no

#

you want to rep a UObject

twin juniper
#

I tried registering earlier

lament flax
#

well i used that doc alone to make it replicating and its working

#

you failed somewhere

#

show you comp constructor

twin juniper
#

because we aren't doing the same thing lmao

lament flax
twin juniper
lament flax
#

Component

twin juniper
#

I've used it: bReplicateUsingRegisteredSubObjectList = true;

lament flax
#

is the comp replicating

twin juniper
#

what is MyActorSubObject here?

lament flax
twin juniper
#

ReplicatedValue & AddRelicatedSubObject aren't there

twin juniper
#

I don't see them, they aren't visible at least

twin juniper
#

in a struct why is attached to an actor component

lament flax
twin juniper
#

even in the source files, I can't find 'ReplicatedValue'

lament flax
kindred oyster
twin juniper
#

I was confused

#

@lament flax still doesn't trigger the OnRep 😭

#

Would this be ok?

WearableItem = CurrentWearable;
CurrentPlayer->AddReplicatedSubObject(WearableItem);```
lament flax
#

if you do this CurrentPlayer needs to have the setup to rep subobjects

twin juniper
lament flax
twin juniper
#

what if I want 2 reference, lol?

lament flax
#

using an array or seperated vars

twin juniper
#

that's the problem

#

I would hate to store my UObject reference on my actor

lament flax
twin juniper
#

that's possible?

#

would that be possible to do in my Struct?

rocky kestrel
#

What is safe/correct way to manage admins in server? I have now:

  1. server launch parameter takes steamIDs to be admins
  2. those are stored to gameMode variable (gamemode exist only on server)
  3. If I want to access admin tools I check on serverRPC -> compare my steamID to admins ID's and if it is found I can access tools.
kindred oyster
#

Is it normal that MP stuff hits hard in the First steps? Last 2-3 Weeks I made huge Progress, nothing ist perfect but after today IT feels as a Punch in my face xD

sinful tree
kindred oyster
#

Yeah, OK than i'am reassured

#

Yeah my actual Scripts seems useless

#

😭🀣

#

Thanks πŸ™‚

reef bison
#

implementing multiplayer afterwards is a common mistake. you will need to rewrite everything if you dont start with it in mind

kindred oyster
#

yeah thats it why I do it now

#

I started about 3 weeks ago

#

first really rought prototype

#

1,5 weeks ago I restarted and make it a bit better

#

now I'am Happy I "restart" and begin with multiplayer stuff

#

if my actual stuff works with multiplayer that would be cool

#

I have a Question

twin juniper
#

Does anyone know why my OnRep doesn't trigger? the class is derived from UObject and I think that I did everything I should.. What's wrong?:

Initialization of the UObject class:

WearableItem = CurrentWearable;
InventoryComponent->AddReplicatedSubObject(WearableItem);

Stored in an actor component attached to the player:
.cpp

bReplicateUsingRegisteredSubObjectList = true;
```.h
```cpp
UPROPERTY(Replicated)
TObjectPtr<class UWearables> DefaultActorComponentSubObject;

virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override{
        DOREPLIFETIME(UInventoryComponent, DefaultActorComponentSubObject);
}

UObject itself:
.h

UPROPERTY(ReplicatedUsing = OnRep_WearableMeshComponent)
TObjectPtr<UStaticMeshComponent> CurrentWearableMeshComponent;

UFUNCTION()
void OnRep_WearableMeshComponent();

virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual bool IsSupportedForNetworking() const override { return true; }
```.cpp
```cpp
void UWearables::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    DOREPLIFETIME(UWearables, CurrentWearableMeshComponent);
}```
kindred oyster
#

I actually spawn a Actor with DataTableRowHandle

#

this event runs on server

#

the Item are spawned on client and server

#

but client doesnt get the DTRowHandle

#

I can also set it after Spawn but this feels better and I can run a construct script where I get the mesh of the item

twin juniper
kindred oyster
#

this for example works

#

is this legit?

dark edge
gloomy axle
#

Can widgets get gamemode variables? Like for example, can I call "get game mode" on a widget?

#

i know that widgets are on clients, so im not sure

dark edge
#

a connected client can't get gamemode

gloomy axle
#

so if the multiplayer game is of type listen server, this would work for client?

#

I have a listen server setup, trying to disable UI visibility based on the gamemode

dark parcel
# kindred oyster

You want to think twice if it's going on production. Having a hard ref in data table can be undesirable.

kindred oyster
dark edge
#

the item should only be spawned on server

kindred oyster
#

wait

dark edge
#

only server should be calling spawn item

kindred oyster
#

I print the row name on construct

#

there it says

#

server: stone

#

client: None

dark edge
kindred oyster
dark parcel
#

This opinion is my own but doing that on construction script sound sketchy

kindred oyster
#

left is server and right is client

dark edge
kindred oyster
dark edge
#

too early

#

use the onrep

kindred oyster
#

now its on on rep

dark edge
#

first make sure that a data table row handle can be replicated

#

I don't know for sure if it can or can't

kindred oyster
#

hm

#

the last update made my UI into german

dark edge
kindred oyster
#

somebody know how to change it ?

sinful tree
#

Editor Preferences has a language setting.

kindred oyster
#

hm someone is strange

dark parcel
#

Show how you print it

kindred oyster
#

OnRep is only executed on Client

#

OnClienbt now it works

#

but on server not

#

I'am confused now

dark parcel
#

On rep meant to be called on client only. While in bp it gets called by server and the client if the server make the changes, in cpp it is only get called by client as it should

dark parcel
#

Show how you spawn the actor, in entirely

kindred oyster
#

ah

#

wait

dark parcel
#

As client, server rpc (passing the dt handle (if that can be replicated, I don't know)

kindred oyster
#

it is only a test spawn action

#

actually the OnRep works on client

#

and it sets the mesh

#

on server it doesnt

#

so the mesh cant be changed there

dark parcel
#

Hmm so the dt is hard coded, the problem might lies else where.

kindred oyster
#

at the start I thought I set the mesh on construct of the actor

brittle ledge
#

Regardless I'd recommend actually packaging and testing

#

A lot of stuff don't work when they should in the editor; and work when they shouldn't; mostly the later

kindred oyster
#

is it so

dark parcel
#

This kind of stuff should work in pie

kindred oyster
#

that makes testing really hard

dark parcel
#

Probably just things like joining lobbies

#

That you have to be in standalone or package

twin juniper
#

Anyone is willing to help me? (long code tho - 20 lines)

kindred oyster
#

if I change the mesh after the spawn on server I bet it will work

dark parcel
#

Gtg now, might check later

kindred oyster
#

no actually its empty

#

wait

#

I can do it

#

this should also work

limber gyro
twin juniper
#

The 'CurrentWearableMeshComponent' is using RepNotify

kindred oyster
#

with this in addition server and client works (I need to check if dt is valid because the client run into error)

limber gyro
# twin juniper what var exactly?

well this is just a wild guess, components have a variable called bReplicates(not sure about the name) that might need to be true in order for it to replicate and for u to get the notifies

kindred oyster
limber gyro
#

well its not just components, i think its all actors

twin juniper
#

yea but I want to not Replicate it, since if I do, it will work but replicate all his property on tick over the machines when in fact, I can only recreate that actor on all clients when the RepNotify triggers...

limber gyro
#

i might be wrong here but i think u need it to replicate to have rep notifies trigger

#

as the name implies, its a notification of a replication

nova wasp
limber gyro
#

the rep notify function is only there to let u know that the value changed since unreal only sends values when needed if i am not mistaken

nova wasp
#

We told you not to create new replicated objects for every item, not to never replicate

#

Can't help more right now as I'm busy

#

I think it might need a replicated object as the outer, unsure

#

Also look into replicated subobject list docs if that helps

twin juniper
twin juniper
limber gyro
#

i cant answer that, that depends on what ur doing and ur architecture

twin juniper
#

when I spawn / use the UObject, I do:

InventoryComponent->AddReplicatedSubObject(WearableItem);

which should make the UObject replicated

twin juniper
limber gyro
#

dude i cant answer that for you lol, i have no idea what you are building

twin juniper
#

Do you know a good tutorial about Replication of UObject that I could follow?

#

also, I' mtrying to replicate a derived class from another derived class from UObject

UObject -> Class 1 -> Class to Replicate

nova wasp
#

The in between class is not a good idea here

twin juniper
#

the class 1 is empty anyways

#

it's just to group all of them

nova wasp
#

You can have them point to one another internally or whatever, but I think you want a replicated actor or component as the outer that you know works instead of this chain of pointers

nova wasp
#

It's better to keep it simple here if it's new stuff

twin juniper
#

ex: in BP, I want to see all the class of a type...

limber gyro
#

what exactly are you trying to replicate?

#

like in the game

nova wasp
#

You can organize things in a bunch of ways that don't involve pointer indirection, being fancy here is just complicating what unreal wants

twin juniper
limber gyro
#

thats not what i asked lol

#

i mean in the game

#

is it a weapon?

#

what does it do?

twin juniper
#

a mesh on the character

dark parcel
limber gyro
#

so u want to replicate a mesh on a character, what for?

twin juniper
limber gyro
#

i mean, what is it

#

is it a weapon?

#

is it armor?

#

a power up?

#

what is it

#

is it attached?

twin juniper
#

attached to a socket

limber gyro
#

i dont think u need to do all that at all, u probably just need to attach that actor in the server and set it to replicate

twin juniper
limber gyro
#

you could probably just attach it in the server and in the client

#

and it would look the same if i am not mistaken

#

as they would be synced

twin juniper
#

@nova wasp told me to do it in a better way

nova wasp
#

I don't care what the replicated property is on, it could be an actor component or whatever

twin juniper
#

yea, I need a repnotify to fire on all clients

kindred oyster
nova wasp
#

But whatever it is on must replicate

limber gyro
#

u need to think of solutions that fit your problems, theres no need to do things more complicated if they work properly when done in a simpler fashion

brittle ledge
twin juniper
#

0 optimized

limber gyro
#

if that attachment is simply cosmetic you can just attach it in the server and in the client, attach it in the client and send an RPC to the server

brittle ledge
#

When you mark something as 'net Load On Client' You are not causing it to actually replicate. You are just allowing it to exist in client; no server-client communication is happening.
If you have your actor, and replicate its movement; that does get udpated; communication is happening in that regard.
The visuals are not being transmited or anything like that. If you think they are

kindred oyster
dark parcel
twin juniper
nova wasp
brittle ledge
limber gyro
nova wasp
#

We said don't spam a new replicated static mesh components each time something is picked up, not to never replicate any objects

twin juniper
limber gyro
#

its not optimized

brittle ledge
limber gyro
#

attaching in the client and then sending a reliable RPC to the server is probably the most optimized way

#

as its a 1 time thing

twin juniper
twin juniper
nova wasp
limber gyro
# twin juniper it's already on the server at first

that doesnt say much, in order fot you to have a working solution you need to understand your constraints, you can have it replicate by default no problem in say a 3v3 game with not a ton of items around, but if your looking at an MMO thats probably not gonna be a good idea, it all depends on what your doing

twin juniper
brittle ledge
# twin juniper I understand what I wrote lol (not UObject replication but my code yes, :3)

I didn't mean that uwu. Just that; you were asking for advice and asking if x is the more optimized way of donig things. I am a sucker for optimization and love all of that. But usually that is something you do yourself rather than ask what the best way of doing things is. Cuz like... ultimately you are just vulnerable to getting bad advice otherwise and there is no insurance what you'll do will actually be optimized to begin with. so to speak.

limber gyro
#

if u wanna have that many items, ur only bet would probably be just sending the 1 time RPC

#

and forget about those items moving around with physics

#

and being in sync

twin juniper
#

maybe I could set it to replicated, and the next frame, set the replication to false since i don't need it anymore

nova wasp
#

I can say for sure that a new entire unique object recreated is kind of overkill when a pre-existing replicating object onrepping a property will do though

limber gyro
#

could work, but its a messy aproach

nova wasp
limber gyro
#

does any 1 know if the playerState always exists before a character is created?

brittle ledge
nova wasp
#

Gotta go

twin juniper
#

OnRep doesn't work since my uObject doesn't replicate

limber gyro
#

dont use it then lol

twin juniper
#

No Replication = No UPROPERTY(replication smt here)

nova wasp
#

I think a simple setup could be starting with it as a property on your pawn or playerstate just to mess around

limber gyro
#

it would be a good learnign experience

#

the property would be a bool

nova wasp
limber gyro
#

something like "isEquiped"

twin juniper
#

and I would only replicated the bool?

#

how would i call a function to all clients?

brittle ledge
#

RPCs

twin juniper
#

Server -> ?

#

wdym rpcs

brittle ledge
#

Server -> All Clients

twin juniper
#

what's the name of that rpc?

brittle ledge
#

All Clients RPC

twin juniper
#

you need a owning object for that tho

brittle ledge
#

tru

brittle ledge
limber gyro
#

theres a function thats is something like "get all players", u can call a client RPC on that, theres probably a better way to do that with a multicast im just not seeing it

twin juniper
brittle ledge
twin juniper
#

Is it efficient?

brittle ledge
#

YES

limber gyro
dark parcel
dark parcel
#

I don't have a single multicast rpc soo far. Probably gonna have one later for sfx and chat messages.

limber gyro
#

im using one for beams SFX but i think its the only one

#

im calling it from a character, i was wondering if any 1 has an example of a multicast being called from the game mode for example

dark parcel
#

No point, game mode only exist on server

limber gyro
#

ye but you could fetch connections like player state

#

something to send an effect to every one directly from the server

#

like if the game is over spawn some particles, this is a dumb example i know

twin juniper
#

@brittle ledge docs?

dark parcel
#

I will just use GAS

limber gyro
#

its probably not meant to be used like that

limber gyro
dark parcel
#

Gameplay effects

brittle ledge
brittle ledge
limber gyro
#

c++

twin juniper
limber gyro
#

both

#

both is always better

limber gyro
#

where are the rpgs?

twin juniper
#

bro is trolling

dark parcel
#

Every rpc use actor channel afaik

#

I don't know what it means to not need an owning object

twin juniper
#

how would my thing be done (without multicast)

gloomy axle
#

Can a non-player owned actor tell the gamemode to do something?

I'm basically implementing an "extraction zone" where if the zone overlaps with an actor that has a actor component of type AC_ExtractionObject, then increase the "Progress" variable in gamemode by 1

brittle ledge
dark parcel
gloomy axle
#

maybe game state would be better?

twin juniper
gloomy axle
dark parcel
brittle ledge
gloomy axle
gloomy axle
#

what

twin juniper
#

there's no link between new RPC and the normal compendium

gloomy axle
#

what

#

?

#

new RPC?

dark parcel
sinful tree
twin juniper
# gloomy axle new RPC?

idk, someone talked about a RPc calling on all clients on the server, without knowing about them

sinful tree
#

I believe Nova was talking about multicasts.

gloomy axle
#

multicast is probably best

#

each client needs to know this anyways

twin juniper
dark parcel
#

There is even dev that ship game with 0 multicast

gloomy axle
#

okay, good for that dev

sinful tree
gloomy axle
#

But why isnt it the way

#

seems like a good use case for it?

dark parcel
sinful tree
gloomy axle
#

Okay I see where I went the wrong way

dark parcel
#

Multicast only get called on relevant players, think about late joiners and players outside relevancy

gloomy axle
#

I'm still unsure how I can communicate from a non-client actor to a server

#

or at least the gamemode

brittle ledge
twin juniper
dark parcel
#

Give a use case so maybe it can be explained better.

brittle ledge
#

Multiplayer is literally just communication in between server and client. YOu want everyone to be on track while causing the least amount of stress on the server. The onyl way to achieve this is to know the tools you got to work with; just gotta read the documentation and all that.
Edit: to adress why it isn't as simple as just tellig you what to do step by step is because there is no general solution, it does depend on exactly what you want to do.

gloomy axle
# dark parcel What r u trying to do?

I'm currently implementing an "extraction zone" prototype, at the moment it's just a trigger box that detects if the overlapping actor has an actor component AC_ExtractionObject. If it does, I'd want the A_ExtractionZone actor to tell the gamemode "hey, the players made progress, +1 to progress int"

dark parcel
#

The overlap will happend respective to each machine.

In saying that, you don't need to care when the actor overlap in client machine

#

On overlap, switch has authority

#

If authority get game mode do w.e

gloomy axle
#

when will the item have authority?

dark parcel
#

So only the overlap in server machine is accounted for and since it's the server it have access to game mode

gloomy axle
#

I see

dark parcel
gloomy axle
#

so overlap is a server registered event?

dark parcel
#

No

gloomy axle
#

?

twin juniper
#

maybe replicating for 1 frame is the better solution, it might be tricky but it's safe, reliable and always the same

dark parcel
#

Everyone running their own instance, everyone have a world on their own. Everyone is running the codes that you packaged in their own instance

dark parcel
#

The overlap may happend in my machine , your machine. It gets called when ever it gets called. So it's not about registering or w.e that means

#

You simply filter the code

#

So when Ur the client u do nothing when the overlap is called

gloomy axle
#

the logic for this is happening in the ExtractionZone actor though

#

not the player controller

dark parcel
#

K and?

gloomy axle
#

okay bro

dark parcel
#

It have overlap function yeah?

#

Overlap, switch has authority.

If authority (server) get game mode , do w.e

worthy oak
#

And if your the client overlap event you just ignore it

twin juniper
dark parcel
#

Player controller don't even come to the picture btw. Neither ownership like datura mention @gloomy axle

gloomy axle
#

that's what I'm concerned about

worthy oak
#

Right so if you have your object in the world and overlap

#

The server will call it and the client

gloomy axle
#

Okay great

worthy oak
#

Switch has authority is making sure the server version is the one your doing the code on

gloomy axle
#

thanks for the clarification @worthy oak @dark parcel

gloomy axle
worthy oak
#

Nope πŸ™‚

gloomy axle
#

thank ya

worthy oak
#

Of course

twin juniper
worthy oak
twin juniper
#

I just asked if you think it was a good solution to my problem, if yes, thjen I'll try to implement it

dark parcel
worthy oak
#

Try it for science

dark parcel
#

πŸ˜„

worthy oak
worthy oak
twin juniper
worthy oak
#

Get it working first

brittle ledge
twin juniper
#

I wanted to talk about it and know more... that's all, no spoonfeed

worthy oak
worthy oak
twin juniper
worthy oak
#

Getting a working example is

twin juniper
worthy oak
#

is it XD

#

Try it. Profile it, see if it’s more efficient

#

test different uses cases to make sure it’s actually working

twin juniper
#

never used the profiler

worthy oak
#

And not just working in a specific example

worthy oak
kindred oyster
#

I interact with an actor, I run this event (on server)

twin juniper
kindred oyster
#

with server it will be executed, if I interact with client it doesnt

worthy oak
#

Then someone giving you the answer

twin juniper
#

yea, there's no official answer anyways...

dark parcel
#

Server rpc from client = hey server, run this code in your machine.

worthy oak
kindred oyster
#

yeah but on server it prints nothing

#

but it should?

twin juniper
dark parcel
#

Ownership

#

@kindred oyster

brittle ledge
gloomy axle
#

implementing multiplayer logic makes me wanna throw up

#

but i want money

#

so

worthy oak
dark parcel
#

You can only call rpc on clients from things you own. By default that's your controller , pawn, player state

gloomy axle
#

then i cant work on art

twin juniper
dark parcel
#

So in your case assuming you do it on some item actor and never setting the ownership, your rpc is simply dropped

kindred oyster
#

damn

gloomy axle
#

damn

twin juniper
#

make art and make it working, both?

kindred oyster
#

I suspected such stuff

gloomy axle
worthy oak
#

Was gonna say

#

Multicast lol

twin juniper
gloomy axle
#

focus on making shit work first

#

then put make up on it

worthy oak
kindred oyster
#

thas the reason my test on player controller works

dark parcel
gloomy axle
#

i cant even begin to imagine the replication logic in fortnite blueprints

#

if they even use blueprints

dark parcel
twin juniper
#

let me tell you, the core doesn't use bp

gloomy axle
#

thought so lol

kindred oyster
#

yeah this are rocks staying around in level

#

the player can pick on it

#

it breaks and drop small stones

gloomy axle
#

nice, you made rock simulator 3000

kindred oyster
#

yeah πŸ˜„

gloomy axle
#

now sell it on steam for 5 bucks and make millions

twin juniper
#
CurrentWearableItem->SetIsReplicated(true); // WOO! but so dog water for fps
kindred oyster
#

first of all I wanna make a game I want to play

#

and learn

twin juniper
#

I need socket lvl optimization

gloomy axle
dark parcel
#

I'm just gonna call bs

gloomy axle
#

or maybe he's calling it in an event tick

twin juniper
dark parcel
#

Network bandwidth management != fps

kindred oyster
dark parcel
#

How are they collerate

worthy oak
twin juniper
gloomy axle