#multiplayer

1 messages Β· Page 725 of 1

fallow shadow
#

Soon (in about an hour)

quasi tide
#

@dark edge I wanted to revisit the gun component idea (I was too busy earlier to ask about it). More of an overall design question. Does it not get annoying setting up new actors to bind to any gun comp functionality? Such as firing or reloading, etc.

dark edge
#

So a shotgun fires on activate primary

#

a machine gun starts auto firing on activate primary and stops auto firing on deactivate primary, etc.

#

We use projectiles in our case so no GunComponent but the idea still holds.

quasi tide
#

Gotcha. So a base item class and you just subclass that when you want a new one?

fallow shadow
#

i am BACK

#

ok so

#
void AMyCharacterBase::SERVER_start_firing_Implementation() 
{
    IsFiring = true;
    
    const FRotator SpawnRotation = GetControlRotation();
    const FVector SpawnLocation = ((FPMuzzleLocation != nullptr) ? FPMuzzleLocation->GetComponentLocation() : GetActorLocation()) + SpawnRotation.RotateVector(GunOffset);

    SelfWeapon->primary_fire(SpawnRotation, FPMuzzleLocation->GetComponentLocation(), SpawnLocation, this, Mesh1P, FirstPersonCameraComponent, GetCapsuleComponent(), true);
    CLIENT_start_firing();
}
#

this is what executes first when the lmb is pressed

#
UFUNCTION(Server, Reliable, WithValidation)
void SERVER_start_firing();

this is the declaration
actually have both:

UFUNCTION(Client, Reliable)
void CLIENT_start_firing();
quasi tide
# dark edge yup

Yeah - seems quite similar to the actor approach, just slightly less inheritance.

fallow shadow
#

@dark edge for visibility

#

going insane with this shit

#

why wont it exist wtf

young spoke
#

whats best way of getting the network id of a player from a client instance? do ppl use
GetWorld()->GetFirstPlayerController()->GetLocalPlayer()->GetCachedUniqueNetId()

winged badger
#

i read them from PlayerStates

pulsar lotus
#

How to join or find session by ip?

delicate jay
#

im not sure whether to put this in #multiplayer or #cpp but im trying to make an fps multiplayer (new to multiplayer) and for equipping the weapon actor i was wondering what the easiest/most efficient way for me to make it so the owner sees it attached to the firstpersonsocket and everyone else sees it attached to the thirdpersonsocket would be, this is what I have right now and it only attaches to the firstperson so everyone sees it attached to the firstperson, thank you (:

dark edge
#

How are you choosing which mesh to attach to? Does the 3rd person mesh not exist on the owning client?

delicate jay
#

if i uncomment that then it shows on the third person socket only for everyone, not both of them or something like that

dark edge
#

Read it line by line

#

It is working exactly how you told it to

delicate jay
#

i know it is

#

there isnt a problem with it im not asking for a fix

winged badger
#

both sockets begin RIghtHandSocket is not a problem?

dark edge
#

OK so how are you detecting the owning client in the first place?

#

do that same thing here

#

OR

delicate jay
dark edge
#

It's not a problem, you just have nowhere that this code will behave differently on an owning client vs anywhere else.

delicate jay
#

yeah ik idk how to make it so it does tho

#

this is my first time doing multiplayer stuff before

dark edge
#

How are you handling the meshes?

#

You're presumably already hiding/showing based on net mode or whatever

#

do the same thing

#

Or better yet, make some function that does that and returns the mesh to use

delicate jay
#

in blueprints i just ticked the thing render if owner

dark edge
#

and use that function here

delicate jay
#

so it renders if your the owner and if not you dont see it

winged badger
#

well, fun thing about replicated actors, they tend to replicate the Parent they are attached to

delicate jay
#

setownervisibilty

winged badger
#

and then attach to it OnRep

dark edge
winged badger
#

no

dark edge
#

Dafuq, it should be

#

that's dumb lol

winged badger
#

if you're attached you shouldn't really be moving around much

#

on your own

dark edge
#

I mean that attach parent should be a movement-related property, but my project does nothing of this sort so I've never encountered it

delicate jay
#

also im not sure if this matters but the two meshes use the same skeleton, the skeletal meshes are different but the skeletons are the same so it actually does use the same socket

devout berry
#

Hello all.
I have a respawn method in my gamemode, but when I try to call an RPC from the player controller to get the gamemode, the cast to my gamemode class fails on the client.

How exactly can I request a method on the gamemode from within a client player controller?

dark edge
winged badger
#
/** Handles attachment replication to clients.  */
USTRUCT()
struct FRepAttachment
{
    GENERATED_BODY()

    /** Actor we are attached to, movement replication will not happen while AttachParent is non-nullptr */
    UPROPERTY()
    class AActor* AttachParent;

    /** Location offset from attach parent */
    UPROPERTY()
    FVector_NetQuantize100 LocationOffset;

    /** Scale relative to attach parent */
    UPROPERTY()
    FVector_NetQuantize100 RelativeScale3D;

    /** Rotation offset from attach parent */
    UPROPERTY()
    FRotator RotationOffset;

    /** Specific socket we are attached to */
    UPROPERTY()
    FName AttachSocket;

    /** Specific component we are attached to */
    UPROPERTY()
    class USceneComponent* AttachComponent;

