#multiplayer

1 messages ยท Page 365 of 1

compact gulch
#

we ended up using ec2 now with a node.js... we're going to test this.. we might move to GoogleCloud soon and use the serverless node.js

#

lol

#

yeah it's annoying to set it up

thin stratus
#

@merry hemlock RepNotify is just a way to react to replication.
Setting a Variable to "Replicate" will send the value to the clients if the server changes it (not other way round).
RepNotify does the same + calling the OnRep function when the value arrives

#

For you here, we use RepNotify, so you can react to the replicated text and set it to the Renderer

#

@compact gulch Yeah heard of that approach. We use GameSparks + GameLift

merry hemlock
#

ah, otherwise I'd have to have some Tick or check of the variable's state

compact gulch
#

we sorta decided aginst gamelift due to the SDK requirement.

thin stratus
#

GameSparks does Matchmaking, asks GameLift to start a Server and send the Info, and then GameSparks passes that to the players and they connect

merry hemlock
#

RepNotify is a bit like binding widget text's to a variable function?

thin stratus
#

I wouldn't start comparing this to anything

compact gulch
#

yeah we're doign that. Gamespark matchamking , gets EC2 to launch server and pull players in.
we did extra logic to make sure we always have fresh instances available

#

we hardcode the limit like 5 sessions per instance. when 3 is filled up we boot another instance.

thin stratus
#

It's what I said. Variable gets replicated to Client if Server changes its value.
If the value is 10 and server sets it to 11, the clients will receive that after a few milliseconds (ping).
OnRep just makes sure that, in addition to just replicating the variable, it also calls that function when the value arrives

#

There is not much more to say about that

#

@compact gulch Yeah that's basically what GameLift does anyway

#

I didn't want to reinvent the wheel

#

And the costs for the instances are the same iirc

compact gulch
#

have u tried google cloud?

thin stratus
#
  • GameLift has the scaling
compact gulch
#

we're going to explore both and compare the cost

thin stratus
#

It's client stuff. I haven't been able to test anything else

compact gulch
#

ohh

#

i c ic

thin stratus
#

I know that both are expensive :D

compact gulch
#

makes sense

#

i believe aws is more expensive than cloud

thin stratus
#

Can be

merry hemlock
#

ah...just trying to make sure i'm understanding it as well as I can

thin stratus
#

I'm just happy I figured out how to use GameLift from GameSparks

compact gulch
#

i've a few ppl who are using cloud . just for the IAAS part. they mentioned AWS is significantly more expensive

thin stratus
#

So I don't need the SDK

#

Simple HTTP Requests were enough

compact gulch
#

right.. i see you're the authority on this topic

#

eveywhere i search i see your name

#

gamespark and gamelift

#

haha

thin stratus
#

I was probably the only one at that time doing that

compact gulch
#

probably

thin stratus
#

Everyone else has either their own backend or is quiet about the process

compact gulch
#

i also see Ahsan Muzaheed a lot

#

not sure if you've seen him a bit

#

it's so hard to find someone who has skills on this..

it's ehtier you , RyanJon2040 , or the Muzaheed guy

thin stratus
#

Ha, Ryan

#

Talked with him about it. He had the node.js solution. I explained him the GameLift solution iirc

merry hemlock
#

If I am spawning actors in the game mode, what is a good practice to get into for determine their spawn transforms? I don't want to hardcode values, so should I just GetAllActorsOfTag and then use the transforms of the different target points? Or is there a better way?

thin stratus
#

Na, that's fine

#

You'd want to only get these once though

#

So save them in an array

#

And onPostLogin, simply do "Length of Array == 0? -> GetAllActorsOfClass"

#

And if it's not 0, then well, you got points

merry hemlock
#

Is it normal to have a branch where you basically set aside all the server functions? That is where I'd do the initial GAAC

thin stratus
#

Well this is not directly Server vs Client code

#

You are simply doing "First Player" vs "Rest of Players" here

#

And the FirstPlayer happens to be the Server when using ListenServers

merry hemlock
#

Which for me is going to be the use case

#

again, this is mainly to get a few initial customers to get enough money to pay a professional

#

One of the other things I wasn't clear on is having an actor placed in the level do things to the players

#

versus having the gamestate do it

#

I have functions designed to teleport players

#

Just want to make sure they replicate

winged badger
#

you don't need functions to replicate to teleport players

#

just need bReplicateMovement = true

merry hemlock
#

that means if I can see each actor move around, if they get teleported that automatically works?

winged badger
#

you would need RPCs only if you wanted some additional stuff

#

like waving at the other guy and then going poof

merry hemlock
#

but the teleport would work

#

awesome

#

How do events from gamestate replicate to client? I'm confused about ReplicateOnOwningClient? What if you want the gamestate to target a specific player controller?

icy nacelle
#

Hey all! I've got a slight problem here with server replication.
Currently reconfigurating the controls for when the players are aiming and not aiming. Everything works perfectly for the individual clients, but setting the actor rotation is not replicated to all clients. Is this because its an actor and NOT a pawn? Even though they're pretty much the same thing? Bit confused at where I'm going wrong. Hopefully someone has encountered and got over this problem before and might be able to shed some light on where I'm going wrong. Thanks!

merry hemlock
#

grandmaMax what is your character movement from? if it is from default pawn it won't replicate

#

I see 3rd person so that's shouldn't be an issue though

mild hull
#

when you spawn the VR player, save that controller and than you can call any event that is set to execute on client by using that controller

merry hemlock
#

How would I access as a client if it is in game mode?

mild hull
merry hemlock
#

How do I get the reference to the VR controller if it was spawned in game mode? just cast to game mode?

mild hull
#

on server any actor can access it

merry hemlock
#

but if I'm a client playercontroller?

mild hull
#

the one on the server or client side?

merry hemlock
#

the client side

#

if I want to make say, the server stuff do things, from the client's side....i'm using gamestate as my access point because most of my data is there

mild hull
#

put a event into controller, set it to execute on server and in that event you access the gamestate

icy nacelle
#

@merry hemlock Why dont it replicate if its default pawn?

merry hemlock
#

@icy nacelle Epic make the character movement module, for the character type actor, they made it replicate automatically

#

they didn't do that for the default pawn

icy nacelle
#

Thats strange, because my movement was always replicated while using thirdpersoncharacter

merry hemlock
#

because you were using the right character movement

#

try it with a default pawn and see what happens when you move

icy nacelle
#

I think I'm confused at how to use the default pawn?

merry hemlock
#

How do I reference other player controllers from the gamestate, (if i am a client) remember it is a unique test case

#

That's my biggest problem I need to be able to target a specific player spawned by game mode, and sometimes these events need to be trigger from the client, on the gamestate

#

Do I just pass the PC reference to game state?

#

From the game mode

mild hull
#

you dont, you add Event that executes on server into the controller, on client side you call that in your own controller and in that event thats execute on the same controller but on serverside you can send infos to gamestate or the instructor

merry hemlock
#

I seem to be able to call events on the gamestate though (from the client)

#

I just cant target the correct player because player controller 0 is always client

mild hull
#

than set 2 refs on the server when you spawn them (instructor and VR), but based on the nice drawing thats pinned here, gamestate is there but not owned by client

quartz vector
#

I don't think Server has PlayerController for every Player

#

I thought PlayerState was for replicating things about Player

manic pine
#

server has every playercontroller, everyone has every playerstate

quartz vector
#

ah ok

#

so using "GetPlayerController" with index 0 only works on Client i assume

manic pine
#

right, if its not splitscreen

merry hemlock
#

I might just use the Unreal Web Server instead of messing with replications...I've got way too much iteration to test

merry hemlock
#

I just need to figure out a way to KNOW on my gamestate what pawn references are where so I can target specific players (and do this from a client)

mild hull
#

create 2 variables, InstructorController and VRController, set them and use them to get to the owned pawn.

#

if you want to send something to the instructor pawn you would call a event on your controller or pawn that is executed on server and from there send it to the instructor pawn, by using the ref to InstructorController

merry hemlock
#

I'm working on it, I'll put screenshots and maybe you'll see what I'm doing wrong

#

my problem is I only seem to be targeting one player controller, the first one aka server

#

ack, one plroble mis my pawn doesn't have input from the client

candid merlin
#

