#multiplayer

1 messages · Page 253 of 1

rotund urchin
#

i dont want to predict, i just want to move from last update location to current update location

dark edge
#

Why does change weapon do the work and not the notify?

cerulean barn
#

does the notify have to?

dark edge
#

I would prefer the notify did that work yeah

cerulean barn
#

ur saying just set the equipped on the buytton clicked?

dark edge
#

The notify is "hey, our equipped weapon changed"

#

That's how I'd do it

cerulean barn
#

how would it set the old one hidden, and the new one visible?

dark edge
#

You still need an rpc to get it to the server

cerulean barn
#

i know the new one visible

#

but how would i set the old one hidden

dark edge
cerulean barn
#

but the prior weapon to the change is visible

#

where am i setting it hidden

dark edge
#

It is included in the all weapons

#

In c++ you can get the previous value of a replicated variable, but I don't think you can do it in BP

cerulean barn
#

like on equip change notify i can set the new one visible

#

but not the old one hidden

#

if u get me

#

so should i set it hidden on the server + multicast then visible on rep?

dark edge
cerulean barn
#

loop through hotbar and set hidden on every equip chjange?

dark edge
#

I would do all of the logic in the onrep

cerulean barn
#

and a server rpc to call the set equip so it runs on server?

dark edge
#

It wouldn't be consuming if it was 500

cerulean barn
#

okay

dark edge
cerulean barn
#

ill lyk!

cerulean barn
#

im getting an issue where after switching it shows nothing

#

unless i switch to a diff slot and back to that one then it shows agian

dark edge
#

is there any error?

sinful tree
#

Your HotBar may not have the equipped weapon at the time the OnRep of equipped weapon is firing.

cerulean barn
#

yeah i think its a delay issue

#

do i need to delay something

dark edge
# cerulean barn

Try just hide all hotbar entries that aren't CurrentWeap then just show CurrentWeap

#

don't depend on it being in AllWeaps

cerulean barn
#

isnt this doing that

dark edge
#

no

#

what if Hotbar is empty?

cerulean barn
#

looping through all hotbar, if its not equipped, hide it

dark edge
#

how would Current ever be showed

#

show Current on the Completed path

sinful tree
#

Also... Doesn't hiding an actor end up causing it to not be replicated?

cerulean barn
dark edge
cerulean barn
#

its doing this

dark edge
cerulean barn
#

oops

#

i forgot the equipped weapon variable connected to visibility

#

it still doesnt work ^

dark edge
#

why are you unhiding self

cerulean barn
#

i changed it

#

i forgot to drag the equipped weapon

#

pretend its there

#

same issue

sinful tree
#

Ok... So, it doesn't stop replication when hidden... HOWEVER... Setting hidden on the server ends up setting it hidden for everyone.

dark edge
sinful tree
#

I have replicate movement off.

dark edge
#

I really wish there was a writup somewhere with what all did what and what is guaranteed to replicate before what else

#

Like can a replicated pointer beat the thing it's pointing at to the client?

cerulean barn
#

what am i doing wrong..

sinful tree
#

You already are doing so by using the OnRep.

cerulean barn
sinful tree
#

And you dont want the server setting anything hidden as it'll end up hiding that actor for everyone.

cerulean barn
#

but im setting it hidden on the server

#

then visible on the server

#

whats the issue i dont undertstand

cerulean barn
sinful tree
#

Errr yea right XD

dark edge
#

depending on what hidden actually means

sinful tree
#

The loop probably should only happen on the server in that case, there's no real reason to have all clients do that loop.

dark edge
cerulean barn
#

so only the server hides shit

#

not every client?

dark edge
#

try that yeah

cerulean barn
#

kk

dark edge
#

being hidden is evidently replicated

#

I'd split the problem up, just have all weapon actors attached to capsule out floating in space and make sure the hide / unhide works, then worry about attaching to meshes

cerulean barn
#

so this is working for the third person mesh but not the first person

#

code:

#

two part

#

same func

sinful tree
#

Attachment is also replicated.

cerulean barn
#

the attachment shouldnt be done on the server at all right?

#

just the clients

sinful tree
#

If you're using the gun actor for any kind of logic then it would need to be in the appropriate place on the server.

cerulean barn
#

so only attach on the server?

#

how would the is locally controlled part work then

dark edge
sinful tree
#

Nope.

#

replicate movement is still off

dark edge
#

god damnit

#

How would you have a split attachment then? 1 replicated actor attached to different things on different machines

cerulean barn
#

i should have replicate movement off?

#

i thought i should be replicating the movement

#

so the server hides it... the server shows it... then the client attaches it 1p or 3p, whats wrong with this method?

#

i have my base weapon class on replicates & replicates movement

dark edge
cerulean barn
#

if i make an animation on the gun

#

is that a movement?

dark edge
#

that'd be local anyway

#

you'd never replicate that

cerulean barn
#

on the 3rd pesron mesh

dark edge
#

you'd replicate the fact that you fired or whatever

#

You'd replicate the fact that you played RifleFireRecoil, not the fact that the rifle moved smoothly over time as the animation played

cerulean barn
#

okay i disabled replicate movements

#

so how come it works the second time i press the slot just not the first time?

dark edge
#

and your current onrep code if it has changed since last time

#

full code from input event to the last thing

cerulean barn
#

ignore the mess on the attaches (it does it right)

dark edge
#

idk if that's your problem but that is a problem

#

also why do you even have Current Weapon Int as a variable

#

lose it

cerulean barn
#

for playing the animation

#

that has nothing to do with any of this

dark edge
#

animation should be included on the weapon definition

cerulean barn
cerulean barn
#

its for this

dark edge
# cerulean barn

What's this about, what is WeaponAdded? You're not using it in the onrep

#

btw that can screw up, you're not guaranteed to get every weapon added

#

just onrep Hotbar

#

when Hotbar changes, go remake the hotbar UI

cerulean barn
#

i use onrep weapon added to add the image

dark edge
#

OnRep_Hotbar -> rebuild UI
OnRep_CurrentWeapon -> show/hide and attach stuff

cerulean barn
#

to the hotbar

dark edge
#

you aren't guaranteed to get every update

#

you are just guaranteed to have the final value

cerulean barn
#

but this wouldnt cause the current issue right?

#

onrep my hotbar array ur saying

#

ah

dark edge
#

no but I'd fix it now rather than trying to chase down a super bad bug

#

Yes you have 2 bits of state in your character.
What weapons are on hotbar, and what weapon is currently held.

#

when the hotbar changes, you wanna update the UI
when the held weapon changes, you wanna show/hide stuff and do attachment

cerulean barn
#

yes

#

correct

dark edge
#

when thing changes = OnRep, basically

cerulean barn
#

so for the hotbar onrep

#

how would i know if a value has been added or removed from the array

dark edge
#

who cares, just nuke and remake for now

cerulean barn
#

thats what im saying, to make it

dark edge
#

just empty the bar and refill it from Hotbar array

cerulean barn
#

ah

#

ok

dark edge
#

if you had like 1000 it'd be different

cerulean barn
#

how do you do a for loop in blueprints

#

from 0 -> var

#

ig ic an just google it rq

#

nvm its pretty self explanatory

cerulean barn
#

is this good?

#

anyways regardless if this works, we have a bigger issue on hand

cerulean barn
cerulean barn
#

lol

#

wtff

#

why is it doing that lol

#

its spawning in a big ass gun not putting it on the slot

#

why is it doing that lol

dark edge
cerulean barn
#

look at last screenshot

dark edge
#

I don't like the raw for loop, you could just make a function on HotbarHUD that gets passed an array of weapon actors and does its thing

#

then it could just be HotbarHUD.Update(weaponactorarray)

cerulean barn
#

does its thing

#

u mean sets them all blank?

#

but technically this should work

#

not sure why its not working

dark edge
#

the character can just say "here's my weapon array, go nuts"

cerulean barn
#

ill change it but why doesnt this work?

#

its literally spawning in a weapon into the game as a huge ass weapon

dark edge
#

show the bit of code where you spawn the weapon