    FRepAttachment()
        : AttachParent(nullptr)
        , LocationOffset(ForceInit)
        , RelativeScale3D(ForceInit)
        , RotationOffset(ForceInit)
        , AttachSocket(NAME_None)
        , AttachComponent(nullptr)
    { }
};```
dark edge
winged badger
#

its in USceneComponent, so this would require Root component to be replicated for it to break

dark edge
#

So how DOES one attach an actor to different things on different machines?

delicate jay
devout berry
#

@dark edge I don’t follow your question. I wrote I am trying to call a rpc from the client Pc to a game mode

quasi tide
#

Do a server call to the server PC then in the server function call the method on the game mode.

#

the cast to my gamemode class fails on the client.
This makes sense - gamemode doesn't exist on the client.

devout berry
#

I am under the impression, that is what I am trying.

fallow shadow
#

this is really weird

#

can you atleast give me some debugging tips

#

do you need more code? i can give more code

dark edge
fallow shadow
#

gimme a mo

#
void UMyRevolver::primary_fire(FRotator rRot, FVector vMuzzleLocation, FVector vLoc, UObject* context, USkeletalMeshComponent* Mesh1P, UCameraComponent* FPCC, UCapsuleComponent* capsuleself, bool SERVER) {

    const FRotator SpawnRotation = cRot;
    const FVector SpawnLocation = cLoc;

    if (GetWorld() != nullptr && SERVER)
    {
        FActorSpawnParameters ActorSpawnParams;
        ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;

        // spawn the projectile at the muzzle
        AgfProjectileHitscanB* prjHitscan = GetWorld()->SpawnActor<AgfProjectileHitscanB>(SpawnLocation, SpawnRotation, ActorSpawnParams);
        prjHitscan->spawn(FPCC, MuzzleLocation, capsuleself, [=](FHitResult fhrResults, UWorld* world) {
            if (fhrResults.Actor->IsA<AMyCharacterBase>())
            {
                AMyCharacterBase* Casted = Cast<AMyCharacterBase>(fhrResults.Actor);
                Casted->set_health(Casted->get_health() - 65);
                client_notify(Casted->get_health());
            }
        });
    }
        if (!SERVER) {
            // All of that animation and sounds and other client side stuff
        }
}

#

the way i do this is i use the same primary fire function for both the client and server side stuff because its just less code

#

this is really weird

#

so i have another weapon that spawns actual projectiles

#

if i try using it in this arrangement the actors spawn... but they seem to use some sort of weird logic

#

blueprints tell me that they have a 999 lifetime (which is what i set for debugging) but they despawn within 15 seconds

#

or that their spawn speed is 1000 units but they are going at some 10000

fathom aspen
# devout berry

It should be working fine. You don't have to call an RPC. OnUnPossess is called only on server on PC

#

And if it does get called on client, ask yourself how you destroy a replicated actor on client beforehand?(but quite sure it's not)

devout berry
#

I usually get weird behaviour when I destory a pawn directly after unpossess. For some reason I still need a delay.

#

(Unrelated to what you said. Did not know that event is allegedly only on the server)

dark edge
#

@fallow shadowIs the weapon owned by the client?

fallow shadow
#

yes

#

its an AActor component

#

defaultsubobject'd to the character

#

(client)

dark edge
#

Wait wtf your weapon is a component but you spawn an actor to shoot

#

this is all sorts of fucky lol

quasi tide
fallow shadow
fallow shadow
dark edge
#

@fallow shadowSo if you do a print string, does the run on server event fire as expected? Are you sure the problem is the actor being spawned, not the RPC to begin with?

fallow shadow
#

im not too sure but im pretty sure the RPC itself works as intended

#

i put a dummy variable in the RPC and every function it invokes to check if it has authority (its the server) and it always was

karmic shuttle
#

is there any way to make my replicated variable update instantly? a run on server event from the client doesnt update the replicated variable for almost 5 seconds

dark edge
#

It's updating slow because your net update rate on that actor is low

fathom aspen
#

ForceNetUpdate

karmic shuttle
#

im on a blueprint project, is it still accessible?

fathom aspen
#

It is

karmic shuttle
#

ah where would this be?

fathom aspen
#

On any actor really

karmic shuttle
fathom aspen
#

You call it after you change your replicated property/variable

karmic shuttle
#

hmm im running this after a cast

#

is this alright to run outside of the place im updating the variable? appreciate all the help

fathom aspen
#

Yes. Also make sure you are doing all this stuff on the server

karmic shuttle
#

yep its on a run on server event

eternal canyon
proven grove
#

Hello guys,
I am learning the multiplayer on Unreal and I was wondering if the server-side of a game was only the gamemode? I mean, I'm trying to make a little game with a dedicated server but I'm not sure where to put my server logic, even if the gamemode sounds logic to me. Will clients be able to access to gamemode too or it is only for the server?

winged badger
#

Check pinned messages on this channel, find Cedric's network compendium and read it

#

there are just too many questions to ask them here one by one @proven grove

proven grove
#

πŸ‘ I'll look for it, thanks

karmic shuttle
#

so i have a actor in the world which i want to display a clientside widget but the actor seems to be running on the server even though replicates is set to off

#

would anyone have any idea how i would make the client control the actor without replication?

crystal crag
#

With a dedicated server, even though there isn't a local player like with a listen server, is there still an instance of ULocalPlayer on there for each player actually connected to it, or does it only exist client side?

#

I'm guessing the latter, but was looking for confirmation

fathom aspen
fathom aspen
# karmic shuttle so i have a actor in the world which i want to display a clientside widget but t...

Replication set to off means your actor won't be replicated to clients if spawned on server. If it's spawned on client, then it's on client, you don't need to replicate it, though the server has no clue it exists, and it won't be synced using the replication system(if you want that). So replication set to off doesn't say anything about where an actor exists, so you need to know where it was spawned.

karmic shuttle
#

its preplaced in the world

fathom aspen
#

You don't create widgets for such actors

#

It just doesn't make sense

#

You create widgets for players so they are added on screen

#

Players through PlayerStates/PlayerControllers/Character have a client-side and so widgets can be created there and added to screen accordingly

karmic shuttle
#

its a vending machine which displays the players items and money clientside in the world

#

do you have another method in mind?

fathom aspen
#

Ah so it's not UMG

#

but 3d widgets

karmic shuttle
#

its umg

fathom aspen
#

Ok then create for the player

karmic shuttle
#

i create the widget on the player and pass it in to the actor in the world

fathom aspen
#

A vending machine can't interact with widgets

karmic shuttle
#

oh i have all the stuff set up and working but its the multiplayer replication thats weird

fathom aspen
#

It's a life saver

crystal crag
#

@fathom aspenI knew the dedicated server didn't have a player by default, but as players connect to it, I wasn't 100% sure (until now) whether or not a ULocalPlayer was created on the server side (and not replicated)

#

thanks for the reply

fathom aspen
#

until now means you still not sure? πŸ˜„

crystal crag
#

No that meant until you gave me your answer I was not sure

#

πŸ™‚

karmic shuttle
#

@fathom aspen i call this from the client

#

but it seems like these variables are serverside saved in the actor even though theyre just called from the client on remote

fathom aspen
crystal crag
#

If he is using a dedicated server he might have to check that checkbox that loads umg on the server side. I think it's unchecked by default

#

I haven't read the conversation chain, so sorry if what i said was way off point with where you are at with things

fathom aspen
#

load umg on server-side?

#

umg is client only

twin juniper
#

Any help is appreciated!

#

I'm of the opinion that the Simulated Proxies don't need to use physics at all, and the movement must be taken solely from the authority

#

can someone tell me how to figure out what functions should be server sided and client sided

crystal crag
#

Right but there is an experimental option to load it on dedicated servers

#

I'm pretty sure there is at least. I've never used it though

fathom aspen
twin juniper
#

mhm okay thank you

fathom aspen
crystal crag
#

Ufunction(blueprintauthorityonly) functions are only meant to be run on the server. Also yes, as wizard said, if the methods implementation is wrapped in a check for "Is authority" then it is meant for the server. If it checks if it's not server then it's meant to be run on the client

#

@fathom aspen ok, fair enough

pale pewter
#

Is it okay to use client shipping build to connect to dedicated server development build?

ivory island
#

How do we replicate the actors we created from the GameMode to the clients? We're using a node in the GameMode to create actors, but those actors are not replicated. We also replicate an array of actors, the array is replicated with 2 entries, but the references to the actors are gone.

fathom aspen
#

You can't have a replicated array/property in the GameMode as you can't access the GameMode from clients. It doesn't make sense to have replicated properties in the GameMode

twin juniper
nova wasp
#

unsure if it's a big help

twin juniper
#

Oh shoot I was right

#

I have to simulate movement manually on the simproxies

#

What's Vector Interp, or FMath::VInterp?

nova wasp
#

yep, there are two of them though

#

one is linear

#

i think that one is smoothed a bit

#

iirc...

twin juniper
#

Yes, Cubic Interp basically helps for when the ping is bad by making educated guesses about position and velocity

#

lerp/vinterp should in principle be accurate for extremely short client sim deltatime

nova wasp
#

my internet could help demonstrate the magic of long distance movement corrections

twin juniper
#

trust me, I'm Indian, I know

#

the switch between Slerp and RInterp is also illuminating

forest bolt
#

Hey Guys, I'm implementing an assymetrical jump in multiplayer and what I basically do is use the jump system already in the character and change the gravity scale and velocity mid-air to my needs. However, even with a reliable RPC sometimes there's some correction between the client (the autonomous proxy) who is jumping and the server, causing jittering. But looks completely normal for the other clients.

Is there anything wrong in using the gravity scale for this? Any insights on how to make it work?

forest bolt
#

Jump Started on the left. Server locations are displayed in red and client in green. They differ after the apex and then the server corrects it.

hollow eagle
#

Unfortunately there's no easy fix for that - you likely need to implement a custom FSavedMove to handle prediction and rollbacks.

#

Other workarounds may include custom movement modes or root motion, but those have their own complexities.

forest bolt
hollow eagle
#

fyi the important bit is the last section at the bottom - "Customizing networked character movement". The rest of the page is definitely useful as it goes into detail about how prediction works, but the actual things you have to do are just in that bottom section.

#

Also take a look at root motion sources (mentioned on that page) which may provide a simpler way to do things depending on how your jump works.

forest bolt
forest bolt
hollow eagle
#

it technically doesn't need to be from an animation if that's what you're thinking it is - a root motion source could be completely programmatic

#

I haven't worked with root motion sources much myself but you might be able to get one to just control vertical velocity while still allowing for normal air control.

forest bolt
#

I'll explore this first before trying the custom movement

hollow eagle
#

If it works (and I don't know if it will) it'll probably be much simpler. Good luck!

hushed spoke
#

Hello everyone, I have a switch weapon system that I’m trying to replicate. The player holds a child actor component, and when they switch weapons, it’ll set the child actor class to a different one. However, when I attempt to set the child actor class to a new one, all players are affected.

lament garnet
#

couple of things.. a system like this is better handled using repbotifies

#

and child actor component is trash, ill never trust it

hushed spoke
hushed spoke
winged badger
#

with CAC, you never know, might be modifying the CDO

lament garnet
winged badger
#

breakpoint in the c++ with debugger required

hushed spoke
hushed spoke
lament garnet
#

you need to store stuff like bullet counts outside tho, i had a struct for each weapon and a struct that rappresent the currently equipped one

hushed spoke
#

But as I said I read that if I spawn the child actor on runtime instead, then the server will modify the instances instead

#

Do u know how I could spawn the child actor component on runtime?

#

I tried it, but it wasn't spawning anything

lament garnet
#

just like any other component, you create it and register it to the world

swift turret
#

any idea what is in these packet?

twin juniper
#

Guys do j need to maintain seperate codebase for character that replicates and character that work in standalone game??

#

Can you tell me how to do it.Do I have to use of statements to achieve that

#

*if statement

#

Let's say my stand alone character can shoot directly while my multiplayer character needs to send an RPC to server and from that server need to get a multi cast function then he can show the visual effects.

#

I am talking about dedicated server

#

Then I think it won't work..

#

I wrote my character code assuming I am connecting to dedicated server

#

Thanks for advice.

red salmon
#

Can somebody help me with a link to a documentation/ tutorial about steam to ue4 security info, like how to make a proper moderation system or how to not leak IP addresses of players?

fallow shadow
#

OK-AY I am back

plucky prawn
fallow shadow
#

so i still have the issue where the code executes but nothing happens

#

i even stopped using the actor for hitscan bullets and now i directly do the line trace from the weapon actor component

red salmon
meager fable
#

How can I get my IP adress and port when running a dedicated server?

bitter oriole
meager fable
bitter oriole
meager fable
bitter oriole
#

Send HTTP request to said server

#

Read response

#

Alternatively since it's 2022, use sessions

meager fable
#

There is seriously no other way the IP and port where I'm setting up a server than making another server and checking where the response comes from?

twin juniper
#

Does UE5 replicate physics?

I saw in the handful of cases I have been diving into, that it usually isn't possible. I must use custom cubic interpolation logic for the simproxy.

Then there are things such as prediction for autonomous proxies that I don't know about. Any idea where to look?

bitter oriole
#

Your machine fundamentally does not has access to this information

#

You'd need to find the network access point and ask it (how?) its public IP

#

In practice both parts of this sentence are very big "how"

#

Hence the easy answer: go ping a server

twin juniper
#

Oh does OP trust whatsmyip or similar sites?

fallow shadow
#

also im back uhhhh so

#

i have confirmed that the code does in fact run on the server

#

the line trace just

#

doesnt happen

#

it doesnt happen

#

why

#

idk

#

it works if im on a listen server and the server tries doing it

#

but if a client it doesnt

azure viper
# twin juniper Please help!

Same problem, but use search. Better let client Calc physics and just submit rotation, velocity etc to server πŸ˜‚

chrome quest
#

@chrome bay sorry for the ping but if I want to NetSerialize FInstancedStruct without modifying engine files, can I just inherit the struct and add the function there?

twin juniper
#

I need to figure out how to adapt the sample and the off-the-shelf script

#

I'm using the simple Transform Replicator plugin from the chat. So far it fits everything I need a simproxy to do

#

I haven't explored any autoproxy-side logic, and I guess I need to look deeper.

#

My laziness and inertia are keeping me from it but I guess I can do it.

chrome bay
chrome quest
fallow shadow
#

gonna ask one more time because im suffering so much oh my god

#

i have a character that can fire their gun right

#

ok so it goes like this

#

character -> call server rpc -> weapon (actor component) -> do line trace -> respond to line trace results -> call client rpc to do all that client side stuff like sound and animations

#

The issue is that the line trace doesnt happen

#

actually nothing that interacts with the world works

#

spawning actors or line traces etc etc

#

and before you ask yes the server rpc executes and yes it is actually on the server

#

i checked with HasAuthority

rapid bronze
#

Did you set the component to replicate?

fallow shadow
#

uhh how do i do that?

#

bReplicates kinda doesnt work im p sure

chrome quest
#

SetReplicates()?

fallow shadow
#

Ill try

#

nope doesnt exist

rapid bronze
#

Component->SetIsReplicated(true);

fallow shadow
#

just as a PSA im inheriting from a base class that inherits from UActorComponent

chrome quest
fallow shadow
#

nope doesnt work

winged badger
#

whats the last point that executes?

fallow shadow
#

actually what do you mean "last point"

winged badger
#

put breakpoints along the execution flow

#

and see whats the last one that hits

fallow shadow
#

Ohh yeah then its the if statement where i try to execute the line trace

#

if the line trace hit anything it would've entered the if statement which doesn't happen

winged badger
#

so there you go

#

this should not be treated as a multiplayer, but a collision problem now

#

or math

#

depending which part of the trace is broken

fallow shadow
#

yeah but you see the thing is

#

if i draw a debug line with the exact start and end point that the line trace uses

#

it does hit stuff

#

both stuff i can see and cant see

#

and if i fire from the server on a listen server it works perfectly

winged badger
#

does it hit stuff, or does it go through?

fallow shadow
#

it goes through

#

by hit i mean i can if anything visualise the line trace and it definitely goes through a wall or character or anything else

winged badger
#

you'll need to show code, describin g it is very inefficinet

fallow shadow
#

Aight

#
    if (GetWorld() != nullptr && SERVER && GetOwner()->HasAuthority())
    {
        FActorSpawnParameters ActorSpawnParams;
        ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;


        FHitResult OutHit;
        FCollisionQueryParams CollisionParams;
        CollisionParams.AddIgnoredComponent(capsuleself);

        FVector Start = muzLoc;

        FVector ForwardVector = FPCC->GetForwardVector();
        FVector End = ((ForwardVector * 4000.f) + Start + FVector(0, 0, -100));

        if (GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_WorldDynamic, CollisionParams)) // The last breakpoint hit is here
        {
            if (OutHit.bBlockingHit)
            {
                if (OutHit.Actor->IsA<AgfClassBase>())
                {
                    AgfClassBase* achCasted = Cast<AgfClassBase>(OutHit.Actor);
                    achCasted->set_health(achCasted->get_health() - 65);
                    client_notify(achCasted->get_health());
                }
            }
        }

    }
dark edge
#

@fallow shadowIf you show debug on that trace does it look correct?

fallow shadow
#

wait a second debug on trace?

dark edge
#

const FName TraceTag("MyTraceTag");

World->DebugDrawTraceTag = TraceTag

FCollisionQueryParams CollisionParams;
CollisionParams.TraceTag = TraceTag;

#

incorperate that

fallow shadow
#

aye aye

#

wait what am i supposed to see?

#

i dont see anything when i fire

#

Oh ok i fired from server

#

its a white line and a red marker where it hits

#

uh

#

yeah this doesnt happen at all on the client

winged badger
#

and how would the client draw a line?

#

all you send it is the health

#

it doesn't have any hit information

fallow shadow
#

wait wait wait that's only there to update the hit clients' health

#

if i remove it everything stays the same except the client doesnt know its hit if it gets hit

#

the issue is still that the client just cant shoot

#

it calls a linetrace on the server

#

it just doesnt happen

#

Actually no correction

#

if i remove the client_notify line nothing changes

#

it just works as intended

dark edge
fallow shadow
#

wdym by "watch"

dark edge
#

literally watch

#

you're doing listen server right?

#

Although you really oughta just work your way back from that trace with breakpoints and figure out where it's busted at.

fallow shadow
#

which is just for testing the game is intended to be played on dedicated

#

im watching

#

im looking at the client that's shooting the bullet

#

no thin white line appears

#

nothing

dark edge
#

well then you're breaking before the trace

#

put breakpoints everywhere, track down the last on that gets hit

fallow shadow
#

aight

dark edge
#

Might be simpler to just print to log at each step calling out what the step is but you do it how you want

fallow shadow
#

might put a few breakpoints in the linetrace itself too

#

nope

#

nothing breaks

#

it follow throughs on the line trace

dark edge
#

you're probably not making it to the trace, put breakpoints/debug logs everywhere from the input to the trace

fallow shadow
#

on literally every line up to the trace i could

#

and it followed through

#

it entered the trace

chrome quest
#

@chrome bay, sorry for the ping again. I've been able to make a child instanced struct replicate. Works fine.

I'm assuming by editor support, you meant the make/break nodes you created right?

fallow shadow
#

hell i even had a few breakpoints in the trace method and it reached all of them

halcyon totem
#

ok I am trying to set my view pitch on event begin play but when I do its setting the view pitch on all the other players?

#

its not suppose to do this as its a child class. does anyone know why this is happening?

fallow shadow
#

@dark edge i finally figured it out

#

So the reason it doesn't work is really stupid

#

The way i do this is to avoid repetition

#

the RPC to the server is in the base character class

#

for some reason calling a function in a base class as an RPC doesn't work

chrome quest
#

πŸ€”

fallow shadow
#

i made a test function that does the same thing except its directly in the character class im playing as and it worked

chrome quest
#

That's strange.

#

It should work.

lament garnet
#

i should be able to launch two standalone games and connect between the two on the same pc right?

torpid nymph
#

when I start my game as a client, there's a few frames where I can see the map before I actually possess a character ( I start at 000), I want to hide that transition by immediately going to fade to black before I actually get a character assigned, I remember fixing this issue quite a while ago but can't remember how

lament garnet
torpid nymph
#

which fading thing? I don't get a proper fade until after a few seconds after I'm already in the game 😦

torpid nymph
#

so I still get a few frames of seeing the world before it does the fade

lament garnet
#

make your own gameviewportclient

torpid nymph
#

nice, will look into that

lament garnet
#

i need some help :\

#

im trying to joing a session between two standalone instances

#

when i join the server get this
[2022.06.21-20.07.07:218][145]LogNet: Verbose: UNetConnection::SetClientLoginState: State changing from LoggingIn to Welcomed
[2022.06.21-20.07.07:258][146]LogNet: Verbose: Level server received: Netspeed
[2022.06.21-20.07.07:258][146]LogNet: Client netspeed is 100000

#

and the screen go black

#

the second i alt-f4

#

i get this

#

[2022.06.21-20.07.42:744][319]LogNet: Verbose: Level server received: Join
[2022.06.21-20.07.42:744][319]LogNet: Join request: /Game/Maps/MainMenuMap?Name=ZENITH-xxxxxxxxx?SplitscreenCount=1
[2022.06.21-20.07.42:745][319]LogBlueprintUserMessages: [GameplayGameMode_BP_C_0] TempPlayerController_BP_C_1
[2022.06.21-20.07.42:767][319]LogNet: Join succeeded: ZENITH-xxxxxxxx

chrome bay
karmic shuttle
lament garnet
fluid summit
#

Hi everybody! any reason as to why a RPC (on server) called from a UI using a reference to a replicated actor is not working?

fathom aspen
#

If the actor isn't owned by the invoking client, the server RPC will be dropped

latent heart
#

You can only use the controlled pawn, player state or player controller. Generally.

twin juniper
#

what should I do if my multiplayer save game system won't load the save for clients and only loads it for the server player I can't figure it out.

latent heart
#

Maybe the loaded stuff isn't set to replicate?

#

Or something.

#

Or you're spawning it wrong.

twin juniper
#

like the variables you mean

fluid summit
#

what is your setup and what is your desired behavior?

twin juniper
#

just checked all my loaded stuff is set to replicate I'm new to unreal and followed a youtube tutorial for the multiplayer replication save and load system can I send blueprint screenshots to somebody and maybe they can help me out further if not it's fine I'm sure I'll figure it out eventually

fluid summit
#

You can post them here, no problem

twin juniper
#

alright sure

fluid summit
twin juniper
#

so this is what I have in my eventgraph and then I also have 2 functions which are savegame and loadgame which is here

#

and obviously I have a playersDB and a save game and all of that stuff cause the tutorial showed me that but anytime I load in the game it only saves for the server and not the client despite it being set to server and multicasted and originally it wouldn't load at all but I figured out I was missing a connection

#

sorry for the blurryness

#

also the stuff offscreen in the load game screenshot is just it connecting to the variables again like in the save game screenshot

fluid summit
#

Okey i can see a few possible problems.

  1. Put a few "print" to see if your methods are actually being called, you are making calls right after login and some actors may not be ready at that moment
  2. Your save/load call, even if doing multicast, should be done on Remote and pass the data to a RPC on server. Or do a RPC "On Client" and from there, pass the data to another RPC "On server".
#

Remember that your save slots are local

twin juniper
#

but atm I'm printing strings to see if the methods are being called

#

alright I put a few print strings and it seems that it's loading

#

and prints hello for all the print strings I put all along the blueprint so it must be the 2nd problem

fluid summit
#

Try to check this first or read the compendium by zedric

#

An overview of the essential concepts for writing multiplayer game code in Unreal, in under 25
minutes or your money back.

Sample project: https://github.com/awforsythe/Repsi/
Patreon: https://patreon.com/alexforsythe
Twitter: https://twitter.com/alexforsythe

00:00 - Introduction
01:24 - Net Mode
03:33 - Replication System Basics
05:13 - Acto...

β–Ά Play video
twin juniper
#

alright

#

oh I think I get it.

#

let me see...

fluid summit
#

From there, grab all the data that you need from the save game slot and do another event set to repliate "On Server" and pass all the data.

fathom aspen
#

You shouldn't be using GetPlayerXXX(0) at all. There are always other ways to get what you want

#

You got a Player param there which you can use

twin juniper
#

that fixed it

#

thank you so much

#

and yeah for now on I won't lol

#

actually nevermind it didn't fix it so I'll try acrisios suggestion next

#

and do some more research in relations to network replication

fathom aspen
#

Yes and you should read the compendium which you can find in the pinned messages

twin juniper
#

The gamedev.tv course and the compendium together made me understand the basics in less than 24 hours

fluid summit
#

The compendium and youtube made me understand that i don't understand the basic in less than 6 months

viscid night
#

Hi, I am facing an issue while updating AI's Widget component image across clients. What I am doing is one player enables the image of the AI's widget component but I am not able to replicate that across second client. I have read on forums that I can use a replicated variable and based on that update UI. I am not sure what a right approach would be to solve this.

fluid summit
#

what widget is it?

#

healthbar?

viscid night
#

Just an image that shows what State AI is in

fluid summit
#

if you want to change the widget directly, do a multicast.
The best would be to store a variable that determinates the state and do a OnRep.
With the OnRep you can check remote and update all the clients*

viscid night
#

I tried that. if the second client tries to update the variable, the listen client (client 1) doesn't receive the OnRep

#

Also AI cannot send a server RPC as it is not owned by the client and the server RPC will be dropped.

uncut schooner
#

Like an AI manager

viscid night
uncut schooner
#

Do the same function in the AI manager

#

And multicast there

#

Then it will happen on everyone

viscid night
#

Sorry I am not sure if I understood that correctly. I have this marking enemy function that calls Update Marked Icon event for the Current Enemy Character To Mark which further updates the widget component's image.

#

This marking enemy function is called in the third person character BP

fathom aspen
#

Multicasts are not for stateful events, so don't use them for sure. Use OnReps instead. AI states and data that players need to be aware of should go into AI PlayerStates. There is where you store AI data/states and it gets replicated to all players.

viscid night
#

Thanks for the response. How can I give an AI a PlayerState? I thought PlayerState is created for every player on a server!

fathom aspen
#

You do this bWantsPlayerState = true; in your AIController class constructor

viscid night
#

Thanks Very Much, I will try using the AI PlayerStates for storing AI data.

fathom aspen
#

Yes please. And just FYI, you can store them somehow in your player character class, but that's not where they are meant to be and it clutters that class for no reason

viscid night
#

Thanks Much, I understood

fluid summit
viscid night
dark edge
viscid night
fathom aspen
#

AController::GetPlayerState

#

Like you would get a player state for a PC

#

AIController inherits from AController

viscid night
#

thanks I got that but I couldn't figure how can I add variables n stuff to AI Player State as for a normal Player State for a PC we just create a BP and use it

fathom aspen
#

It's the same PlayerState class iirc

#

Yeah look into AController::InitPlayerState

#

That's the function that spawns the PlayerState

viscid night
#

thanks I will look into it

fathom aspen
#

AAIController::PostInitializeComponents what calls it

viscid night
#

thanks

glossy plover
#

What's the best way to tell all players to unprossess their characters (at the end of the game for example I want to freeze all characters?) Should I run a "On Server" event on the gamestate which is turn runs a "Multi Cast" event on the gamestate?

winged badger
#

no, gamemode should do that

#

and multicast is not required

#

also, default behavior will destroy the pawns on unpossess

glossy plover
#

I did it like this on the gamemode...this makes sense?

regal narwhal
#

Hi, Is there anyway to check if the session is still exist before join? I have basically list of session from the SearchLobby but the session owner might destroy before the client join.

fallow shadow
#

Ok i finally figured out why my character wont shoot

#

it cant draw a line trace from an UActorComponent

#

why????

fallow shadow
#

if i draw the line trace directly from the ACharacter it works flawlessly

quiet fjord
#

How can I block a game that is already started so that no one can join my game, would it be done with update session?

lament garnet
fallow shadow
#

server

lament garnet
#

reliable or unreliable

fallow shadow
#

reliable

lament garnet
#

i have no clue then πŸ˜†

#

reliable should work even if the component is not set to be replicated

marble gazelle
#

show some code^^

fallow shadow
#

this is the actor component declaration

    // Class weapon
    UPROPERTY(EditAnywhere, Category = Gameplay, Replicated)
    UgfWeaponBase* wSelfWeapon;

this is how i add it to the character

    wSelfWeapon = CreateDefaultSubobject<UgfWeaponRevolver>(TEXT("WEAPON"));
    wSelfWeapon->SetIsReplicated(true);

now on fire it runs a reliable server RPC that calls primary_fire from wSelfWeapon

#

in primary_fire is just a line trace that doesnt happen

#

but if i directly put the line trace in the server RPC it works

#

This is the server rpc

    const FRotator SpawnRotation = GetControlRotation();
    const FVector SpawnLocation = ((FPMuzzleLocation != nullptr) ? FPMuzzleLocation->GetComponentLocation() : GetActorLocation()) + SpawnRotation.RotateVector(vGunOffset);
        // If i just do a line trace here it will work properly 
       // wSelfWeapon->primary_fire(SpawnRotation, FPMuzzleLocation->GetComponentLocation(), SpawnLocation, this, skmMesh1P, ucFirstPersonCameraComponent, GetCapsuleComponent(), true);
    CLIENT_start_firing();
#

@marble gazelle

marble gazelle
#

So the RPC from the client -> server is received on the server. But the client doesn't receive the client RPC?

fallow shadow
#

no no that's not the issue

#

the issue is that

#

in the server RPC i call a function in an actor component

#

and in the function there is a line trace

#

the line trace straight up doesnt happen

#

but if i directly have a line trace in the server rpc it works

marble gazelle
#

works where on the server or on the client

fallow shadow
#

server

marble gazelle
#

is the server a dedicated one or just a master peer

fallow shadow
#

i test on listen servers but it happens on dedicated too

marble gazelle
#

Where should the line trace run, on the server or on the client

fallow shadow
#

ok wait let me do one more tldr; I want to do a line trace on the server:
this does not work:
input -> rpc -> weapon (which is an UActorComponent) -> line trace

#

but this works:
input -> rpc -> line trace

#

by works i mean it happens

marble gazelle
#

well then set a breakpoint in your weapon code and check what happens^^

fallow shadow
#

it executes

marble gazelle
#

do you use the same coordinates?

fallow shadow
#

i checked already

#

yep

#

same code even

marble gazelle
#

well without the actual code I can't tell. if you run the exact same code it should work

fallow shadow
#

i just copy paste it directly into the rpc

#

maybe if i did input -> weapon -> server rpc -> line trace

#

i gotta try this first then ill send full code if it doesnt work

marble gazelle
#

that shouldn't matter, the question is, what information is your function taking from the weapon, is it the same info you take within the rpc

fallow shadow
#

yes

marble gazelle
#

did you check the debug draws?

fallow shadow
#

yes

marble gazelle
#

does the ray cast from the weapon create a debug draw?

fathom aspen
#

Read the compendium found in this channel pinned messages

halcyon totem
#

I have created an 1d aim offset but I cant put any animations on there

steady cape
#

Is there a reason components might refuse to pass the multicast event to the clients, considering it and it's owning actor has replication enabled and no network emulation is done (a.k.a. no fakelag) ?

short walrus
#

Hello, does anyone know what is the best practice to replicate an array of objects (e.g. tarray of actors) from server to clients? For example, I'd like to replicate all the actors that are visible to my pawn and my team. If I try replicating an array like I replicate all the other stuff (Replicated annotation in property, entry in doreplifetime) it replicates the array size correctly, but all the pointers seem to be invalid

#

Is it a good practice to replicate array of objects? should i be replicating just object id's?

steady cape
#

That's one reason I could think of replicated arrays are all NULL pointers

#

Oh, wait, objects

#

Yeah, those don't replicate on their own, so they can't exist both on server and client unless you manually manage them on both ends with some mutual actor that does replicates

#

Or you can just attach them to actor's net driver using C++ if you know how to do so

pallid stone
#

Getting this spammed constantly in my log
LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: PaperSpriteComponent /Game/2DSideScrollerCPP/Maps/UEDPIE_0_2DSideScrollerExampleMap.2DSideScrollerExampleMap:PersistentLevel.worldProceduralGenerator_1.PaperSpriteComponent_75 NOT Supported.

It's being made in the onConstruct script, once made, I have createdSprite->SetIsReplicated(false); But still coming up.

Any suggestions?

#

Code is

            createdSprite->RegisterComponent();
            createdSprite->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
            createdSprite->SetIsReplicated(false); ```