Hey guys, got a problem with actor replication that i can't wrap my head around for a few days. Any help would be much appreciated! From the PlayerBP i have a 'Run on Server' Event that spawns an actor (weapon) and i attach both meshes with Attach Component inside the WeaponBP, i also set the owner in WeaponBP (set owning pawn function is called from the PlayerBP). I have the FPS mesh set to only owner see and the 3P mesh set to owner no see. This all works perfectly when seen on the server. I geuss this is becouse the server is the owner. How do i fix it so it's propely shown for all connected clients?

merry hemlock
#

Did you check Replicate on teh Actor Class Defaults I mean?

candid merlin
#

Yep, replication seems to be working fine. I just don't know how to set the visibily options. Currently clients see the first person weapon version, not the third person one.

#

If i run a dedicated server with 2 clients, it works fine for each client but when they look at eachother you see the first person mesh, not the third.

merry hemlock
#

specifically they spawn and attached weapon and change it's visibility based on replication

candid merlin
#

Thought my search these last few days i watched that video, but i'll take another look.

#

Yep that sadly doesn't help me. They don't fiddle around with Owner No See / Owner Only See problems ๐Ÿ˜ฆ

merry hemlock
#

IsLocallyControlled I think is what you want to explore

#

I suck at replication and you'll see probably about 100 questions from me in the next 24 hours but based on everything peopel have tried to help me with, I think IsLocal is what you need to look into

candid merlin
#

Thanks, i'll look into it.

mild hull
#

you only need to set owner no see and owner only see, exactly the same for everyone

#

its the owner, the actor knows who owns him and changes based of that

candid merlin
#

That was what i was thinking aswell Mizuki. I just don't seem to be able to do so. I think this is becouse the owner of the spawnned weapons is the server?

mild hull
#

you set owner when you spawn

candid merlin
#

Both the Set Owning Pawn and Attach to Owner functions are in the Weapon Base BP

mild hull
#

the spawn node has owner pin

candid merlin
#

do i set a reference to Self? i think i have tested that before

mild hull
#

self should work, isnt the 2nd attachToComp overriding the first?

candid merlin
#

Nope, when i remove the Owner No See / Only Owner See from the Weapon meshes i have 2 weapons in my hands on the server.

#

Thanks btw Mizuki. Does anyone else have any idea?

compact gulch
#

we're facing an issue where DIrectX runtime is alreayd installed on a VM ( Aws instance ) , but unreal still says directx runtime component required.. any idea how to solve this.
@thin stratus see if you know about htis? we manage to install it , DXDiag is showing DX12 , restarted , but still unreal won't launch , asking for directx runtime

vital steeple
#

anyone know why a replicated actor appears to be destroyed by players correctly when i do a normal multiplayer test in PIE (with dedicated server), but when i host a server as a player, then join with my extra PIE clients, the same replicated actor is only seen as destroyed by the server?

#

(the server that i create manually for my test is a dedicated server, though the player appears to spawn anyway)

merry hemlock
#

hey man

vital steeple
#

sup blake ๐Ÿ˜ƒ

merry hemlock
#

Trying to think, I suck at replication

#

Make a event that replicates on all controllers with a print message that says the Actor was destroyed

#

and call that from whever you destroy the character

#

just make sure you can get the events to all link up and replicate

vital steeple
#

hrmmm

merry hemlock
#

it's multicasted isn't it?

#

when you destryo it

#

show me the destruction

vital steeple
#

its not multicasted because its the server destroying an unowned replicated actor

merry hemlock
#

the actor itself is replicated but i'm not certain the destruction is

vital steeple
#

i thought i didnt have to multicast unowned replicated actor stuff

#

hrm

merry hemlock
#

totally guessing here man, you could be completely right

vital steeple
#

i guess its weird that it works with PIE multiplayer?

#

thats whats messing with me

#

but as soon as i host a server it doesnt work

merry hemlock
#

what happens when you set the destroy event to multicast

vital steeple
#

testing now! ๐Ÿ˜ƒ

#

same thing

#

weird

#

but i see the building destruction notifications

#

(like kill messages in CSGO or w/e)

#

weird...

#

damn... i really thought i had replication figured

#

i think youre right though. you need to multicast on the replicated actor, which seems odd

merry hemlock
#

i hope someone corrects me if i'm wrong

#

but i think it's because even though the actor is replicated, it's destruction is not

#

like the server sees it as gone

#

but the clients still do

#

here's another test

vital steeple
#

yeah for some reason i thought that a replicated server owned actor would automatically replicate down

#

becuase thsta how it works in PIE default mp test

merry hemlock
#

when the actor doesn't get destroyed, can you make it change ANYTHING on teh client's side, meaning, does any of the movements move or anything update, or does it just freeze

vital steeple
#

nothign happens

#

hrm

merry hemlock
#

try this

#

do a function that makes the actor send something to the client, like update a value continuously

#

and see if that update keeps happening even if it is destroyed

#

it SHOULD stop if the replication stops, (because the server destroyed the actor)

vital steeple
#

ok ๐Ÿ˜ƒ

merry hemlock
#

again, i'm here on this channel because I have no idea what I'm doing

vital steeple
#

no worries, when it comes to replication, it seems like no one really knows

#

๐Ÿ˜ƒ

#

yeah confirmed

#

client thinks it still exists

#

thats so weird

#

it works fine for players

#

just not for buildings

#

both use the same health component

#

i should probably just sleep on it. i been working on this for hours. thanks blake!

#

your advice to verify what the client sees was helpful, verified that it exists and it wasnt just some other weird replication thing

#

the actual destroy script isnt replicating for some reason

merry hemlock
#

np good luck

vital steeple
#

ill def let you know when i figure it out

merry hemlock
#

yes please

vital steeple
#

we should chat about your project as well. ๐Ÿ˜ƒ

merry hemlock
#

trade show in less than a week

#

I'm offering it for sale as a class, I have enough content to do that, Fire Chief's don't have to buy any hardware and I give them a credit for the class if they end up buying the hardware

vital steeple
#

well i hope it works out. its a cool concept

merry hemlock
#

thanks, i'll let you know how it pans out....no idea...I'm the only VR thing there as far as I can tell...

vital steeple
#

weird

#

works fine in 4.18 but doesnt work in 4.17

#

thats... unsettling?

reef ingot
#

Hey, I'm following the dedicated server guide on the wiki and trying to build for version 4.18 are there any specific target file instructions I have to follow

reef ingot
#

^^Ignore that i played around and think i've got it building

inner iris
#

@reef ingot usually good to check the corresponding ShooterGame build with whatever engine version, and see the targetfile they use there

ripe raptor
#

Anyone here had issues with spawned actors crashing PIE in multiplayer, in RepLayout.cpp

#

RepLayout::InitFromObjectClass to be specific

old abyss
#

If I run two instances of my packaged game and CreateSession in one instance, and JoinSession in the other, it reports back that it was successful, but the two players can't see eachother. Is this purely a replication issue or is there more that I have to do to get MP working? If I play using the in-editor preview with 2 players selected, they both spawn correctly and can see eachother, which makes me think it's not a replication issue.

#

Trying to JoinSession or DestroySession without first creating a session on either of the running games will fail, making me think they are successful in interacting withe achother somehow. One game knows that the other has created a session. Really new to networking, apologies for the question.

old abyss
#

Also if I CreateSession with game window A, and then JoinSession with game window B, then destroy session on game window A, B's player will respawn back at the start after 15 seconds or so. I don't know what to make of this, they are definitely communicating but can't see eachother in a packaged game. Any tips? EDIT: Fixed, I was missing an Open Level node with "listen" in the options

ripe raptor
#

apparently

#

replicated variables in blueprints make PIE crash when debugging multiplayer

#

how jolly

opaque tinsel
#

im running into a weird problem, my server see the client character playing the forward animation with its back towards the server player when the client is running towards the server player

manic pine
#

rotate mesh 180 degrees around Z?

opaque tinsel
#

but it works for the server, its just what the server sees the client

glossy wasp
#

@opaque tinsel Are you replicating the rotation in BP? Only position is replicated and thats if you check the box on the actor

manic pine
#

yeah but assuming hes using same pawn for client and server they should be equal unless he adjusts mesh rotation with hasauthority

#

could it be there's already a pawn in your level that one of the playercontrollers take possession of, instead of using bp to spawn it

coarse condor
#

Alright, Iโ€™m going to be honest. I have no clue how to make a Multiplayer game in UE4. Can someone please help me out? Iโ€™m looking to make a multiplayer game that can be played over multiple computers that arenโ€™t on the same network.

hazy haven
#

@coarse condor for a holistic solution, there are some good courses for ue4 multiplayer on udemy

inland sun
#