#

the computer is doing exactly waht you tell it to do

cerulean barn
#

ye

#

why did it move to scale

#

i had it on location

#

wtf

#

its not longer attaching

#

so after deleting the weapon to add var it now no longer attaches and my hotbar stuff is not adding anymore

dark edge
#

are you intending to no longer add a picked up weapon to your hotbar?

#

what happens after spawn weapon

#

looks like nothing

cerulean barn
#

mustve detatched when i stored variable

#

i fixed it now

cerulean barn
#

still same issue where its not showing on first person mesh

#

unless i switch weapons a couple times

dark edge
quaint roost
#

question about net dormancy

  • I have an actor with a replicated bool (default true)
  • I set this actor to be net dormant to start
  • Game starts, but my player is not in net relevancy range of this actor
  • Suddenly, the server toggles the bool to false. But there's no player in net relevancy range
  • The actor goes dormant again
  • When I move my player in net relevancy range, will I have stale data on the client until the actor wakes up?
fossil spoke
#

Also your sequence of events doesnt make sense.

#

The actor goes dormant again

#

How does it go dormant again if:

#

I set this actor to be net dormant to start

#

It was already dormant?

#

Did you flush its dormancy when changing the bool?

#

Did you call ForceNetUpdate?

#

Things like this can cause different behavior.

#

So its important to be very specific.

#

If the Actor was Dormant to start with and it never changed dormancy while its bool value was changed.

#

It will send the last value it had prior to being dormant.

#

Which by your account is the default value.

#

UNetDriver::ServerReplicateActors_PrioritizeActors manages all of this

#
// Skip Actor if dormant
                if ( IsActorDormant( ActorInfo, WeakConnection ) )
                {
                    continue;
                }
#

If an Actor is outright dormant, it will not be added to the consider list.

#

Meaning, it wont replicate any changes.

quaint roost
#

yeah forgot to mention, when the server toggles the bool to false, it also calls ForceNetUpdate

fossil spoke
gaunt crown
#

@chrome bay Is this a way to handle it instead?

I made the Sit action on the character, kind of feels right to have it there, as it's a player action like "Jump" or "Sprint" that has to do with the character doing something.

These are my dormancy settings and how I am replicating the chair to basically replicate a set boolean IsOccupied so that way no one else can sit on an occupied seat. I flush Net Dormancy right before replicating the Bool to set it to Awake just to replicate that change and off it goes back to Dormant All

That way we only replicate this Chair once. technically speaking.

#

The Sit function has all the necessary logic to handle moving the player onto the chair, disabling movement, and then calling SetSeatOccupied on the chair itself to state that the seat is taken. So I still need to replicate the chair for this one bool check. But at least I am just simply flushing to get out that new bool value, and instantly going back to dormant again anyhow.

I do the IsOccupied to turn off the 3D Widget that displays "Press E to sit" sort of thing. So I need that there. Otherwise I wouldn't need to replicate at all.

Just wanting your thoughts if that's the right setup.

gaunt crown
#

And just wanting to confirm this is correct yeah?

https://gyazo.com/079d8794ebcd3ceceda901a9e59e855d

Everytime I sit on the chair and get off of the chair, the chair goes awake to replicate the bool above and goes back to dormant right after the update through using the Flush Net Dormancy, but the Server never changes? I thought that was a bit weird as I'd think it would change for all. But I guess it only matters for the clients because server always knows everything always right?

pallid stone
#

When you're testing in editor and you press f8 to stop possessing the character so you can float out and look at variables, when it's 2 players (listen server and client), you see what the first client see's/knows about on the content outline. Is there a way to switch that over to the listen server or another client so you can check what they see/know without it being a bunch of print strings?

tardy fossil
#

hmmm if i have a few hundred actors that only need their initial data replicated, and never have RPC's or anything after spawn, would it be worth it to make a custom net channel to pipe them all through?

latent heart
#

Oh I totally didn't see the push model bit!

mortal blaze
#

Hello 🙂

I'm trying to have a different directional light between each client. I managed to do this with the "has authority" for a different directional light between the server and the client, but as long as there are multiple clients, they all have the same directional light.