short walrus
# steady cape Oh, wait, objects

Well for start I'm trying to replicate an array of actors. They all have replication turned on, and all are present on both client and server.

steady cape
winged badger
#

to replicate an Actor pointer 2 things are required, a pointer to Actor has been replicated and Actor itself has been replicated

uncut schooner
#

Hi, Is there a good way for the server to check if the clients input matches their direction, For example if The player is running forward then it lets you run but if not it stops you?

fallow shadow
#

does the steam subsystem work in PIE?

uncut schooner
#

Is there a replicated Inptut vector variable somewhere?

winged badger
#

no to both of you

quasi tide
#

Zlo is being efficient with their answers. 🧠

fallow shadow
#

can someone assist me in installing the steam subsystem

#

how do i use them

#

where do i put them

fathom aspen
fallow shadow
#

aye

fathom aspen
# pallid stone Getting this spammed constantly in my log ```LogNetPackageMap: Warning: FNetGUID...

As it reads. They are not network supported, and they can't be made such with ease afaik.
Pretty much like a decal component doesn't replicate. You shouldn't be replicating them even if they do support networking. You replicate the action you do. So let's say you are changing the SpriteColor. You change it after a player died for example. So you replicate a boolean bDied for example and when the OnRep is called you set SpriteColor

#

Replicate the action, not the entity itself