How can you delay a players spawn into the map until they finish loading? Im using world comp to allow spawning and teleporting to diffent areas. They spawn and begin to load even if they are not loaded and can cause them to fall thru the world.

coarse condor
#

Thanks @hazy haven

thin stratus
#

@inland sun Well, you can always set the DefaultPawnClass to None in the GameMode

#

And then control spawning them yourself

#

OnPostLogin in the GameMode gives you the PlayerController of a Player that successfully logged in and joined

#

You can either spawn and possess the character there or save the Controller reference and do it later

#

@coarse condor Simply read my Compendium

#

It's pinned to this channel

#

No need to instantly pay money on some courses

calm zenith
#

is it considered legit to sandbox two steam accounts on one computer just to do network testing? will I not get any of the accounts banned? Or maybe there is a better way to test?

coarse condor
#

@thin stratus how would I find a server online to use?

#

Or do I use a hosting site?

quartz vector
#

where do I add PktLag=# to simulate network lag

jolly siren
quartz vector
#

yeah the PktLag stuff in that blog didnt work

jolly siren
#

it goes over 3 places you can put it

quartz vector
#

I tried console and defaultengine.ini

#

and found forum post of peole saying it's not working and to just use "Clumsy"

jolly siren
#

it's always worked fine for me

#

and I use it a lot

#

what value are you setting it to?

quartz vector
#

I tried 120 and 1200

#

someone said it's disabled for certain builds

#

it looks to disable network commands on either
(UE_BUILD_SHIPPING || UE_BUILD_TEST)

jolly siren
#

you aren't doing this in the editor?

quartz vector
#

yeah im in editor

#

I'm probably just doing something wrong

twin juniper
#

hey guys so like

#

im trying to figure out how to make my setup reload the gun

#

the montage needs to be a multicast

#

but the issue is that

#

we are reloading "twice"

#

cauhsing the player to lose twice the number of bullets

#

because its multicast

#

is there a way to do this better?

#

never mind

#

i got it

#

๐Ÿ˜‰

#

added this lol

thin stratus
#

@ANGUs GAMEs#1421 To host a Dedicated Server, you would need to rent a server where you execute the Server on.
ListenServers are Players who host themselves. Or you provide players with the DedicatedServer exe, and let them create their own

#

@twin juniper To save nodes, you can always drag out the "MontageToPlay" (or other pins) pin and do "Select"

#

And then plug the Enum into the Wildcare pin of the select node

#

That way you only need one PlayMontage node

twin juniper
#

@thin stratus true

#

but other than organizational purposes it doesnt actually make a difference right?

thin stratus
#

Yes, right*

#

Also

#

You don't want to go back to the Server after the Multicast

#

The Multicast should be only for visualy

#

You can query the length of a Montage and put up a delay

#

It's helpful to learn a tiny bit of C++ to look through the shootergame weapons

#
  • For better organization, you should make one base class for weapons that handle all the shooting, reloading etc. and have variables for their animations etc.
#

Then you can simply create a child of that base and only need to fill in the reload montage in the class defaults

#

This way you don't have to go back to your code if you add a new, similar functioning weapon

twin juniper
#

yea

thin stratus
#

But only make a child and adjust the values

twin juniper
#

thats what i did

#

but the montage is just separate

#

coz i only have 3 montage types

thin stratus
#

Fair enough

twin juniper
#

๐Ÿ˜›

agile crane
#

Hey, can someone help me how to make an infection game mode? If you dont know how the game mode works let me explain: Normally 12 people are recommended to play in, two or 3 people start as an infected randomly, and the other ones are survivor, once you die you become infected, the last survivor will win. And it must check if you started as an infected last round, if you did 100% chance you won't spawn as an infected next round but if you died and become infected you could still spawn as an infected, but every one start as an infected randomly, and there's a timer in the game mode, about 4/8mins recommended.

#

If someone can help me then it will be sooo appreciate ๐Ÿ˜„ I've been trying to make that but I cannot find a way.

brittle sinew
#

That's a very large questionโ€”if you can break it up into small parts that are somewhat easily attainable, you will both most likely be able to do it easier and also get help more easily ๐Ÿ˜ƒ

quartz vector
#

How do you set elements in a TMap?

agile crane
#

You mean I should repeat in small parts?

quartz vector
#

when I try with Replicated component turned on it crashes

severe widget
#

Breaking the message into parts isn't what he means

agile crane
#

oh

#

I don't really understand then

#

But do you at least read the full question? Or no?

severe widget
#

lol the amount of text isn't the problem.

#

Its like

brittle sinew
#

Yeah, I meant the scope of the question, not its literal size, hehe

severe widget
#

Hey can somebody help me construct a space program? I have diet coke and mentos

quartz vector
#

Ok I'm stuck here:

{
    UEquipItemComponent* EquipComp;
    if (UEquipmentFunctionLibrary::IsEquipItem(EquipItem, EquipComp)) {

        FEquipmentSlot& EquipSlot = *EquipmentSlots.Find(EquipComp->EquipmentType);
        if (EquipComp->EquipmentType == EquipSlot.EquipmentSlotType && !IsValid(EquipSlot.EquippedItem)) {
            AActor* EquippedItem = EquipComp->OnEquip();
            FEquipmentSlot Slot = EquipSlot;

            EquipSlot.EquippedItem = EquippedItem; // THIS IS WHAT CRASHES IT!!!!!!!

            return true;
        }
    }
    return false;
}```
#

EquipSlot.EquippedItem = EquippedItem crashes editor when running dedicated server and only when "EquipmentManagerComponent" is Replicated

#

otherwise this all works fine

agile crane
#

uhhh, I mean, the game type in a nutshell is just two people start as an infected randomly, if that's what you guys are able to help me then please tell me how thanks. If I can at least make that its alright

quartz vector
#

This is run from server by a wrapped Server, Reliable, WithValidation function

agile crane
#

Like, how do I be able to get the two random players?

#

Its just what I'm basically asking.

brittle sinew
#

See, that's a much better question to start with ๐Ÿ˜ƒ

agile crane
#

๐Ÿ˜ƒ

#

Can you help me? PLease ๐Ÿ˜„

#

I'll be happy if someone does

fossil spoke
#

@quartz vector It would help if you posted an little about the crash as welll.

quartz vector
#

There are no errors

#

and when i debug in c++

#

no access violations or anything

fossil spoke
#

Check your crash dumps?

quartz vector
#

where's that at so i can check real fast

fossil spoke
#

Saved folder

jolly siren
#

probably just a NPE because you aren't validating EquipComp against null

quartz vector
#

checking

#
{
    OutComponent = nullptr;
    if (!IsValid(Test))
        return false;
    OutComponent = Cast<UEquipmentComponent>(Test->GetComponentByClass(UEquipmentComponent::StaticClass()));
    return IsValid(OutComponent);
}```
agile crane
#

Can anyone help me please what do I need to do to get two or 3 players randomly? I'm sorry if I'm asking too much but I tried but I have 0 idea how I could do it, I dm UE4 on twitter they read my messages but do not respond.

quartz vector
#

let me generate another dump i cant find anything in this one

#

[2018.01.13-21.35.58:231][769]LogWindows: Windows GetLastError: The operation completed successfully. (0)

#

that;'s last line lol

fossil spoke
#

@agile crane RandomIntInRange with 0 being the first element and your PlayerCount being the last?

#

Simple stuff really that can be easily googled

agile crane
#

oh, I need to do random int in range and switch on int?

fossil spoke
#

@quartz vector Yes its probably telling you that it crashed successfully lol, look further up the log.

quartz vector
#

I typed some explicit language right before that function is called

#

and it outputed to log right before the crash

#

I see the item destroy on client due to replication

#

and then crash

agile crane
#

Is there anything more I need to add after that? cause it prob won't check who will be being infected or smth. I'm kinda confused

fossil spoke
#

You just answered your own question just then didnt you?

#

Check if they are infected?

#

If not, do something else

agile crane
#

Wait, I'm gonna try smth if it cannot works I'll ask again ๐Ÿ˜ƒ

fossil spoke
#

This is why @brittle sinew asked you to expand your question into smaller more easily tackled problems

agile crane
#

alright!

fossil spoke
#

If you slice up your main problem into smaller parts it makes it ALOT easier to create an final solution by solving the individual parts seperatly instead of trying to figure out an grand master solution

agile crane
#

okay

brittle sinew
#

Also, if I were you, I would just try to map out what your flow needs to do, even outside of UE4