I manage the directional light in the level blueprint (because I don't think you can reference it otherwise), and I have the impression that in the level blueprint, there's always some kind of replication for all clients.

I have an interface that appears in the level blueprint when I overlap a collision box in another BP.

Does anyone have any ideas for how to have these directional lights different between each client?

cerulean barn
#

hello,

I have a hotbar system which spawns in all of the weapons that are in it, and only sets the equipped weapon visible when holding. i am having an issue where when changing weapons its not showing the weapon on the first person mesh (unless i change slots a couple more times) im thinking there might be a delay issue... or is this the proper way to hide and show actors on the server? please let me know thanks! (ignore the mess on the attachments, they are correct.)

#

questions, is the server supposed to hide weapons? am i hiding the weapon the proper way?

my layout

server-> hides weapon -> shows weapon
local client -> attaches weapon to arms
other client -> attaches to mesh

nocturne quail
digital herald
#

The Animation Blueprint has a Blueprint Threadsafe Update animation function, and in C++ it's done using a type called an Anim Instance Proxy. It's not too difficult to implement it in C++ but the process is slightly different.

#

I'm working on newer multiplayer content that takes advantage of the Anim Instance Proxy to update these in C++ using multithreading

nocturne quail
#

this is how i use GetBaseAimRotation and its working not correctly, the local offset and server offset are not same.

I would use your approach i think

void UArmaAnimationInstanceBase::NativeUpdateAnimation(float DeltaSeconds)
{
    Super::NativeUpdateAnimation(DeltaSeconds);
    Speed = Character->GetVelocity().Length();
    Direction = Character->GetCalculateDirection();

    FRotator DeltaRotator;

    if (Character->IsLocallyControlled())
    {
        DeltaRotator = (Character->GetBaseAimRotation() - Character->GetActorRotation()).GetNormalized();
    }
    else
    {
        DeltaRotator = (Character->GetControlRotation() - Character->GetActorRotation()).GetNormalized();
    }

    Pitch = DeltaRotator.Pitch;
    Yaw = DeltaRotator.Yaw;

    UpdateAnimPropertiesBP(); //use for IK Update in blueprints
}
nocturne quail
digital herald
nocturne quail
#

if i have like like 200 players connected and each of them is getting that update on every tick

digital herald
nocturne quail
digital herald
# nocturne quail Ok and Thanks for that open source project, it has lots of usefull things 😄

No problem, and on the subject of Tick, think of your Anim Instance as holding states that can frequently change - if you are implementing event-based mechanics, such as one-offs like attacks, weapon firing, etc, then you're probably going to just play an Anim Montage rather than transition into a state machine's state, or in projects using motion matching, an anim in the pose database etc.

cerulean barn
#

not sure why its not showing on first person but it is for everyone else

#

does this set it visible on all clients too?

nocturne quail
cerulean barn
#

as you can see here.

#

the first time i change to that slot it is invisible in my arms. if switch slots a few times then it is visible. could this be a delay issue? i am not sure why it's not working on the first switch

nocturne quail
cerulean barn
#

watch the video

#

it attaches after a few tries, but not the first switch

nocturne quail
# cerulean barn

your state for other clients you are already tpp and should always be tpp, only switch the state locally
means visibility switch only locally

cerulean barn
#

i dont understand what ur saying

#

my mesh has a body component and arms

#

i attach the weapon to the arms locally and the mesh for everyone else

nocturne quail
cerulean barn
#

yes

#

i understand that

#

i am hiding / showing the weapon via the server

#

and i am attaching via the clients

#

which is why i have a islocally controlled check

nocturne quail
cerulean barn
#

for the attachment?

nocturne quail
#

attachment and visibility

cerulean barn
#

i thought the server does the visibility

#

not the client

nocturne quail
#

you only need server visibily if you want to replicate changes to other clients

cerulean barn
#

yes the actor is replicated to other clients

nocturne quail
#

involve client rpc which will do it directly just for you

cerulean barn
#

but keep server visibility

#

just client rpc for attachment?

nocturne quail
#

you need to keep it on server if your focus is on listen server and you will be the host

#

dedicated servers don't need any visual things

cerulean barn
#

im hiding the actor on the server

#

and showing it on the server

#

thats how it should be done

nocturne quail
#

server->clientrpc->hide/visible/attach/detach

cerulean barn
#

but it replicates...

nocturne quail
#

it will not replicate change if you call clientrpc by server

cerulean barn
#

when you say clientrpc you mean multicast?

cerulean barn
#

if i do this then how will it ever attach to the third person mesh

#

and how will it set the actor visible on other machines

nocturne quail
#

why you need to hide on other machines?

#

other machines don'e need to seee you with arms

cerulean barn
#

im spawning in a gun on the server... it needs to be hidden everywhere

nocturne quail
#

you spawn the gun only when you first pick it up, later just play with it

#

don't need to respawn it

cerulean barn
#

im spawning the weapon in on the server

#

then hiding it

#

btw i only set my equipped weapon via a server rpc

nocturne quail
#

bad design

cerulean barn
#

how is this bad design?

nocturne quail
#

you don't need many hidden weapons attached to the character

#

i see you only set visible the equipped weapon

cerulean barn
#

so my hotbar is basically a bunch of hidden weapons except the equipped one

#

when i change my equipped weapon, i set it visible

#

and the rest hidden

nocturne quail
#

that's bad design, you only need data of those guns, when you need to use one of them just spawn it from the data and destroy the old that you want to hide

cerulean barn
#

theres a ping delay when switching between items

#

that means id have to spawn it in everytime in my hotbar

nocturne quail
#

yeah it will be good system

cerulean barn
#

for my inventory, i store just the data, and if i add it to my hotbar, i spawn it in

#

since the hotbar is just 5 items

#

keeping 5 items spawned in shouldn't be a problem

#

makes it faster when switching weapons

digital herald
#

Yeah you basically just have a 5 actor object pool

cerulean barn
#

but anyways, what could be wrong with my current setup that causes the wepaon to be invisible on the first person mesh just the first time between switching?

cerulean barn
exotic wasp
#

5 weapons max and this is perfectly fine IMO

cerulean barn
#

yeaaa

#

i just dont know whats wrong

exotic wasp
#

I wouldn't use an rpc though. Probably best to use a replicated property

cerulean barn
#

im using a onrep equipped weapon variable

exotic wasp
#

Ok that's good

cerulean barn
#

server rpc to just set the equipped weapon

exotic wasp
#

Misread

nocturne quail
#

also, you don't need to hide them, just attach them to different socket on character

cerulean barn
#

that is true

#

i dont need to hide them

#

but do i want 5 weapons attached to my character at once?

#

not really

#

or 5 objects

#

whatever it is

#

maybe theres a better way i can hide them ?

#

instead of this

digital herald
#

That seems fine to me. And disable tick if it's not already while hidden

exotic wasp
#

only thing I can think of that might cause weird issues is that hidden actors stop replicating iirc

cerulean barn
#

so once i set it enabled its no longer replicated?

exotic wasp
#

you could set the visibility

cerulean barn
#

let me try that..

nocturne quail
#

just scale it down to 0.01 😄

digital herald
#

Yeah that's how I do it in my FPS

cerulean barn
#

isn't that what im already doing

cerulean barn
nocturne quail
cerulean barn
#

how else can you hide a replicated actor

digital herald
cerulean barn
digital herald
digital herald
cerulean barn
#

what about the collisions

#

does that also replicate

exotic wasp
#

do your equipped weapons have collision?

cerulean barn
#

im pretty sure

#

i should prob disable that regardless

#

seems useless

nocturne quail
digital herald
cerulean barn
digital herald
cerulean barn
#

do you have it set it hidden / visible onRepNotify changing the equipped weapon?

#

so after deleting the collision it fixed my issue...

#

now they are showing visible perfectly fine

#

and hiding fine

#

dont know how setting collision can mess it all up but it did

nocturne quail
cerulean barn
#

i mean this worked

digital herald
#

Really just sending a weapon cycling index.

cerulean barn
#

im still having the same issue actually, when hiding it, then setting it visible, it's not showing visible on the first person arms

#

unless i switch around a few times

digital herald
cerulean barn
#

it attaches fine for the third person mesh

#

on the first person mesh it's just floating around the body

#

not attaching

digital herald
#

What's your attachment code look like

cerulean barn
digital herald
cerulean barn
#

yes

digital herald
cerulean barn
digital herald
# cerulean barn

Maybe you aren't changing to a valid weapon... instead of just printing "attaching locally", you should use GetObjectName on the weapon itself and see what that is equal to in the instance of a failure.

#

See if when you swap it's None or something

cerulean barn
#

ill show you a video of what i mean

#

first switch it glitches then its fine...

#

always fine on third person mesh

digital herald
#

Oh I see it's already there (object pool, duh) just not attaching.

#

Maybe instead of Attach Actor to Component try Attach Component to Component using the weapon's mesh component

cerulean barn
#

but u see it only glitches on the firsxt switch for the arms

#

after going back to it, it works

#

and it works always on the third person mesh

digital herald
#

Yeah that is weird

#

I don't know if there's an possibility that socket name is wrong the first time but it could be something you could print string to see.

#

Looks like it attaches (it's following) it just has an offset

cerulean barn
#

yeah

#

it connects fine after switching a few times

#

just not on the first switch

#

i have no idea whats wrong or how to fix it lol

#

could it be some sort of delay issue

digital herald
#

I do detach the old mesh first

#

And I use the SKM class's attach function

Mesh1P->AttachToComponent(PawnMesh1p, FAttachmentTransformRules::KeepRelativeTransform, AttachPoint);```
cerulean barn
#

before setting invisible you detach/?

digital herald
#

I set Hidden in Game right before

cerulean barn
#

u set hidden in game then detach?

digital herald
#
void AWeapon::AttachMeshToPawn()
{
    APawn* MyPawn = GetInstigator();
    if (!IsValid(MyPawn) || !MyPawn->Implements<UPlayerInterface>()) return;
    
    // Remove and hide both first and third person meshes
    DetachMeshFromPawn();

    // For locally controlled players we attach both weapons and let the bOnlyOwnerSee, bOwnerNoSee flags deal with visibility.
    const FName AttachPoint = IPlayerInterface::Execute_GetWeaponAttachPoint(MyPawn, WeaponType);
    
    if (MyPawn->IsLocallyControlled())
    {
        USkeletalMeshComponent* PawnMesh1p = IPlayerInterface::Execute_GetSpecifcPawnMesh(MyPawn, true); 
        USkeletalMeshComponent* PawnMesh3p = IPlayerInterface::Execute_GetSpecifcPawnMesh(MyPawn, false);
        Mesh1P->SetHiddenInGame(false);
        Mesh3P->SetHiddenInGame(true);
        Mesh1P->AttachToComponent(PawnMesh1p, FAttachmentTransformRules::KeepRelativeTransform, AttachPoint);
        Mesh3P->AttachToComponent(PawnMesh3p, FAttachmentTransformRules::KeepRelativeTransform, AttachPoint);
    }
    else
    {
        USkeletalMeshComponent* UseWeaponMesh = GetWeaponMesh();
        USkeletalMeshComponent* UsePawnMesh = IPlayerInterface::Execute_GetPawnMesh(MyPawn);
        UseWeaponMesh->AttachToComponent(UsePawnMesh, FAttachmentTransformRules::KeepRelativeTransform, AttachPoint);
        UseWeaponMesh->SetHiddenInGame(false);
    }
    
}
cerulean barn
#

im using blueprints but same concept ig

#

i need to detach actor from component

digital herald
#

I attach component to/from component, you are attaching the actor which will defer to the weapons root.

What is your weapon's root - the mesh? Or a scene or something else

digital herald
#

Yeah it shouldn't matter but you can try Attach Component to Component - though idk why you don't have it working properly just the first couple times 🤷‍♂️

cerulean barn
#

detaching from component didnt work

#

i get the same issue where it floats around the first switch

#

could it be a delay issue?

#

i dont see what else

digital herald
#

But what would it be skipping that a delay would compensate for?

cerulean barn
#

I have no clue

#

Neither did the guy yesterday

#

we r all just as confused

#

There has to be a diff way to do this then since other people have object pool hotbars

cerulean barn
#

(First switch doesn’t attach then second switch does…)

tardy fossil
#

maybe your OnRep is getting called on the client before it's possessed the pawn so the IsLocallyControlled fails and that Current Weapon variable doesn't get set for the first weapon?

cerulean barn
#

impossible because im getting my print message

#

note when i do this on my server game instance, this doesn't glitch at all. it works fine

thin stratus
cerulean barn
thin stratus
#

Are you aware that actor attachment is replicated by the engine already?

#

So if you start attaching it locally you will get that and the replicated attachment fighting each other

cerulean barn
#

but the weapon im switching to isn't "attached" yet

#

its just spawned in

#

i spawn them all in, hide them, and attach the equipped weapon

#

i set the rest to hidden

thin stratus
#

Just saying

#

Also hidden in game stops replication

cerulean barn
#

so what would be a fix for this?

#

i appreciate the help btw

thin stratus
#

Hiding the ones that aren't important isn't a problem I guess. Idk if you are trying to attach weapons to different parents based on first person vs third person

#

Cause that would need c++ in theory.

cerulean barn
#

i am attaching to arms if locally controlled and mesh if not

#

but the thing is, it works after i switch a couple times, just not the first time

thin stratus
#

Hm yeah that's basically gambling

cerulean barn
#

idk if u saw the gif i sent

#

how so?

thin stratus
#

I did see the gif

thin stratus
#

There is code in the actor class that handles replicating attachment info

cerulean barn
#

hmm

thin stratus
#

Which means by default a replicated actor can only be attach to one and the same parent on all players and server

cerulean barn
#

i see what you are saying

thin stratus
#

You'd need to either attach a non Replicated dummy

cerulean barn
#

so it would be impossible to split between first person and third person in this scenario

thin stratus
#

Or override the OnRep_Attachment in a weapon c++ class to not do that

thin stratus
cerulean barn
#

because this onrep is being called on the server, and on all clients

thin stratus
#

Isn't that coming from an intro?

#

Onrep*

#

Are you filtering the server?

cerulean barn
#

when i change my equipped weapon (through a server rpc) it triggers this

sinful tree
#

OnReps trigger on the server too.

cerulean barn
#

yes

#

so in the onrep i filter the server to do the hiding / showing

#

then i do an is locally controlled for the attachments

#

which is why i dont understand why its not attaching locally even if its printing the message

sinful tree
#

If this is your "filter" for the server then after the branch at the end there the server will be attaching it.

cerulean barn
#

so before the is locally controlled just check if has authority

#

and if false continue ?

#

oh wow that fixed it

#

thanks man

#

i forgot that is locally controlled doesn't just filter the server out

sinful tree
#

Just remembrer you can't use that replicated actor for any game logic because it won't be in the expected spot on the server.

cerulean barn
#

wdym

sinful tree
#

It's not attached on the server.

cerulean barn
#

r u saying like collisions?

sinful tree
#

So it won't be in the same place on the server.

#

Anything about it.

#

Position/rotation

cerulean barn
#

can u give an example where that might be a problem?

sinful tree
#

Shooting the gun.

cerulean barn
#

my mechanic just shoots it from the cross hair

#

not the muzzle

sinful tree
#

If you want to know where the barrel is VIA a socket on the gun, the gun won't be in the player's hands.

cerulean barn
#

do you think keeping my logic like this is bound to a problem

#

or is it fine

sinful tree
#

As long as you remember that you can't use the gun's location/rotation in any game logic, then it should technically be fine.

cerulean barn
#

what about shooting a bullet from it

#

like visually

sinful tree
#

On the server it won't be in the location that it's showing on clients.

cerulean barn
#

where would it be on the server?

sinful tree
#

Wherever you ended up spawning it on the server.

cerulean barn
#

ah

#

so here

#

where does the server usually spawn in guns on a fps?

#

the first person character or the 3rd person character

#

ig with this logic the gun isn't following the character on the server

#

tecnhically

#

itll just spawn in there

digital herald
#

What exi was saying though is attachment is replicated so you'd really only need to do the attachment on the server. Doing it on both is the gambling part.

cerulean barn
#

which is why i can't attach it on the server + have it on third person & first person

digital herald
#

Attaching a replicated actor on the server will replicate that attachment to clients

#

Oh you have the same mesh for first and third person. Gotcha

cerulean barn
#

no i dont

#

i have two different meshes

digital herald
#

On the weapon I mean

cerulean barn
#

my weapon is just an actor with one mesh

#

could i run into a problem attaching the weapon only on the clients and not the server you think?

digital herald
#

Datura already pointed out the issues with that

cerulean barn
#

ill play it by ear

#

one problem at a time lol

#

how do you do it in ur game?

digital herald
#

My weapon has two meshes, just like the character. One is for the 1st person and one for the 3rd person and they are attached separately.

cerulean barn
#

and im assuming you do them both on the server

#

thats pretty smart actually

digital herald
#

Mainly because it was originally based on the UE4 ShooterGame sample project. If I looked at it today maybe I'd do it differently.

#

Maybe not.

cerulean barn
#

welcome to the show adriel

dark edge
#

Wait a second, actor attachment is replicated, is component attachment?

#

You could have a root scene component in your weapon, then just in the first person case, attach the weapon mesh to the first person arms.

#

That would play nice. If my assumption is correct that actor attachment is replicated but component attachment below that actor is not necessarily replicated

cerulean barn
#

hmm

#

and then keep the attachment on the server?

dark edge
#

You would end up with, on all machines, the weapon actor is attached to the third person mesh, but on your machine, your weapon actor's mesh is attached to the first person mesh.

cerulean barn
#

and on the server?

dark edge
#

All machines

cerulean barn
#

ok

digital herald
#

With two separate meshes I don't have to worry about a race condition between attachment replication and rep notifies

dark edge
#

@cerulean barn show the component layout of your weapon

cerulean barn
#

its just this rn

dark edge
#

Yeah so attach actor just attaches the actor's root component. Just see if you could then attach the skeletal mesh to your first person mesh in the locally controlled case

digital herald
digital herald
#

Overriding OnRep_Attachment in C++ could prevent that as exi said

dark edge
#

My project is designed in such a way that everyone gets to see the same thing all the time and there's no problem.

digital herald
#

Well, give it a try and get back to us. I personally would do it different (and have) and what I did works but hey give it a try. I just think that sharing one weapon mesh between two character meshes, when the weapon is replicated, is not deterministic and will just result in this bug.

cerulean barn
digital herald
# cerulean barn override it to do what

Well, say on the server you attach it to the third person mesh. Then in OnRep_Atrachment, on the locally-controlled client, you attach it to the first person mesh.

That's the only way to surefire get it to behave because the attachment has already replicated and won't clobber your first person attachment

cerulean barn
#

this is probably the safest solution ?

#

besides having two meshes

dark edge
#

Have you tried it yet, you don't even know if it works.

cerulean barn
#

nope i havent tried it yet

#

idek how to override it, ill have to figure that out first lol

digital herald
#

Personally it feels like a hack to me.

dark edge
cerulean barn
#

not the actor?

#

sure i can try that

dark edge
#

I would have thought attachment replication would be under under replicate movement since it pretty much is a movement related property but it's probably been like that for 20 years

cerulean barn
#

this is being ran on the server + all machines

#

so there shouldnt be a problem with this

dark edge
#

You're probably clobbering yourself a little bit because what happens on the server is what happens on the client since attachment of an actor is replicated, but it should technically work as is.

digital herald
#

I guess that works since it's the scene root attached on the server and the mesh attached on the client. Seems a little hacky but if it works it works

cerulean barn
#

it works

#

thanks guys

dark edge
# cerulean barn it works

It's hacky, your final setup will probably look a bit like overriding OnRep_Attachment, so you can just attach the gun actor to the character actor on the server, and it'll attach to the correct component on each machine based on if character is locally controlled or not. But that'd be C++ only

cerulean barn
dark edge
#

You'd do it once in C++ and forget about it, but if you don't have any C++ in your project at all just put it on the back burner until you do.

cerulean barn
#

i had to add c++ for the steam advanced sessions to work

#

so i already have that

dark edge
#

It'd be simple:

OnRep_Attachment -> is the thing we're attaching to a MyCharacter? -> yes -> is that MyCharacter locally controlled? -> yes -> attach to its arms
-> no -> attach to the 3pp mesh

#

You'd need your weapon and character base class to be in C++

cerulean barn
#

ohh

#

yeah later issue

#

would i still be able to have a firing animation from the first person view tho?

#

for now

#

and like a reload etc

dark edge
#

all that's possible

cerulean barn
#

okay great

cerulean barn
#

my fire logic which is in my weapon event graph

why isn't ros_fire being called when a client shoots a gun?

#

only when the server shoots a gun does it call.

lost inlet
#

And who's the owner of the actor?

cerulean barn
#

is it not the first person character

glossy wigeon
#

Hey guys, I'm wondering I want to handle savegames, now I was thinking a subystem would be nice, until I realized it won't be replicated 😦

I still like the idea of having a subsystem for it but since they are not replicated, I was thinking of maybe having the subsystem calling a function on things like the game mode or something, that then will call a server sided function that then calls the subsystem on the server side, but not sure about that, since it feels a little complicated.

What do you say, how to handle that, so that I also have a nice way of accessing it.

dark edge
glossy wigeon
#

So now it is "save game" and "load game", maybe later download/upload the save game.

dark edge
#

What is in these save games?

#

What is being saved?

glossy wigeon
#

Basically everything, in the long run there will be two things, but it's the players inventory/abilities/... and then another thing will be the current levels state.

dark edge
#

You can do all that local and then have a RPC in PlayerController to upload a build or whatever to the server

glossy wigeon
#

But I will 100% run this on the server, especially for loading the savegame, since I was already running into the issue, that adding inventory items on the client will ofc not be replicated ^^

dark edge
#

I said local

#

server has local too

#

The only thing that has to cross the network is a client telling a server some data about something they did previously, like a saved build or whatever

glossy wigeon
#

But I was thinking I can have a Server function on the player controller, or smth like that, since it will also allow me to check if the player has rights to do that correct?

glossy wigeon
dark edge
#

Like say an ability build

glossy wigeon
#

oh that is already on the server anyway, since it has authority on it.

dark edge
#

Then what is the problem, what needs to go across the network here from client to server?

#

If you're talking about something like Minecraft with server sided inventory then it's just like any other game, the server saves and loads the savegames

glossy wigeon
#

The question is where do I put the code to not fully spread it out over the whole project ^^

dark edge
#

Gamemode probably

#

that's where player connections and getting their pawn and such happen

glossy wigeon
#

I currently use a subsystem for it that works really nice, but it is not replicated 😦

dark edge
#

why would it have to be replicated?

#

ALL of this is happening on server

glossy wigeon
#

yea but the call "start saving" is done on the client

dark edge
#

the things that happen as a result of loading a game will be visible to clients through replication of various things

glossy wigeon
#

so I would at least have to wrap it in a custom event that is called on the server

dark edge
cerulean barn
dark edge
#

the client isn't doing any saving, it's requesting that a save be done on its behalf, serverside

dark edge
#

you can either have the local gun ask its serverside gun to fire, or have your local pawn ask its serverside pawn to fire MyGun

glossy wigeon
#

but maybe i have to just live with the server event

dark edge
#

your client can load a game, sure

cerulean barn
dark edge
#

but it'll only be on their machine

dark edge
cerulean barn
dark edge
glossy wigeon
#

Yea that's why I was thinking, what if the subsystem calls a server function on the game mode which then in turn calls the subsystem on the server.
But not sure if this will just add more complexity.

dark edge
#

are you using child actor component?

dark edge
#

there is no game mode on clients

#

read the compendium

cerulean barn
#

which is a bp_weapon actor

dark edge
glossy wigeon
cerulean barn
#

the server is doing the spawning

#

so i assume its not setting the owner

dark edge
cerulean barn
#

here right?

dark edge
#

I prefer to not have rpcs in things beyond pawn though

cerulean barn
dark edge
#

you will have lag like that though, this is why shooters are hard. you can do some stuff like locally telling it to fire too

cerulean barn
#

this is my current logic

cerulean barn
dark edge
#

client already owns the character

cerulean barn
#

why doesnt it do that automatically

dark edge
#

because you don't always want all things you spawn to be owned by you

cerulean barn
#

yeah that fixed my issue though; thanks

cerulean barn
#

just wondering since this whole tutorail i followed was pretty shit (apparently)

#

is that a bad way to do it

cerulean barn
cerulean barn
#

ive come to notice

dark edge
#

not literally, but if you're new, you can't tell the difference

cerulean barn
#

yeah i had no idea

#

until i had to redo the whole weapon system

#

he had them all as components

#

not actors

dark edge
#

You're gonna redo it many times in the future

cerulean barn
#

the weapons ^

#

yep

dark edge
#

just get good at coding lol

cerulean barn
#

but im getting a better understanding of whats going on

dark edge
#

I've redone my vehicle system 5x now

cerulean barn
#

so the thing is, i already know how to code in c++ and shit but not in unreal

#

everyone told me to start in blueprints

#

but i like coding more than this stuff

dark edge
#

It's a good idea to get a feel for how the engine is set up, then go digging into C++

cerulean barn
#

would i have to restart?

dark edge
#

if you don't know the difference between an ActorComponent and SceneComponent and UObject and Actor and GameMode and GameState you'll be absolutely lost on the C++ side

#

but once you know the architecture it's really not that bad. It's like if C++ was trying real hard to be C#

dark edge
#

start with a single file that has your project structs and enums and a BP function library

#

Then you can start making your own components and base actors

cerulean barn
#

so i should prob just keep messing around until i get more comfortable

#

its only been a couple weeks ive been doing this

dark edge
#

Say you're making a simple basic shooter, you'll at least end up with a c++ base class for your game framework classes and your pawn and your weapon

#

So for instance an AK47 might be like:
UObject -> AActor -> YourWeaponBase -> BPYourWeaponBase -> AK47
( C++ )( BP )

cerulean barn
#

why does it need two bases

#

?

#

YourWeaponBase -> BPYourWeaponBase

dark edge
#

edited

cerulean barn
#

i see that but it needs both bp and c++ base?

dark edge
#

not needs but it's nice to have

#

you can prototype in the BP base then move functionality to the C++ base when it's fleshed out

#

eventually the BP base will be damn near empty

cerulean barn
#

you think i should start that stuff now or when im more comfortable

dark edge
#

Here's what you have right now:
UObject -> AActor -> BPYourWeaponBase -> AK47
( C++ )( BP )

#

I'd start out making a C++ types file anyway

cerulean barn
#

i dont fully understand, in the same project?

#

like the c++ files

#

or would i make a new proj

dark edge
#

What starter project did you start with?

dark edge
cerulean barn
dark edge
#

That's all itll take to convert it to a C++ project

cerulean barn
#

already had to do that

dark edge
#

I'd make sure your IDE is set up first though, I recommend rider

cerulean barn
#

when i implemented lobby system

dark edge
#

oh then you're set

cerulean barn
#

i just use vsc for c++

dark edge
#

fire up your IDE and make a new BPFunctionLibrary file

#

You're off the beaten path but you should be able to get it going

cerulean barn
dark edge
#

that's how you make your own nodes

#

once you get comfy doing that make your own base classes for character and weap and such

cerulean barn
#

i understand u can make the base classes in c++ but wdym u can make your own nodes

#

i dont even have a structure setup for anything yet

#

for the inventory i just have weapons setup for now

cerulean barn
#

okay i understand you can create custom nodes but wouldnt i just be using the nodes already created?

#

or are there some things you cant do with the "provided" nodes

dark edge
cerulean barn
#

got it

dark edge
#

and for safety you want to put your custom structs in C++ is the general wisdom

#

BP structs can break in really bad ways

#

and this will get you used to doing Unreal stuff in C++

cerulean barn
#

so i should try and slowly convert my project to c++

#

is what ur saying

dark edge
#

Yeah i would

#

I still prototype in BP only, but I move stuff to C++ as it gets settled

cerulean barn
#

so u test stuff in bp and if it works u convert to c++?

dark edge
#

yup

cerulean barn
#

like i should be converting my base weapon and base first person character into c++ classes

dark edge
#

I mean if it's simple I jsut start out in C++ but I'm much much faster in BP

quasi tide
#

Or just keep it in BP

cerulean barn
#

id prefer to code then keep nodes honestly so why not

dark edge
#

yeah it all depends on what you're trying to do

cerulean barn
#

i like coding more than this

dark edge
#

it's all programming

cerulean barn
#

yea

dark edge
#

just typing vs drag and drop really

cerulean barn
#

how would this be converted to c++

dark edge
#

wouldn't

cerulean barn
#

like built in stuff

#

like event begin play etc

#

ah so you can only create custom nodes

dark edge
#

the BP layer is kinda your final hook things together and do visuals layer

cerulean barn
#

so use c++ to do logic, and hook that logic into the bps

dark edge
# cerulean barn so use c++ to do logic, and hook that logic into the bps

It's not an either/or decision. Learn what makes C++ and Blueprints different, what they have in common, and how to use them together effectively. We'll also learn a thing or two about performance optimization and some basic software design concepts.

Read the article version: http://awforsythe.com/unreal/blueprints_vs_cpp/

00:00 - Introduction...

▶ Play video
cerulean barn
#

ill check that out

dark edge
#

give that a watch

cerulean barn
#

he explains how to use them for custom nodes & base classes and stuff?

dark edge
#

He explains the philosophy around what typically goes where

cerulean barn
#

ok

dark edge
#

working in Unreal with zero BP is insanity, as is working with zero C++ if you're doing anything anywhere near complicated

#

you'll at least have some data-only BPs most likely

cerulean barn
#

when picking an engine i was almost against unreal just for the blueprint aspect

#

as i enjoy coding

#

but i came around

dark edge
#

I like programming, whatever gets my ideas into logic the fastest. I'd do things 100% with BP if it was exactly as capable and performant, but it's not.

cerulean barn
#

yeah i agree

dark edge
#

It's about 100x slower, that doesn't really matter for press button -> call Jump, but it matters for Tick -> 5k lines of code

bronze glade
#

Hey everyone, I have a very beginner question. I have watched a lot of videos and read documents about general replication with actors and events and things, but I am having a hard time finding good, thorough resources about game mode / game state / player state / etc. I don't know how to tell when I am putting too much on the game mode and when things should be delegated elsewhere. For example I could have a match timer in the game mode that is constantly sending to game state to be replicated each second, or it could just pass the max value for the timer and each client can count down on their own. Things like that, where to store variables, do certain functions, etc. are a bit hard for me to understand where they should belong. Does anyone have any good resources? I found a couple in the pins but would love some more if there are any!

dark edge
#

Say you were making a bullet system that did heavy simulation like Arma. That's C++ territory, it'll work in BP but be hella slow
If you're just doing a few things on begin play of an actor, that's fine in BP

cerulean barn
#

slower but more easily accessable and less complex

#

bps ^

dark edge
#

Also any time you're dealing with assets, you wanna be in BP

#

you don't want to be typing out asset paths in C++, that's a huge smell

#

your C++ weapon can have WeaponMeshComponent, but BP is where you say what mesh WeaponMeshComponent should use.

dark edge
#

calling into overridden stuff is fine, but if it's declared at the BP layer it lives at the BP layer

cerulean barn
#

understood

#

I’ll definitely check that out tonight and try to convert my base classes to c++

sinful tree
# bronze glade Hey everyone, I have a very beginner question. I have watched a lot of videos an...

PlayerState = An actor meant to house information relating to a specific player regardless of what pawn they may be possessing. Good for things like Player score, name. It replicates to all, always.
GameState = A replicated actor that can be used to house information pertaining to the game that is easily accessible via "Get GameState". Good for things like Timers, Team Scores. Replicates to all, always, so it's good for general information pertaining to... the state of the game.
GameMode = A non-replicated actor responsible for handling the spawning of players and is responsible for handling details about what other default classes to use. Sometimes refered to as handling the "rules" of the overall game. This actor doesn't get replicated to clients.

cerulean barn
#

But just to reiterate , I keep the bp first person for event begin play, and I call the custom c++ nodes in it ?

#

I’m sure the video will explain, so I’ll have to check that out

dark edge
cerulean barn
#

yes

dark edge
#

GameMode = Should have been called GameController to keep the Controller/State energy going

nocturne quail
#

why is the pitch not the same on server/client?

void UARMAAnimationInstanceBase::NativeUpdateAnimation()
{
    Speed = Character->GetVelocity().Length();
    Direction = Character->GetCalculateDirection();

    FRotator DeltaRotator;
    const FRotator CharacterActorRotation = Character->GetActorRotation();

    if (Character->IsLocallyControlled())
    {
        DeltaRotator = (Character->GetControlRotation() - CharacterActorRotation).GetNormalized();
    }
    else
    {
        DeltaRotator = (Character->GetBaseAimRotation() - CharacterActorRotation).GetNormalized();
    }

    Pitch = DeltaRotator.Pitch;
    Yaw = DeltaRotator.Yaw;
}

according to the docs they should be the same since GetBaseAimRotation is intended to return a replicated local pitch!

cerulean barn
#

So technically c++ coding is just coding nodes

nocturne quail
dark edge
cerulean barn
#

What else is it used for then?

dark edge
#

that's where the nodes come from

dark edge
cerulean barn
#

Because you can’t have only a base class because u can’t have the event begin play I thought

dark edge
#

what

bronze glade
dark edge
#

Every actor has a Begin Play somewhere

cerulean barn
#

my earlier question was how to code the event begin play or shoot interaction

#

I interpreted you can only do that in bps

dark edge
#

nah

#

Everything you have access to in BP, and more, is available in C++

cerulean barn
#

So I can make a solely c++ base character & weapon class

#

Is that the goal?

sinful tree
#

You can, and you'd base them off of ACharacter and AActor respectively.

dark edge
#

Fire -> play FireSound -> spawn bullet //C++
FireSound = Gun.wav //BP

cerulean barn
#

Got it

dark edge
#

watch that video

cerulean barn
#

will do

#

glad to be coding again 🫡

nocturne quail
nocturne quail
# nocturne quail why is the pitch not the same on server/client? ```c++ void UARMAAnimationInsta...
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
LogTemp: Server Pitch: -19.308472
LogTemp: Client Pitch: -26.823709
#

Epic Games what is going on? 😄

#

this starts happening when the equipped weapon is set to SetViewTargetWithBlend by character

#

because of this small difference the bullets hits the wrong target the red dot above the aim point

west bluff
#

Hello, what is the correct approach to make my character look at its target in a multiplayer environment? Does the Character Movement Component (CMC) provide any built-in method for this? I would like to avoid sending RPCs every tick if possible. Thanks!

nova wasp
#

I think just sending the target it's looking at would work great as a first try because that way it doesn't need constant updates, just what it is looking at

#

but I'm not sure if the target is a replicated object or just an arbitrary point in space

exotic wasp
#

for whatever reason

nova wasp
#

and the old RemoteViewPitch

exotic wasp
#

did it recently change?

nova wasp
#

yes in 5.6 they moved to another property

exotic wasp
#

is 5.6 out

nova wasp
#

it is very imporant you override GetBaseAimRotation and GetViewRotation to do what you actually want imo

nova wasp
#

I'm on main and I'm amazed this got changed

#

seems like something they would never touch

exotic wasp
#

it was pretty shit considering it entirely breaks if you have a player oriented a direction other than up

nova wasp
#

the shrimple thing imo is to just have a separate aim rotation entirely

exotic wasp
#

this is the way

#

but if the framework would just handle it that would be cool too

nova wasp
#

also this is more advanced and not needed for most projects but having your entire pawn replicated movement and state happen in one struct removes a ton of headaches from property replication

#

there is no chance you get it split into multiple packets when it is one dumb unga bunga struct

exotic wasp
#

hmm I don't think there's anything stopping a struct from replicating it's parts separately

nova wasp
#

this is mostly for things that MUST be known together, for example if crouching moves you and you receive the moved transform before the crouch you WILL jitter

nova wasp
#

you can definitely delta serialize but it will consider the parts in whole

exotic wasp
#

I know nothing about iris

nova wasp
#

if the parts are distinct network objects yes they will be sent seperately, but I think POD types that aren't network references are sent atomically

#

I assume the old replication actor channels make a similar gaurantee but I'm not sure

#

(you don't need to use iris yet, it's still quite experimental but serves as a drop in replacement unless you use the replication graph)

exotic wasp
#

there's a atomic specifier but I can't remember what it does

nova wasp
#

really? I want to see it

exotic wasp
#

is it actually honored? 🤷‍♂️

nova wasp
#

nothing seems to use this

#

my fault for being too used to iris

#

the simple thing is to just make a net serializer

#

which is easily done in the old setup

quasi tide
#

Iris doesn't do atomic struct rep?

nova wasp
#

Iris net serializers are frankly 10x more complicated than they need to be... they really should have a "simple" mode

nova wasp
#

by default

#

with delta flags per member (if it can delta serialize the type)

#

it is still sometimes needed to make custom serialization if you have something where you can preclude sending large amounts of other things

#

or send things that aren't replicated at all

#

Iris will warn if you use a struct that has old custom serialization but not a new iris one

nova wasp
#

@twin vessel yes if you make a custom serializer that responds to stuff changing (in iris you could arguably make a new fragment but... I don't even know how to make that work well)

#

frankly... just make an onrep and compare the previous with the current

#

you don't need to get fancy to just check one one small thing changes each time its received

#

assuming its not an extreme number of properties

twin vessel
#

I would rather keep everything inside the struct for sake of clean code, unless it is bad practice.
How would you know which member is replicating from the serializer?

nova wasp
#

the serializer would know which member is replicating by just reading the bits

#

when you write it, it probably changed and you can just do whatever

#

for example fast array serializers work that way

#

but seriously... just use an if statement lol

#

unless it is extremely expensive to compare the two or you need some special case

#

I don't even know what this struct looks like so I can't really compare much

#

you might need to make a custom equality operator for the type but that's easily done in most IDEs with one click

twin vessel
#

The objective was to have a struct that i can just add to an UObject to act as a small component

nova wasp
#

hmm... yeah unfortunately property replication kind of assumes the owner has ufunctions

nova wasp
#

this is really dumb I think and internally to me there is no reason you can't replace it to use function ptrs

twin vessel
#

Was hoping to do something like what fast array does

nova wasp
#

dumb structs are not wrong, that is just what they want to do

#

they are far less complicated than allocating an entire lifetime'd object

#

that said this is going to kind of fight the assumptions unreal makes

nova wasp
twin vessel
#

What do you mean by which replication?

nova wasp
#

TFastArrayReplicationFragment has a CallRepNotifies but I will insist that this will be tedious to figure out how to make your own... Iris has some absurdly obtuse boilerplate

#

that's what Iris does

#

for the regular setup I don't know, I would just breakpoint the fast array callback

nova wasp
radiant halo
#

Hi, i am trying get the proper rotation of my characters, for some reason it's not translating properly. (have not started handling things with C++ yet, just blueprints)

nova wasp
#

you can also mark parts of a ustruct with NotReplicated to have only part of it sent in the packet (or just make them... not uproperties)

twin vessel
#

Well thanks for the insights, i will give a look to how fast array does it, but at this point i might actually go for this solution or stick to UObjects

nova wasp
radiant halo
#

this one?

nova wasp
#

try it out

radiant halo
#

it wasnt it :/

nova wasp
#

is bOrientRotationToMovement enabled?

radiant halo
#

yes

#

i just set it to false and now it works! Thanks Megafunk! 😄

kindred quail
#

Hello everybody!
I am working on a multiplayer game using the steam api. I watched a view tutorial videos about adding the Advanced Session Plugin and got that set up successfully. I am currently able to connect two clients using ASP. But i ran into a problem when in multiplayer regarding my item pick up / throw down actions.
Whenever the Host picks up / drops an item it is replicated successfully, meaning the connected clients get the deleted / added items replicated. However when a client attempts to do so, the items are not getting removed from the world when picked up and also not added when dropped.
I already watched several videos for replication, but could not figure out what the problem is. I was also not able to find replication issues involving ASP.
Does anybody have any experience with ASP and replication issues? I've had this problem for weeks now and cannot solve it.

These are the tutorials I followed for impkementing ASP and trying to resolve the replication issues:
ASP setup: https://www.youtube.com/watch?v=5nMKEKV0acI
Replication basics: https://www.youtube.com/watch?v=bBK8A-mFH-s

chrome bay
#

ASP won't have anything to do with it

#

Replication works the same regardless of whatever session backend you use

#

99% of the time you should almost certainly be able to reproduce the same issue in editor.

lost inlet
#

So you would need to show that to us

#

In all likelihood, you've called a server RPC on an actor that client player does not own

kindred quail
#

This is the chain of function calls and events when a player picks up an item. before the RPC_Server_DestroyItem is called the item is being added to the player's inventory at the currently selected slot.
How do i check whether the client owns an actor?

lost inlet
#

Yeah I'm not surprised this doesn't work properly

#

Is the only interaction to the server just telling it to destroy the actor?

kindred quail
#

yes

#

same goes for dropping / spawning an item.

lost inlet
#

Like I said, not surprised

#

Inventory management should also happen on the server

#

It should be server authoritative

#

And yeah, the RPC doesn't run because the player doesn't own that actor. As a client, you cannot call server RPCs on actors you do not own

kindred quail
#

ok, thank you. that helps a lot already

#

would there be an easy fix for my inventory system or would it be better to start from scratch with server-side handling in mind?

lost inlet
#

Based on the information I see, it probably would be better to redo it. This really looks like something that was designed for singleplayer that you tried to make multiplayer after the fact

#

Which you should never do

kindred quail
#

Yeah, i followed a starter tutorial for inventory management intended for singleplayer and apparently understood multiplayer wrong. i was thinking it would be as simple as telling the game "you are now multiplayer" but my assumption was completely wrong as i now know.

#

Thank you, though. Now i finally know what the issue is.
I will rework the parts i did without multiplayer in mind.

ruby parrot
#

Okay, this is weird..when I "Play as client" then this does call the OnRep-function on the Struct_Equipment

#

When I make a cooked build, this doesnt OnRep and I have to this:
Does someone know why?

lost inlet
#

presumably set members in BP doesn't call the OnRep

#

but you'd get as play as client because you're a client receiving a replication change

#

if you're the server, you wouldn't

#

in C++ land, it's a pretty typical pattern to manually call the OnRep function, and it seems like that's what you'd have to do here

ruby parrot
#

well but i am getting the OnRep on the client,so the server must have "done the change".....

ive asked grok and it seems that there just is a difference between cooked builds and editor.

just another quirk of UE 😄

lost inlet
#

ive asked grok

#

oh dear

#

and yeah, if you change a replicated value on the server and it's replicated down to clients, you'll get an OnRep as part of that process

ruby parrot
#

i mean i figured out how to fix it anyway...i just wanted to see if theres a "logical" explanation for it to be this way, as you would think "if it works in editor,it works in built environments too"...well at least as someone who is still a newbie 🙂

ruby parrot
lost inlet
#

"play as client" is supposed to emulate a dedicated server setup. so if you're testing in singleplayer, or you're a listen server host, then there's no replication at play there

ruby parrot
#

i see, that could explain it, yet if i do the "set w/Notify" it actually does do the OnRep, but i guess internally as a listen-server-host it just is a "set variable"?

lost inlet
#

"set w/ notify" is what BP provides which is basically just:

OnRep_Value();```
under the covers
ruby parrot
#

yeah. okay. well then i know... gotta set the entire variable after i set members inside of it, got it.

ruby parrot
# lost inlet oh dear

and dont be too negative about this 🙂 AI is pretty good for hobby-ists like me. Im 38 and I cant go back to school to learn UE etc. so grok is as close as a tutor as i can get (besides youtube tutorials)

tardy fossil
#

i hear the replication graph is getting phased out or something.. but the actual class it's based on isn't being phased out right? UReplicationDriver

lost inlet
#

Well if you mean phased out as moving towards Iris, I guess, yeah

twin juniper
#

Hi, I am making a custom pawn for a random multiplayer project of mine, and for some reason, figuring out how to rotate the skeletal mesh has been a pain, and now, its rapidly changing rotations for no apparent reason, one time it goes to the desired rotation, and another time it goes to the default rotation set in the player blueprint. The PIE session's netmode in the video is set to Client.

nocturne quail
# exotic wasp aim pitch is not replicated

This is how I open ADS


void AARMACharacterBase::ToggleADS(bool bWantToADS)
{
    if (AARMAPlayerControllerBase* PC = Cast<AARMAPlayerControllerBase>(GetWorld()->GetFirstPlayerController()))
    {
        EquippedWeapon->OpenADS(PC);
        GetMesh()->SetVisibility(false, false);
        SKM_Hair->SetVisibility(false);
    }
}

void AWeapon::OpenADS(APlayerController* PC)
{
    if (!PC) { return; }
    const bool bSightAttached = (SightObject != nullptr);
    
    const FVector CamLocation = bSightAttached  ? 
        Optical->GetSocketLocation(FName("ADSCameraSocket")) : 
            WeaponMesh->GetSocketLocation(FName("CameraSocket"));
            
    const float Fov = bSightAttached ? SightObject->SightFieldOfView : TargetingFOV;

    ADSCamera->SetWorldLocation(CamLocation);
    ADSCamera->SetActive(true, false);
    ADSCamera->SetFieldOfView(Fov);
    PC->SetViewTargetWithBlend(EquippedWeapon);
}

void UARMAAnimationInstanceBase::UpdateAnimProperties() //Tick
{    
    FRotator DeltaRotator;
    if (Character->IsLocallyControlled())
    {
        DeltaRotator = (Character->GetControlRotation() - Character->GetActorRotation()).GetNormalized();
    }
    else
    {
        DeltaRotator = (Character->GetBaseAimRotation() - Character->GetActorRotation()).GetNormalized();
    }
    Pitch = DeltaRotator.Pitch;
    Yaw = DeltaRotator.Yaw;
}

BaseAimRotation works fine if the character camera is active, when i switch to the weapon camera it starts bad behavior

chrome bay
#

You can't arbitrarily change the mesh rotation because character movement does that for smoothing

#

It will always reset to face the default orientation eventually

twin juniper
#

I am not using character class, im using pawn class

chrome bay
#

Well also, both the server and controlling client will be calling RotateMesh, so they'll be arguing over it constantly

#

you'll also probably have loads of logspam about remote clients not being able to call that RPC because they don't own the actor too

#

You should guard the call appropriately as a start

nocturne quail
#

Seems like Epic games is more focused on FPP arms which will use normal character aimrotation but in my case i am using totally different approach by using the weapon camera while keeping the tpp mode, so basically looking through the weapon camera.

the system i invented has many pros.
1: no need sync fpp/tpp mesh state since i simply not using fpp mesh for first person view 😄
2: tpp mesh working as fpp when looknig through camera mesh
3: no need to mess with mesh visibility which breaks replication

#

but has only one bad side, baseaimrotation not working correctly

limber oak
# nocturne quail This is how I open ADS ```c++ void AARMACharacterBase::ToggleADS(bool bWantToA...

You didn't invented this system, its already exists and fully supported by UE 🙂

baserot is tied to the local pc control rot in the replicated packed property server reads from your local controller rotation and sends your replicated pitch/yaw state to other clients

you don't need this

if (!Character->IsLocallyControlled())
{
    DeltaRotator = (Character->GetBaseAimRotation() - Character->GetActorRotation()).GetNormalized();
}
else
{
    DeltaRotator = (Character->GetControlRotation() - Character->GetActorRotation()).GetNormalized();
}

instead do

USTRUCT(BlueprintType)
struct FRotatorDelta
{
    GENERATED_BODY()
    FRotator DeltaRotator;
    FRotatorDelta(ACharacter* Character)
    {
        if (!Character->IsLocallyControlled() && !Character->HasAuthority())
        {
            DeltaRotator = (Character->GetBaseAimRotation() - Character->GetActorRotation()).GetNormalized();
        }
        else
        {
            DeltaRotator = (Character->GetControlRotation() - Character->GetActorRotation()).GetNormalized();
        }
    }
};

void UpdateAnimProperties()
{    
    FRotatorDelta RotatorDelta(Character);
    Pitch = RotatorDelta.DeltaRotator.Pitch;
    Yaw = RotatorDelta.DeltaRotator.Yaw;
}
nocturne quail
nocturne quail
#

still small tiny difference but it works

thin stratus
nocturne quail
thin stratus
#

YawAndPitchPack = UCharacterMovementComponent::PackYawAndPitchTo32(SavedControlRotation.Yaw, SavedControlRotation.Pitch);

#

const uint32 PitchShort = FRotator::CompressAxisToShort(Pitch);

nocturne quail
thin stratus
#

Although I'm not entirely sure if that still happens the same way

#

Might just be the general ControlRotation replication

nocturne quail
#

I will test it later, currently it works as intented and the bullets spawn at correct location

thin stratus
#
// ControlRotation : FRotator handles each component zero/non-zero test; it uses a single signal bit for zero/non-zero, and uses 16 bits per component if non-zero.
ControlRotation.NetSerialize(Ar, PackageMap, bLocalSuccess);
#

Or rather the FRotator NetSerialize

#

But it's gonna be the same stuff

#
oid UE::Math::TRotator<T>::SerializeCompressedShort( FArchive& Ar )
{
    const bool bArLoading = Ar.IsLoading();

    uint16 ShortPitch = 0;
    uint16 ShortYaw = 0;
    uint16 ShortRoll = 0;

    // If saving, we need to compress before writing. If loading we'll just serialize in the data so no need to compress.
    if( !bArLoading )
    {
        ShortPitch = TRotator<T>::CompressAxisToShort(Pitch);
        ShortYaw = TRotator<T>::CompressAxisToShort(Yaw);
        ShortRoll = TRotator<T>::CompressAxisToShort(Roll);
    }

    uint8 B = (ShortPitch!=0);
    Ar.SerializeBits( &B, 1 );
    if( B )
    {
        Ar << ShortPitch;
    }
    else
    {
        ShortPitch = 0;
    }
#
if( bArLoading )
{
    Pitch = TRotator<T>::DecompressAxisFromShort(ShortPitch);
    Yaw    = TRotator<T>::DecompressAxisFromShort(ShortYaw);
    Roll = TRotator<T>::DecompressAxisFromShort(ShortRoll);
}
#

So just something like this should work:

void UpdateAnimProperties()
{    
    FRotatorDelta RotatorDelta(Character);
    Pitch = FRotator::DecompressAxisFromShort(FRotator::CompressAxisToShort(RotatorDelta.DeltaRotator.Pitch));
    Yaw = RotatorDelta.DeltaRotator.Yaw;
}
#

Or wherever you need that

nocturne quail
nocturne quail
#

and character always looking upward

glossy wigeon
#

For a server function, is it possible to get the client/player that was calling it?

thin stratus
#

There is not really a reason for it to drop the -

nocturne quail
glossy wigeon
nocturne quail
glossy wigeon
nocturne quail
#

if(HasAuthority())