#

That way you save yourself some net bandwith, as you're replicating a simple data type

fathom aspen
steady cape
#

Not sure

#

That is kinda messing my other function call that is coming externally from my pawn (owner), and it's only serverside

#

Though, might recheck, maybe there are some switches

#

I'll delete them and see if it works

steady cape
#

Yeah, didn't really change anything

winged badger
#

component need to have replication enabled as well for that

steady cape
#

It is

fathom aspen
sinful tree
#

You may want to instead use an OnRep variable that you set on the server's begin play that can then trigger the OnRep function on clients as the actor (or component) begins on the clients once they are replicated to the clients.

latent heart
#

Except an onrep might not fire if the initial state of the character will probably include that changed variable if set on begin play

dark edge
#

Does it work if there's a delay before calling Yeah?

quiet fjord
#

a question how can I use the filters for when I create a room in multiplayer

#

I want to put that when my room is complete that room does not appear in the find lobby

winged badger
#

you update session data

#

and filter them out client side if they are full

#

you also have session search filters

#

that do that for you

lusty yarrow
#

Hey guys, not sure where to ask this, but I want to securely send API requests to my web api. I own a certificate on the server, how would I go about using it to secure the data sent by the client?

#

Do I have to get the cert file and manually add it using the openssl implementation in the engine?