fossil spoke
#

Think about the process of what would have to happen to an Player from beginning to end in order for the game to begin.

agile crane
#

I'm confused right now, I added random int in range, what do I need to add more? A switch on int?

#

I cannot find the way to make it with switch on int really, I'm so lost

#

how to I switch on a random player? Cause I think I can make it if there would be a node like, switch on players who's connected, and with the random integer in range could switch to anyone and become infected

fossil spoke
#

RandomIntInRange gives you an random integer, you use that integer to "select" an Player that has been designated as that number in the list of Players that are connected.

agile crane
#

yeah I know

fossil spoke
#

GameState holds an Array of PlayerStates, you could also use the GameMode to track incoming PlayerControllers

agile crane
#

Oh

fossil spoke
#

These both represent Players in the Server

#

You use that Random Integer to select one of those Players

#

PlayerArray->Get(RandomInteger)

agile crane
#

Do I need to do like, Get game state>get player array ?

fossil spoke
#

I dont know, its your code, try it out and see what happens.

agile crane
#

I cannot find a player states with random int nor player array. Can you help please?

fossil spoke
#

Ok mate seriously. This is easy stuff to google. You need to go back and watch some basic Youtube tutorials on working with Blueprint and get your fundamentals down.

agile crane
#

uhhh, if you say so

fossil spoke
#

Looks right to me

#

Only problem you have is, if you dont have 12 Players your going to get an Index Out of Range exception

agile crane
#

I will setup a save file for the max player for sure, like, when I change the max player value it will save the value and I'll set the save to a variable and the variable will be the max player, hard to explain but I know the way.

#

Right now I'm trying to find a node to convert array to int or smth, is there a switch on array node that can exist? Just asking.

agile crane
#

@fossil spoke Alright. I'm stuck since a long time, I searched for the solution but no help really, I really cannot find the way to make my thing, I don't know what to try anymore. I'm sooo confused and lost, if you could please help me or teach me cause I will never progress right now.

fossil spoke
#

How new to UE4 are you?

#

When did oyu start using it.

agile crane
#

I've been using UE4 since 2 years

fossil spoke
#

Are you an programmer or an Artist?

agile crane
#

both, my game aren't really big nor I tried multiplayer. My game are just fnaf fan game

fossil spoke
#

You need to go back and research the fundamentals of Blueprint and Programming in general. I cant hold your hand throughout the entire process. This is really simple stuff and the only way you will learn is if you apply yourself and do the research.

#

I dont have the time to tutor.

agile crane
#

I did all research but I cannot find a way dude! I searched like; Choose a random player or get players connected or get player array random and such

#

If you could just please tell me which node I need to put really quick it would be so appreciate dude! Its depressing for me

quartz vector
#

@agile crane maybe you need to narrow your scope

#

If you can't isolate the pieces that you need to put into place at least at a foundational level

#

then you need to figure out why that is

#

my guess is you have a broad thought, don't know where to start, and jumped straight into Unreal with the first mechanic you could think of

#

and probably haven't put anything down on paper yet

agile crane
#

uh. Maybe. Did not really understand what you mean tho

quartz vector
#

I mean you do not go into Unreal thinking "I'm going to make a Zombie survival horror MMO"

#

you will end up all over the place

agile crane
#

maybe, but there are some stuff I don't understand that I need help with, duh

quartz vector
#

you need to narrow your scope down because then you will have more specific questions

#

like what?

agile crane
#

Just look up on what I asked earlier

quartz vector
#

I see questions that are along the lines of "Which button do I push to make an infection game"..not to be harsh

#

like someone else is going to design this for you

agile crane
#

no

#

I was asking which node I need to put

#

but I asked for the infection game type earlier

quartz vector
#

is it multiplayer?

#

i assume so

#

there is not a simple node to do what you are wanting to do I don't believe

#

it requires you to some how store which pawn class to spawn for each player

#

and then the Server should spawn these pawns where they should spawn and make the playercontrollers possess the correct Pawns

#

i BELIEVE this replicates, if not, you will be coding that too

#

how you do all of this is up to you

agile crane
#

I know, I was just asking how can 2 random players out of 16 can spawn as an infected or just a different character

quartz vector
#

You can get all actors of class "PlayerController" from server

#

that should get you an array of all the PlayerControllers on server

#

and you pick 2 randoms, spawn their zombies or whatever, possess them and take them out of the array

#

then spawn all the others as their characters

#

off the top of my head

#

u probably do this from GameMode

#

if you have spawn points...you can get all of those to determine where to spawn ppl

agile crane
#

sounds like what I wanted to do, but on array I cannot find a random node or anything that can switch from the character

quartz vector
#

err pulled that on google...apparently it has some issue

agile crane
#

oh okay

quartz vector
#

save random int as local variable

#

and use it for outputs

#

but should work

#

and should be Length-1 for max

#

Also

#

Random Integer In Range

#

probably even easier

agile crane
#

sounds good

quartz vector
#

just right click in BP

#

turn context off

#

and type "Random Int" you find the same things

agile crane
#

but what do I will need to use next? Switch on int?

severe widget
#

so uh.

quartz vector
#

what

severe widget
#

If you took that macro and modified it so it didn't have a bug, you could use that to randomly get anything from an array of that thing.

#

there is no next step

#

for getting a thing

quartz vector
#

There's a node already lol... "Random Integer In Range"

#

maybe didn't exist at the of that post

severe widget
#

lmao

#

its a convienience macro

quartz vector
#

yeah it gets the array element i believe

severe widget
#

its not like you can't use it because a subset of its nodes exists

quartz vector
#

ya

severe widget
#

iunno good luck w/ him then

agile crane
#

Its really hard, and so confusing to make that but with what you said I learned that you can put length for put random integer in range

quartz vector
#

we all come from different backgrounds in these things but imo you shouldn't try to make a game at all right now

#

you should follow the tutorials on youtube

agile crane
#

Okay then..

quartz vector
#

good luck

agile crane
#

thanks

quartz vector
#

