#multiplayer
1 messages ยท Page 679 of 1
Do you have to use live UObjects for the items?
and a list of defaults, server just creates them
Like instead of a struct with an item class + a stack count
creates the UObject, adds it to Fast Array,a dn done
which.. leads me to a question ๐
i have a fast array for items (for the replication)
i create UObject for each item, atm i also replicate the UObject, but i am just wondering if i should not replicate the UObject but create a local copy
the UObject holds some convience stuff (BP accessors, etc)
and if i need to access the item from the FastArray i can do so via a GUID..
WELL.. i recently delved into this
Because i hated that I was replicating all my slot objects
right, yeah
So I now have them generated from a data-table at init time and make sure they are stably-named. so far it's worked out pretty well
So I can refer to them over network still, but they aren't replicated
thing is i have ItemDefinitions that describe the item
Why are you guys not just using structs for abstract items?
Like RangedWeaponItemDefinition
cause structs can not interface with BP easily
Basically i am thinking of the system works like this, RangedWeaponItemDefinition -> Inventory Manager -> AddDefinition(Definition) -> Create UObject for definition, add to fast array seralizer -> client callback -> Create UObject
IDK if it's the nooby approach but we just have item as struct when stored in an inventory and instantiated as an actor when in the world. Works pretty well so far.
Mines probably a bit more unique because I have the separate items + slots as uobjects
because reasons
Client <> server communication is done via Guid/Definition
And once again, thank you very much!!!
But the original system was stupid costly because I couldn't have something in an inventory unless it was also in a slot, and the slot itself was a server-spawned rep'd item, so it was pretty terrible.
Weird case though
I just did all from Jumbax's wiki page. I removed Instanced also and i think it is.
But I imagine most inventory items are either going to be an actor like a weapon or something, or a static asset like a data asset
But i think i should not use UObject
@chrome bay i spawn the actor when the definition is given
yeah
(for guns, etc)
makes sense
I think we're doing the same. The struct is the definition of the item in our case.
yeah I do the same essentially. My items are just this
UPROPERTY(BlueprintReadOnly, Category = "Inventory") FST_SlotInventoryID InventoryID;
UPROPERTY(BlueprintReadOnly, Category = "Inventory") UObject* Object;
UPROPERTY(BlueprintReadOnly, Category = "Inventory") FName Key;```
I guess I don't really know what a data asset does that a struct doesn't.
Well it's static data
So instead of replicating all those fields, you only replicate a single class object
dont even need to replicate it
it exists on client and server by default
and i can point to it easily
What about for procedural items?
Ah yeah, I'm thinking in terms of runtime-given stuff
Yeah like path of exile or Diablo
No 2 items of ours are ever identical, they all have property ranges and are rolled.
and stored in the fast array
i dont have random stats tho
but if i did, you can just pass them along
I have a feeling passing them along starts looking like just replicating a struct as definition and I'm back to where I am lol.
i mean the DA is just static data, describes what the item is, and what it has
stats can be pulled from anywhere
infact doing that in my system is trivial
i pull the base weapon stats
but you could easily pass along a seed
to generate the same random data for each client
If you wanna do diablo style items, they used a set length of bytes to represent the items and you generate the item based on those available bytes by using the random from stream nodes. Those bytes are what you want to replicate instead rather than replicating individual values.
yea
We have some mechanics for guaranteeing or forcing mods but I had thought about just replicating the seed
pass in overrides?
You can reserve bytes in the stream for forcing specific values.
Is there an ongoing cost to replicating a decent sized struct if it's never changing?
Like 10-20 fields. Not finished.
and rep as little as possible
But it only ever changes that generation or modification. It's not like stuff's changing every frame or even every minute
Are you also sending over item name in your struct?
Name is derived but basically the struct looks like
Actor class
Item level
Item rarity
Mod list
Mod levels
And a few more small fields
So my actor class is acting a bit like a data asset
That'd be like the Base Item in PoE
Actually, how heavy is it to replicate UObjects?
I'd personally say that you should not solidly set the data of items on even procedural items. You should have a static data asset of item defaults. What actually gets saved is a percentage or integer count of how offset the stats on the item are from the default. This allows very easy future balancing, and much easier item stats. When you generate the item, you wouldn't actually generate actual stats, but the stat offsets from the default.
That's what the mods are. Final value equals base value Plus mod, with item and mod levels coming into play
Otherwise you end up with stuff like original diablo where some items were godly, and people were duping them from older patches because they were nerfed for new spawns but older versions were still better.
Yeah we don't save or replicate the final value, just base item, modifications, and the randomly rolled levels
Rarity = number of mods
what if that base value is say 100
and you reduced the max it can be to 90
people with the 100 version will have a OP item
Base value is defined in the class ref
as long as you have ways to balance its all good.
and rebalance already given items
Yeah I can see how data asset vs using a BP class as data could make sense. The main problem is we don't really have that many bases that are functionally identical. They all can very pretty wildly. Although we are moving back toward using gas so it might end up just all being data
If all the final numbers live in the ability system component and all the rest of an item definition is data then no reason to have BPs
Item def would morph to being a mesh, some data for equip slot, an on equip GE, and abilities
Plus mods but they'd be GASified too
How do you guys sync local (and predicted) ammo variable on server-triggered reload event?
My guns fire too frequent and client consume a local ammo variable, but I'm not able to sync with the replicated ammo variable with ShooterGame's reload logic
I have some ideas I tested and working well but I'm not sure if they are the best way
Though I remember I solved this a few months ago but I had a VCS disaster and I forgot how I did it completely ๐
I want to expose a replicated variable in PlayerState, but I only want players who own it to be able to change it, how would I go about doing that?
The code that changes it still has to occur on the server right, through UFUNCTION(Reliable, Server) function?
yes
and only the owning client can call server RPCs
the relevant player controller should already own the player state
Oh riiight ownership. Sorry I am still learning this stuff.
So by default there shouldn't really be any way for other players to be able to call server RPC functions on other player states?
no because they don't own that actor
if you try to call a server rpc on an actor that you dont own you will get a warning in the logs saying: No owning connection for actor XXXX, function will not be processed
If you are referring to the item by an id
shouldn't the server use its valid copy to do its thing? why would you send those values from the client?
Never said anything about client sending the server anything.
what does it mean client have 100 base value and server has 90
You're quoting numbers from Kaos, and even he didn't say anything about client or server.
The question is how to handle updating/balancing procedural items.
But it's sorted
I think you shouldn't let players join the game if they are missing updates XD
check your assets versions
so Kaos gave an example of changing item stats right?
how can that affect a client that is still using the old item which had higher stat in a multiplayer game
if the server is involved
The idea being if you stored the determined values of rolls (example say you rolled critical chance as 10%) then you have no way of really re-balancing that item's roll. It's set that the item has critical chance as 10%. If you stored the roll as a value, say between 0-100, then you can reassign what that value stands for. Eg. 100 can == 10% or during a rebalance, 100 == 8%, all without having to change the items that exist already.
So basically you just store the item based data asset and the rolls or even just the seed.
So if you make any balance changes, the derived items will adjust
I would actually probably want to save the specific modifiers and not the roles or seeds, it would suck to rebalance the modifier rarity and load the game and your items are all completely different
This is a rogue like so I don't need to think two super long-term. But we do have item storage between runs. So all items are eventually disposable, but they are not tied to a specific run
How would i spawn an actor on listen-server, so it won't be visible for listen-server itself, but everybody other will see it?
The server will have to know if it's existence, but you could visually hide it.
You could modify its behavior for the server itself but it would definitely have to exist if it is a replicated actor meant to be kept in sync. Unless you do some shenanigans with rpcs but that's a different story
Yeahy, but if i hide actor, it will become hidden for all clients
Maybe i could use not replicated actor and just NetMulticast it to be shown for every client? Im making weapon equipment
Multicast is not the asnwer as that only fires for those that are relevant when it is fired.
HiddenInGame is not replicated. Visibility is. Just spawn it on the server and set HiddenInGame True right after spawning.
Im writing in c++. Doesn't work
Does visibility false cull replication or does it still do that behind the scenes
I figured out that SetVisibility for Root Component hides actor ONLY for server, but not for CLIENTS in my case. And SetHiddenInGame hides actor on CLIENT, but if called on SERVER, it hides actor for each CLIENT too.
How to make this happen to clients also? It is in Gamemode. Currently only add widget to server.
by using something that's also on the client
you can likely use the game state or player controller to send an RPC to show the widget
Okay!
game modes are server only
Hello ... Is that supposed to be normal to have 2 clients with exactly the same controller when simulating 2 clients ?
Can I check via BP if my client is listening/hosted?
Are there any good tutorials on how to make FPS games? I can't get weapon equipment to work, because i need weapon and character meshes to be different if IsLocalControlled()
Each client should have one controller. Those two controllers exist on the server. However on each client there will only exist one controller, the local controller
Im very sorry for being so annoying, but what do you think about this idea: What if i would make Player Skeletal Mesh(bOwnerNoSee = true), attach ThirdPerson Static Mesh(bOwnerNoSee = true) to it, and then attach First Person Skeletal Mesh(bOnlyOwnerSee = true) to camera and just change meshes when weapon gets equipped or unequipped
Like this
Not annoying at all. It's very reasonable to have a separate local mesh for FPS compared to the world weapons that everyone else sees
gotta be careful to not replicate them in case you're making a ListenServer game
among other things that you'll stumble upon over time with visibility
For the first person things you can use SetOnlyOwnerSee but beware if you ever wanted to change camera ( Example: death/spectator vision ) and you haven't destroyed those FPS actors, they will now become visible when you dont want them to, if you handle the logic in a certain way
And rather than setting those settings on your weapon mesh in the editor. I would recommend you make utility C++ functions for handling visibility. There will be more than just your weapon, you'll also have the arms mesh, and potentially other things you will want to spawn for gameplay
So it's good to have all that functionality of properly settings the right things from code in one place
And you just call that code on BeginPlay for meshes that you have added from the editor, versus calling it at runtime when you spawn new meshes
@viscid monolith
Great, thanks very much!!!
Bump
You mean something like this?
๐ค I've tried Is Server but returned true before I started hosting, gonna try again
if( IsDedicatedServer() ) ... ( DedicatedServer )
else if( IsServer() ) ... ( ListenServer )
else ... ( Client )
Apply to blueprint
to do whatever you want for the 3 different types
no luck, gonna try with packaged
depends on what you have selected as your option for running when clicking Play for PIE
IsServer() && IsDedicatedServer() is redundant
What does standalone return for Is Server?
There's 3 states, you need 2 checks right?
It returns true
Because on standalone every PIE instance is the Server
I'd argue that's not a good way to go about reasoning for it. One's gotta understand why it is true
???
If the concept of dedicated/listen server/standalone aren't grasped, just checking the return value isn't helpful
I'd be like memorizing that 2+2=4 without understanding why, shitty example I know, please forgive, it's been a long day
Basically you are always server unless you are a client.
Understanding why something is, is what fuels learning
not sure why you're trying to explain to me
Basically I need to know if my client already started listening or not
but if it returns true if there is no connection then useless
World->GetNetMode() will be NM_ListenServer if you're a player hosting a listen server
NM_DedicatedServer for a headless server
What do you mean by "If my client already started listening" ?
( sorry I gotta go for a bit, but do elaborate so someone can get you the info you need )
In PIE:
Standalone: your instance is the gameplay client & the authorative server
ListenServer: your instance is the client, the editor runs a dedicated server in the background
The IsServer/IsDedicatedServer functions check for the type of setup you have, not whether or not there are connections
u can make your client listening by typing into console: open mymap?listen
I need to know if that thing were being typed
is GameInstance server only?
No. Game instance exists on every copy of your game, however, they are only accessible to the local game - ie. the server cannot access the game instance of a client directly.
amazing that's what I need then
I can set a bool if that would tell me if the local was made to listen
thank you
alrighty im having a replication issue. heres my struct
USTRUCT(BlueprintType)
struct FTimedRun
{
GENERATED_BODY()
UPROPERTY(BlueprintReadOnly)
int32 PlayerNameIndex = 0;
UPROPERTY(BlueprintReadOnly)
float Time = -1.0f;
};
i have this struct in a TArray on another class
UPROPERTY(ReplicatedUsing = OnRep_StageRunTimes)
TArray<FTimedRun> StageRunTimes;
UFUNCTION()
void OnRep_StageRunTimes();
what im doing for testing is i start a listen server without the client connected and i do 2 runs (in the screenshots they are element 2 and 1) which adds 2 elements to the array. then i connect with the client, and the server does 1 more run (shows as element 0 in the array in the screenshots). i place a breakpoint in the debugger at the start of the OnRep function to see what StageRunTimes looks like after those 3 runs on the server and client. the server is the first picture showing everything correct with all the PlayerNameIndex at 2569 and the correct Times. the client in the second picture shows player name index 0 for elements 0 and 1 (these would be the last 2 runs as i am shifting the array down one with each run so the latest run is always element 0, but it shows the correct time. now the other weird part is if i do a fourth run on the server (third screenshot), it shows the correct PlayerNameIndex for the run with a time of 0.616674423 (element 1 in the first two screenshots and now element 2 in the third screenshot because again i am shifting the elements 1 to the right with each run). its like my struct is replicating just the time and sometimes the PlayerNameIndex instead of both. if i connect the client to the server before doing any runs, and then have the server do a bunch of runs then everything on the client is correct as well. it seems however many runs i do before the client connects is how many runs behind the client is for replication as it does not want to get the PlayerNameIndex for some odd reason
Looking for a resource or a tip on how to differentiate between players. Lets say I have 2 players. player 1 spawns a unit and can select and control it. How do I stop player 2 from being able to select and control it? I basically just need to know the best way to set up item ownership and have that save and be persistent between saves/loads and reconnects.
if player 1 is spawning it, just check with whatever function you call to control it do a check. make it take in the pawn/character thats trying to interact with it and check if that equals the owner
Assign an owning player state to the unit, don't accept commands from others
The Player State is how you identify a player in network games.
that may backfire in combination with seamless travel
as seamless travel persists all controllers that have a PlayerState
Looking for some help on Replication
@maiden abyss Unit should probably just have an array or a single property of a pointer to playerstate(s). Pointers are cheap. Can replicate the array/property. Local ui can use that array to detect if they're allowed to control it, local control functions can use that to detect if they're allowed to RPC. Then server can also check that before doing any AI stuff.
Specifically getting a client to "Run on Server"
Using the "I watched a youtube video on replication" base
It either runs a multicast:
Or if a client, runs on server which will then multicast
If run on server, works perfectly
If run on client, doesn't run the "Set Role Server" event
The actor is set to replicate and always be relevant
Probably that actor is not client-owned
As in it's not a player controller, character, player state, or owned by either
This prevents server calls entirely
Should this fix it?
or is the problem now that Player Index 0 is still the server?
If you run it on the server for the player that will be calling those events, sure
Hm, problem is that I want clients to be able to run it
But none of them to strictly "own" it
That's a common design problem
The only solution is to move those events to a player-owned class
usually Pawn (character)
So there's no way to get an actor to "Run on Server" without it being owned by a player controller?
There is not
You can't call Server RPC's on an actor you don't own, that's just a fundamental design feature of the engine
So you have to workaround it
Hm okay, thank you
How does player controller ID work
both my client and server seem to have an ID of 0
pretty sure all players got an id of 0 on the client*
It's just a counter that identifies the controller within that local game instance
If by client and server you mean a Client and ListenServer, then each player on that instance will have their playercontroller ID be "0", because that's the local one. However the listenServer will also have an additional 1 for the Client's controller on the server side
As each game client has the local controller, but the server also has the controllers of everyone. So a dedicated server would have the controllers of everyone but not one of its own
I made the wrong assumption about controller IDs
Where I'm at currently is that I set ownership of the actor to whoever calls the "Update Role" event
but even then, with the actor being owned by the player calling the event, I can't get it to execute a "Run on Server" event
You can only RunOnServer from a client-owned actor
that means if you're trying to call "UpdateRole" on Actor1 owned by Player1, from Player2 because you want to give it to Player2 - that doesn't work
Actions need to originate from owned clients, and affect other things, not the other way around. You gotta adapt your thinking on that front when working with UE
Just a bit stuck on how to tackle my specific problem
break down the problem into steps.
Step1 make something callable that you get to work with RunOnServer from client
I've got 16 "House" actors, each house has a "Role" variable, I want any player to be able to update a houses role
Step2 transform your workign example into something that solves your problem
And if you cant, figure out where you went wrong and try again
Then on any player ( client-owned actor, like the character ) you can have an "UpdateHouseRole( AHouse* ) [RunOnServer]"
Ah
Assuming the houses are replicated
I'm dumping all logic into "House" actor
Yes, that won't work
I set everything up to run standalone
using public functions called by other actors
Yeah that's the first mistake
I can advise playing as client ( cough making your game )
Later once you have more experience playing with ListenServer and 2 instances
Anyone using Steam Advanced Sessions plugin have "Join Session" from friends list working? Having some trouble where it doesn't actually join the game.
I've moved all of this over to Player Controller
And now when client tries to change role it changes it correctly for all clients and server
however if server tries to change role it only updates for the server
I'm confused as it should be doing a multicast to all clients to set role?
@verbal tendon
general pattern for such things:
(1) regardless of whether owning-client or server calls it, have one that is as "RunOnServer"
(2) Have the RunOnServer one call a Multicast event
no authority check involved
that pattern guarantees the right things happen
Follow the pattern I described above
so SetHouseRole needs to be [RunOnServer]. Then that needs to call a MultiCast to all clients ( from server ), because it runs in RunOnServer, and then will then run everywhere
You currently have 3 events, you need 2 for the pattern to work
Keeping in mind that based on the networking needs of your project and this being a game world setting, that's maybe not HOW you want to set it up
That's context and information you havent shared. You might want to do a RunOnServer RPC for the action, and then handle the rest behind a replicated variable and OnRep functionality
However what I've described above works, and you need to experiment a little to get a grip on the networking side of things anway ๐
Custom1 need to be multicast, and yes
Client Or Server calling the RunOnServer event, guarantees that the logic is executed on the server, assuming you call it from server/owning client actor
then the server executes the multicast to run the logic you want executed on all clients
Does that make sense?
yep makes perfect sense, just on a call then I'll test it ๐
Still running into the same issue
when done on server - only executes on server
when done on client - executes on client and server
Going to see if it's a problem with how I'm calling it
.26 but I got it fixed right after posting this lol
If a Widget cannot be replicated why can I set its variables to replicated? Will that do anything?
ofc
for some reason my game mode spawns a camera actor instead of my specified pawn. Any reasons why?
In my case it wouldn't matter. I have a name plate above actors, that needs to be replicated obviously.
ye thanks
prefers attaching the PS to its Pawn and have it handle the name display
Hmm why widget Get Owning Player always returns the local PlayerController even if it was called from a widget of a replicated actor?
Because widgets are only client side. Your computer knows nothing about another players UI other than what is communicated through replicated actors
I don't know why it would return the local player controller instead of nothing but it certainly wouldn't return another player unless you are the server. Whatever you're trying to do with this, it sounds smelly
There is a Widget component on each player's actor meaning there are other instances of that widget for each players on every client
UI is still local. Always. That return will never be different unless you're playing in a splitscreen setting with multiple players on the same machine.
I have problem with Ui and server.
This creates Ui inside player pawn
This spawns character from controller
This calls spawn character event in game mode
When start game everything else work but server doesnt have ui
Is the logic that spawns this UI originating from OnPostLogin?
Becaue you've shown us the nodes that create the widget, but not from where they're being executed, and that's the part you're having a problem with
create widget is executed beginplay in pawn
Try with a single frame delay. Some of that stuff has terrible race conditions on listenserver.
Where is the pawn spawned?
I wouldn't advocate adding delays to solve problems, because then you don't understand what#s not going wrong
you're just hiding the problem
Pawn's beginplay is likely running before possession is setting that it is locally controlled.
@kindred widgetNow its working!
Yup. So there's a better way to fixing this problem
I would advise a function that you call after the spawning that calls this logic instead of having it in begin play
knowing where your ordering issues are and explicitly solving them is better, imo
thank you
Because this is likely not the last time you'll run into an ordering/dependency issue, so as long as you explicitly solve them everytime, you can shuffle them around when needbe
Not sure how that function after spawning is going to fix that on clients.
Realistically in Blueprints there is no good fix for this. There are no decent hooks post possession for server and client in blueprint.
I see now thank you
Server has OnPossess afaik
Yeah. And if that was the only condition an init functiona after spawning is fine. But again, client.
Restart or Set Pawn virtual functions in C++ are a great place to inform HUD that possession has happened for event driven. The only decent way to handle this issue in blueprints only is a client only tick in HUD for the locally possessed pawn and switching logic calls when it changes.
:/
I have a struct array what I need to Set Array Element using the server, but if I run it on server it doesn't set the array element. Debugging shows that it goes through the entire step it just doesn't actually set it. It works fine if I don't have the server set it, but I really need the server to set so the client and server have accurate data. Any ideas? Is this a known bug?
Is it replicated?
It is
Show your setup
The passing of that array over looks a little sus
That could be it, but if I bypass the server event and do a direct call on that function it works for the server, just not for the client obviously
How many arrays live in the inventory component?
3
They're all the same struct, but yes stored item. Specifically Pockets, Backpack, Equipment
I would either have 3 inventory components OR have some designator of which array to hit, like an enum or name or int.
Them have your event just take name/enum/int, index, amount
Before the event is called there is a switch on enum the pulls the correct array
Pass that enum over.
Okay I'll give it a shot
I'm trying to let players pick up a box in a v simple way, by calling BoxActor->AttachToActor(PlayerCharacter)
From the ListenClient server/host perspective, it's happening fine, but from the client's perspective, the box is still stuck on the ground.
I'm calling the above code in a UFUNCTION(Server,Reliable) function inside a component owned by the client...
Any ideas? :S
OK I'm a big doody brain, I hadn't set Replicates to true on the BoxActor
That one's kinda important, ngl ๐
Btw, are you attaching your box on RPC intentionally?
If it's not intentional, it might not be the best solution for attaching
Unfortunately it makes no difference. It is pulling the correct array either way I do it, it just will not set the array element when explicitly called on server.
For testing, try just setting an array element after like 5 seconds and see if it actually does it. You want to make sure that your replication setup is correct before dealing with triggering changes from the client
Yep, I can set an empty one with something new, but I cannot change one that has data it in it seems. Only when it is explicitly called by the server. Just a normal unreplicated event and it does work.
Hold the phone, it did work replicated
can I use "Get All actors of class" or interface etc. on client-side where player is out of bounds and still get a reference ?
Edit: It seems it doesnt work from what I gathered online, sadly
@dark edge I got it, thanks for the help
Lmao we're you looking at an old copy or something?
No, I changed it back to a direct call to the function, then ran the set element part on the server
Using your suggestion of setting and removing on a delay triggered on begin play confirmed that there something wrong with how I was calling it
Hello, I was wondering if anyone was able to successfully able to debug their shipping configuration mode in Steam through Rider?
Is there some steps to correctly disconnect from server ?
I get this RestartHandshake Issue, can i remove the clients from server correctly
Hi there! I have a problem with custom spawning of players. I'm using this function however the controllers are not inhabiting the Pawn. (It's GameMode)
void AKT_BaseGameMode::SpawnPlayers()
{
for (int LPlayerIndex = 0; LPlayerIndex < MaxPlayerCount; LPlayerIndex ++)
{
for (auto LPayerStart : PlayerStartArray)
{
if(LPayerStart->PlayerStartTag == FName(FString::FromInt(LPlayerIndex)))
{
const FTransform LSpawnTransform = LPayerStart->GetActorTransform();
const FActorSpawnParameters LSpawnInfo;
UGameplayStatics::CreatePlayer(GetWorld(), LPlayerIndex);
AKT_PlayerCharacter* LPawn = GetWorld()->SpawnActor<AKT_PlayerCharacter>(DefaultCharacterClass, LSpawnTransform.GetLocation(), LSpawnTransform.GetRotation().Rotator(), LSpawnInfo);
if (IsValid(LPawn) && UGameplayStatics::GetPlayerController(GetWorld(), LPlayerIndex))
{
UGameplayStatics::GetPlayerController(GetWorld(), LPlayerIndex)->Possess(LPawn);
Players.AddUnique(LPawn);
}
}
}
}
}
Pawns is spawned and pointers is valid. I have this exception, but I don't understand why it is being raised.
Maybe someone knows what my problem is?
oh god the rider debugging experience
not sure why you would call CreatePlayer like that
do you have engine symbols installed?
What is strange?
the call to CreatePlayer for one
I'm doing this first time
using a custom "spawn players" function for another
yeah, the engine has a lot of this in the game mode framework already
you can override the spawning behaviour
to say, spawn a specific player at a specific player start
what function to use for this?
would be good candidates to override
BlueprintNativeEvent so a virtual function is declared with the _Implementation suffix
i.e. should I just use my code to select the spawn location in this function or does the function already have this code?
please look at GameModeBase.h and search for "spawning"
and look through how the base game mode handles this
it'll probably give you some idea on how you want to override the behaviour
Ok, thanks for the help
Yeah I would strongly advise against doing all those custom calls. Not only can it be buggy, also you lock yourself into something, and if you ever want to upgrade and then engine changes the way it does these things, you're gonna have bugs again. Best is to have as few calls to the underlying engine code as possible to get the custom behavior you need. The optimal amount of engine functions to call for this is one.
If you ever need to call more than one engine function to do a very specific thing, you gotta stop, take a moment and think. You're probably doing something wrong.
Mileage may vary, but that's a general good rule of thumb to live by.
I have a large level divided in tiles... All the tiles are list of actors/BP stored as list in save file that load at runtime..
It is an adroid game so the player might not have all packages of the level at runtime and it downloads them during the game..
The server loads all the packages during initialisation, hence all the tile actors and bp have already been loaded on the server.
We want the client to load a few tiles and connect with server (the tiles actor spawns bp, which need to be replica of server)... As the player moves the tiles on the client can unload or load.. but keep on replication with the server...
Any idea on how to do it??
I have tried using replicated actors and replication graph.. but I am not able to delete client objects once the player moves from that tile...
I tried to dynamically create level for each tile and add them to level streaming.. but I am facing issues.. and not sure if this is the correct method...
I tried just loading the tiles and spawning bp on client side as the player comes to the tile.. but that creates a duplicate on the client and the bp are then not replicated..
By replicated I mean if there is a button and that starts a light on server for all players to see, and I spawn the button and light bp.. then it does not show in all players...
In which function are you guys giving weapons to your player (i mean default items at first spawn), i'm actually do it at OnPossess but i think it's might be too late to do it ๐ค
We do it on begin play.
Personally I like PostInitializeComponents. Has time to set state before Beginplay is ran.
Well. The inventory is set on spawn, equipped on begin play
My beginplay mostly just calls same calls that state onreps do.
I do tried it before but got some issues with my hud, but since i reworked it all i might give it a try again ๐
Ya that's what we do. Equipment is a state for us.
Mine is... yeah.. it's here to be here ๐ญ
I update my hud from character destruct and PawnClientRestart.
i set mine like that
i was used to spawn it in onrep_playerstate but was not accurate since post init components was called before
ClientSetHUD is called by gamemode if i'm remember well so it's pretty good to spawn ur hud there so you can do all stuff like init quickbar hud etc before pawn is possessed (depends on how u're managing all of that)
Is there a reason why my widgets are not working on a replicated actor?
I don't want to replicate the widgets, just to have them function locally on a replicated actor
Show us some code ๐
When clicked, the button depresses as if being clicked
However the print function doesn't run
Widgets exist Widget Components on a replicated Actor in the world
Widgets do not replicate?
They shouldn't
Are other player controllers present on the client or just only in the server?
Only on the server and the owning client
oh ok
So I can rewrite my logic for the third time xd
A doc would be good to have how base classes are behave on replication, but too late now
Good to know, thanks!
@verbal tendon FYI restarting the editor fixed my problems yesterday, I've also moved to using replicated variables as all I'm doing is changing variables. Thank you for your help yesterday ๐
You're welcome. I'm glad you got everything working! ๐
Hey all, I've been developing a TP multiplayer shooter for some time now, and it hadn't donned on me that I need an actual playerbase and community for the thing to, y'know, survive. I've been too focused on actually programming it and had fun while doing it to realize my reality. It's designed with 2-10 player listen server MP in mind
From what I've seen, the best course of action is to probably add some decent singleplayer gameplay, which I can do, but does anyone have any advice or anything I should know while going this route?
Because the game was built on the idea of 2+ player multiplayer
I think this might be a little beyond what this channel is supposed to help with. You've got to dabble into community development, marketing, etc... if you have nobody else helping you with this. I'd suggest finding a publisher for your game, that can help and manage that aspect, and most importantly has experience with it
@polar lotus We realized the same thing. Turned our PvP top down shooter into a Coop roguelike
I'm working on a Co-op shooter myself. Not only is it easier to market because you're not competing with the big names directly - organic marketing is easier and you also need much less critical mass to sustain the multiplayer part of the game
Good to hear I'm not alone, how's that going so far?
I mean if ur using a listen server
Than single player should work just fine
Well yea
Multiplayer netcode works fine in singleplayer, but I've now been tasked with making a game that's multiplayer at heart into a singleplayer game
The programming isn't the hard part, it's actually making a fun singleplayer
Where the game designers at? ๐
Don't forget to stress that if the game's design is pivoting, the release schedules and the project planning needs to as well, you're gonna need new time for iteration and testing that was spent for the old core gameloop
Mind you this isn't a project with hard deadline, it's just me solo dev'ing a side project that I'm taking semi-seriously
Alright ๐
Because I've been working on it for a few years now
I mean I have an abundant supply of game development horror stories that reinforce the fact that this pretty logical idea is not a given in many places
So I sent warning ๐
What do you mean?
I can also back this up from personal experience. Not just from game dev either, pivots without proper schedule adjustments can happen anywhere in software dev.
"it's agile development"
It's actually predatory company practices that lead to crunch and negative health effects for employees
Sorry gotta go for a bit, plenty of horror stories around project management. I thought you might be workign in a team, but working alone it's not that much of an issues except for your own expectation management
Depends on what ur doing
Oh wait ur talking more game design
Never mind
cries in "press both buttons on opposite sides of the room at the same time to unlock this door"
It's going, sorta wish we didn't make some design decisions that needed a lot of tech work but they'll pay off. Nobody's gonna pay for Generic Shooter 2022 so you gotta do something new.
What about 2024
?
I wouldn't want to make a generic shooter in any year. You gotta do something unique.
Sadge
My game's main mechanic is what I call swapping, it's where if you kill another player, you teleport to where they are and essentially swap with them
I have some ideas on how that could work in singleplayer but I'm still figuring it out
what happens the door remains locked XD?
but a game like falls guys might be easier to make and can be a very good hit
Already been made plus boring plus no single player content
needs critical mass to succeed
what you mean critical mass ?
many people
well unreal is capable of 100 players tops with some serious optimization in replicating stuff
otherwise you have to find another custom solution
๐คฆโโ๏ธ
Where the hell are you gonna get 100 people to play your game?
i meant players online in a game match
That's not what we're talking about tho
you can publish on steam and advertise what you mean?
Valorant might have failed too but riot spent millions in ads everywhere
indie
Launching a multiplayer only title as your first just sounds like a failure in the making.
I prototyped a couple multiplayer only titles and yeah I'm not going to touch them because they don't really have legs by themselves.
and that's what donned on me today
For a 10 vs 10 game to pretty much always have a match starting, my napkin math says you'll need to sell several thousand copies.
How you gonna do that if nobody is online. It'll just fizzle unless you have some real marketing behind it.
Yep
100 players in a game match realistically means 1,000 players online, which realistically means something like a million sales
Which isn't realistic
pubg was like that right? it's possible
but it's just tough
A million sales has happened but if you're a indie nobody, it's not going to all happen at once. The dream is for your game to do like three sales, and then turn into 10 and then turn into 100 and then turn into 1000 and then turn into a million. If the first 10 have a bad time, you fizzle.
PUBG was a lifetime ago and had a publisher
And it was by a guy that made a very popular mod, that's why it is called playerunknowns
but he was not a game dev
It had some cachet before launch
The very safe assumption about your game is 3 online players lifetime max
Plan for that
He basically prototyped pubg as an H1Z1 mod and it was very popular. There was already a player base when the standalone got launched
Minecraft, PUBG, Among Us etc got massive successes by somehow launching what everyone wanted to play but didn't know
PUBG is likely the only one where even the devs knew it'd work
among us was actually released in 2018 and it became a hit recently like a year ago which is kinda weird
Yeah it's ridiculous
It's why planning for success is dumb - plan for 200 sales, 7 Steam reviews and 3 online players
It's very realistic for a first game
If you get there for your first game it's arguably a success
And Minecraft has staying power single player. When I bought it, it didn't even have multiplayer. It wasn't even infinite, just an island lmao
everyone is dreaming about success for his first game ๐
That's fair, but success should be defined as 1000 sales
and if you are lucky 100k lmfao
You should at least give yourself all the chances possible to succeed. If it's multiplayer only, you are gimping yourself unless you have an incredibly compelling design and a ravenous fan base ready for it. Prismatica is going to do great, even if it's only multiplayer, because they are marketing already and have a very compelling product.
We should probably move to making mobile games and rely on ads revenue 
An actual indie success in 2021 is something like Industries of Titan with 50k saless
That's Steam best seller sales there
F*** that I'd rather dig holes and fill them back up
Take amount of reviews, do 50x
You used to be able to with steam spy but people have made some correlations with reviews. It's rough but it'll get you within an order of magnitude typically
Fairly accurate stuff all things considered
Steam Spy also has a range that in my experience is about one zero close
we have 2k reviews lol
Sounds like a 100k units title to me give or take 50k
how do you know if they didnt refund ? or they cant after leaving review?
You don't, it's just a rough estimate of the magnitude of success
A game with 2K reviews is unlikely to have 20k sales or 500k
20k would mean 10% of every single buyer ever took the time to leave a review, 500 would mean not even 1% did
Both are possible but not realistic
The median is something like 1/60 IIRC
If I get 100 different people on this planet to pay for my game, that's a success for me
This isn't my first project, but it is my first big project
I've done a handful of gamejams before
Shipping a completed game that 100 people buy is honestly a success
PvP games is also hard, as you need dedicated servers
I'm doing listen servers
Co-op/single player games can run on listen servers.
So p2p
listenserver != p2p ๐
Technically one of your players is the server
They have a P2P socket interface, but the game itself is not using P2P when running as a listen server.
I mean yeah
A client/server setup is inherently not P2P, but it can operate over a P2P transport. Different layers can operate in different ways.
It's not actually p2p but the idea is that the players talk to each other and there's no central server you're paying for
Right, just don't call it p2p because that's a very specific thing that isn't supported by default in unreal. It's a listen server.
Got it
players don't talk to each other, true p2p players do talk to each other, listen server players talk to 1 player who is the server (correct me if i am wrong)
semantics
It matters - they're entirely different networking models.
No not that, I'm just bad at calling stuff the right names
Aaaaanyway, my game does listen server MP
as long as its not PvP, its good ๐
Well, it is pvp, but after talking here earlier today it's no longer going to be.
Well sort of, I'll still give players the ability to do pvp, but I'll have to pivot over to some good singleplayer gameplay
I think it kind of depends on what you want to achieve with the game. Generally yeah, you do not want to do PvP from a listen server, but I think it can be ok to do in certain circumstances. For example if it doesn't matter if people cheat in your game, and you don't mind the server player having an inherent advantage. For example if game sessions are invite only with friends, like a party game or something maybe its ok... If one of your friends is a cheater you would maybe consider not playing with them :P. But, if you were planning on having matchmaking with random people, or anything of a competitive nature, then I would use dedicated.
Yeah we're using listen for coop and will use dedicated for PvP if it gets that far.
It's a permadeath game so the PvP has to be decently secure
Probably will just have all gameplay happen on dedicated for PvP ladder but that's a long ways out.
I mean I can name a few well known games that did listen servers with PvP
Of course, I am saying it is fine if you know what you are getting ๐
Yeah mine's mostly designed to play with friends, which is kinda where the idea stemmed from
I still like the idea of just hopping in a random match from a public listen server browser and going ham, then again I need an actual playerbase for that ๐
Our design has playing with friends, then your entire party can go ham on a level against another party, but one of the parties is going to permanently die. Should make for some butthole puckering if we can pull it off
Sounds fun ๐ But yeah, as others have pointed out, if you are playing with random internet people, and your game becomes popular, people will cheat for sure if they can.
How should I implement a race-start countdown in a multiplayer setting, to release control to all players when the countdown finishes? Would a reliable multicast RPC from the gamestate be good enough?
That's tricky. Are the cars predicted locally?
I am using the character movement component right now, I believe it does right?
Like if I hit the gas, does it respond instantly or does it respond after ping milliseconds
Yeah the CMC is predicted
I would just replicate the time and if they have bad ping, f*** em
And that's exactly it, my game needs to be popular first, and odds are it won't
If it does, then maybe I can justify licensing some anti cheat and possibly dedicated servers, but that's a few orders of magnitude out of the ballpark right now
Lol, exactly
It's a problem I would love to have
That's the old definition, we're not talking p2p full mesh. In the modern definition there's only dedicated servers vs p2p ( everything else, and that's basically listen servers these days )
Is there any documentation on life cycle, from which i can understand which class gets created in which order. need to understand about GameMode, GameState, PlayerState.
Nah there are games with real p2p still
What happens when you start up your Unreal Engine game? This video is a guided tour of the Engine's initialization process: along the way, we'll glimpse the high-level structure of the Engine (modules, game instances, local players, and viewports) and we'll see how all the different parts of the Game Framework (game modes, game states, player co...
That is good.
Thanks
dedicated server and listen server are both client-server models
p2p is not a client-server model
p2p is not a listen server
p2p is p2p 
Again as per outdated definition yes. As per modern definition and common usage, no. Every network topology that's not using dedicated servers is classified as P2P.
ok, well you're wrong, but i guess you're not going to hurt anybody
We can agree to disagree. It's a moot point anyway and only one of terminology, so who cares
literally go to google and search for "P2P" and search for any results within the past year about networking and... well, unless the definition you'll find across the entire internet changed while I am writing this message
agree to disagree is fine 
thank call of duty for popularising "p2p" referring to "player hosted listen servers"
EOS p2p does use relays though so it is handy for hosting listen servers
How can you say that p2p -> "mesh" networking is outdated when it's actively used... torrents, blockchain (ugh, but still a good example), IPFS, Destiny 2 (hybrid client/server + p2p model), some RTS games, fighting games, etc...
Just because some companies have decided to use the term p2p when talking to the public doesn't erase its actual technical definition which is not even remotely outdated. We're in a technical context, use the right term.
Hell, even EOS P2P is still P2P - it's just talking about the transport (which is indeed directly connecting peers... ignoring relays, but they're not actually processing data so eh) instead of the application (the game itself).
lol
peen2peen
Yeah I would never consider listen server as peer-to-peer. All the machines are not peers, one is running the show and everybody else talks to it
Hey all, I'm currently working with the IOnlineSession interface, and am confused by what the FName SessionName parameter to the various create/join functions is used for. Is that actually sent to the provider (eg Steam) in any way? Should I set it to a constant string? My understanding is that FName implies static, but I want to double check I'm not messing something up.
Looking at the source, I think that FName is just used for storing the session in memory locally
anyone know how to fix this lol? Sometimes both clients work.. sometimes not
Why this happens and how to fix that?
What's likely happening is that you haven't set the "Online Team Tag" on the server.
If you have, then the damage causer isn't Player Character 0 on the server's side.
Get Player Character isn't reliable to use in multiplayer as the index of the players can be different on clients and server.
@sinful treeIm setting it like that (When spawn player :: player controller)
"Get Player Character isn't reliable to use in multiplayer as the index of the players can be different on clients and server."
How to do that?
Where would you ever call that from where you didn't know what player you were?
So every player that spawns is being set to team red?
Don't use Get Player Character. In this scenario you have a reference to the damage causer which is exactly what you want - a reference to the character that did the damage, rather than trying to reference a random character by index. The value being output of it's team variable will be whatever is set on that particular character.
Also, the "Event AnyDamage" only executes on server, not on clients. So you should only ever be able to see the server's value from there and the server is saying red, so it should be correct. If somewhere down the line the clients aren't showing the right team value, then it could be for a lot of different reasons, but your code here doesn't show anything that executes on clients currently.
Both damage causers prints same "Vanessa" what is name of that character
Okay!
"So every player that spawns is being set to team red?" no sever:red, client1:blue, client2:red, so on
I was just confused because this works. But now I see any damage runs only in server
When testing multiple clients with dedicated server in the editor, are all files (textures, material, etc) shared? I have a Material Parameter Collection that uses player location and camera location to modify a material. It seems that only one client can update the Material Parameter Collection. This wouldn't be a problem when shipped but it makes testing difficult.
MPC is local
You can use a replicated variable to drive it if that's what you're after.
What's the desired behavior?
so i actually don't want it replicated
im occluding objects from the viewport between the player and camera
and right now it acts funky because it uses the player location of the last player that updates it to determine when to occlude or not
i want the clients to use their own MPC basically
but i haven't had luck creating and updating MPC at runtime
but maybe im thinking about it wrong - are you saying it creates one MPC for each instance of the client?
i guess i was under the assumption it was the same thing as having a single render texture, it shows the same on each client
There's no way your render target is replicated.
Have each player updated locally with their own info
its not normally, but if both clients reference the same texture it shows the same on both
Oh yeah reference is one thing. But the actual data isn't flying across the internet
right, ya i think it would work if they were running completely separately. i was wondering if there is a way to test that way in the editor
In plain English spell out what exactly you are trying to have happen
It looks like you want to fade objects sort of like divinity original sin
when hitting play in the editor, for 2 clients and dedicated server, each client would have a separate MPC/textures/etc. I don't want them to share any references to local resources
similar, ya
Yeah so just have each character, if locally controlled, update the material parameter collection.
Material parameters and render targets are not going to be automatically synced just because you're playing in pie, it'll work.
ok cool, i must be running into another issue then. thanks!
Not sure how you're doing your masking but it should just be a point distance from line test, all you should need in your material parameter collection is the character position. A function of that, camera position, and pixel position will be your opacity
How do folks normally handle Changeable Spectator Cameras (ie 1st and 3rd person) ? Would it utilize Regular Cameras attached to the Player Pawn?
Do listen servers with OnlineSubsystemSteam and SteamSockets expose the player's IPs?
like could a client get the actual IP of a listen server that they're connected to?
steam sockets will not reveal IP addresses
players connect through a relay run by valve so the only ip they see is the ip of the relay.
well, assuming relays are enabled. I believe that's optional.
what is the client side callback for end of seamless travel in playercontroller?
e.g if I want the client player controller to do something each time a new map starts
Hello! Having an issue in a Multiplayer LAN lobby in trying to create. On the client side The Host Playername (overhead widget) is not populated. Works fine in host side. Pictures of code to follow
Host side works great. ( Random generated names for now), but on the client side. Im not seeing host name
Works great in PIE btw. But not at all when run in Standalone
PlayerInfo struct is populated in GameMode, OnPostLogin
PreClientTravel
So i guess there is PostClientTravel ?
post is only executed on server by game mode
Well, look at PlayerController.cpp then u might find if it calls client function
If not, you might have to handle this urself with events
Hey everyone, in collab viewer, when i close my hands, the other player 2 also closes his with my controller, infact any person who joins, if i close my hands all of the players will close theirs, this also works if they closed it, they will see my hands close too, but i wonโt see it, thanks to anyone who knows how to fix this๐๐ป
Probably because you didn't setup the Motion Controller stuff properly
All of these are listening to your own controllers
Is there something to uncheck or Check? Do u think thatโs the case?
Arent they driven by motion controller components?
Iirc you have to make sure the user index is unique or so
But it's been a while
I ended up fixing it, was an issue with ownership ๐คฆโโ๏ธ thanks again for your help
i'm thinking it might be a Replication thingy
Why would it be
It seems very much local
Have you checked what I suggested or did you just ignore that? :P
tbh i'm not sure what you meant here, are you talking about blueprints?
Yeah in the Component for the MotionController
Didn't they come with a component usually?
The Hand component I guess
that's all that comes with the Collab Viewer template
Yeah I think this thing comes with something called a PlayerIndex or so
but not sure if that's the reason tm
Maybe also try in #virtual-reality
This is def a coding issue somewhere
hmm i see
so it's not a replication problem ?
well i'll try to see what's causing this, thank you @thin stratus for your time i truly appreciate it
Do the others see their hands closing when you close it?
Or do you only see it on your local end?
if it's only locally then it shouldn't be a replication issue
i only see it on my end, let's say i close my hands right? then P2 will close his too, but if P2 closes his hands he will close mine too, but i won't see that on my screen
hope this is clear
Yeah so only locally
You aren't actually controlling their hands
Then it could be an AnimBlueprint issue
where it maybe tries to grab from a fixed pointer, let GetPlayerPawn
Instead of GetOwningPlayerPawn
huh interesting
Or the Controllers are somewhat linked up via the MotionController Component
And they all react to your input somehow
Hard to tell
never used that collab thing
sure is
no worries thank you tho, at least you gave me some clues
much obliged : )
This is my BP in the anim btw
Yeah that's shite
You are grabbing the first player for all of those
use the TryGetPawnOwner, which is already in your graph, should be used
Or actually
You can't get the pawn owner like this
Use GetOwner, cast that to the MotionController BP
And then get the owning character from there
It might have a PlayerPawn variable
ngl i couldn't understand the last 2 lines
and Get Owner won't compile (Error) This blueprint (self) is not a Actor 'target' must have a connection
The Owner of this AnimBP is the BP_MotionController, not the VR Pawn
Yeah then use GetOwningActor
GetOwner seems to be the Actor version, so just delete that
Yeah correct, you need to have the Pawn that owns those hands
There should be a PlayerPawn variable
That you can get from the cast
ok i changed it to what you told m, but now i can't connect the Target ( pressedgrip )
Bp motion controller object reference is not compatible with bp vrpawn object reference
if u mean pull a node from the Cast To BP_MotionController, blue node As BP Motion Controller > pull a node called " Get Player Pawn " , if this is what you mean, then this doesn't work
please pardon my ignorance
Yeah that's what I mean. The Screenshot of the motion controller BP shows a PlayerPawn variable
okay so this works
but only problem now is that i don't see him when he closes his
Yeah that's now a replication issue
Cause the boolean you get from the pawn is not replicated and there may be no code setup to set it properly
yeah guess i'll check the replication panel and do trail and error kinda thing to figure out
thanks
Tried to check these and packaging them tried them one by one, still can't see the other player closing his hands unfortunately
Feel silly asking this but SetOwner() should be run on server correct?
Should be called there
That's what I thought. I was just having a weird brain fart. Thanks
Got another silly one, might be better in C++ but this is a replicated project. SpawnActor(...) I have a property that I want exposed on spawn (already set the method for that) is there a way to do in C++ like there is in BP or do I need to make a function I call right after spawning? (These events are running on client - it an RTS style game. Client is getting a preview of a building they may want to construct)
alternatively would a delayed spawn be better?
SpawnActorDeferred
@novel siren In C++ to do parameters like that, you usually do a SpawnActorDeferred, set your variables you want to set on the return pointer, then call FinishSpawning on the pointer.
Is what you want
That is what I thought, thank you for confirming. I really hate having to work with one API 4 days a week and then the UE4 API 3 days a week. I feel like I forget some basic crap
Well, you don't have to remember, you just need to know how to find the knowledge
I often google and find my own answers
same but sadly with spawn actor I was getting the API only for regular spawn actor and same for deferred and a LOT on BP
If I ask here, usually means I spent at least an hour googling. Might be that I forget what terms are best to use though
As I have been developing my game, I have wondered if it would make more sense to just make a TMap of FUniqueNetIdRepl as the key and a struct containing the player controller/state as the value. Then, instead of storing weak object ptrs to the player state in all of my uobjects on the server that access them, just do the look up. Because if the character gets re-assigned, the controller gets replaced (due to disconnect / re-connect or whatever), I now have to update every single UObject that holds a weak object pointer to them to have the latest valid copy
that seems like a lot of work as the number of systems grow
has anyone else done something like this? Obviously it wouldn't remove the need to store pointers to the player controller / state entirely, but it might cut down on it quite a bit..
I mean
Sounds logical
If you have a lot of places where you need to reference the PS and PC once and you don't want to update them constantly, then you could just save the Net ID and perform any kind of lookup through that
Yeah that's what I was thinking
I never had to do that cause either needing those pointers was a case by case situation or the connected systems were small, like one team state that needed updating
Hey everyone ! I'm working on a character controller for multiplayer and I was wondering if anyone
used a similar approach before I start going the wrong way.
Basically I'm using an ActorComponent that polls all potential player inputs for the frame, and after that i'm passing this input component to my state machine. The state machine then looks at the inputs for the frame and does it's thing.
For multiplayer, I would replicate the inputs that changed this frame to the server, and the server-side state machine would ( theoretically, with some delay ) execute the same logic as the client, and then replicate the inputs to other clients.
This is for a survival, non-competitive game, with up to 4 players coop, so bandwidth and delay is not too big of a deal.
My question is : Does this seem okay at first glance ? I know I'll have to implement movement correction and maybe some syncing algorithm down the line, but yeah, any thoughts ? Thanks ! ๐
any ideas ?
Are there specific features of your game that would prohibit using unreal's built in synchronization mechanisms? It's sounds like you're pursuing a "lock-step-deterministic" approach common to RTS games
It's kind of using UE system ?
The character controller uses a state machine system based on UObjects so no replication possible ( at least not without a lot of work from what I understand ). The state machine is required because of how complex the controller can get.
Ahh, I see. Just looking to simplify the network inputs for character synch. TBH, replicating arbitrary UObjects isn't too much work, just a fair bit of boilerplate. This series breaks it down in one of the earlier lectures, but I'll see if I can't find a source that doesn't cost $25. https://www.patreon.com/reubenward. My instinct is that your lockstep approach is going require much more work. I can elaborate on that claim if you want
If it's boilerplate then it should be fine.
My idea to get around this replication problem was to have the properties stored on a ActorComponent as well, that would be able to replicate. The state machine would just execute methods using these properties.
I can elaborate on that claim if you want
If it's not a bother, I'd like to know your opinion on it ๐
Here's another (free) breakdown of UObject replication: https://jambax.co.uk/replicating-uobjects/
That sounds like reinventing the wheel imo
Yep this is interesting, thanks
The main reason for this system is the state machine, I haven't found an "easy" way to create a complex character without it. It works well, but I've never used it with multiplayer. It's based on an implementation I had previously done in unity but for singleplayer. I'm trying to find a way to make it work in multiplayer ^^
If you want to limit the character synchronization data to just player input, you're effectively making it "lock-step-deterministic.". That is, given the same player inputs sent to every client, the character sim should deterministically compute the same output. But this only works if all clients and the server are starting from identical world state (think chess by mail)
Out of the gate you have a few problems. I'm reasonably confident UE4s character movement functions are not deterministic (mostly wrt floating point precision and out of order computation on different machines). So that code would need to be replaced or modified. Also, player-player collisions will be wrong on your local client because your local client will be predicting ahead of remote client movement. Remote clients will have different world state for the same player input. Also, any world state that affects player movement but is outside deterministic code will cause desynchs.
Even if you manage to get all the other dependencies working with determinism, maintaining deterministic code is hard, and requires waaaaay more boilerplate validation code than replicating uobjects. A hybrid approach would also require more boilerplate
I could probably summon several more reasons, but I'm typing on my phone. Let me know if you need more clarification.
As an aside, I'm unaware of any games that take a hybrid approach (mixed server-client and lock-step-deterministic) in the same simulation. I wish I could point to one. (Fun fact, older Halo games used lock-step for co-op, but client-server for pvp multiplayer. The oldest Halo games were all lock-step-deterministic)
This doesn't really require lockstep determinism... what's been described would work fine with normal network prediction.
In fact what's been described (aside from the state machine, which is irrelevant to the networking) is basically how all predicted games work.
Client processes input and sends the same thing to the server, server processes input and sends back result.
Client interps to new state if necessary.
One thing to note is that "input" should be an abstraction - you're not sending "player pressed spacebar" to the server, you're sending "player wants to jump" to the server.
That's what I had in mind yes ๐
Simulation happens on both sides, but server takes precedence
That's just normal prediction stuff, sounds fine to me.
Depends what "sends back results" entails. If it's a bunch of state in Uobjects, that needs to be packed in the movement RPC
That's an implementation detail. The general idea is fine.
Idealy the UObject do not contain "important" variables, they access them from one or several "Data Storage" Actor components, which are replicated
Ha, ez for us to say, poor Kiok has to do all the work ;)
Sure, it just sounds to me like the question is "does this direction make sense", not "how specifically do i implement all this"
Ahah ๐
That's a good call. Have the Uobjects do the business logic, but have the component store the data
Yup yup, but any feedback is welcome ๐
Those are not orthogonal concerns
One leads to the other, but I prefer not to dump a load of information on someone who hasn't asked for it.
@hollow eagle yes.
Fair enough, I didn't read back for the full context.
Thank both for your feedback ^^
Does anyone have any good references for server/client best practices for spawning actors, for example if the Server spawns in an actor what's the ideal way you make sure dynamic changes determined by Server reflect for client actors for constructionscript/beginplay
Hey do someone know a good Template to buy on UE4? i need multiplayer for atleast 50 Players
No, don't
To be able to make a game that'll run well for 50 players, you'll have to know your way around the engine well enough that buying a template is worthless
yes, a magical template
I'm not entirely sure what you mean if you're already replicating values properly. Most replicated state will be received in the initial bunch by the client and will be applied when BeginPlay is run
but you can't always depend on it
Hey!
I've run into a bit of a problem. I've created a function to be called on the client side and executed on the client side but for some reason it seems to be getting executed on server side(Even with the server rpc function commented out) and I haven't really been able to figure out why. I was hoping one of you could give me some insight
It's being called from ball.cpp which is just a ball I spawned in on the map. Would that mean I'd have to call it from server to client then
The function isn't an RPC. If whatever is calling it runs on the server, then it'll run on the server.
If whatever is calling it runs on the client, then it'll run on the client.
This might be a bit of a stupid question but how do I know for sure if it's being called on the client or if it's being called on the server
Because I have another function that's pretty much the same except shoots with a greater force which is only being called client side opposed to server side
Which is kinda confusing me
Is it possible it's being called on both the server and client? What part of ball.cpp is calling it?
Which is called from...?
Look, if you only want this called on the client then you either need to have the function call (or the function calling your function, or the function calling that function, etc) originate from something only called on the client, or you need to guard against it being called on the server.
If you can't figure that out, post the start of where all this code is called from.
If this is coming from Tick then it's going to be called on both the server and client. If it's coming from a timer, it depends on where you set the timer. If it's triggered from an input it's already being called on the client only.
Ah
So if I have a function in tick and within that function I call another function it will be executed on both server and client
If I understand correctly
No. Tick is executed everywhere unless you've done something to prevent it from being called on one or the other. What you wrote was technically correct but the wrong way to look at it.
The server is playing the game too. So the ball class on the server will also be running tick, and all the same code will be executing (unless you guard parts of it to run only on the client)
This code doesn't really make sense though. If this is just something being triggered by a timer you'd want the server to be doing it... there's no reason for the client to tell the server because the server should already know.
Well its being called within the tick function within ball.cpp. so it should it should be called on both the server and the client right?(please forgive me if I still don't understand ๐ )
Correct.
My point was that tick is being called on both, therefore everything inside tick is called on both.
So with that logic would it work on both singleplayer and while playing on a dedicated server?
Because that's the problem which I'm running into. I have one function only executing client side and another only executing on server side but both being called from the tick function within ball.cpp
when using FastArraySerlalizer, will i run into issues if i have some structs in the items array on the server that I don't intend to replicate? Right now I just don't call MarkItemDirty on them when modifying them. Basically I want to store all my stat structs in one place, but only replicate some of them, so I have a bool in each one that signifies whether that stat needs to replicate, and if so I will do MarkDirty after any change, if not I don't do anything. On the client side I don't need access to the non-replicated structs at all.
Can Blueprint Componets run an event on the server from a client where it was added to their character?
I keep getting Could not find valid Replication Graph. no matter what I put in the .ini. Have any ideas?
As long as that component belongs to an Actor that belongs to the Client, then yes. So in this case a possessed character is set to be owned by the client at possession. So if the component is set to replicate and was created on the server version of the client's character, and replicated to the client's version of the client's character, then that client could call server RPCs on it.
Got two weird ones (at least to me) - tried debugging to see the cause for one. The other is more a ownership logic thing and may need help just walking through. RTS style game (as usual)
First issue, the game time is a custom calculation that can be changed (to speed up or slow down or pause the progression of time in the game). Both players and host (listen server) can modify this setting (currently). The modifications occur via UMG (UMG to Player Controller, Player Controller to Game State) and that part works fine. The current speed at which game time progresses is relayed back to the player via a progress bar (Game State to Player Controller, Player Controller to UMG). (In case anyone asks, direct transmission of the data to UMG caused the data to become null). The prog bar basically has 6 steps (0 = empty, 5 = 100% filled). The math to make sure that the prog bar fills correctly is accurate. The default (at the start of the game) should be 3 , which fills half the prog bar. For the host this is correct. For the client it is displaying as if it is at 4. While the prog bar is wrong for the client all other data being passed back and forth is correct. And using break points to check, the values on both host and client are the same. Any ideas what may be causing that sort of issue?
Second issue. yesterday this was working correctly (today I finished translating it over from BP to C++). The logic is the same, the steps are the same. When the host spawns in a building, it use to be visible ONLY to the host. It is now visible to the host and to the clients (except it is a different material that the clients see). Given that I followed the same logic, I am not sure what I fouled up and could use some help just walking through it.
does anyone use epic online services?
Update to first issue, in standalone the prog bar is wrong for both
Issue 1 resolved. I did the math wrong (and for some reason it wasn't replicating on host, it is fine).
and issue 2 fixed. Curious why the UMG is getting messed up in PIE but not standalone (I know about some replication issues that occur in PIe versus standalone)
What does the replication condition "initial only" do? from the name and the description I thought it would only replicate the first time the server sets the variable, but that isnt the case.
@heady python It replicates once per client. It will give the client whatever the server has set at the time. After that it can be set on server and will never replicate to client again.
An example might be that if you start up the server. You have an integer and set it to 13. A client connects. This client gets 13 replicated to it. Later on server sets this value to 21. Client 1 does not get this replication. Now client 2 joins in. They get 21 replicated to them. If the first client then leaves and rejoins, they will have 21 replicated to them.
Thank you! Theres nothing i could find on the internet about this. Do you know if the server will still compare its value to clients that have already been replicated to? so after every player has joined and updated their values to match the server, will the server still be running unnecessary checks?
That I don't know. Possibly. It's not worth fretting over honestly as those checks are very cheap until you scale quite a long ways. If you want conditional replication control on that scale, it's probably worth checking out the PushModel.
sweet, ty
Hey guys I'm back again :P
I still haven't been able to fix the issue I've been having.
I have a function in ball.cpp that's being called by Tick in the ball.cpp class. From my understanding the functions within this function should be executed on both server and client.
void ABall::FindShootingCandidates(){
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ClassToFind, FoundActors);
if (GetWorld()->GetTimeSeconds() >= NextShotTime) {
for (AActor* ThirdPersonCharacterRef : FoundActors)
{
ASoccerCharacter* Player = Cast<ASoccerCharacter>(ThirdPersonCharacterRef);
if (FVector::Dist(CollisionComponent->GetComponentLocation(), Player->GetActorLocation()) <= MaxPlayerDist) {
if (Player->WantsDribbleShot) {
DribbleShot(Player);
}
else if (Player->WantsChargedShot) {
ChargedShot(Player);
}
}
}
}
}
The problem I've been having is that "Dribbleshot" gets called on both server and client but only when playing as a client on the dedicated server setting. But when playing on singleplayer(standalone setting) it doesn't get called at all.
And the other problem is that "ChargedShot" only gets executed on the client no matter what setting.
I hope someone is able to give me some insight on this matter
Why are you doing that on tick? Do it when NextShotTime is up
or on an anim notify if that's setting your timing
hey guys, quick question. Lets say I want to apply velocity to the player when he pressed a button.
For example, I want to do a sliding action. Where is the proper place to adjust the player's velocity?
Should I modify it in the following places
- PlayerMovementComponent::PerformMovement
- PlayerMovementComponent::ReplicateMoveToServer
It's a very simple ask, generally there should be some sort of discussions or teachings on this sort of important aspect of game dev, it always seem hard to find in depth multiplayer discussions
is this some kind of turret shooting players?
I seem to be running into an issue with member variables existing from within GetLifetimeReplicatedProps()
I'm using SpawnActorDeferred, I set a variable called SettingsData, I then print out if Weapon->SettingsData returns an object before calling Weapon->FinishSpawning() and it's not null. But it's somehow null in GetLifetimeReplicatedProps(). I even printed logs to make sure GetLifetimeReplicatedProps() was being called after everything and it appears to be. What gives?
Shouldn't you use GetRealtimeSeconds instead to check for NextShotTime @stable ravine ?
GetLifetimeReplicatedProps() is called on the class, never the instance
ahhh
It's all part of creating the FRepLayout for the actor
Everytime I try and do a Run on Server event on an actor component, that client crashes back to the main menu.
I only have the issue when the Component is added at Runtime. It works fine when the component is added manually in the character BP
It's probably not network addressable
If you're creating it at runtime, it should be replicated and only the server should create it
But then how would a Client interact with it? I've set up replication a bunch before outside actor components, but this just seems difficult
This is what I use currently to create the Actor Component. All is fine until a client runs an event in the actor component that is set to Run on Server. That's when they crash.
If there is a better way to do this, that would be fantastic to learn. I currently want to put it through a Actor component so I can add it to any Character Blueprint at Runtime.
It won't work because your creating the component on multiple connections, and each will create different components. If you want to create a component at runtime and use it over the network. the server has to create it and mark it as replicated. So long as the actor is also replicated, clients will create the replicated component when they receive it from the server.
Is my event there not creating it on the server?
No
begin play runs on every instance
So every instance is creating their own copy of that component, and clients will have two of them.
Ah, okay. But if there are multiple character actors of the same blueprint, doesn't the component need to be added to theirs?
A replicated component created at runtime by the Server will be spawned on clients the same way client actors are spawned.
So is this just an event begin play issue? Like if I removed that, would I just call the server event using a different way?
The issue is you're creating a replicated component on every instance, including the Server
'Add Component' needs to be behind a "Has Authority" check
And the pointer to that component also needs to be replicated, so that clients can get to it
I guess the question i should be asking is, can a client create a component for themselves that can be replicated, that the other actors don't get?
no
Okay, that is where I was lost
Relevancy is only possible at the actor level
I was hoping to add actor components based on a player picking up a powerup
So what you're saying is it has to be in the original blueprint, or a new actor blueprint
What I'm saying is you can't have a component that only replicates to one client
It follows the same relevancy rules as the actor
So if one person gets the "ability" (actor component) then everyone does for themselves?
Everyone's copy of that actor would also have that component
The same as if it was a default component of that actor
I'm wanting to dynamically add components to individual players across the network, and that includes replicating that to other players to see, but I don't want those players to have that component for themselves on their own actor. Is that possible? Hopefully that helped. If not, I'm sorry, I couldn't find any documentation about this very specific issue online with actor components.
They won't have it for themselves
The component will be added to the same actor on every client
if you add it to a given players' pawn, it doesn't mean another players' will get it too - it means their copy of the other players' pawn will have it.
That's what I'd like it to be. Would what you told me earlier do that?
I can't figure out this..
First pic is from player character
second pic from enemy interface function
Want to make that blue team player cant deal damage to blue team enemy
What's wrong with it?
Where do I put "Set is Replicated"?
somehow client cant do damage to anyone. Server can do damage to enemy team. But I figured it out! It was how did I call that function
When should you use switch has authority ? Wouldn't I just run the code on the server instead?
If u are using a function that gets called on the server and the client
Then it comes in handy
ah ok, thanks!
which multiplayer libraries are available to make client server based games? BTW: I'm an xbox live developer so on xbox wouldn't I just use the XDK liibraries? Or are the multiplayer libraries built in are the only ones for establishing connections, sending and receiving commands to clients, etc..?
and is it automatically serialized the objects and stuff like the actor for player, enemies?
btw: I'm Ken, I'm a self taught programmer who has done some amazing stuff such as I'm the one who reverse engineered the 3do file format from total annihilation, and released the djgpp source on cavedogs website chat, then Kinboat and I went in together and we both created 3doBuilder, to which I still have the sourcecode. I can do VB but I'm way more comfortable in C based languages like C#, C++ especially, any scripting languages.. I'm also the StOrM3 who worked with benji york on snesKEY, which we gave the mame project enabling users to make mame arcade machines.
I have made 7 complele games from start to gold master, 2 of which won contests
First, you cannot use the XDK (which is outdated anyway) without an agreement with microsoft. Anyway, there are no specific libraries for networking for xbox - unreal handles that for you.
Online subsystems are a different story, but you don't get access to that without being a registered developer.
You really have 2 different problems here that need to be treated separately: 1) Matchmaking 2) The actual replicated gameplay logic.
I am a registered developer, which is why I can access the xdk I just saw it yesterday in devkit mode dropping files from my desktop to my xbox series s
If you're talking about being registered for UWP development then you can't even use unreal with that without a custom build of the engine that hasn't been maintained in a while.
If you actually have a signed development agreement with Microsoft then you should have access to the GDK (not the XDK) and can get the xbox-specific code from Epic.
I have UE5EA installed, development editor x64 and yes UWP is one option but I can put the binaries targetted for xbox I can drag and drop like models etc.. from my PC to my xbox.. but please explain both options your talking about above
Hello, I seem to have messed something up that was working before and not sure what I did. When this tree takes damage, I want it to change the material, and and spawn fire effects on the tree. However, my material isn't applying and I only occasionally see fire climb up the tree.
its OK Help him out I will just read a little more in the manual
I multicast from the server (dedicated) after damage is applied and see my print string and such
Let me rephrase... are you talking about https://www.xbox.com/en-US/developers/creators-program/ or are you talking about an actual agreement with microsoft under id@xbox or through a publisher with a signed NDA?
My point is that you don't have an option if you're talking about the creators program - that only supports UWP.
And if you are indeed talking about an NDA'd agreement with id@xbox or a publisher, then you'll have to direct your questions to them as it's NDA'd.
not creators program it had an NDA its an agreement with microsoft I'm also an windows insider, and xbox insider, and whatever else they had I've know microsoft for a long time I actually won the firs zune off the line from them at the vista release party at opryland hotel in nashville and landed on the frontpage of their monthly newsletter
Then you should know that you cannot really discuss it here.
I have another actor which places a decal on the ground with the material on the ground no problem, and you can see it cover the tree a little, but I want the whole tree to turn orange
Anyway, there are no "multiplayer libraries" to use with xbox outside of the online subsystem you likely received with the xbox extras for the engine.
I can't discuss what I'm making or any changes they make, but in general I can talk about multiplayer related to UE5
OK thank you, you answered my question.. I'm going to have to use the FLAX engine then because of targetting linux stand alone server tech...
Not really sure what that means, unreal's networking is platform-agnostic.
but are the multiplayer libs installed that I can use to target a standalone listen and report server then just use the correct libs for whatever platform I'm targetting for the clients?
There are no "multiplayer libs". Unreal uses whatever network stack the platform has, which on every platform is just going to be a standard socket library. Xbox does not have specialized libraries for developing multiplayer games - you work with sockets just like you do on desktop platforms.
Again, unreal's networking is platform agnostic.
The only xbox-specific stuff will be related to online subsystems - accounts/party/session/etc - all of which are optional provided you obey the restrictions of the platform holder.
Have you verified that the multicast is actually being called on the server?
If AnyDamage is being hit on a client then it won't send that RPC.
OK so low level nothing to help ontop of the sockets lib.. See i'm looking at another engine, that uses enet for their networking low level stuff also based on sockets but has the serialized stuff on top of it, so it auto serializes objects for you etc..
Unreal does that as well.
But it's part of Unreal itself, not anything xbox-specific.
yea really the xbox stuff is all on client side and really related to messaging and chat etc..
pretty sure my print string showed, I will verify again
That print string will happen regardless of where the function is called
it's not within the RPC
thank you, you have been helpful..
I understand, I mean placing another one
gotcha
I've tested multiple aspects and moved my print around
Check the output log as well.
yeah, I've been checkin the log file on the dedicated server
Check the client as well.
Depending on the materials you're setting, this might not be an issue with the RPC - for example, if the materials aren't enabled for the kind of mesh you're putting them on. That'll generally appear as a warning in the logs.
oh cool, good point, yeah I moved print string to the front of the RPC and its called on the client and server
I'd put it inside the RPC and see what happens.
You want to verify if the RPC is happening at all.
Right now that's just showing that AnyDamage happens on both client and server (btw - is that something that you want to happen?), but doesn't say anything about the RPC.
I moved it and restarted the server
I wonder if somehow the damage isn't overlapping/applying to the tree
I saw one do it and one not, let me try somethin
my print is in the rpc now
I'm going to blanket apply damage to all tree actors in a box, and see if they all light up
ok silie dillie okie oh, cook underway
Does calling a server function (rpc function) from the server itself trigger a network request or does it just call that function with no overhead?
it directly calls it
I get Could not find valid Replication Graph. when running net.repgraph.printall. I've tried putting our repgraph in the ini and even the one from Epic (the basic one). I've also tried binding the delegate on InitGameState (saw someone suggest that here) and I get the same error. Anyone have any ideas?
I think my issue is damage not applying properly, not the way I originally had the code
Looking by Google and message history of this discord, you are the first person mentioned this issue
I don't know anything about Replication Graph, but I couldn't find any resource or guide to help you out on the web either
So your only chance might be debugging or if it's a bug, submitting bug report
Looks like this is how UE tries to find rep graphs:
UReplicationGraph* FindReplicationGraphHelper()
{
UReplicationGraph* Graph = nullptr;
for (TObjectIterator<UReplicationGraph> It; It; ++It)
{
if (It->NetDriver && It->NetDriver->GetNetMode() != NM_Client)
{
Graph = *It;
break;
}
}
return Graph;
}
Hi, I have a small question
Why when I play in Simulated Multiplayer with 2 clients both character have the same controller (Controler_C_0) ?
shouldn't each one of them have one controller each ?
They each see only their controller. Is this in a listen server setup or 2 separate standalone windows?
hum, good question
I added a node to show the object name with "getController->GetObjectName" and it's always the same C_0ร
they should only see their controller, I agree. So even if C_0 is the same name but not the same controller, It should work
but I have a couple of tables and methods in the controller itself and it seems they are colliding when I simulate
I have 2 windows: the UE Editor one, and a small separate window
First make sure you actually have 2 connected instances. If you do, you probably have to gate stuff by HasAuthority or IsLocalController etc