steep panther
#

how the heck do I get from a UMG panel to my admin controller on the server to run a kick player from server?

winged badger
#

dedicated server?

steep panther
#

yeah

winged badger
#

you don't

#

it has no players, so no UI

steep panther
#

so not really possible to do an admin panel that can kick players from in game?

winged badger
#

make an admin controller

#

that gets instantiated with say, a specific login url

#

engine not happy showing UMG on dedicated servers

#

every accident i remember when something tried to show it there, crashed

steep panther
#

figured it out

#

im not saying to have umg on server

hallow sand
#

πŸ˜›

#

Told you it would work lol

#

Add server calls on player character, call character from UMG, bam server based UMG buttons

graceful breach
twin juniper
#

bool UVehicleMovementReplicator::ServerSendMove_Validate(const FVehicleMove& Move)
{
    return Move.IsValid();
}

void UVehicleMovementReplicator::ServerSendMove_Implementation(const FVehicleMove& Move)
{
    if (const float ProposedDuration = ClientState.ClientSimulatedDuration + Move.DeltaTime;
        ProposedDuration > GetWorld()->GetGameState()->GetServerWorldTimeSeconds())
            return;
    
    OwnerEp->SimulateMove(Move);
    ClientState.ClientSimulatedDuration += Move.DeltaTime;
    UpdateServerState(Move);
}

@chrome bay just using this instead for now. Overticked moves are ignored so no kicking. Moves need to be valid though: the check simply involves seeing if the thrust and control values are in [-1.0, +1.0].

knotty yacht
#

anyone experienced with beacons able to help me out, I'm still learning them?
I'm saving address to user cloud upon successful connection and then in the event of a crash I'm spawning a beacon and try to connect to said address to see if session still exists.
Now if it does, it connects and everything works, but if it doesn't, calling
InitClient(url);
returns true, but the the beacon will just try over and over without ever failing.
Anyone might know the reason?

quiet fjord
#

Guys, how can I block a game that has already started so that new players cannot join?

#

is it done with the update session?

steady cape
#

Now I see this is not true

#

Well, thanks for that, but now I have another issue: it seems like my map isn't being replicated at all

#

Or (might have asked that in the first place) there are some way I can make replicated array be in the specific order?

#

This would rid me of making this workaround

gusty raptor
#

Hi, i used to parse option strings for my custom terrain generator in the gamemode

#

however so i moved that code to the actual actor, so it works on clients to

#

Is it only possible for server to parse option string? how would clients be able to use them?

fathom aspen
#

Make into a replicated property in the GameState and your clients would know about it

fathom aspen
steady cape
#

So, if I have