can you replicate Actor spawn from Client -> Server or only Server -> Client
like if u spawn something on client (doesn't spawn on server) and then call Server_SpawnThing(ClientSpawnedActorRef)
what happens
does Server spawn something and then replication spawns another on Client?

manic pine
#

clientspawnedactorref has no meaning on the server

#

it'll either be null or just a meaningless pointer

#

what youd rather wanna do if going down this route would be to spawn on client, tell server to spawn, wait for client to replicate, then intercept that replication and e.g. make it invisible or whatever, and just have it reference your client-only object

#

alternatively replace client-only object with the newly replicated one

quartz vector
#

that would be a "client authoritative" inventory so to speak?

#

I'm either going to go a route like that, or spawn a DummyItemVisual on client add...like a simulated Add

#

this thing pulses

#

and when same function is called on server, it actually adds item, which would replicate to client and tell inventory UI to re-build widgets

#

which would remove the dummy visual and replace it with real one

#

not sure which system is better....

#

essentially the Server is "holding" the items pending Release

manic pine
#

client authoritative inventory sounds dangerous, since you could potentially let clients crash server

quartz vector
#

yeah

manic pine
#

but doing 'client prediction', like ACharacter does for movement, is fine obviously

quartz vector
#

seems like that's a more difficult approach

#

in that my my inventory bags will have some sort of access time that is server auth'd

#

nothing crazy, just don't want a twitch inventory

#

so I have to show something to illustrate this to begin with

#

plus, I don't know how you would intercept Server replication and swap client and server item...seems like a lot of cleanup that isn't needed with this other approach

#

with same result to user

#

"Dragged item...item pulses for like half a second... item adds"

manic pine
#

you might just want to let client alone handle access time here...

#

it could be hacked so client can access inventory immediately, but so it could with server auth as long as client actually has the inventory data

#

unless you put checks on moving/using objects(to see if inventory is open on server)

quartz vector
#

on client the item wasn't going to actually be added at all

#

FInventoryItemInfo was going to be put into a ItemsPendingDrop Array

#

so not actual item just the image/size data

#

this was going to generate a false Widget showing where Item is being added

#

while sending the request to server, which does all of the validation

manic pine
#

right, but the client could still say he moved it to the server without opening inventory

quartz vector
#

that happens too when picked up from world

#

no UI open

manic pine
#

yeah

quartz vector
#

but ItemsPendingDrop would be stored on the ItemContainerComponent

manic pine
#

anyway brb, off to dinner

quartz vector
#

so it's active even when out of UI

inland sun
#

If Anyone is available to answer a few questions for me on some basic stuff in UE4 multiplayer please DM me. I am trying to get going in the right direction to get replication learned and so forth to fix my multiplayer project.

brittle sinew
#

I reckon you'll get both more eyes on the question and more help if you ask in here ๐Ÿ˜ƒ

#

(plus, it might help others who see it)

winged badger
#

i am using a seamless travel in my MP game, however, if the client manages to load the map before the host does none of the actors placed in the level are in sync, any ideas?

thin stratus
#

The Server shouldn't be able to load the map before the host o.o

#

Are you sure you are still connected properly?

winged badger
#

yes, and late joiners have no problems

#

actors spawned in the level work ok as well, for all clients

thin stratus
#

That I haven't heard of yet, sorry

twin juniper
#

hey whats cheaper for a mmorpg, more peformance friendly. 1. Tree animated by Shader. 2. Tree baked animation...

bitter oriole
#

Shader animation ?

#

But that's a strange request

#

You'll have millions of larger issues before you get to that

quartz vector
#

Why is my Server reliable function not calling from reference in UMG?

mild hull
#

umg is client only

quartz vector
#

Oh you can't even call Server function?

#

like this isn't allowed?

mild hull
#

is itemcontainer a widget?

quartz vector
#

no that is a Component

mild hull
#

thats ok

quartz vector
#

the Server function doesn't even call

mild hull
#

does the server know that you own that component?

quartz vector
#

good question, how on earthw ould i know that

#

similar code works from a UObject I have

mild hull
#

who created the component

quartz vector
#

Oh wait

#

this runs SERVER_TryAddItem which spawns the inventory item and adds it

thin stratus
#

Component needs to be Replicated and set on an Actor that the Client owns

quartz vector
#
                                                                        UItemContainerComponent * OriginItemContainer)
{

    if (CanAddAt(Item, CompartmentIndex, SubCompartmentIndex, SlotIndex)) {
        if (IsValid(OriginItemContainer)) {
            OriginItemContainer->Remove(Item);
        }
        TryAddAt(Item, CompartmentIndex, SubCompartmentIndex, SlotIndex);
    }
    
}```
thin stratus
#

Otherwise Server RPCs are dropped

quartz vector
#

let me double check how the actors are setup

#

and components are replicated

#

Now I'm not sure who owns these at this point lol

#

Server spawned them all

thin stratus
#

Client owned is usually the Controller

#

And everything controller owns

quartz vector
#

Ahh i never set an owner i dont think

thin stratus
#

Means if the Server spawns it, you need to give it the Controller of the CLient as owner

quartz vector
#

or i did but i didnt pay any attention to it

thin stratus
#

This is not a container that sits somewhere in the world that multiple people at the same time can loot or?

quartz vector
#

not at this point no

#

it's in a player inventory

#

if (GetOwner()->Destroy(true, true)) {
return Cast<AActor>(GetWorld()->SpawnActor<AInventoryItem>(InventoryItemClass, FVector(0.f, 0.f, 0.f), FRotator::ZeroRotator));
}

#

but yeah i didn't set any owner

#

this runs from server

thin stratus
#

Alright, cause you should always split your Inventory into "Inventory" and "Manager"

#

Where the Manager sits on the PlayerController and just gets "InventoryA" and "InventoryB" passed and performs the moving of items etc

mild hull
#

and cant you set it to only relevant to owner?

thin stratus
#

So you can always go from UI to Server

quartz vector
#

i do have an InventoryControllerComponent

thin stratus
#

Cause owner can only be one person at a time and a chest/container that two people are working on would then break

quartz vector
#

but i think it's on the Character right now...need to move it to PlayerController

#

it just adds references to all of the Equipped Item's with ItemContainer components on them

#

for easier access

#

but I was going straight through the Container through the UI

#

makes sense

thin stratus
#

Yeah, if that container is on the Player, no problem

#

If it's on a chest that the Server or only one person at a time can own, you are f*cked

#

Cause then only one player at a time can own and work with it

quartz vector
#

it's on an Actor

#

shit

#

However...

thin stratus
#

You need a Manager class that you pass teh Container reference

quartz vector
#

this is a newly spawned Actor so can I set a different Owner?

thin stratus
#

Which would sit on the Controller

#

You can

quartz vector
#

so let me tell you the events that happen

thin stratus
#

You could do that on overlap with a collision or linetrace etc

quartz vector
#

all of these have ItemContainerComponents to make this simple

#

EquipItem_World is already present in the level

#

Player interacts with it...SERVER_TryEquip is called

#

Item_Equip is created and EquipItem_World is destroyed by server and it is equipped

#

so PIckup is similar to that

#

it is routed through server which calls some functions to convert it to an Inventory item basically

#

so if I understand what you are telling me

#

When the Server spawns this new item with and ItemContainer and equips it

#

the client doesn't own it or something?

#

and therefore can't work with it through UI?

#

and the SERVER rcp's on ItemContainer will be dropped

#

And this works because it is routing through possessed Character's "InventoryController" instead of directly with ItemContainers?

mild hull
#

cant you test with getOwner?

thin stratus
#

Like this, it doesn't matter if it's on the Player or some actor

#

You always root your calls through the manager on the PlayerController that allows ServerRPCs

#

Given "Container" and "PlayerInventory" are the same base component class

#

@quartz vector

quartz vector
#

they are not same base class

#

my Containers are just "ItemContainerComponents" that I add to things

#

if it also has an EquipItemComponent it can be equipped

#

and when Equipped to the EquipmentManagerComponent...this event is broadcasted

#

and picked up by my InventoryControllerComponent

thin stratus
#

Hm, well you can always add different events to the manager

#

And handle the containers differently

#

But I would root it via PlayerController

quartz vector
#

so if the equipped item has an ItemContainerComponent...then InventoryController makes a reference to it

thin stratus
#

Easiest thing

quartz vector
#

so move my InventoryController to PlayerController

#

and then change the UI to work through there instead of directly with Items?

thin stratus
#

Yeah would say so

#

Then you get rid of the owner problem

quartz vector
#

cool

#

so what happens on SpawnActor

#

if you don't give it an Owner

thin stratus
#

Server owns it

quartz vector
#

so that's only fine if you're interacting from the server

#

to the server owned thing

#

but UI is client?

thin stratus
#

Server owned Actors only work with Multicasts

#

Client and Server RPC don't work

#

Client not, as there is no owning client

#

And ServerRPC not, as the client needs to own the actor for that

quartz vector
#

ahh ok cool

#

great information here...im kinda new to the MP stuff

thin stratus
#

Read my compendium :P

#

Just saying

mild hull
#

didnt you read his bible or at least the first 12 pages after that it only repeats everthing until close to the end

quartz vector
#

where is it?

#

i only read the wiki articles on replication

thin stratus
#

Pinned to this channel

#

gotta scroll a bit in the pinned messages

quartz vector
#

I just need to get the delegates hooked back in to refresh it

#

thanks a ton i would have never figured that out on my own

wide chasm
#

I've got multiplayer set up with advanced sessions, I have a physics object in my world and it is different for each players, how would I fix this?

#

player*

thin stratus
#

You can try setting it to replicate movement

#

The session plugin shouldn't have anything to do with that

wide chasm
#

Hmm, how would I do that?

acoustic aspen
#

bReplicateMovment

wide chasm
#

Doesn't work :/

quartz vector
#

is there a standard term for a "Dummy" object that represents something else that will happen in future?

#

my Inventory Add is done in 2 steps: Client calls some Simulation of Add function that instead of adding the item to inventory, generates a DataObject with some basic data.

#

If this exists, it means the inventory is handling an item and cannot process other items

#

2nd: Server_AddItem function is called to perform actual item add

severe widget
#

TransientPlaceholder kappa

quartz vector
#

this replicates inventory back to player after same duration timer

#

lol

#

I might actually use that

severe widget
#

Not sure if there's a standard term, sorry.

quartz vector
#

TransientItemPlaceholder

severe widget
#

Just so long as you have a field called PlaceholderName, you know, so you can name them.

quartz vector
#

rofl

#

TransientHandledItem maybe?

#

Now what would you call a function that is intended to be ran by the client on the client

severe widget
#

dangit i blew it

quartz vector
#

before the SERVER_functions are run

severe widget
#

anyway uh.

#

I dunno, why do you need a descriptor for that?

quartz vector
#

because when i don't name things well I get shit in here

severe widget
#

Well I mean you obv name the func

#

but like

#

CLIENT_PREREP__Name is ridiculous.

quartz vector
#

true

mild hull
#

TransientFunctionToCreateTransientItemUntilServerRemoveIt() like this?

severe widget
#

there it is

#

see, nice and readable.

quartz vector
#

perfect

severe widget
#

does what it says on the tin

#

Could use Predict

#

PredictItemAdd

wide chasm
#

when i go to the object locatation as pawn 2 it teleports me somewhere random, but i'm standing on the object from pawn 1's view

#

any help?

#

I have replicate on and replicate movement

#

and the object shows up in different locations

mild hull
#

is object supposed to be visible or do anything?

wide chasm
#

nope

#

wait

#

yes

#

its supposed to be visible and have physics enabled

mild hull
#

did you set replication for it?

wide chasm
#

yes

wide chasm
#

you there?

#

Fixed it

mild hull
#

great what was it?

wide chasm
#

I had to add the object and set replication after multiplayer as set up

calm plaza
#

hey smart people, are custom functions auto replicated or nah?

#

i thought they were but clients arent applying impulse to a mesh along with the server.

wide chasm
#

How do you get the location of player 1 or player 2

compact gulch
#

hey guys. does anyone knows a way to tear off worlds? meaning disconnect but let client stay in world

warm arch
#

?

compact gulch
#

was that question mark for me ? or Normercy or hexia?

warm arch
#

Ellaborate

compact gulch
#

oh

#

so i want the server to leave

#

but client to stay in world after game

#

u know how TearOff() works for actor

#

i wonder if they can be done for entire world

warm arch
#

It could (maybe) be done but I don't really see a real efficient way of going about it

zenith yarrow
#

Has anyone here used UDPEcho() to ping anything in ICMP.h before ? I would like to know if it is reliable or unreliable ?

manic agate
#

Guys, how many objects can be replicated until it becomes too laggy? I know that the anwser depends on many things, but generally what's the range? 10, 100, 1000? (in your experience, of course)

thin stratus
#

As you said, depends on many things.

#

One object, if you have too much data in it

#

What you should check is how much bandwidth is fine to be used and the see what your actor would consume

manic agate
#

It was actually more of a curiosity. I was thinking of Fortnite and was wondering how it worked there, with a hundred players and a big world

thin stratus
#

They improved the system quite a lot

#

There is a blog post about it

#

They push these updates with 4.19

#

Check the latest pinned message of this channel

#

@manic agate

manic agate
#

@thin stratus thanks, I'll check it out!

#

Actually now I've got a "real" question. I've got a UObject derived class which is replicated and used in a replicated AActor. It works fine, but now I wanted the UObject class to replicate another UObject. Is that possible?

thin stratus
#

Don't think so

#

You always need an actor to drive the subobject replication afaik

#

But I'm not 100% sure

lost fulcrum
#

Can I serialize specified fields in UObject ? It worked good with just iteration over class fields and checking its metas but only with editor. If the only way is like write custom serialization method like MySerialize(FArchive& Ar) then what is the best way to specify blueprint fields in final BP classes ?

manic agate
#

@thin stratus what if I put as owner of the new UObject the same Actor?
I mean, something like this:
Actor -> UObject1, with Actor as owner
UObject -> UObject2, with Actor as owner

thin stratus
#

Don't you need to actually specify the UObject in the Actors replication method?

#

Can't remember what the name is

#

The one where you place the DOREPLIFTIME macros in

manic agate
#

You're right

#

I tried a different approach and seems to work

lost fulcrum
#

My current approach in inventory replication is just writing all or partial slots of UObjects into FArchive with that custom serialization method and sending it through Client RPC as TArray<uint8>. I just need to control what is being replicated inside each item class

manic agate
#

This is my actor, which overrides the ReplicateSubobjects() method that replicates the subobjects:

bool AUserPawn::ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags)
{
    bool wroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);

    if(MyUObject1 != nullptr)
    {
        wroteSomething |= Channel->ReplicateSubobject(MyUObject1 , *Bunch, *RepFlags);

        wroteSomething |= MyUObject1 ->ReplicateSubobjects(Channel, Bunch, RepFlags);
    }

    return wroteSomething;
}

Then in my UObject1 I manually added the ReplicateSubobjects() method (it doesn't override anything):

bool MyUObject1::ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags)
{
//    bool wroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
    bool wroteSomething = false;

    if(MyUObject2 != nullptr)
    {
        wroteSomething |= Channel->ReplicateSubobject(MyUObject2, *Bunch, *RepFlags);
    }

    return wroteSomething;
}
#

I've tried and in the client the MyUObject2 isn't null anymore, yay!

#

This way I can replicate any UObjects from inside UObject1, and the owner Actor has no knowledge of this

#

(of course, I've omitted the parts where I do the DOREPLIFTIME macro thing)

thin stratus
#

Ah well yeah, that's what I mean though

#

Your Actor needs to kinda drive it :D

manic agate
#

That's right, I've misunderstood what you said ๐Ÿ˜…

manic agate
#

@thin stratus I need your help once more. As far as you know, is it possible to call RPC functions from UObject derived classes which are replicated?

#

I'm trying right know with a Server RPC, but it always gets executed on the client

#

As far as I know, if there are problems then I should receive a message in the log telling me that the RPC is getting dropped, but here I don't get any messages and the functions is executed locally

thin stratus
#

You should try setting the owner of the UObject to the Player

#

if it still drops, then I'd say no

#

But I mean, you could place a ServerRPC in the Actor and just pass the Object along

lean river
#

Nop uobjects cant send rpcs

manic agate
#

The owner is already the Player, but it doesn't matter. Also, I would like to not use the Actor itself for calling the RPC, otherwise I should place A LOT of functions in the Actor's code which are really not meant to be there

lean river
#

Atleat i have a big state system which based on uobject

#

I was not able to send rpc even if owner was playerpawn, controller or whatever

#

So i can confirm uobjects cant send rpcs

#

But uobjects can replicate subobjects, i do this in my system.. i saw you asked this

manic agate
#

Thanks Amph. Have you find a workaround for calling RPC from your uobject?

lean river
#

Impossible to do that, because actors open actorchannel or rpc try to use owners actorchannel

#

Uobjects do not implement owners actually i think

#

They have only outers

mild hull
#

cant you use a actor component that manages all rpcs for the uobject?

manic agate
#

True, maybe just inheriting from UActorComponent would work in my case

lean river
#

Yup i do this too..
I have a manager component which handle rpcs

#

Actually im sure rpcs can be implemented to uobjects

#

Simple actor component inherit from uobject

#

Just you need figure out how epic implements networking interface

#

Ahhhaahha i found that... maybe

#

Uobject have a virtual function "callremotefunction"

manic agate
#

I'm trying too to make it work on uobject

#

I just tried overriding "callremotefunction", with no luck

#

It never gets called!

lost fulcrum
#

shouldnt it be NetAddressable to do such stuff ?

lean river
#

I guess yes

manic agate
#

Probably yes

lost fulcrum
#

anyway... Is anyone ever worked with reflection ?

lean river
#

And you need override getfunctioncallspace too

#

I think

manic agate
#

@lean river you're right! I just tried pasting the implementation of those 2 functions from UActorComponent and it works (well kind of, it tells me that there is no owning connection for the UObject's outer, but it's a step forward). Going to launch and I'll keep trying later ๐Ÿ˜ƒ

lost fulcrum
#

Doesn't it comes to reimplementing UActorComponent ?

lean river
#

Yeah, glad to see that :D
I tracked back how epic does this..
Now i clearly see epic using his VM to process rpcs.

When you call rpc that passed to virtual machine, vm do a callback and call those two functions

#

Your overrided function will pass to owners netdriver, netpack the rpc data

#

On process side repeat and call vm , overriden functions then call rpc function

#

Of course this is short theory :D

#

So every uobjects implements rpc functionality through the vm.. and using owner netchannel

lost fulcrum
#

oh, it checks relevancy every RPC

#

ok. its only for reliable multicasts

lost fulcrum
#

Is Replicated property specifier only adds flag to the property or it also generates code ?

sterile pebble
#

is there something different with SetOwner in 4.17? I dont understand why my actor is simulated proxy on client side, when client is the owner

lean river
#

Well i think that generate code of course..
If you look at datareplication.cpp there is lot of code which collect uproperties

wide chasm
#

How do you get the location of player 1 or player 2 seprately, in a multiplayer game? someone please help

quartz vector
#

is there a way to intercept replication of a property

#

Server changes inventory... inventory structure replicates to client

#

How can client know when this happens

#

RepNotify?

mild hull
#

repnotify?

lean river
#

Repnotify!

quartz vector
#

gee it's right there in the name lol

#

so if not running dedicated server

#

will that still work?

lean river
#

Nop

#

:D

quartz vector
#

so have to code a special case for it then

lean river
#

I mean will works on connected clients

quartz vector
#

since if Client is Authority it doesn't need to rep notify

#

it just handles itself i guess

#

Like a purely MP game that features an "Offline" mode for testing/exploration

lean river
#

But listen server will not call repnotify

quartz vector
#

with nothing saved

#

guess I can sort that out later...it's really a "simple" thing I am trying to do

#

Client runs its own TryAdd and calls Server_TryAdd

lean river
#

So for example if you want update ui from repnotify or after repnotify you should check for standalone and listen server netmode after you changed inventory and call repnotifyy manually

inner iris
#

@quartz vector yeah what Amph just said- calling the repnotify function manually only on the listen server after changing the repnotify property will mean it gets called everywhere.

quartz vector
#

is it not possible to pass parameters through OnRep function?

lost fulcrum
#

why ? At the time when OnRep called your property must be already updated

#

Otherwise its more like RPC

quartz vector
#

i just need to pass a value

#

let me see if i can add some comments in code to explain better

#
            TransientHandledItem = NewObject<UTransientHandledItem>(this, UTransientHandledItem::StaticClass());
            TransientHandledItem->InitProperties(ItemInfo, CompartmentIndex, SubCompartmentIndex, SlotIndex);

            FTimerDelegate TimerDel;
            TimerDel.BindUFunction(this, FName("ClearTransientHandledItem"));
            GetWorld()->GetTimerManager().SetTimer(ClearTransientItemTimerHandle, TimerDel, 1.f, false);

            return true;
        }
    }
    return false;
}
void UInventoryControllerComponent::ClearTransientHandledItem(/*Called on timer*/)
{
    OnRep_ClearTransientHandledItem();
}
void UInventoryControllerComponent::OnRep_ClearTransientHandledItem(/*Need SlotType to Broadcast*/)
{
    if (GetOwner()->HasAuthority())
        GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Green, "Called On Server: " + bHandlingItem ? "True" : "False");
    else
        GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Green, "Called On Client" + bHandlingItem ? "True" : "False");

    if (bHandlingItem) {

        bHandlingItem = false;
        TransientHandledItem = nullptr;

        OnContentChangeDelegate.Broadcast(/*Needs to pass enum SlotType*/); //UI binds to this to update the container in correct "Slot"
    }
}```
#

bHandlingItem is ReplicatedUsing=OnRep_ClearTransientHandledItem ... i don't even know if i have this setup properly tbh

#

all I need to do is clear the UTransientHandledItem pointer on both client and server

#

and then broadcast to client what essentially is "Contents in this SlotType have been changed...redraw UI"

lost fulcrum
#

oh

quartz vector
#

The function where bHandlingItem is set to "true" and TransientHandledItem are spawned has signature with "SlotType" already

#

bool UInventoryControllerComponent::TryAddItemAt(AActor * Item, const EEquipmentType SlotType, const int32 CompartmentIndex, const int32 SubCompartmentIndex, const int32 SlotIndex)

#

so is it not possible to pass this value through my RepNotify?

lost fulcrum
#

I think no, I guess you should either replicate that value through another variable or use RPC

#

seems like proper inventory system is some kind of global pain

quartz vector
#

it's just a side thing im trying to add for quality purposes really

#

Server authenticated Inventory can feel unresponsive

lost fulcrum
#

if your handled item is replicated then you can just replicate is variable

lean river
#

@quartz vector you cant pass variable to onrep functions

quartz vector
#

so I spawn a placeholder thing that is responsive to client that shows it's being done

lost fulcrum
#

or also simply have dedicated slot for currently handled item

quartz vector
#