0: Object1,
1: Object2
```it stays```
0: Object1,
1: Object2```across every machine it is replicated too
#

If I remember correctly, order of object doesn't persist with regular arrays

fathom aspen
#

Well there's no such thing to keep replication order. You never know how much time would it take each connection to get that replicated property

#

You should make it resilient with such cases

steady cape
#

So... I'm going to need to make one RPC with one object to be sent and then call it for every object in the array?

#

Because I need that order

#

Can't think of other ways to it

fathom aspen
#

Well here you face another problem. If you call the RPC from an actor that isn't relevant to a specific connection you never get that RPC fired in the first place for that connection

#

Read last pinned message in this channel so you get a better idea of when RPCs vs OnReps are used

steady cape
#

I know when those are used

fathom aspen
#

Can I ask what you are trying to do?

steady cape
#

This is a player loadout

#

Upon pressing a button it equips the next item in the array, wraps around to start when reaches end

#

Selection is determined by an int pointing to offset in the list

#

And this has to be persistent for every player because duh

#

Items of loadout are created serverside ('cause it's a set of actors that replicates) and therefore needs to be replicated

fathom aspen
#

Well array order is preserved on server and client if that's what you ask.

#

What you're looking for is an inventory system and by looking through this channel search you can find a plenty of examples

steady cape
#

But alr, I'll recheck

steady cape
fathom aspen
#

It's true. FastArrays don't preserve order for example but that's another topic

steady cape
#

I'll check and report later

thin stratus
#

Has anyone lately dived into making a Leap ability with GAS not end in correction-hell from the CMC?
Lyra uses RootMotionSource, but on Emulated NetSettings even Lyra gets tons of corrections (which is again super sad given this is supposed to be a proper example).

#

Or generally abilities with movement...

#

Why is this always such a pain with UE

#

Everything that doesn't go through ServerMove is just crap. And it seems like corrections hit super hard with RootMotionSource stuff

thin stratus
#

The only way I get this smoothly working is by ignoring client corrections until before performing the RootMotionSource and reenabling it with a Sync Node so both have perfomed the leap

twilit radish
#

I may be wrong but didn’t Lyra just massively speed up acceleration as their β€œdash”?

thin stratus
#

Na they have a GA Dash with a RootMotionForce

#

And an RPC inside that, they just didn't care I guess

twilit radish
#

Ah alright.

#

It's confusing though because ALyraCharacter and ULyraCharacterMovementComponent both do stuff with replicating custom acceleration πŸ€”

#

But I guess that's for something else then.

thin stratus
#

Yeah not sure

#

Might be for animation matching or so

twilit radish
#

Also, Cedric. Do you know how the CMC prevents speed hacks? I'm trying to better understand how the code in general works every now and then but every time I look at it I keep wondering what prevents people from doing stuff like that πŸ€”

#

All it seems to do to me is that it just limits the max delta time it calculates based off a client time stamp. But what is preventing me from sending a bunch of movement packets to 'simulate' high FPS games and then setting my client time stamp to look as is if it reaches that max every time on thus a high incoming rate?

pallid mesa
thin stratus
#

Hmpf...

pallid mesa
#

hahaha xD I know

twilit radish
#

The wonderful world of MP πŸ˜›

pallid mesa
#

works for dashes, leaps and such, other than that... might revisit the CMC, again, corrections should be almost non existant unless there are discrepancies

thin stratus
#

I used to make dashes by literally programming them into the CMC

#

But that was for games where you just had that one dash

#

Not a bunch of GAs that could all move you in different ways

pallid mesa
#

it just works, but programming a dash onto the cmc is a show

thin stratus
#

Yeah I flex with that when meeting the ladies

pallid mesa
#

yeah indeed specially with grandeous stateful systems

#

x'DDD

thin stratus
#

I just know that modifying the CMC state from outside is causing correction.
Changing movement speed via the GA (via some GE in the end that drives a speed attribute) is somewhat okay

#

The correction is invisible

#

But everything else feels like the wrong setup

twilit radish
#

Also different question. Is it possible to link the client time to the server time? So know when at a given point in time on the client what the server time is? The current system from Unreal is rather weird and suffers from latency :p

thin stratus
#

I asked that before to link up some timer

#

But I can't recall what the result was

#

I think I just sent a timestamp or so

#

Or wait

#

People said to just end the future timestamp

pallid mesa
#

yes

#

hang on, for you

thin stratus
#

So if you have a timer of 10 seconds, just talk about it in terms of CurrentTime + 10.
Then Server and Client show it correctly

pallid mesa
twilit radish
#

But what if the client's PC time is out of sync?

thin stratus
#

If you just use the replicated server time, it will get in sync eventually

#

You can also do what vori posted

pallid mesa
#

but the gamestate server time is inaccurate

#

most of the time is enough

thin stratus
#

It is enoug hfor most things yeah

pallid mesa
#

this one is more precise except for the first 10 seconds

thin stratus
#

If you play some random AAA game, you notice that the timers never exactly work

#

Respawn countdowns for example are always off by some degree

pallid mesa
#

clockos are hard

#
  • duck
twilit radish
#

xD

thin stratus
#

I think that falls under MP is hard

#

But you might be able to show that code snippet to the ladies

#

Or boys, fwiw

#

sigh Can't wait to get the office tomorrow to fix Movement Corrections caused by RootMotionSource in a GA that I didn't code and inherits from 3 freaking parent GAs (chain)

twilit radish
#

πŸ˜…

pallid mesa
steady cape
#

Looks like I've been mislead by some other source about this

#

Big thanks for opening my eyes

winged badger
#

it can happen but its not guaranteed

dark edge
#

@twin juniper move it here

#

OK so what's the design, replicated airplane movement?

twin juniper
twin juniper
dark edge
#

Are you trying to use physics or are you doing flying on your own?

#

You said simulating physics on a skeletal mesh so I'm thinking physics but what is actually doing the flying mechanics?

twin juniper
# dark edge Are you trying to use physics or are you doing flying on your own?

please describe this

void AFlightReplicationEntityPawn_Master::SimulateMove(const FVehicleMove& Move)
{
    const auto UpdateLinearVelocity = [this, &Move]()
    {
        EntityPawn_CurrentThrottle = FMath::Clamp(Move.CurrentThrottle + EntityPawn_ThrustValue,
                                                  -MaxThrust, +MaxThrust);
        const FVector TargetLinearVelocity =
            RootEntityBody->GetForwardVector() * (Move.CurrentThrottle * Acceleration * Move.DeltaTime) + GravityVector;
        EntityPawn_CurrentLinearVelocity = FMath::Lerp(
            RootEntityBody->GetPhysicsLinearVelocity(), TargetLinearVelocity, InterpolationConstant);

        RootEntityBody->SetAllPhysicsLinearVelocity(EntityPawn_CurrentLinearVelocity);
    };

    const auto UpdateAngularVelocity = [this, &Move]()
    {
        EntityPawn_CurrentAngularVelocity =
            -RootEntityBody->GetPhysicsAngularVelocityInDegrees() / AngularVelocityScalar * Move.DeltaTime
            + Move.ForwardVector + Move.RightVector + Move.UpVector;

        RootEntityBody->AddTorqueInDegrees(EntityPawn_CurrentAngularVelocity, NAME_None, true);
    };

    UpdateLinearVelocity();
    UpdateAngularVelocity();
}

that's your answer

dark edge
#

So it looks like you're simulating physics but NOT using physics to do the actual forces and torques, it's a weird setup but it can work i guess.

twin juniper
#
USTRUCT()
struct FVehicleMove
{
    GENERATED_BODY()

    // Perceived time-slices from every client Tick
    UPROPERTY()
    float DeltaTime;

    // Timestamp from when move began
    UPROPERTY()
    float StartTimestamp;

    // Per tick:

    UPROPERTY()
    float CurrentThrottle;

    UPROPERTY()
    FVector_NetQuantize100 ForwardVector;

    UPROPERTY()
    FVector_NetQuantize100 RightVector;

    UPROPERTY()
    FVector_NetQuantize100 UpVector;
};
twin juniper
dark edge
#

You're directly setting velocity but using torque for orientation

#

You should choose one or the other IMO. I'd prefer using forces and torques but it's up to you.

twin juniper
dark edge
#

Anyway, have you looked into the physics replication stuff? This can just work in multiplayer out of the box, depending on if you need prediction or not. For slow-responding things like airplanes, waiting 30ms for a response from your input is fine.

twin juniper
#

I have not.

dark edge
#

That's a wacky ass requirement if they want to directly override physics velocity but not physics rotation

twin juniper
#

Well the code looked way worse before what I did

dark edge
#

I'd hate to see it lol

twin juniper
#

the AngularVelocity was not even factoring in DeltaTime earlier

twin juniper
#

that's the only thing I'm being tested for

#

(it's an unofficial hiring test)

dark edge
twin juniper
#

so how will we ever get rid of that warning

#

I'm unable to test it properly because UE5 is set to lag if it's not in focus

#

fixed that, testing

#

oh no it's a mess I must sleep over (before midnight here)

dark edge
#

That entire architecture seems like a mess but the high level overview of how I'd do physics driven flight is like this

Tick -> Send input to serverside -> Calculate forces -> calculate torques(might not be necessary, depending on flight model) -> Apply them

#

The physics replication settings can keep the clients smoothly in sync with the server.

twin juniper
#

this is the movement side, yes?

#

this is pretty much exactly what happens btw

#
void AFlightReplicationEntityPawn_Master::BeginPlay()
{
    Super::BeginPlay();
    
    GetWorld()->GetPhysicsScene()->OnPhysSceneStep.AddLambda([this](FPhysScene*, const float FixedDeltaTime)
    {
        if (GetLocalRole() == ROLE_AutonomousProxy || GetRemoteRole() == ROLE_SimulatedProxy)
        {
            LastMove.DeltaTime = FixedDeltaTime;
            LastMove.StartTimestamp = GetWorld()->GetGameState()->GetServerWorldTimeSeconds();
            LastMove.CurrentThrottle = EntityPawn_CurrentThrottle;
            LastMove.ForwardVector = EntityPawn_RollResultantForwardVector;
            LastMove.RightVector = EntityPawn_PitchResultantRightVector;
            LastMove.UpVector = EntityPawn_YawResultantUpVector;

            SimulateMove(LastMove);
        }
    });
}
...
void AFlightReplicationEntityPawn_Master::SimulateMove(const FVehicleMove& Move)
{
    const auto UpdateLinearVelocity = [this, &Move]()
    {
        EntityPawn_CurrentThrottle = FMath::Clamp(Move.CurrentThrottle + EntityPawn_ThrustValue,
                                                  -MaxThrust, +MaxThrust);
        const FVector TargetLinearVelocity =
            RootEntityBody->GetForwardVector() * (Move.CurrentThrottle * Acceleration * Move.DeltaTime) + GravityVector;
        EntityPawn_CurrentLinearVelocity = FMath::Lerp(
            RootEntityBody->GetPhysicsLinearVelocity(), TargetLinearVelocity, InterpolationConstant);

        RootEntityBody->SetAllPhysicsLinearVelocity(EntityPawn_CurrentLinearVelocity);
    };

    const auto UpdateAngularVelocity = [this, &Move]()
    {
        EntityPawn_CurrentAngularVelocity =
            -RootEntityBody->GetPhysicsAngularVelocityInDegrees() / AngularVelocityScalar * Move.DeltaTime
            + Move.ForwardVector + Move.RightVector + Move.UpVector;

        RootEntityBody->AddTorqueInDegrees(EntityPawn_CurrentAngularVelocity, NAME_None, true);
    };

    UpdateLinearVelocity();
    UpdateAngularVelocity();
}
dark edge
#

That's a bit different, that's sending moves to the server, not controls

twin juniper
#

Ah, the moves are sent to the server in the replicator

dark edge
#

I'm talking about sending controls to the server.

twin juniper
#

intriguing, directly sending the controls?

dark edge
#

Yes or some derived data based on the controls. For my project, that's throttle, brake, steering angle, etc.

#

Mine's land vehicles though

twin juniper
#
void AFlightReplicationEntityPawn_Master::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

    PlayerInputComponent->BindAxis("Entity_Thrust", this, &AFlightReplicationEntityPawn_Master::OnEntityThrust);
    PlayerInputComponent->BindAxis("Entity_Yaw", this, &AFlightReplicationEntityPawn_Master::OnEntityYaw);
    PlayerInputComponent->BindAxis("Entity_Pitch", this, &AFlightReplicationEntityPawn_Master::OnEntityPitch);
    PlayerInputComponent->BindAxis("Entity_Roll", this, &AFlightReplicationEntityPawn_Master::OnEntityRoll);
}
...
void AFlightReplicationEntityPawn_Master::OnEntityThrust(const float ThrustValue)
{
    EntityPawn_ThrustValue = ThrustValue;
}

void AFlightReplicationEntityPawn_Master::OnEntityYaw(const float YawValue)
{
    EntityPawn_YawValue = YawValue;
    const FVector TargetVector = RootEntityBody->GetUpVector() * (EntityPawn_YawValue * YawRate);
    EntityPawn_YawResultantUpVector = FMath::Lerp(FVector::ZeroVector, TargetVector, InterpolationConstant);
}

void AFlightReplicationEntityPawn_Master::OnEntityPitch(const float PitchValue)
{
    EntityPawn_PitchValue = PitchValue;
    const FVector TargetVector = RootEntityBody->GetRightVector() * (EntityPawn_PitchValue * PitchRate);
    EntityPawn_PitchResultantRightVector = FMath::Lerp(FVector::ZeroVector, TargetVector, InterpolationConstant);
}

void AFlightReplicationEntityPawn_Master::OnEntityRoll(const float RollValue)
{
    EntityPawn_RollValue = RollValue;
    const FVector TargetVector = RootEntityBody->GetForwardVector() * (EntityPawn_RollValue * RollRate);
    EntityPawn_RollResultantForwardVector = FMath::Lerp(FVector::ZeroVector, TargetVector, InterpolationConstant);
}

here are the controls per se

twin juniper
#

maybe the nomenclature is whacky because of gamedev.tv influence

dark edge
twin juniper
#

they look like control variables for "heading"

dark edge
#

If it's desiredheading that's fine

#

if it's simulated heading then that's weird, it's mixing controls and results together

twin juniper
#

the values called "yaw, pitch, and roll" here are actually just Throws, so they scale a rate and change the direction by influencing each axial component of the heading vector

#

(afaik)

dark edge
#

But anyway, the physics replication system can do the heavy lifting of keeping things smooth for you, assuming the physics movement is what's considered the canonical end result. I'd dig into those settings, there's a ton of tunable parameters.

twin juniper
#

Please point me to the docs, I'll look into them in the coming week after I fail to make this example work within Saturday

dark edge
#

My project has buildable land vehicles and the basic system is exactly what I outlined and it works perfectly. The only downside is there's NO lag compensation, but lag compensation in physics is horrendously complicated.

twin juniper
#

I believe we are indeed looking for lag compensation when we talk about smooth movement

#

unless I misunderstood that requirement because of my inexperience

dark edge
#

lag compensation is when you press jump in a game and you jump instantly on your screen, with the server still being authoritative

#

it's HORRIBLY complicated for physics driven movement

twin juniper
twin juniper
dark edge
#

Watch the GDC talk on Rocket League networking if you want, but anything with prediction is totally overkill for an airplane game. Airplanes don't respond that quickly anyway.

twin juniper
#

well I'm on a less wrong path then

#

I'm still not able to turn off that warning

dark edge
#

These are the tuning settings I was talking about

#

Read the source code on them, it's pretty much the only documentation

#

The stock settings are pretty strict

#

Like you don't care if an airplane is within 1cm of where it should be

twin juniper
#

afaik there was also some random error which crashed the engine when I wasn't looking

#

I will seriously consider sleep now. There's a whole IRL to deal with outside this multiplayer sample.

pallid mesa
#

oh movement replication!

#

really good luck with that πŸ˜„

regal geyser
#

What is the smart way of synchronizing all created teams by server (When player connects he is assigned a random team inside GameMode)?

My approach was to change RepNotify variable inside GameState with all created teams, and when new team is added to the array, every client would be notified. The issue is that I need to update HUD of all clients to display all currently created teams. But I'm not sure how I can access local player and his HUD component from inside of a GameState RepNotify event.

thin stratus
#

Two ways

#

Either you ensure that your HUD is easily accessible e.g. via the PlayerController

#

So you can just get the PC and access the HUD in the GameState

#

Or

#

You add a delegate/event dispatcher to the GameState

#

And bind/listen to that in the UI

#

Which is what I would do

regal geyser
#

Thank you! Okey I'm going to try the latter but just out of the curiosity, how can I get local PC inside of a GameState?

#

Tried using get controller and cast it but that failed

thin stratus
#

GetPlayerController should work fine

regal geyser
#

With 0 as default index? It says it should be local player but I've read multiple times that this doesn't have to be true sometimes when connecting to server

thin stratus
#

For a local player it will be correct

#

They only have their own PC anyway

#

ListenServer should also get their own with thay

regal geyser
#

Yes thats what I thought so, okey thanks a lot for help!

dawn delta
#

If I switch to source engine build on 1 machine to build dedicated servers, do I need to do that on all workstations to maintain multiplayer compatibility?

nova wasp
#

or you could just distribute the packaged build?

#

or package the engine itself to save some time

#

unsure if it will consider it a different version, my assumption is yes

dawn delta
#

ya, just tested and it considers it a different version. I didn't want to have to have source on all workstations for quick testing, but maybe thats best way.

#

was saving packaging/distribution for bigger testing runs

nova wasp
#

distributing your engine build should not be too difficult

#

as that will change less often than your game project, I assume

dawn delta
#

What I really want is to connect to the server via PIE. That works with the PIE that is source built. That doesn't currently work with the PIE that is not source engine built.

twin juniper
dark edge
twin juniper
#

So I can just focus on the movement logic and not worry about the rest at all, right?

#

Could you provide me a sample under 1-2 KLOC which shows a vehicle being replicated over a network? CMC is way too big and covers a totally different beast in my eyes.

nova wasp
#

huh?

#

well, I guess there's smoothsync

twin juniper
nova wasp
#

they base it off of the source engine movement replication

eternal canyon
nova wasp
#

ruh oh

#

nevermind then πŸ˜…

eternal canyon
#

from what i remember the person plans on making a server auth version

#

at some point

nova wasp
#

at the very least one could yoink the interpolation I suppose

twin juniper
twin juniper
nova wasp
#

well, as mmmm says it's not authorative out of the box

#

but I suppose it would be a nice thing to study

#

certainly beats the default interpolation

twin juniper
#

the problem we're dealing with has a domain far surpassing our needs and understanding of it

nova wasp
#

...is this even a competitive game?

twin juniper
#

yes, it's meant to be a 5v5 team deathmatch

#

obviously it sucks arse rn

#

I mean I made the gameplay worse than what my in-charge gave me

nova wasp
#

I guess my point would have been to maybe just half ass it and go client side movement if it was pve

twin juniper
#

I'll let you read the repo

nova wasp
#

I don't have time to read it and I'm really not an expert here, I'm just saying what I would try first

twin juniper
#

okay, so TL;DR it's server auth

twin juniper
#

I removed the replicator
alas

tiny anchor
#

What's a good way to attach an item to my character's hands and have it properly setup for FPS, while having it correctly set for others to see (multiplayer)?

twin juniper
twin juniper
tiny anchor
#

I don't understand how CMC could help me there πŸ€”

fathom aspen
tiny anchor
fathom aspen
#

You literally said what you want. You already have FPHands set as OnlyOwnerSee, and I think any attached actors to that mesh will have the same behavior(if not you do it explicitly). Same goes for TPMesh you have it as OwnerNoSee and you attach that item to it and you get same behavior

#

The functions you need to know are literally SetOwnerNoSee, SetOwnerOnlySee

#

That's at runtime

#

Or you do it in details panel

tiny anchor
#

So is it only one item, or do I need to duplicate it?

fathom aspen
#

You can't have same item attached to two different meshes

#

So the answer is yes

tiny anchor
#

Oh alright, that makes sense

#

Thank you very much

eternal lake
#

Hello there! πŸ˜„

AController::Pawn is set to REPNOTIFY_Always.

Will this cause Listen Servers to receive an OnRep call when changing the value (on the listen server)?

violet sentinel
#

no, call onrep in mutator explicitly if you want it on server too

eternal lake
#

Cheers

faint gust
#

I’m having an issue where animations are not played on the other client on the server how would I go about fixing this

chrome bay
#

It's commonly used when clients are modifying replicated variables (which is usually a big no-no, but sometimes neccesary)

#

And because the whole controller->pawn replication is a complete mess

#

But Epic dare not touch it these days

twilit radish
#

What's the issue with it?

twin juniper
twilit radish
#

But what's the issue in the first place?

twin juniper
#

My code is quite amateur and doesn't exactly do the job right.

twilit radish
#

It kind of depends on what you want to achieve I suppose but from what I see a lot of games just take the approach of having a small buffer of locations and then working their way through that with a lerp for example or some different smoothing algorithm. There are definitely other techniques like extrapolating which you can do if you want but just using a lerp with a buffer does the job most of the time good enough.

#

It's a bit difficult to know for us how to exactly apply that to your code though. Which is also mostly up to you I would say πŸ˜›

eternal lake
chrome bay
#

Ah no, in C++ world RepNotifies are only called client-side, since they are "receiving" the value. Blueprint rep notifies are a giga-hack

static sable
#

hi, I have my server actor controlled by a behavior tree. Using my playercontroller I send a move command to that actor.

But when that actor turns, it's very choppy, because only the data that come from the server update the actor's location/rotation. I would like to run a local instance of behavior tree on client actor so it updates client actor accordingly and sever eventually just corrects the actor's location/rotation.

How to do it since there is no controller associated with the client actor therefore client actor's behavior tree doesn't even start?

quasi tide
pallid mesa
#

xD

faint gust
#

i have this respawn code witch works fine in singleplayer but in multiplayer it dosnt and i have tried to get the controller from the player input but it just causes an error

rapid bronze
#

Don't multicast a spawn

#

Only RoS

#

Plus you using PlayerController0

faint gust
#

yeah and i dont know how to get the number of the player that died

rapid bronze
#

No need for a number

#

You can just pass the controller ref of the one who died

It just depends on how you have it all setup

#

And where

normal quartz
#

still new to networking myself, but i believe its because controllers aren't replicated, so everyone's own controller including the server is index 0 as far as they know, it's used for local splitscreen multiplayer, which is why you need the ref

faint gust
#

im running it like this would i get the ref with get controller and put it there?

rapid bronze
#

No, on a server Index 0 is the first player

Locally it's always yourself

#

Where is that

#

In what class

faint gust
#

the player class

fathom aspen
rapid bronze
#

The GM may not even be accessed

#

GameMode can only be called on server

faint gust
#

ahh

#

so the etire system dosnt work with MP

rapid bronze
#

Read the compendium

normal quartz
#

but maybe that explains what i'm missing about how controllers work here - this spawn stuff in the game mode works for everyone except the server. if i run a server and 3 clients and i put a print string here, i get four hellos, but the server never gets a pawn or a UI, and the first client (the second one to join, so should be index 1 in that array) spawns at spawn tag 0.

#

what's in the screenshot is almost exactly the same as a video tutorial i followed and it works there

rapid bronze
#

If needed, GetPlayerController is good to get all players in the GameState

GameState has an array of PlayerStates that you can iterate and use the index of that in GetPlayerController to iterate all controllers

#

Alternative that storing everyone in the GameMode OnPostLogin

fathom aspen
faint gust
#

ok what im not understanding is how to request the server to do anything if gamemode is only on the server and i dont know how it would even be posible foe be to do this

rapid bronze
fathom aspen
normal quartz
fathom aspen
faint gust
rapid bronze
#

RPC

normal quartz
faint gust
#

what is RPC

rapid bronze
#

But I mean, the player shouldn't tell the server how it dies anyways

#

Server gotta know

fathom aspen
#

But the tl;dr for you should be don't follow tutorials

#

They are your worst enemy

#

Read the compendium if you haven't got to do so

rapid bronze
#

Always understand what you're doing if you plan to follow a tutorial so you know when they do something wrong

Blindly following will only cause problems

fathom aspen
normal quartz
faint gust
#

ok so i shouldnt trust the client telling the server hey respawn me right

fathom aspen
rapid bronze
#

Never trust the client

fathom aspen
#

You got PlayerArray in GameState

faint gust
#

right so i need an event to know when somthing gets destroyed

fathom aspen
#

It's already handled for you client and server side

normal quartz
#

i'll certainly swap it over to that logic, i guess i just wanted to know for future reference what the problem here was if possible. thanks a bunch all for the help

fathom aspen
faint gust
fathom aspen
#

Though it's not replicated

faint gust
#

ok so the server has all player states correct

fathom aspen
#

Correct

faint gust
#

so i can loop through all players checking for it being destroted corredt

fathom aspen
#

Well that's obviously not the way you would do it

rapid bronze
#

Wha

fathom aspen
#

How do you know if a player died?

#

Think about it?

#

He gets damaged for example and then you check health on server and if health is below or equal zero then he's dead

faint gust
#

so i check for death conditions instead of just death

fathom aspen
#

Correct. You make your functions fire on events

#

Player died -> do this

#

Not: check on tick if player died then do this

#

That's what is called event driven code

rapid bronze
#

Since it's always ran on server, everytime you take damage check if health below equal 0 aka you died, if true you can run a HandleDeath event, even on the GameMode if you have a common death function handle

faint gust
#

the thign is the only death condition is falling off the world what event would i use for that

rapid bronze
#

So you don't have health and such? The only thing that can happen is getting destroyed?

faint gust
#

there is no health currently

#

im working on other stuff right now

fathom aspen
#

FallenFromWorld?

rapid bronze
#

FellOutOfWorld iirc

fathom aspen
faint gust
#

is there a version for blueprint or would i have to make a c++ accsessor

fathom aspen
#

Nope

#

But you don't need it to be exposed

#

You can have a some volume under your level

#

That does that collision handling for you and acts accordingly

faint gust
#

and have a BP on the volume that when its touched it runs an event on the gamemode

fathom aspen
#

Well you already have an event called HandleDeath or OnDeath, so you access the GameMode from that actor and call it

#

Or call the interface function that does the death, and then OnDeath is called automatically

#

Plenty of ways really

faint gust
#

what?

#

i dotn see an event on the gamemode for death

fathom aspen
#

You make it πŸ™‚

#

It's game specific

#

But it should have a point where you call Destroy for some stuff

faint gust
#

ok so i would make the volume make the gamemmoe run that function right?

fathom aspen
#

Yes

faint gust
#

so what kind of voume should i make?

#

there are ALOT

rapid bronze
#

Volume overlaps player, you get mister player from the overlap, you run the death function through the GM

#

Box volume

faint gust
#

i dont see a box volume

rapid bronze
#

You have to make a BP

faint gust
#

ahh

rapid bronze
#

Then add it

faint gust
#

box collision right

rapid bronze
#

Yea

faint gust
#

so i just make a cube and scale it right

rapid bronze
#

Yeah

#

How UE handles it is that it checks if you are under a certain Z but you don't have to do that

faint gust
#

should i make it thick so it things dont phase though it

rapid bronze
#

I mean sure

normal quartz
#

in case it helps anyone else, got the logic switched over to using the game state's array, but the issue was the timing; i was collecting the Player Starts on BeginPlay and the server was logging in too quickly before it was done πŸ™ƒ made sure that step was done before trying to spawn anyone

faint gust
#

like this right?

#

it works πŸŽ‰

twin juniper
#

Also please ping me as I'm not frequenting the channel.

sinful tree
# faint gust like this right?

This is not a good way to do it. What you've done is open a means for players to teleport around the map whenever and wherever they want to as you're allowing the client to tell the server that they want to teleport and the destination.
The "BeginOverlap" event that triggers your code should be already running on the server - all you should need to do is use a "Has Authority" switch and use the "Authority" path to connect with your existing code, and you can then remove the "Run on Server" part from your "Respawn Player" event.

Correcting as I've suggested will mean that only the server will ever check what is happening on the overlap and determine what to do next instead of relying on the client to tell the server to respawn the player and where to move that player to.

faint gust
sinful tree
#

The idea of the authority switch is you're checking if the current instance of the game has a certain level of permission over the object. The "Has Authority" should be placed immediately after your "OnBeginOverlap" event.

faint gust
#

done! so that should fix it right

sinful tree
#

Yes, but also make sure to change the "Respawn Player" event. It shouldn't use the "Run On Server" option.

faint gust
#

what should it use?

sinful tree
#

Whatever the "None" option is. The event should just run, doesn't need to be an RPC.

faint gust
#

πŸ‘

sick acorn
#

Hello, I have an object in the game that rotates. this is a simple square 50 by 50 by 1 meter, and when I'm on it, the stob pulls me from the old side to the side ...

The closer I am to the pivot of the component, the less jerks how to fix it?

dark edge
sick acorn
#

understand ?

#

I really need to know why this is happening.

dark edge
sick acorn
#

i use the simplest sync code

dark edge
#

Show your code. Are you using the CMC or no?

sick acorn
thin stratus
# sick acorn

It might make more sense to AddWorldRotation instead of setting it and it utilize DeltaSeconds instead of WorldTimeSeconds

#

Has anyone checked the progress on the NetworkPredictionPlugin lately?