UObjects can't replicate from UActorComponent iirc

lean river
#

straightforward because uactorcomponent also using owners netchannel aka actor or pawn

quartz vector
#

AActor can replicate subobjects

lean river
#

๐Ÿ˜„

#

but uobject can be replicated from uactorcomponent

lost fulcrum
#

but you can serialize stuff into FMemoryWriter and send through RPC as TArray<uint8>

#

then deserialize at clientside

quartz vector
#

could I do this same thing by calling a Client RPC?

#

and just replicating bHandlingItem

lost fulcrum
#

yes

quartz vector
#

ok let me try that...don't think I need repnotify here

#

also...how do you get the ping of a client

lean river
#

it is in playerstate

quartz vector
#

basically my Inventory has like a .250s artificial delay and I would like to cut half of the players ping off of that

#

if someone is lagging more than that then they just receive the actual update slower and their inventory is not as responsive

lost fulcrum
#

lol, inventory with lag compensation

quartz vector
#

that's right

#

Next level inventory, bro

bitter oriole
#

@quartz vector You should always show local data to the player directly, without waiting for the server's answer

lost fulcrum
#

would even cooler if you move all items in past slots and check if player hit correct slot with cursor like real lag compensation is done in shooters

quartz vector
#

loot is validated against an external database

#

loot is all owned by server

bitter oriole
#

Sure

quartz vector
#

i COULD let client move the item if it's legal on client

bitter oriole
#

You should

#

That's networking 101

quartz vector
#

but i would then need to do something when server updates it

bitter oriole
#

Well yeah

lost fulcrum
#

dam, I have correctly working inventory with all the stuff and I really like it

bitter oriole
#

You need to do exactly that

lost fulcrum
#

but it only works in editor

quartz vector
#

that is probably what I will do in the end

bitter oriole
#

No one ever wants to have lag in an inventory, that just screams poor quality

quartz vector
#

but right now I'm trying to get the UI to update this properly

#

like if you take a magazine out of backpack to reload, there is a mechanical delay for items being taken out

#

because there are "bags" that are intended to be used for this

#

and reloading out of Backpack is slower....also want to reduce some of the "twitch" inventory because being in inventory is risky

lost fulcrum
#

@bitter oriole rust has that mechanics where you either move items by mouse between two slots instantly or rightclick to move into inventory directly and it moves with small delay

quartz vector
#

but rearranging a backpack just internal contents...i agree, that needs to be responsive

lean river
#

@lost fulcrum lot of game have small delay with inventory operations, did you ever played with wow on us server from europe? ๐Ÿ˜„

quartz vector
#

I still have to spawn a placeholder for client regardless, because as soon as Server destroys and swaps out items that it owns, it will replicate that to client which destroys the items

lean river
#

sometimes 1 sec was the validation and the result

lost fulcrum
#

lol, no

quartz vector
#

many inventorys i have seen online are purely server authoritative so if your ping is low it's fine

#

but if you get a lag spike

#

things start having delays

mild hull
#

why not redo the ui each time it changes and remove all transits?

quartz vector
#

Mizuki, i remove from parent widgets

#

and regenerate them

bitter oriole
#

Really, no one wants any local option to wait for a server response. That basically breaks immersion completely

#

It's really annoying and visible

quartz vector
#

It also opens up people to hack

bitter oriole
#

It absolutely doesn't

quartz vector
#

oh wait ur right

lost fulcrum
#

You may ignore ping actually, just predict server actions and everything will be okay

quartz vector
#

Server is still spawning the items at the end of the day

#

and then replicating inventory

#

what client side does is purely visual

bitter oriole
#

The fix here is to do what everyone has done for decades : when you do a local action, do it locally, tell the server. The server validates it, and sends an update to every client

#

If the server tells something different, reset the client to that

quartz vector
#

that's what im doing lol...it's just not setup that way yet

#

I am coding a mechanical delay based on the item container so i can use it later

#

it won't delay 99% of inventory movement

#

I'm just trying to get that piece in right now before I add the Client side of Adding inventory items back in

lost fulcrum
#

for my implementation is kinda simple like

void InventoryInterface::SwapSlots(int SlotA, int SlotB)
{
    Inventory->SwapSlots(SlotA, SlotB);
    ServerSwapSlots(SlotA, SlotB);
}
#

ServerSwapSlots is just an RPC that requests same SwapSlots from inventory at serverside

quartz vector
#

I wish my inventory items were simple enough to just use structs

#

but you can have Backpacks inside Backpacks inside Backpacks etc...

lost fulcrum
#

that would be terrible to not have methods bound to items

lean river
#

lal my implementation also simple

E_InventoryReturnCode UInventorySystemComponent::TrySwapItems(int32 fromSlot, int32 fromQuantity, E_Inventory fromInventoryType, int32 toSlot, E_Inventory toInventoryType)
{
    FInventoryArrayData fromItem = SavedDraggedItem.ToInventoryData();
    FInventoryArrayData toItem = GetActiveInventoryAsCopy(toInventoryType)[toSlot];

    // Check Quantity
    if (fromItem.Quantity < fromQuantity)
    {
        UE_LOG(OGW, Warning, TEXT("ANTIHACK: Tried to moved more quantity as player have! PlayerName:%s "), *GetOwner()->GetName());
        return E_InventoryReturnCode::ER_HackMoreQuantity;
    }

    E_InventoryReturnCode stackAddreturn = TryAddStack(fromItem, toSlot, toInventoryType);

    if (stackAddreturn == E_InventoryReturnCode::ER_SuccesfullyStacked)
    {
        SavedDraggedItem.Invalidate();
        return E_InventoryReturnCode::ER_SuccesfullAdd;
    }

    return E_InventoryReturnCode::ER_None;
}
#

oops

bitter oriole
#

@quartz vector We've had that discussion before, and you definitely can/should use simple structs for data, not actors, but well, there's no telling you that

quartz vector
#

you cannot use Structs for that until Unreal lets you have recursive structs

bitter oriole
#

There are many ways to go around that

quartz vector
#

you would need FStruct Item with uproperty TArray<Item>

bitter oriole
#

Also you can do that

quartz vector
#

how?

#

you cannot do that

#

USTRUCTS do not support recursion of UPROPERTY like that

lean river
#

ohm

bitter oriole
#

Maybe not, but you can definitely have a TArray of FStruct*, which is basically the same thing

lean river
#

but why you need recursion?

quartz vector
#

Amph because an Item can be an ItemContainer

#

which can hold other Items

bitter oriole
#

We have something like 5 levels of data recursion ourselves

#

100% UStruct

quartz vector
#

you can do nested structs

#

not infinitely nested structs through recursion

lean river
#

yup

bitter oriole
#

Of course you can

#

Just use pointers

quartz vector
#

pointers to what?

#

UObjects don't replicate

halcyon abyss
#

Hello guys! ๐Ÿ˜ƒ

lean river
#

what?

bitter oriole
#

sigh

lean river
#

uobjects not replicate?

#

WHAAAT? ๐Ÿ˜„

quartz vector
#

nope

bitter oriole
#

Anyway, i'm out of that conversation

quartz vector
#

go create a UObject on server

lean river
#

@quartz vector

quartz vector
#

you do not get a replicated UObject on client

lean river
#

my inventory system is jigsaw multi sized inventory system

bitter oriole
#

There is just no teaching him

lean river
#

im using lightweight struct for ordering and placing

halcyon abyss
#

I wanted your advice on a little thing here

lean river
#

and i have an uobject backend

quartz vector
#

AActor is first subclass of UObject that implements replication

lean river
#

for every item

quartz vector
#

you CAN replicate UObject from an AActor

lean river
#

which need special implementation

#

nop

#

thats false

#

you can replicate uobject from actorcomponent too

quartz vector
#

i couldn't get it to work

lean river
#

then i maybe hacked the engine but for me works

quartz vector
#

because ActorComponent doesn't have ReplicateSubobjects function

brittle sinew
#

Components need to be tied to an actor to replicate, though

lean river
#

i replicate uobject for every item which needed

#

override that eh

brittle sinew
#

So at the end of the day, it's really still replicating it from an actor

quartz vector
#

That guy spouts off 24/7 about "You can do recursive structs" never once links any actual article ora nything about it

lean river
#

thats true @brittle sinew .. actually everything replicates through the pawn and local player ๐Ÿ˜„ mostly

bitter oriole
#

@quartz vector I can link you to my production game's code

quartz vector
#

"You can replicate UObject just fine"....anything your ead about it will tell you "Caveat is that the replicated UObject has to be on an AActor"

bitter oriole
#

What's the problem with putting it on an Actor ?

quartz vector
#

you mean like an ActorComponent?

bitter oriole
#

Your inventory isn't tied to a player ?

quartz vector
#

nope

bitter oriole
#

A PlayerController / Pawn ?

quartz vector
#

anything can hold items

#

ItemContainerComponent holds items

bitter oriole
#

I mean, you're shooting yourself in the foot at every turn

quartz vector
#

PlayerController has an InventoryController

lost fulcrum
#

Are items in your inventory just replicate to all players or only to player which currently interacting with it ?

bitter oriole
#

It's like you're trying to make this more complicated tha, it has to be

quartz vector
#

not really...

#

you don't have infinitely nested items

#

nestable*

bitter oriole
#

That's trivial to handle

#

There is zero complexity with this

lean river
quartz vector
#

How exactly do you Replicate UObjects that are in an ActorComponent

#

when ActorComponent doesn't have ReplicateSubobjects function

#

since that is on AActor

#

hell even Epic themself

#

use Actors

#

for inventory things

bitter oriole
#

I'm actually fairly sure my game has overall much more nested data than yours, @quartz vector . Our game data is pretty massive, with dozens of companies storing hundreds of ships storing dozens of cargo slots storing thousands of resources.

quartz vector
#

Nesting 5 different structs

#

is not the same as recursively nesting 1 struct

#

which again, is not supported by reflection

bitter oriole
#

You don't need it

#

But like I said, there is no teaching you

#

Please continue what you're doing

quartz vector
#

I don't care how many levels of nested data you have

#

if you're not recursively nesting

#

having 1000 containers that hold resources

#

is not the sam ething as having 1000 containers each of which that can hold 1000 of the same container

bitter oriole
#

We also have ships that contain ships, FWIW

#

So we do have it

#

But have fun

quartz vector
#

do you have ships that can hold ships that can hold ships .... n

halcyon abyss
#

I need to make a separate client for steam that uses a different AppID

bitter oriole
#

We could, if it made any sense

quartz vector
#

and again

bitter oriole
#

There is zero complexity here

quartz vector
#

2 levels of nesting is not the same

#

you could literally have FParentShip

bitter oriole
#

1, 2 or 500000 is the same code

quartz vector
#

TArray<FChildShip>

#

how did you do it then

bitter oriole
#

TArray<FChildShip*>

#

Like that

#

That's really all there is

quartz vector
#

and FChildShip holds what?

#

FChildShip has to be declared before FParentShip to be usable as property

bitter oriole
#

We have a FShip storing a TArray<FShip*>

#

It's called forward declaration

#

C++ 101

quartz vector
#

yep i tried this last i checked it doesn't work

#

but i will try it again because I will admit that maybe I am wrong

bitter oriole
#

Because you didn't use a pointer, I guess.

quartz vector
#

when I use pointer compiler throws an error

bitter oriole
#

You can also have an ID system, and store a TArray of IDs

#

Which is something we also do extensively

#

You just need a getShipFromID() method

#

And voila, you can have flat structures representing infinitely recursed storage

#

With linear iteration cost

#

FName does that for you, with close to the performance of pointers

#

Like I said, you have 50 different ways of handling that

#

For example, we have "item descriptions" that have a unique named ID, like "spacecraft-typeX", and we store that identifier in game saves, and some structures.

#

On a network we'd only replicate the identifier

#

You end up with a flat array of structs that hold FNames

#

Doesn't get any simpler

inland sun
#

Question: When setting up a teleport system (open level, or teleporting) how do I tag the event so it only effects the person entering it and not the rest of the server?

quartz vector
#

here is the error:

#

error : Inappropriate '*' on variable of type 'FItemSlot', cannot have an exposed pointer to this type.

#
struct FItemSlot
{
    GENERATED_BODY()

    UPROPERTY(BlueprintReadWrite)
    AActor* Item;

    UPROPERTY()
    TArray<FItemSlot*> Slots;

    FItemSlot() {
        Item = nullptr;
    }
};```
#

from doing that

#

remove pointer: error : 'Struct recursion via arrays is unsupported for properties.

inland sun
#

Would I check the "Only Relevant to Owner" box?

quartz vector
#

@bitter oriole see above. And yes I do the same thing with an Enum and TMap in a DataAsset

inland sun
#

and or the "Net Use Owner Relevant"

bitter oriole
#

@quartz vector How about TArray<struct FItemSlot*> Slots ?

quartz vector
#

89): error : Inappropriate '*' on variable of type 'FItemSlot', cannot have an exposed pointer to this type.