#multiplayer
1 messages Ā· Page 467 of 1
and hint: when NotifyLoadedWorld/NotifyServerWorldLoaded is called on map A after travelling from map B
the controller class its called on is the one from map B
only after that does the GM switch the controllers
and all GM functions are virtual and/or blueprintnativeevents
with PostLogin you're restricted to your login url string
with this you're restricted to whatever you put in your LobbyPC/PS
Could someone tell which is a better approach for Amazon GameLift dedicated server hosting (or any dedicated server hosting service for the matter):
a) Integrate GameLift client sdk directly into the game and communicate with the server (make searching/joining session requests directly from the game client)
OR
b) Use a php web service (as i'm familiar with php) that acts a middleware between the GameLift server and the game client for communication (game asks the web service to search for sessions; service finds suitable session and sends the session info back to game client)
having not done it myself, it seems that a) would be simpler than b), though I guess b gives you the option of switching to something else later
also b) adds another potential failure point to debug
also they have a plugin for that don't they?
they have the server sdk plugin for ue4 but not the client, still looking into adding the gamelift client cpp library to ue4
"your client service" has me mixed up with the second option (amazon's gamelift game architecture they recommend).
Also read somewhere on forums that using a middleware service is more secure though it can add some latency
Is there a difference between compressed flags and RPC? Should I pass input values as a compressed flag or an RPC?
examples being move forward right etc
@fluid prawn like outside of normal CMC replication?
Yes
I am currently trying to figure out some things with the CMC
I overrode it and did my own phys custom function that does custom accel friction jump gravity
now im trying to replicated it using UT replication style code
replicate*
Hey,
Someone knows if I can I replicate a UObject pls ?
Or can I only replicate Actors ?
you can replicate UObjects if they're owned by an actor
well, technically their outer is an actor
@copper mango Thx, I have a last question.
I'm creating an ItemHandler that will hold all my items on both client & server side.
I want to create this ItemHandler on server and I want it to be replicated on all clients so that they know all the items that exist.
Should I use UObject or AActor as parent class for my ItemHandler ?
like the items in the player's inventory?
In inventory and also on the floor (in the world) or also in a chest
All the items that exist on the world
@copper mango Actually, I have an ItemHandler (a UObject) and a list of item in it (also inherit from UObject) and I would like to replicate all of this to my clients
why does the client need to know about all the items that exist in the world? that's potentially also easy to hack because then the client knows what's in every chest
@copper mango kk I see, I didnt think about that.
So, all my items should be only stored on server side ? and the player should have information only about his own inventory ?
well, when the items are on the floor can the player see stats about the item?
like if they get close
Actually he can because he has access to my ItemHandler
ok so what I'd suggest, is like you have UItemInfo or whatever
So he can have access to this information with the id of the item
and it can either be owned by an Actor that's on the floor (representing the dropped thing)
which is replicated to client
or it's owned by a chest (which isn't replicated to client)
or it's in the PlayerState inventory (which is replicated)
I dunno if that's the best solution, but that's where I'd start
@copper mango ok I'll do that thx,
But, if a player want for example to access a chest, the server will have to send this player all the informations about the items in it.
Is it a problem ?
and you could make it so the PlayerState inventory is only replicated to autonomous proxy so you can't see what items the other players have
@copper mango Thx a lot š
it's less data than sending all the items in the whole world to the player, so I think it's fine
could just be a client RPC when the player opens the chest
Well true
and the server just gives you a TArray of item infos or whatever
and then if you pick up an item, that's a client->server rpc saying you want to pick up item at index X in the chest, and then the server would add it to your playerstate which then gets replicated back to you
sure, good luck
@copper mango Each Item I have own a list of components and each component inherit from UObject ( a component can be for example a name or dmg of a weapon or even ammo of a weapon ).
Did you think I should do that to store informations about my entities pls ?
I'm new to ue4 just want to know if I could store informations about each item in a better way
so, if I have a gun item, it would have like a component for its name and a component for how much damage it does, and a component for the ammo count?
does it need to be that complicated?
I want to also use this system to store any type of entity (not only item).
But yes for the moment it don't need to be that complicated
like you don't want to subclass Character and stuff like that?
Why ? I should subclass Character ?
I have a class Character (C++) and a BP_Character.
But I don't have a subclass of Character should I have one ?
well, BP_Character is a subclass, just in blueprint isntead of C++
what do you mean by "entity"?
yeah, but then isn't a character an entity then too?
by that definition
and like a StaticMeshActor would be an entity too
š¬ true
I think you'll end up fighting the engine a lot if you think of it in terms of entities and components
like, the engine does have components but they're actor components and they're much bigger functionality than mix-in components
like CharacterMoveComponent and such
well, they don't have to be big necessarily, but it's not really designed for like say an Actor to have 25 components
usually it's like 3-4 max
except for certain exceptions
So I should use actor class for my items ?
well, so like
the chest could be an Actor subclass
and it'd have static and/or skeletal mesh component (depending if you want to animate it)
and maybe a box component for collision detection
and then one of its properties coudl be your UItemInfo or whatever thing
in general, anything that's actually physically in the world should be a type of actor
And I would create a component for the ammo of a weapon ?
When my item is in my inventory it should also be an actor ?
when it's in the inventory, it probably doesn't have to be an actor
so basically the idea is your UItemInfo is the actual data representation of the item
and then the actor would be a physical manifestation of the item if it's say on the floor
or you're holding it in your hand
Ok that's way more simple than what I actually have
But with actor how should I store for example the dmg of my weapon or it's amount of ammo ?
Would I have one class for each item I want to create ?
normally you want to try to design it in a way so that there's a minimal number of C++ classes and then every different type is a data blueprint where you mostly are just changing data like mesh, fire rate, max ammo, etc.
so you might make a Gun class in C++ and then in blueprint make several blueprints for Pistol, Rifle, stuff like that
if you look at the shootergame example, you can see how they setup their items in an MP game
Documentation for the C++ example game project ShooterGame
That exactly the type of thing I was trying to figure out. Didn't know when to create a c++ or a blueprint
thx
it really depends on how comfortable you are with C++, it's very possible to make reasonably functional games in just blueprint
but if you're doing MP you really probably want to do a decent amount of C++ for functionality, and then use blueprints to make data
I'm quite comfortable with c++, that's why I was trying to make everyting in c++ but that's not a good thing to only use c++
MP ?
you don't necissarily want a minimal number of C++ classes
i generally go about 80%C++ 20%bp
but making everything in C++ is the wrong way to go too
but the general idea is right, systems in C++, implementations in BP
@gleaming vector That's what I also have 80%/20% I'm using bp only to link mesh and things like that or for UMG
@copper mango What did u mean by MP ?
multiplayer
does anyone know what the current guidance is for the online subsystem?
i mean does shootergame use it and is it up to date
anyone know why switching weapons on a player on the server in shooter game would cause 3 OnRep_AttachmentReplications instead of 2 on the client?
I expect one replication for the attach of the new weapon and one for the detach of the prev weapon
but instead it seems to get one for the new weapon, one for the detach of the old, and then another for the new weapon again with what appear to be the same exact values for AttachmentReplication's member variables as on the first attach
anyone know if UE4 gives some kind of native "Teaming"? similar to how you get stuff like playerId for free on PlayerState
^for the attachments, I would think it's an implementation thing. maybe try checking the logs if you only detach + reattach on the same weapon, etc. stuff like that until the pattern emerges
hi I'm having a problem that's right now that's keeping me away from continuing with the project: I have clients in a peer to peer session and the host is searching for a dedicated server session using Find Sessions Advanced in the Advanced sessions plugin. The thing is, when the host finds a session, incorporated in a "blueprint session result" variable, I can't find a way to pass this variable to the other clients from the ptp connection. I've tried through replication or simply sending it as parameter in a function, but the clients will always get the variable as NULL and therefore can't join the session. What am I supposed to do?
@weak fog have to implement teams in that sense by yourself, there's teams for AI perception but that's not what you want
gotcha gotcha. was just making sure i'm not doing undue work. thanks!
hi hi. Last day I tried my small project with a friend in a mp session. I got a lot of lag and it was really difficult to use it. We were running the game with the standalone version that you can open with Right Click on the main fail of the project (so not using the compiled version of the game). I was wondering, the netcode of unreal is efficient to have simple things with free lag right? Or is the online system bad by default?
that's not normal, but if you run with "launch game" that version will be unoptimized
you have to package the game to get the optimized version
but if your game is simple it shouldn't be a big issue
so i got this issue where if Player 1 has equipment attached (sockets/skeletal messhes, doesnt matter), and then Player 2 runs far away and comes back, Player 2 can no longer see the items on Player 1. But the items still show on Player 2. Is this a rendering distant issue thingy?
Might be a net relevance issue?
Make sure BeginPlay isnt messing with them, BeginPlay is called again each time an Actor becomes net relevant.
hey guys quick question: Where should I do general things like initializing the steam api and calling global functions for my game? I was thinking about the game instance class, but I want to be sure. How do you guys do it?
Ah okay thanks Devils Ill look into that
Does somebody know what could've gone wrong when the match state in gamestate returns aborted?
@wheat eagle GameInstance is a good place for that.
thats where we handle it
/** Possible state of the current match, where a match is all the gameplay that happens on a single map */
namespace MatchState
{
extern ENGINE_API const FName EnteringMap; // We are entering this map, actors are not yet ticking
extern ENGINE_API const FName WaitingToStart; // Actors are ticking, but the match has not yet started
extern ENGINE_API const FName InProgress; // Normal gameplay is occurring. Specific games will have their own state machine inside this state
extern ENGINE_API const FName WaitingPostMatch; // Match has ended so we aren't accepting new players, but actors are still ticking
extern ENGINE_API const FName LeavingMap; // We are transitioning out of the map to another location
extern ENGINE_API const FName Aborted; // Match has failed due to network issues or other problems, cannot continue
// If a game needs to add additional states, you may need to override HasMatchStarted and HasMatchEnded to deal with the new states
// Do not add any states before WaitingToStart or after WaitingPostMatch
}
@fleet viper
Could be a network issue
// Called when a player is disconnecting due to network failure
DEFINE_GAME_DELEGATE(HandleDisconnectDelegate);
There you go
Apparently its called by this delegate.
someone ran into this issue before, luckily it runs fine in a packaged build
well I got armor and such to remain attached when other players come in and out of render, but not weapons. Basically anything that is attaching to sockets and going thru a multicast seems to not keep the sockets updated if other players get too far out of view. Not sure how to solve
use replication instead
RPC's should be for fire-and-forget stuff
variables should be used for persistent states
once your object goes out of relevancy range it gets destroyed
so whatever you've done with RPC's will be undone
How would I replicate an attach to socket?
a multicast isnt the right way then because thats an RPC
RepNotify or something?
Yeah
I meant, assuming the weapon is an actor, normally it would just replicate it's attachment via rep movement
yes its an actor, so I need to enable rep movement, and then attach with a repnotify?
If you enable rep movement it will attach automatically
But it depends on the game as to whether you want to pay the rep movement cost
okay
would there be a way to update its socket location only when other players come into view or something?
in our game if the weapon is equipped, we just attach to a known socket. no need to rep any extra info
well it's driven by the server
so when it all replicates / is created from replication it should just attach itself
okay so no need for this multicast
shouldn't be
I can attach it on my server function and it should replicate right
yeah if the weapon replicates movement
ok
I'd suggest making the weapon use Net Owner relevancy as well
if in doubt, look at shooter games' setup. that's a pretty common approach
hmm still teleporting onto the players root
its good as long as the players are close
but once you run away out of distance then come back its off the socket
no more multicast though
hold on gonna try a notify really quick
fuk still didnt work
im stumped
okay so what's happening is when the player is far enough away, the other players are deleted/culled/whatever. and the attached weapon is getting deleted with it (for that 1 player who's far away)
when I come back into range, the players are no longer culled, but the weapons arent brought back with them. so I dunno how to fix that
@chrome bay do you have the bones updating on the server?
hey i fixed it by setting the player characters to be Always Relevant. Not sure if thats ideal but ill keep it on until i find another solution
Hey,
I'm trying to use RPCs. My server invoke the rpc but I want to run this call only on a specific client.
The ue4 docs say that my server need to call this rpc from a client owned actor. But the only client owned actor I have is my player controller.
I would like to avoid creating function in my player controller class that have no reason to be in this controller class
How would I call a rpc from server to a specific client without creating the function in my player controller ?
I think the PC is the only thing you can address specifically, that is the representation of the client from the perspective of the server.
Can someone point me in the right direction on how to save player information on a server (as in, a storage server that I rent from amazon or something). I know I can save to a file using the save game object, do I then upload that file somehow to the storage server, or is there a different process? Im new to all of this, thank you
@rotund sapphire id the only way is to use PC, do you know if I can somehow separate my code within my PC class ? Is it possible to use actor component for that ?
I can't think of a reason why wouldnt that work. Do you have issues with an AC?
@rotund sapphire no All work fine now š thx
@chrome bay @potent prairie I think it will replicate the attachment regardless of rep movement right? Was just looking into this same thing because I'm seeing extra OnRep for attachment in shootergame that I don't understand yet:
void AActor::GatherCurrentMovement()
{
if (bReplicateMovement || (RootComponent && RootComponent->GetAttachParent()))```
and:
void AActor::DetachRootComponentFromParent(bool bMaintainWorldPosition)
{
if(RootComponent)
{
PRAGMA_DISABLE_DEPRECATION_WARNINGS
RootComponent->DetachFromParent(bMaintainWorldPosition);
PRAGMA_ENABLE_DEPRECATION_WARNINGS
// Clear AttachmentReplication struct
AttachmentReplication = FRepAttachment();
}
}```
both seem to be able to run regardless of bReplicateMovement unless something else is keeping changes from going out with a rep condition or something
shooter game does do its own replication in addition, because only the root component of a replicated actor's attachment is automatically replicated, and the third person weapon mesh other players see needs a separate attachment to the third person character mesh
does anybody know if the gameplay ability system uses the movement component saved moves?
does anybody know if the gameplay ability system uses the movement component saved moves?
I'm worried it won't do proper client prediction
@raw quarry as far as I know, if you're talking about the root motion tasks, it does and was working in 4.19, but as of 4.20 it seems to have issues with prediction.
some of the folks in the #gameplay-ability-system channel have reported it, and are waiting on a response back.
ok thanks!
is it possible to replicate a component to everyone but the actor the component is part of's owner?
I know there is skipowner on replicated variables but I didn't know about with a component that is bReplicates
skipowner wont replicate it back to owner
not sure if it works with Replicates
you might need to handle that seperatly
not sure if the component has some replication settings
that condition is for variables
there are ways to work around it though
and spawn it, locally, on everyone except the owner
you'll still be able to reference it over network
SetNetAddressable(true) call on the thing
and exactly the same name on all machines
as for RPCs running through it, if owner doesn't have it, it doesn't matter so thats fine
it will not be able to replicate any variables inside of it tho
Anybody got any ideas regarding my question that I asked a few hours ago?
@twin juniper best to save it some kinda database
serialize and store on server
using some kinda REST protocol or something
Yeah I understand that part, but since I know nothing about this, what exactly do I need to learn
will I have to do coding in php or some language like that?
Just trying to find some guide or tutorial on how to go about all of this, since this is all new territory for me
Hey,
I'm replicating a struct that is within an actor.
This struct contain a UObject and this UObject is create on server side.
Someone know why when this struct is replicate to client the UObject in my struct is always nullptr pls ? Is it normal ?
what is a good way to test your game that is connected via steam multiplayer? currently if i want to test something i have to package the game, put it on another pc and join the host pc. is there an easy way to test without doing all of that such as sticking to only one pc?
you can set the number of players in the drop-down menu next to the play button and change the play mode to run in New Editor Window (PIE)
and then in advanced settings from that menu u uncheck Use Single Process i think
derp, didnt think to try that but that seems to work along with misc functions in the game mode like post login, thank you
standalone game also works i thiiink im not that sure lmao i'm pretty new to this stuff
for some reason i had issues testing in standalone using lan settings. the server appeared but it failed to join which may make for some frustrating issues later on but that will be dealt with lol
i'm having an issue trying to replicate wallrunning based off Matthew Palaje's titanfall 2 wallrunning tutorial. i made a forum post but i'm hoping for a faster answer here. the link to my forum post is here https://answers.unrealengine.com/questions/900376/bp-networking-wallrunning-client-issues.html
Clients seem to jitter and the wallrunning simply fails to happen, possibly linked to how LaunchCharacter is wonky when replicated and/or overlap events being weird.
So essentially two cases (so far) where this fails:
- mid-wallrunning when the client suddenly fails to stick to the wall
- attempting to stick to the wall but fails to do so when the EndOverlap is suddenly triggered even though the overlap collider is still overlapping the wall (this is evidenced by the fact that when the client actually leaves teh wall the LEFT WALL message appears again, leaving two of such messages)
i'm currently updating to UE4 4.22.2 to see if this changes anything assuming the first case is a weird bug with ue4 4.20
Someone know it possible to replicate UObject in ue4 ? Iām trying to replicate a UObject stored in an actor.
My object is not null on server side but itās null on client side
@idle flame have to override a couple of functions in the actor https://wiki.unrealengine.com/Replication#Advanced:_Generic_replication_of_Actor_Subobjects
@copper mango thx ^^
Question for you guys I'm having issues figuring out why when I set 2 Players the client does not spawn but the server only possess. I get something that looks like this
when i spawn three characters it's fine? I've tried Actor offsets, I've tried adjusting collisions no success
@fluid prawn try adding more playerstarts in teh scene if u only have one
I've added two
seems to not work but if I do three player starts it works
for some odd reason it wont work for two players
three player start for three players it works*
What if you run as dedicated server, does 3 player or 2 or even 1 work?
How are you choosing spawn points?
I am just using the player start
Did you override game mode functions?
no i did not override the game mode I tried my own and the default
i would just try adding like 10 spawn points and see if you can still reproduce the issue
i had the same issue with my multiplayer project and it was because 2 clients were trying to use the same spawn point
i added a method to delete the playerstart actor after it was used (works for a 4 player coop game), which completely resolved the issue
if there are 2 playerstarts, and you are spawning 2 clients, they should automatically select 2 different playerstarts, not the same
@past rain that's what I thought aswell
Create a new project
See if it works fine there
if it does, then you must have changed something
that messed it up
if there are 2 playerstarts, and you are spawning 2 clients, they should automatically select 2 different playerstarts, not the same
Would that not only be the case if the clients manage to be created at the exact same time?
If you do a server travel to load your map then clients wouldn't join in at the exact same time right?
Could only be a single frame difference but I would imagine that would then allow 2 clients to try and use the same spawn point.
That's true, but regardless it doesnt look like the issue is playerstart, if two clients spawn in the same playerstart they will both still spawn
in his case the clients arent possessing anything
I had the same issue, it wouldn't possess because it didn't finish spawning properly
May have just been the screwy way i was spawning people in though /shrug š
Most likely, by default this shouldnt be an issue
Especially if you arent overriding functions that has to do with spawning
By default the game mode comes with the spawning working
yeah I'm curious why its like this
i just tried default game mode
with just a regular pawn
seems to still spawn the mesh on the player start
but the camera is still under the map and not possessed. Like i mentioned earlier if I do 3 players it possesses properly
makes no sense
@fluid prawn set a default pawn to the correct one for the game mode
like so.
// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/FirstPersonCPP/Blueprints/BP_FirstPersonCharacter"));
DefaultPawnClass = PlayerPawnClassFinder.Class;
I've tried that also. I made a Game mode BP and set the class to my game mode and then went into the game mode override and set the default pawn
still no avail
I'm writing some spawn point code to see if it works
I'll post it in here for those who might need it
making progress
is there any kind of callback on the client when the server makes it an owner of a replicated actor?
I guess you can override SetOwner, but that won't catch replicated changes, so also override OnRep_Owner?
I think that's possible
so I found out what the issue could be but not sure how to solve it yet
So for example if I run my own game mode with the default boiler plate code generated from first person c++ class it will set my default BP_FirstPersonCharacter but the other clients are just floating around like they are in spectator mode but not possessing anything. So I tested something interesting I set my BP_CustomGame mode to the default game mode class instead of the boiler plate one. I can actually see from the clients perspective the server moving around but still the clients are still not possessing anything. It seems that the issue lieing with the game mode
Also this might be the issue but I am using my own Custom Movement component Class.. I just made a child class of the default one so I can add my own custom movement type. That could also be part of the issue.
@fringe dove yes, that is the way to go about it
Okay guys am lost: The client needs to catch the server, but the server never teleports away. (Server -> client works fine).
- Script running on the police (client): https://blueprintue.com/blueprint/ekmkwdre/
- Script running on the criminal (server): https://blueprintue.com/blueprint/ro2jvve1/
- Teleport events: https://blueprintue.com/blueprint/p-_k4khs/
@viral raft can you explain what you're trying to do without the blueprints? like just at a high level
followup to my "my controller looks corrupted" question from the other day: turns out when a remote client connects to the listen server, the server makes them a pawn, which is then momentarily possessed by the server's pawn's controller before being possessed by the new client's controller. not sure yet if this is a bug in 4.20 or in our code.
if you overrode anything in the GameMode, and used GetPlayerController[0], probably
hello people I have a problem: I'm trying to make stats for my game using the steam api. When setting the stats for my game in the Steamworks admin panel, it is an option which asks whether the GS(game server) or the client will store the stat. At first of course that I selected GS and I tried making the code for sending stats server sided. 4 hours pass by, i don't achieve anything because I can't make particular things work and now I'm angry as hell and considering leaving the "Client" option for the stats as I already have the code for clientside. My question is: is storing the stats client-sided dangerous and vulnerable to hacking?
If its stored client side then the client can alternate the stats, so yes
@copper mango I am trying to teleport a player (server or client)
But when trying to teleport the server i get this error:Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor EscaposCharacter_C_1. Function Teleport Server will not be processed.
Teleport server also doesnt get fired on when the server needs to get teleported
@twin juniper sorry , I realised I asked the question in a wrong manner. The server sends the client the stats modified server side and all the client does is sending it to the stats server through steam api functions(the client doesn't actually set any variable, they just send it). Is it still vulnerable if it is done like this?
If the client doesn't have the opportunity to modify the stats, then I don't see the issue with it. Seems safe enough to me, although Im no expert, @wheat eagle
@viral raft oh, if EscaposCharacter is not controlled by the local player, you can't send a server RPC to the server on that character, if that's what you're doing
you'd have to send a server RPC on like your current player controller to tell the server to teleport the other player
Is there any way for a listen server host to just create a dedicated server behind the scenes and connect to it along with any other clients?
So he'd still be hosting but without the potential issues a listen server brings (like choppy client interp when viewed from the perspective of the server). Dedis make it so much more even- everyone is having the same experience- much easier to test
Similar to PIE with dedicated server checked
don't think that's built in, but if you followed the PIE code path for it maybe you could emulate it
Feels like it would be best to sit down and learn how to implement interp, as it would save a lot of headache in the future
Would make making multiplayer games easier
@twin juniper eventually I managed to make the delivery of the stats properly and server sided 100%. Thanks for your answer though.
@wheat eagle pm'd you
Hi, i need approach or advice if i'm doing well or if thinks it's wrong.
I create ItemWeapon like Struct, with Name item, damage, hitpoints and Statics mesh (for equip) and my character have one Struct CharacterEquipment, with have
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Weapon)
FDOWeaponItem MainHand;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Weapon)
FDOWeaponItem OffHand;
Work with this approach is good?
This is for Online game
@ornate crescent Pretty sure this is how they do it in the Shooter example project
where the weapons have a struct with all the info in it
yeah, but in my game, the player can be disarm. so.... the MainHand is weapon
is empty sorry
In the shooter project you can change weapon
Which is the same as disarming then rearming
Definitely worth taking a look at how they did it there
yeah, but is MainHand = OtherItem, not way to detect if is empty
i'm going to take a look to the shooter example
thanks @twin juniper
š
shooter game use actor
TArray<class AShooterWeapon*> Inventory;
/** currently equipped weapon /
UPROPERTY(Transient, ReplicatedUsing = OnRep_CurrentWeapon)
class AShooterWeapon CurrentWeapon;
Yes. I'd make a class out of the weapon
and give it to the character
Thats the way I do it too
yeah but i have a Inventory System, with character with Equipment
all items in Inventory (i think) is best choice is use struct
but for Equipment i try with Struct but i think i change to AActor and add Iteminfo to the actor
@ornate crescent The weapon inventory should be a struct of Weapon no?
TArray<FDOItem> Inventory;
this is array of structs of Items in the inventory of player, have all information about the items
and Character have a Struct (CharacterEquipment) with each slot for equip items
in the CharacterEquipment each items are Struct, now i change to Actor with this Actor have the ItemInfo and spawn the mesh in the character socket
Hey,
Someone know if this table on ue4 docs is correct ?
https://docs.unrealengine.com/en-US/Gameplay/Networking/Actors/RPCs/index.html
I'm calling a RPC in an Actor Component of my Player Character class
The owner of the Actor Character is the server (I think).
I'm calling the function from client to server.
In this table, the rpc should be dropped, but it worked.
Designating function replication across the network
@idle flame if it's the player-controlled character (autonomous proxy) that counts as "owned by invoking client" so it does call a server RPC on it
@copper mango Ok thx didnt know that
but only for the player who's local to it
so like player 2 can't call a server function on player 1's character
yes seems obvious xD thx
@copper mango it is controlled by the local player
hey guy a big question for you that new stuff just got out and a was wondering if was possible to that using this - create a server side with the link below to create a map and modify the terrain with a client side like a spell in game ?
https://www.unrealengine.com/marketplace/en-US/slug/marching-voxels
in theory it's possible, but I doubt it would be easy to convert the project to work with MP. you'd probably have to rewrite it from scratch with networking in mind
How can you get the local player character inside of another player state?
a client cant get another clients playercharacter
from playerstate
UPROPERTY(BlueprintReadOnly, Category=PlayerState, meta=(AllowPrivateAccess="true"))
APawn* PawnPrivate;```
Ok let me rephrase to ensure that
I mean, what does this return inside of a player state
the first player character at index 0 in the array
i was hoping for the local player
so here's the thing: i have a replicated SlotID on player state that defines which player slot they use (role inside the game). I need to MUTE all players that are NOT of the same team, so when the SlotID gets replicated, I need somehow to check whether this means that the player associated to the state that got replicated is NOT in the same team as the local player
bp or c++?
how are you checking for teams?
i mean GetPlayerCharacter should work
to return the local pawn
this is the kind of madness i'm into rn
I know, right.
well i don't see alternatives, which is unfortunate
the PS SlotID gets replicated at different times obviously
Here, this is what I'm doing
this get called OnRep of SlotID
basically: get the Team from the LOCAL character, then compare it to the just replicated SlotID of this Player State. If NOT in the same range of the team, then mute player of the player state.
What I get: the LOCAL character gets muted (?!)
so obviously i'm doing something wrong
so: if i try this locally with "Launch Game" it works (2 instances). If I try this online with another tester, every player mutes themselves.
Any ideas? Really stuck here.
its not BP exposed
If that doesn't work for you, you can always have your controller send your player state your current pawn
Having an issue with dynamically spawned actors where unless I set Always Relevant to true, they donāt seem to exist on some clients despite all the players and the spawned actor being right next to each other (not a net cull distance issue basically)
@naive crater thank you but I don't need the pawn controlled by the player state, I need the pawn of the local player
ok thanks, then my problem is elsewhere even though I don't get it
@ember needle how are you bringing your players into the world, cant you just store player / assign player ids in the game mode on the server when they enter the world and then group them/organize based on the team.. when i spawn players into the game world i always assign them an ID that i have control over .. that should be really easy to check what team they are on like that
i'm still confuse about how to manage my player equipment, if any can help me.
I have a inventory is TArray<FItem> Inventory which FItem is a Struct for every item information (ItemId, itemname and StaticsMeshComponent)
My Character have , example, Weapon. my first approach is this weapon like
FItem MainHand;
But is not the best solution,because if i unequip the weapon, the Fitem struct still stay (i need to set all to 0) . I think this is no the best approach so i think the next solution
Create Actor like AGearActor with this actor have
FItem ItemInfo;
StaticMeshComponent* ItemMesh;
I think this is best approach... but... for this game all equipment are only visual, all logic is only numbers, don't need collision and nothing.
Is the best approach AActor with replication or other approach?
Equipment is only for visual, no need collision and nothing more, only show the MeshCompoentn in the character. The logic in the game is only get the ItemInfo to know the damage, range and hitpoints
Is it possible to make a player controller that records all it's movements like a demo, but can be played back via an AI controller that still controlling an active pawn that can be interfered with? I know the replay system records replication data, so I wonder if you could play that back server side as a virtual client.
you could just store the movements yourself
and replay, sure
you could just store movement inputs from the player
and have the ai apply the same movement vectors
What about slight inaccuracies in the movement though. If that is the case, even a centimeter difference in parameters could throw the replay completely off
@meager spade What if there's a small discrepancy in the variables of the map that cause the recording to become unsynced? Physics need to still be run so that players can purposefully interfere.
Hey friends - I'm having clientside animation jitter I've verified that client and server are both returning the proper move speed for the pawn in question. This capture is from a client, the server owned pawn is moving smoothly, but the client's pawn still jitters when moving. https://gfycat.com/EachFineGosling
Anyone have / solve this problem before?
@unreal pine I assume this is when a player is hosting right?
And you're using the character class?
If I have a child actor on an actor already set to replicate, then obviously the client's replicated version will have a child actor spawned for it..
but.. what if I set the child actor to also replicate.. will the client now have two instances of that actor? One attached to the parent, and one detached?
unreal should be smarter then that
having said that i usually void using ChildActorComponents
"should" instills much confidence in me
I guess I'll have to test
but its easy enough to test
well no, but one of them might not be a child actor component
set the outliner to view client's world and see if you have an extra child actor
it might just be the actor
empty level, no distractions
mmm my levels are pretty barebones
you put one instance of the parent actor in
see if you have 1 child actor on server and 2 on client
I'm just at home write some of the C++ code. I'll have to see about the testing when I'm in the office
i really doubt you will
Iām not sure why but I fixed a similar issue by making sure that ācomponent replicatesā was turned off in the character movement component on my character.
i mean, when unreal replicated an asset with full path
it creates a NetGUID after the first replication so it doesn't have to send long strings
for example
it would surprise me they covered that but failed so miserably on child actors
I guess I'll write the code with the assumption it's gonna work correctly
Oh I guess one more question for you since you're here =)
Do replicated properties do so only when they are updated? or is it tick based? Or a combination?
the netdriver will evaluate the replication per actor, during its "net tick" and its in quoted because that technically doesn't exist
its NetUpdateFrequency times per second
if something in the RepLayout changed, it will replicate changes, if it hasn't, nothing will be sent
nothing will be sent if its dormant, fails relevancy check...
replicating is evaluated per actor per DataChannel (one per PlayerController)
hmm half that is over my head
so if you change a replicated property
I think I'll read as something like: if something changes everything will be sent
it will be sent the next time Actor is evaluated for replication
oh ok
how often that is depends on NetUpdateFrequency
it is a good practice for Actors that have important replicated variables that don't change often to keep the NetUpdateFrequency low
and call ForceNetUpdate after you set the variable server side
oh interesting
it will push the Actor into the replication bucket for that frame
what units is the frequency member?
ofc, if used too liberally, same as Reliable RPCs, the technique loses all its benefits
Hertz
@copper grove player state is where i store the SlotID, seems the right place... Will try alternative routes if this doesnāt pan out
i did flag that comment as unfortunate as soon as i saw it
PS doesn't control anything
but if that is a local player's PS, that variable does hold local Pawn
Hey folks, having some networking issues related to ownership, and I found out that the game mode never SetOwner()'s the spawned pawn to be the player controller? Is there a reason for that? Currently I'm doing it manually in a game mode derivative.
Hey guys! Does anyone know if I can replicate an object to a specific client only, so the object would only exist for a server and one spicific client?
@twin juniper I assume this is when a player is hosting right?
Yes, but happens on a dedicated server as well - just wanted to show how a server side character's animation looks smooth as opposed to the client
@sharp pagoda it does that inside the Possess function
Ah found it, thanks
actually - I found where that animation jitter is happening. Can someone sanity check me here? What's a safe range to stay in for listen servers?
This is on the character movement components
I started pretty extreme just so I could verify that was the correct variable I needed to change
for now, I'm just gonna keep dialing back until it looks bad again, then test over steam
@meager spade Thank you. I already found out about it myself. But now I met another problem. The object simply doesn't replicate at all, when I have this checkbox checked. I create an object on the server, assigning the ownership to the specific client, but the object spawn only on the server. If I uncheck the box, the object replicates to all the clients, as expected.
hey, is there a way to check what is distance between client and server position? basically it sometimes happen to me that I start playing animation and my character slides slightly, but character movement doesn't change velocity so I assume this is due to smoothing
you can turn on p.NetShowCorrections 1 and then it'll show you when there's a discrepancy between the local client and what the server expects
will certainly try it out, any idea how to stop the sliding if this is the case?
I don't think the smoothing functions get called on the autonomous proxy path, I believe those are only for simulated proxies
it's simulated proxy
oh
yea would be slightly easier :D
so the problem is if local player A starts playing the animation and then that's RPC'd to server and then to player B, and player B gets corrections but player A doesn't?
well it's AI so BT calls play animation, client side AI waits till it stops (based on velocity) and plays the animation, RPC is only called to sync that client should play animation when character starts
everything works ok, AI played animation no issues, but right as it stops, it also slides a little, it's more of a visual hiccup that is annoying living hell out of me
ah
so it's almost like the animation ends slightly earlier on the server (which makes sense), and then the server AI controller sends another move input after that, and then your simulated proxy has both the montage playing and the first move after the montage at the same time? maybe?
hm I think that would just override the montage, but no this happens pretty much when AI stops moving and starts playing animation
and seems to be more pronounced in standalone if that helps anyting
oh so it's on the start of the animation, not the end?
so then it's like the simulated proxy code thinks it's still moving, but then it receives from the server "hey you're playing the montage and at this timestamp" and that's where it glitches?
hm simulated proxy starts playing montage the moment when its CMC velocity is zero (or close to zero)
my thought is that while CMC says AI stopped, smoothing might be taking over trying to correct the position to correspond with that on the server, but it doesn't do it through velocity?
hmm, I'm not sure, I haven't looked at the move smoothing code really yet
that's fair :)
ah well back to deep diving into guts of the engine, thanks for trying anyway
dude that p.NetShowCorrections 1 actually helps me a lot right now too š
I'm still getting that weird animation jitter, but at least I know it's not the server correcting the client now
weird that Listen Server Network Simulated Smooth location/rotation Time variable is making a difference of how that animation jitters on the client and server though
I think I was battling with similar issue few months back
but I haven't really read what you wrote yet so gimme a moment :)
oh, it was a little while ago
Hey friends - I'm having clientside animation jitter I've verified that client and server are both returning the proper move speed for the pawn in question. This capture is from a client, the server owned pawn is moving smoothly, but the client's pawn still jitters when moving. https://gfycat.com/EachFineGosling
Anyone have / solve this problem before?
what I found, was that lowering the Listen Server Network Simulated Smooth Location Time to .005 made everything look great clientside
but server side it made it worse
which is weird
what's your network no smooth update distance, and network large correction distance in CMC? I think increasing those values solved most of the issues for me
yeah I actually changed those a lot for testing purposes
one sec
these are my settings right now
if you force dedicated server does it fix it?
no, it actually makes client to client prediction worse lol
like worse than server to client or client to server
right on, I'll give 'er a try
and uh...times...0.05 will pretty much just snap rotation, so maybe increasing it might improve the...smoothing experience? I feel there's something wrong with me saying that :D
@copper mango yeah ok seems smoothing just straight away sets new location and rotation rather than moving actor through CMC, makes sense I guess
I feel like the client shouldn't be jittering on the server ever, since it has authority on its position, right?
is it autonomous proxy?
I don't know š¬
hh is it AI? :D
is it player that is owned by that client?
it's not owned by the server I guess
but the server has authority on it moving, right?
likely no, if it's autonomous it means that some client owns it and server should replicate movement to other clients, but it takes position from client
if it's simulated proxy (AI most often) then it lives on server and server has authority on what it does
you can actually check it, AActor should have property Role :)
might help you figure out who is in charge of what
hmm I see I thought inputs came in through the client, and the server called the add movement to that pawn or whatnot
might be don't take my word for it, I mostly deal with AI
so never really worked with autonomous proxies
on autonomous proxy with CMC, the local client executes the move locally and then at some point sends move(s) to the server, the server validates for the client timestamp and then sends back corrections if it thinks something's worng
ok - that makes more sense that there's position jitter on the server as well now
but shouldn't p.NetShowCorrections 1 be lighting up my screen whenever the animation jitters then?
that only shows something if the server decides the client's wrong and sends a correction
ah, so that's considered a normal update for the server
are you sure it's not a problem with your animation blueprint?
cause you're not moving that fast where it should look that bad
if it's an issue with the animBP, wouldn't it be having problems for the server's pawn on the server?
If you have a moment, I can screen share with you and show you the problem
you wouldn't happen to have some weird avoidance on huh?
not really sure what that means
but no, I'm not really doing anything fancy for setting position
how are you moving the autonomous proxy locally?
just with apply movement input?
er, AddMovementInput
well I had to try :)
yes
and because I have multiple instances of unreal that launch to test replication, I'm able to control both with the same controller
so the input is being called on the actual client
how much simulated packet lag were you using in that gif?
nah in the console
Net PktLag=number
by default it's 0
so you definitely have something abnormal going on if it looks that bad with 0 packet lag
yep, then I'm using 0
I do
@copper mango I tried setting that packetlag, and p.NetShowCorrections 1 will absolutely light up my screen with issues related to client/server
I'm not sure why it's so much better client-side when I adjust these guys down
@echo pond it's set as the max walk speed on the CMC
oh yeah nah you right
yes, it's set from the current move speed I'm sure
so try to change it that if you don't run it's 0 and if you do run it's max, just for test, see if it still jitters
yeah, I'm setting it to a static value
also I'm not sure you are running listener server :)
nope, still about the same
I'm definitely running a listen server
but still have issues with a dedicated
uuhm I think you either have on or the other no?
aaah ok, I misunderstood
do all replicated properties of a new replicated actor get sent with the initial bunch?
I think so, unless you have a replication condition that excludes the initial replication
Where's that?
that's an option for any variable in blueprint
ah good to know, thx
so , when making a server-client type game, without a dedicated server, the server being an actual player, how do you prevent the server from cheating, is it at all possible? would you send some occasional data to all the clients and check for mismatches?
bitcoin
isnt that kinda how they make it, they verify data among multiple users
this was a really good read, kinda answered my question along with searching here for "server cheating" https://www.gamedev.net/forums/topic/690731-do-i-really-need-a-server-to-prevent-cheating-and-ensure-state-consistency-in-simple-games/
In a simple, casual online game like Slither/Agar, would more experienced network/multiplayer developers say I need a proper game server, which maintains an entire world state and prevents clients from doing things they shouldnt? I need to prevent different clients from diver...
hey, I have a moving platform, I dont want to replicate its position ebcause there is too much jitter
when a new client connects, the platform isnt moving, because the event has fired on the server before they have connected. how do I update the client version of the actor to have the same state as the servers
how do I update the client version of the actor to have the same state as the servers
That is replication, right?
If the issue is that its jittering I wonder if you could instead of replicating the actual entire movement, replicate a function to simply start moving? So the client handles the movement, but is told to do so by the server?
yea this is what I was thinking, as the client actor can check the servers state on spawn and then synchronize to it.
but the logic is a bit complicated to sync, that's why I thought there may be an automated way to do it
well i guess the "automated" way is simply clicking the replication box, but that comes with the implications you discovered. It gets tricky when you need to start doing more precise data sending to overcome these types of issues.
you can replicate variables, but for example, if I have a moveto function which is partially complete I can't replicate that
How long is the platform travelling before stopping? Does it then return to its original location?
it's more complicated, it moves between a series of spline points which are constantly changing
oooh...
Wonder if there's a way to split up the movement to fire for each spline point? So if a client connects mid-way through the movement, it only needs to way until it hits the next point before it gets the current position
Or surely there must be a way to just receive the latest position upon connect
it loops through the moveto function looking for the next spline point, so if I want to sync the movement I need to set the clients location to the servers on spawn, then update it's spline array, I get the feeling it will slightly be out of sync regardless
yes, need to request some variables from the server to the client to get current pos, and current moveto point, and figure out how to move it there, because if I replicate the var's it's gonna be wasted after the first frame
are you using a timeline for the movement?
I was thinking there would be some way to replicate the moveto state, variables etc for one frame, then switch it off so they were in sync but not constantly checking
no, just move component to node
I guess Ill try that method, thanks
if there's no other way to do it
Anyone ever have the issue where the blueprint will detect the client as the server?
this begin play gets called on every actor I have why ?
I mean I kill a player and when it respawns again it calls this on the killer as well
why does it call it on the other side as well
Because Replicated Actors obviously spawn on all Players.
And each of the instance calls BeginPlay.
if my character spawn some loot when is killed, who is owner of that actor? (i didn't set owner explicit)
Since that should happen on the Server in the first place, I would say the Server
when a player logs into a dedicated server, is there some way to carry across a variable which was stored locally?
for example I have a map called entry where you set your name and select your class, then you click connect and it opens the map on the dedicated IP
how can I get the data from the client instance? OnPostLogin returns a new playercontroller with no data
you have player state for every player
That also doesn't work on connection
Connection transfers no data by default.
You can use C++ with ClientTravel to pass some options via ?key=value
I want to persistent information across server travel
ya sorry, connect rather
entry is a disconnected local instance, when I press connect it opens the IP which is a different map
Yeah so you have 2 1/2 ways to do that:
- Is having a Backend and just passing the Server the unique ID of the Player so the Server can retrieve the data.
- Is saving the data on the Client on the GameInstance or SaveGame, after connecting performing a ClientRPC on, e.g. PlayerController. Then taking the data and sending it to the SErver via a ServerRPC.
so I need to use cpp? there is no object which can be referenced via BP which persists between a local session and connecting to a dedicated server?
ok, Ill try number 2
backend requires a seperate server to store the data right?
Yeah you don't have any object that is suddenly exesting on the server
Yes
It's the prefered way of course, but also the more challanging and expensive one
yea, I am just working on a personal project, and want to prototype it right now. so I dont wanna set up some DB etc
So once a client connects to a server, it retains it's gameinstance state? I thought gameinstance only existed on the server, and not a client once it was connected
GameInstance is an Object representing the Game itself
It has nothing to do with Gameplay or Multiplayer
It persists until you shutdown the game
Once per Player and only the local player knows about it
But yeah can of course "use" it to persist data
No I mean GameInstance
Is it normal for the GameMode to actually decrement the game timer, but decrement it directly on the GameState as done in ShooterGame? I had thought before that the GM should only handle things like initial spawns and general rules and start / stop events, but no second to second logic like time
ShooterGame has this logic on a timer in the GM:
MyGameState->RemainingTime--;
if (MyGameState->RemainingTime <= 0)
{
// End game
}
Is it equally viable to do all the decrementing directly in the GameState, and if it hits 0 there, then call an OutOfTime function on the GameMode instead of essentially calling state functions in both the GameMode and GameState?
A custom gameinstance class can't be set in maps&modes/gamemode
so I guess I need to modify the base one to store the data
You can set it in project settings @safe marsh
I actually was wondering too about that, I guess the base GI should hold structs for each specific game mode if data should persist between travelling?
Since there can only be 1 GI but could be many modes with different info that could potentially be passed across
The GI does not hold Gameplay data
I suppose games like CallOfDuty just have one generic set of info that can be used across multiple modes (time / score limit etc.)
Well if you were to try and create a custom game for example
You'd have to store that custom game data in the GI between travel right?
No, GameModes get initialized via Options you can pass when calling OpenLevel as well as ServerTravel
These are supposed be read out
And thus also passed from GM to GM every level change
Well if you have like 30 options is it not much more convenient to do it in a strut?
The options string in the node is really hard to read
I guess in cpp it would be much clearer
We have one struct that has a custom "Struct to String" method
Oh that sounds v interesting
It basically constructs the options string
a server can't retrive a clients gameinstance/gamestate class, right? I need to request it via the clients playercontroller?
Stop saying GameState :P
GameState is something totally different from GameInstance
I mean, both of those classess
GameState is replicated and the Server can interact via Multicast RPC and Replicated Variables with the Client through it
GameInstance is not and can only be accessed by each client/game
ok
so I can get a server to send a request to a clients gamestate to return a var from it's gameinstance
FString UHLFunctionLibrary::ToOptionsString(const FHLHostOptions& Options)
{
FString OptionsString = "";
OptionsString += "?game=" + Options.GameModeShortCode;
OptionsString += "?" + OPTION_MAXPLAYERS + "=" + FString::FromInt(Options.MaxPlayers);
// Make sure we don't have negative or zero match times
if (Options.MatchTime > 0)
{
OptionsString += "?" + OPTION_MATCHTIME + "=" + FString::FromInt(Options.MatchTime);
}
if (Options.bFillWithBots)
{
OptionsString += "?" + OPTION_BOTCOUNT;
OptionsString += "?" + OPTION_BOTDIFFICULTY + "=" + FString::FromInt(Options.BotDifficultyLevel);
}
if (Options.bRequireFullLobby) OptionsString += "?" + OPTION_REQUIREFULL;
if (Options.bRequireWarmup) OptionsString += "?" + OPTION_REQUIREWARMUP;
if (Options.bRequireMinPlayersToStart) OptionsString += "?" + OPTION_MINPLAYERSTOSTART + "=" + FString::FromInt(Options.MinPlayersToStart);
if (Options.bMapVoteEnabled) OptionsString += "?" + OPTION_MAPVOTE;
if (Options.bOvertimeEnabled) OptionsString += "?" + OPTION_OVERTIME + "=" + FString::FromInt(Options.Overtime);
if (Options.bTeamDamageEnabled) OptionsString += "?" + OPTION_TEAMDAMAGE;
if (Options.bAutoBalanceTeamsEnabled) OptionsString += "?" + OPTION_AUTOBALANCE;
if (Options.bRespawnByHandEnabled) OptionsString += "?" + OPTION_RESPAWNBYHAND;
if (Options.bWaitBeforeRespawnEnabled) OptionsString += "?" + OPTION_RESPAWNWAITTIME + "=" + FString::FromInt(Options.RespawnWaitTime);
if (Options.bForceRespawnEnabled) OptionsString += "?" + OPTION_FORCERESPAWNTIME + "=" + FString::FromInt(Options.ForceRespawnTime);
if (Options.bForceWarmupEnabled) OptionsString += "?" + OPTION_FORCEWARMUP;
if (Options.MapCycle.Num() > 0)
{
OptionsString += "?" + OPTION_MAPCYCLE + "=";
for (int32 i = 0; i < Options.MapCycle.Num(); i++)
{
OptionsString += Options.MapCycle[i].ToString();
if (i < Options.MapCycle.Num() - 1)
{
OptionsString += ",";
}
}
}
return OptionsString;
}
@grizzled stirrup
It is indeed cleaner in C++
Thank you so much!!
This is amazing
Exactly what I was looking for
No need for loads of structs cluttering the GI
FHLHostOptions is obviously custom
Yep, you'd create that in the base GM right?
We have a custom header file for structs
Ah cool, cleaner than including the GM anywhere it's needed! thanks
OPTION_RESPAWNBYHAND etc. are #defines to avoid typos
I assume if each player picks a skin in the lobby along with say an emote, in that case they'd store their chosen skin in the GI between travel and retrieve it when playing the match?
Yeah, although as mentioned before, a proper backend would be cleaner
However if it's not important if they cheat
And it's only a handful of customizations to pass
cheating is fine in my game (not trying to prevent it)
then you can use ClientTravel
And create an options string for that too
?Skin=SomeName?Emote=SomeEmoteName
Options can be retrieved in AGameModeBase::Login
Ah that's a great point too
(serverside)
Damn you can really bypass the GI!
If you have either c++ or backend, yeah
The only thing our GI does is overall backend connection and data
So it connects to the backend, retrieves inventory, etc. of the player, as well as info about the game (store stuff) and that's it
Really nice
Luckily my game can probably get away with no checks
But it sounds like you have a great solution there
Also can use this same options string to be able to change the gamemode but play on the same map right? To avoid having to make duplicate maps for different modes which I've seen people do
If you are on GameModeXY
And your match ends
And you want GameModeZ
Then you just pass a different GameMode for ?game=shortcode
Or rather you change it in the Struct
And convert it again to a string
So easy! Thank you very much
That's amazing
I've been sleeping on these option strings
Seems extremely powerful and saves a lot of work
ShortCodes are setup in the Map&Modes Project settings
GameMode alias or whatever they are called
It's basically a Name to Class Map
Ah great, will look into it now
Really appreciate the help!!
Last super quick question while you are here (and I'm reading your compendium), in general you should avoid timers in the GameMode for setting state like time right? That should be done in the GameState and any events that need to be fired called from there to the GM? Just a bit confused on the matter since ShooterGame does decrement the GS time directly via a timer like so:
MyGameState->RemainingTime--;
if (MyGameState->RemainingTime <= 0)
{
// End game
}
There is really no direct rule about it, the RemainingTime sits in the GameState for obvious replication reasons
Either GameMode or GameState have a DefaultTimer implementation by default
I think GameMode
And they utilize that to count down the GameState timer
Ok so it's equally viable to have the GM just say to the GS "hey start the timer" and then the GS calling an EndEvent on the GM when it reaches 0?
Yeah we do the same more or less
We have two timers though one in the GS and one in the GM
Any reason to have 2? Just curious and trying to separate state from init setup
GM handles stuff like automatically respawning players after they are dead for x seconds
Ahh
Or checking the bot count
Or the bot teams
To AutoBalance
Or to add and remove bots if a player leaves
Ok so it's not a time decrement timer on the GM but more a regular state check?
Yeah
Gotcha, that's awesome
Thanks a lot
Back to your compendium for more learning now, appreciate you taking the time to help!
Just c hecked, i think GameState has a DefaultTImer function
That you just override
And for the GameMode you'd need to create one by hand
(1 second looping timer etc.)
I'm not sure if GameStateBase has it (it might though)
But yeah either way will try and keep time in GS
It doesn't
I'll just create my own since it's trivial
But MatchState based games should use the non-base ones
True I might reparent in that case- all I have to do is change the .h to derive from GameMode and GameState instead of base right?
Base GS and GM are slimmed down versions for games that really don't need any match based stuff
Yeah and adjust the includes
Cool will do that then and make use of the nice match flow options
Waiting to start etc.
Was going to do my own simpler enum with just 3 options but yeah it's better to just derive from what they have
// If a game needs to add additional states, you may need to override HasMatchStarted and HasMatchEnded to deal with the new states
// Do not add any states before WaitingToStart or after WaitingPostMatch
Again I'm confused on why it's a namespace and not an enum but I'm not sure if it's older code or it should be a namespace in that case
Mostly due to the ability to easily add in between given states
Also inheritance in enums isn't a thing or?
So you can't really extend that
Ahh I see makes sense!
namespace MatchState
{
extern HOVERLOOP_API const FName CountdownToEndWarmup; // Counting down before ending warmup
extern HOVERLOOP_API const FName PlayerIntro; // Showing a lineup of the players before starting
extern HOVERLOOP_API const FName CountdownToBegin; // Counting down before starting the actual match
extern HOVERLOOP_API const FName MatchEnteringOvertime; // Match is entering Overtime
extern HOVERLOOP_API const FName MatchIsInOvertime; // Match is in Overtime
extern HOVERLOOP_API const FName MapVoteHappening; // Match is in Vote Map State
extern HOVERLOOP_API const FName WaitingTravel; // While the client waits for traveling
}
Example of what we do
So that gets added in between the existing states? Or it's a complete override?
They aren't ordered
It just extends the namespace
The "ordering" happens by you not calling it wrong :D
Ah I see š
You can set the MatchState to whatever you want whenever you want, which doesn't mean that's good
If you need more examples, check the UT source code
Thanks will do! UT source code in general is tricky to understand as a fairly new beginner, but I'm sure an invaluable resource to learn from
well, I got it working but it took like 6 different RPC calls to pass the data around
It's like Pro shooter game š
Yeah it is, but you'll find lots of cool stuff too
@safe marsh It needs 2
OnPostLogin -> ClientRPC -> GetGameInstance -> GetData -> ServerRPC(Data)
Both RPCs sit in the PlayerController
Yeah the bot and lag compensation code is amazing at a glance, the only problem I have with it is all the hoops you have to jump through for example to fire a weapon, it makes it very hard to visualize what is happening unless you are very familiar with the code (at least for me)
right, Ill try that
Ah don't fiddle with that : @grizzled stirrup
The best is to code the weapon system yourself
And then maybe take some tricks from the other one
Like "How do they spawn effects?"
Yeah I have coded a far simpler system and it's working great but I was very curious on how the pros do it
I usually use it to answer questions and not to copy from it
Will definitely approach it like you said for other things
yeah I didn't copy from it either just wanted to understand how they do it as a professional level product
And it seemed quite complex and confusing
But I hear Fortnite's weapon code is even more complex as it uses the ability system haha
I'll stay to my simple stuff and only ref when looking to understand how Epic would solve a particular problem
so it seems to work, except the printname event isnt being called from the gamemode
it only gets called if I filter the gamemode with another RPC
(like this)
not sure why, but that seems to work, I have to filter it twice?
- RPCs in the GameMode make no sense
- The rest should actually work
Despite the last image
all, what is the best way to know that all players are ready with replicated states and gamestate after a seamless travel?
iām asking because iām getting an onrep called on playerstate for a repnotify variable, but its content are the default ones, not the ones of the CopyProperties functionality
ok then... š maybe a way to get an event when PlayersArray of a GameState is replicated?
@ember needle what Im currently doing in my game is simply having an if statement in the GameState tick function that checks if PlayerArray is equal to number of required players to start the game
Once it is, we know all the players have loaded in and life is good
Not sure if there is a better way, but it works well for me
(obviously the if statement only runs on the server)
Yeah I was doing similar stuff (with a timer BTW) but conceptually... š so I started creating my own player array based on PostLogin and Logout events and then replicating that... but there are so many corner cases where things can misalign.
Yes there is
I think I once read someone here say you're gonna have to like
override half of game mode
I'm having some problems setting up a steam enabled dedicated server (while everything works fine without steam). I use a session subclass to create a proper server session and followed all documentation I could find, but it still won't show up on clients. I've found some messages in the log which may be related (these are no custom calls by me):
[S_API FAIL] Tried to access Steam interface SteamNetworking005 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface SteamUser020 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
These messages have zero results on google.
I understand that SteamAPI_Init is only called on clients because it requires login, and there is no Steam login on the Linux dedicated server. Still, at the moment I have no clue how to fix this.
Does anyone have a hint?
This is the session setup:
void ABaseGameSession::RegisterServer()
{
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
IOnlineSessionPtr SessionInt = Online::GetSessionInterface();
if (SessionInt.IsValid())
{
FOnlineSessionSettings HostSettings;
HostSettings.bAllowInvites = true;
HostSettings.bUsesPresence = false;
HostSettings.bAllowJoinInProgress = false;
HostSettings.bAllowJoinViaPresence = true;
HostSettings.bAllowJoinViaPresenceFriendsOnly = false;
// TODO HostSettings.bAntiCheatProtected = true;
HostSettings.bIsDedicated = true;
HostSettings.bShouldAdvertise = true;
HostSettings.NumPublicConnections = 6;
HostSettings.NumPrivateConnections = 0;
if (FParse::Param(FCommandLine::Get(), TEXT("forcelan")))
{
UE_LOG(LogOnlineGame, Log, TEXT("Registering server as a LAN server"));
HostSettings.bIsLANMatch = true;
}
else
{
HostSettings.bIsLANMatch = false;
}
SessionInt->CreateSession(0, NAME_GameSession, HostSettings);
}
}
}
@thin stratus hey cedric, pinging you because this was your pull req... does it make sense to check for authority on server in the case of setting a rep variable after a travel?
I'm experiencing some weird interference and wondering if the addition of the switch may help... Basically I'm seeing the SlotID OnRep event being called with SlotID's default value, not the one it has before the travelling...
So I was thinking that this might be due to some "clash"between replication and copyproperties
Is it possible to create some ordering between two actor channels? I need a newly created replicated object to have it's replicator created on the client before the netguide resolve, otherwise I get an onrep with a nullptr. I tried manually flushing the channel representing the new object as well as a forcenetupdate, but it's still a packet race. Note that I get the expected behavior if I step through, allowing the packet to arrive in time.
yea will do, hoping someone had figured this out already
@ember needle It can't hurt, I don't think I#m actively checking though
But you can also just print
And check if Remote even prints :P
remote prints? you mean if itās called on clients?
however it prints the default value... that's what I don't get
Sad thing is, if I enable verbose logging, S_API FAIL no longer occurs. So I suppose this is an issue with Steam API 1.44 š¦
Hi,
I am STUCK ,
How to connect to a dedicated server with OnlinesubsystemNULL from a client with OnlinesubsystemSteam
Can't
Well, not through OSS you can
You might be able to connect with "open <ip>" console command if the Steam OSS allows it
Stranger, but then you would connect without authentication. Which defeats the whole point isnt it?
There's no point doing this
Doing your own matchmaking while using Steam is just weird
it's not at all weird when steam is not the only platform
that mean there is no right way of doing it
The right way is to use the same online subsytem on both ends i guess.
but then I cant use default port 7777 cause steam force the port to 27015
actually I tried with steam on both side but it created this port conflict, after which I removed steam from the server, now my client can connect without steam but not with steam
Well I guess I have to do some experiments with default port setting
so for a whole week i was trying to fix what i thought was a networking bug with my wallrunning where clients would randomly unstick from walls.
turns out i never noticed the server player also did the same thing because apparently i have a large kidney bean can-size hole in my brain. i am thankful my wallrunning is shitty across all realms of existence
first thing you test when you have a client bug is does it happen on server
second thing you test is what does server see when client is experiencing the bug
and if that doesn't provide any useful information, what does other client see when first client is experiencing the bug
most of movement related replication breakdowns happen on owning client only
yeah i didn't test the wallrunning enough on the server, saw it work correctly whenever i tested it, but i only did a couple wallruns before seeing what would go wrong on the client š
integers show up allright but i couldnt understand why not for the text
I tried string type as well and I am so confused
they are replicated
noone sees eachothers nick name variable
Send nickname to server with an RPC, so it gets distributed for everybody. But you should have the nickname on server already.
those variables are on the game state
kills and deaths works just fine
I created nickname right near them
and set it to replicate as well
ohh
wait
thanks for the help
I am so tired I forgot about that one lol
is there a cvar or something to render the server's view of everything? (here's an example, the red wireframe in this video: https://forums.unrealengine.com/development-discussion/content-creation/1449576-multiplayer-how-to-get-smooth-character-interpolation-on-moving-platforms-without-jittering/page2)
So actor channels appear to be lazily created, what would be the proper way to force them to be created? Flushing the net connection? Maybe a force net update?
Neither do the trick
Calling RPCs seem to work, but that can't possibly be the expected way
I sadly need to though, I'm working on getting some order of dependency between channels
NetPriority will help
From my post earlier: ```Is it possible to create some ordering between two actor channels? I need a newly created replicated object to have it's replicator created on the client before the netguide resolve, otherwise I get an onrep with a nullptr. I tried manually flushing the channel representing the new object as well as a forcenetupdate, but it's still a packet race. Note that I get the expected behavior if I step through, allowing the packet to arrive in time.
but you're still fucked if the packet gets dropped
Yea right now I'm messing around with the SpawnAcked stuff in the actor channel, seeing if I can leverage that
slightly inelegant
but if its a matter of life and death
TWeakObjectPtr from replicated object to its replicator, and OnRep that to get the dependancy reliable
one of those will fire correctly, always
Hm, nasty but it would work yea. I'm going to make one last effort and manually create these channels and see how disastrous it gets
Oh yea, I broke it
i have not yet had a case where higher priority Actor ended up client side after the lower priroty one
if spawned in the same frame on server
but, i can't say i trust that 100%
Yea i'll probably do that for the time being, just need to leave myself a big "fix this shit later" note
i increased by PS priority, and never got any of the ensures triggered
that i noticed
and that code is now few months old
(doing a fairly complicated object graph when spawning my player, so PC, AICon, PS, Pawn and Character are all involved there)
Yep seems reliable enough for now, thanks for the pointer @winged badger
let me know if it breaks at any point, not sure if it can
and i would like to know is it possible
if they arrive in the same packet, it shouldn't be
Same packet no, the issue is separate packets
Hi everyone, I have a quick question:
I am updating healthbars in multiplayer via rep notify triggering a callback that the healthbar binds to, but on clients it is delayed by about ~1 sec (the projectile impacts them, delay, then healthbar updates)
Anyone know how to make it more responsive on the client?
@red musk You would also have to "simulate" the Health changing on the Client
See how the Impact Effect hits immediately, that would be when you update the Health for the Client, the Server would then Replicate the correct value down to the Client incase the Client calculated it wrong.
The Client calculating it themselves is purely cosmetic.
So should I simply not hide this behind switch has authority?
For this exact reason.
So both client and server update immediately
And the replicated player state ideally keeps them in sync?
@red musk you could also try increasing your NetUpdateFrequency so it gets there a bit faster
@thick shale Thats not ideal, your better off predicting it than just brute forcing the solution.
This is widely called "Client Side Prediction"
The Client predicts that what happened for them is going to be what the Server is going to report to them later.
It masks lag.
The lag still exists, but only if there needs to be a correction.
Thanks!
@red musk If you don't want to implement client side prediction yourself, Unreals GameplayAbilitySystem has a (simple) client side prediction which works well for many cases.
I'll check it out!
hey i have a kind of specific question for a mechanic i was working on, it's fairly similar to Mei's Ice Wall in Overwatch, essentially pulling a pillar out of the ground through scaling a flat cylinder mesh up to full height over time. I'm using vinterp with a timeline to set the scale, and it works fine. the problem is that in multiplayer, any player standing on top of the pillar has super jittery movement as it scales up, and will not appear to actually be able to stand on top of the pillar until they actually move again (for example, client 1 will fall through the pillar on client 2's screen any time he isn't moving, even though he is stationary atop the pillar on his own screen). I tried it by just spawning the pillar at full size under ground and then moving it up under the players, and that works just fine with no movement jitter, but obviously that creates huge issues anywhere you could potentially be under the pillar's spawn point.
Anyone have advice for smoother replication of actors on top of a scaling object, as right now i just let them get pushed up and then replication gets very weird
here's the "spawn at full size and just move up" method that is smooth but wont work on anything with multiple stories https://gyazo.com/0cd12d341d51e8caa438cd66ff4014dd
and here's the "scale object up from feet" method that is broken https://gyazo.com/b3795b6a697bda01b72253124a7e2ea6
@vivid seal are you saying it works fine in autonomous proxy but the simulated proxy jitters? Or both do
check the second gif, thats two clients on dedicated server and both jitter/fall through the mesh
the first gif is the mechanic made in an entirely different way, and i like the movement but there are other issues
What if you replicate the scale/time velocity as well as the actual scale so that the client can predict the scale change in between replication updates?
Because the variable replication in the best case scenario is like you 5-10 updates per second from the server
If you replicate the velocity and the client also predicts the change it should look smoother
And the actual scale will still get corrected by the server
Alternatively you could try to fix the other issues with the movement appropriate if that doesnāt make it look better for you
i had something similar (server sent a multicast for clients to scale their own mesh and then another multicast to adjust after the scaling was done), is there a better way to do that?
and the server was scaling it also at the same time?
yes, the only noticeable effect was the correction at the end stopping the movement, but its still jittery for a second
but i might have set it up incorrectly
what issues do you have with the moving up instead dof scaling approach?
if i use it anywhere where something could be below me (in a building, over a cave, etc.) it would spawn on a lower level
it just feels like a weird solution
Ah yeah that would be a problem
you could spawn multiple floor-height segments and just move them up at different rates like an accordion expanding, but that is janky
https://gyazo.com/dbb3d9b8b90a9a600a2da3a99cc2cb06 this is about the best i can do, the jitter and stuff AFTER scaling is fixed, still jarring during the scaling itself but im too tired to work more on it
Oh if I remember the CMC does a little bit of caching if the last FindFloor result so it doesnāt need to recalculate it every time
If you figured out the character was on the platform when it is growing, you might be able to change it to invalidate the last fine floor result maybe
Hi, Iam pretty new to multiplayer and have some general questions. So I do get the whole replication and server client relation thing, but what confused me was that in order to make unique calls you obviously need to have some unique object making that call, like a character controller. does that mean that my character class for example can't have for example an inventory component, or can it have one, but all references to self must be done via a controller reference?
Do you want this inventory being replicated or not?
Do the other clients needs to know about it or not?
Hey guys, total physics noob here. How do you replicate "weld" ? I have simulated actors, they replicate, but when I try to attach and weld it goes all wrong on the client. I can post a video if needed.
I need some advice on setting up a replicated chest that they player can open and loot. I have the inventory system set up, but what is the best way for the player to request the data from the chest? I know that I could probably replicate the items in the chest if the player is within a certain distance, but is there any way for the player to 'request' the items from the chest when he interacts with it?
If you can hook the chest to the inventory system then just show up the chest's inventory instead of players, with the items within. Pry saves you a lot of extra code doing this way.
You can also take example of how the inventory system is built and make a simplified version that is specially dealing with loot inventories that can be added to any actor. Packed all logic in a component you can pass in to any object
inugames, you can try attaching on client side as well it may be missing the rep of weld property by a bug perhaps.
Also, replication of physics is a long time issue with unreal and you may want to be cautious with this idea
@rotund sapphire Thanks, i will try now.
Replication can still be an issue with physics simulated objects. They usually show up more when you introduce network latency.
Stuttering and alike
I understand. Actually, it's just a "proof of concept" of sort, I don't plan to use it.
Btw, I found that the attached actor is detached when the parent has the physics turned on. I hold an actor with another one attached, when I release it I turn physics to the parent to on. Then on the server both stay attached and weld, but on the client they are detached.
Like in the video. When hold they have physics to off, when released to on. Still, they somehow stays attached
blue is the parent and client is on the right
How do I only replicate an actor (ie. Chest) if the player is within a certain distance?
there is a clear video series on replication principles on ue, hosted on youtube. iād recommend to start from there. youāll get a grasp on your question (network relevancy and onrep variables)
just the basics
@ember needle Thanks. If the actor (chest) replicates it's inventory based off of the distance the player is away from it, what is to stop cheaters from viewing the contents of any chest based upon the distance?
I think it would make more sense to somehow only allow access to the contents of the chest if the player interacts with it. But I can't figure out how to do that
Hi, is it required to register dedicated server with steam, if I am using OnlinesubsystemSteam on the client side
client with steam cant connect to server without steam
For round based games like CSGO what is a wise way to reset the game for the next round? Mainly thinking of AI controllers and characters. Should I iterate over all controllers and unpossess, then iterate over all spawned pawns and destroy before doing a fresh init / respawn on the next round?
Something like:
for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; ++It)
{
AMasterC* CurrentC = Cast<AMasterC>(*It);
if (CurrentC)
{
CurrentC->Destroy();
}
}
@grizzled stirrup Yep, this is what we do
void ATDGameMode::RespawnAll()
{
for (FConstControllerIterator Iter = GetWorld()->GetControllerIterator(); Iter; ++Iter)
{
Respawn(Iter->Get());
}
}
void ATDGameMode::Respawn(AController* ControllerToRespawn, const AActor* const PlayerStart)
{
UE_LOG(LogOnlineFramework, Verbose, TEXT("Respawning player: %s"), *ControllerToRespawn->GetFName().ToString());
send client rpc, etc...
// Destroy the pawn we're leaving if we have one. This won't destroy dead bodies since the controller detaches before respawning.
auto* Pawn = ControllerToRespawn->GetPawn();
if (Pawn)
{
UE_LOG(LogOnlineFramework, Verbose, TEXT("Destroyed pawn: %s while respawning player: %s"), *Pawn->GetFName().ToString(), *ControllerToRespawn->GetFName().ToString());
Pawn->Destroy();
}
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
auto* NewPlayerPawn = GetWorld()->SpawnActor<APawn>(DefaultPawnClass.Get(), PlayerStart ? PlayerStart->GetActorTransform() : ChoosePlayerStart_Implementation(ControllerToRespawn)->GetActorTransform(), SpawnParameters);
if (NewPlayerPawn)
{
ControllerToRespawn->Possess(NewPlayerPawn);
... send client rpc, etc
}
}
Then you can just RespawnAll() when you want to soft restart the match
This is awesome, thanks a lot for the example!!
@timber tree You need to create a session in your game session's RegisterServer, a snippet from ours:
SessionSettings = MakeShareable(new FOnlineSessionSettings());
SessionSettings->NumPublicConnections = 10;
SessionSettings->NumPrivateConnections = 10;
SessionSettings->bAllowJoinInProgress = true;
SessionSettings->bIsLANMatch = false;
SessionSettings->bUsesPresence = false;
SessionSettings->bAllowJoinViaPresence = false;
SessionSettings->bIsDedicated = true;
SessionSettings->bShouldAdvertise = true;
SessionSettings->bAntiCheatProtected = true;
SessionSettings->Set(SETTING_MAPNAME, GetWorld()->GetMapName(), EOnlineDataAdvertisementType::ViaOnlineService);
OnCreateServerCompleteHandle = Sessions->AddOnCreateSessionCompleteDelegate_Handle(OnCreateServerCompleteDelegate);
if (Sessions->CreateSession(0, GameSessionName, *SessionSettings))
{
UE_LOG(LogOnlineFramework, Log, TEXT("Successfully registered server."));
}
else
{
UE_LOG(LogOnlineFramework, Error, TEXT("Failed to register server."));
}
Let me try
if i spawn an actor on server, that is replicated
then i add a static mesh to it at runtime
that will have to be multicast right? cause the mesh is being set on the server, but clients are seeing nothing
reliable component or on rep probably, I would imagine you want late joiners to see the mesh too
then a multicast does it
yeah just its weird cause i did look a bit of how UT4 does dropped pickups, but it does no multicast and it adds the meshcomponent at runtime
(obvs trying to find ways to reduce network usage)
@sharp pagoda In this line of your respawn send client rpc, etc... What happens in the client RPC?
A few things, including hud updates and whatnot
kinda similar to what i did, so im just confused how there's works and mine doesnt
Ah cool thanks!
Hi guys I'm just getting started with multiplayer I manged to finish a small game jam project with one of the templates on the community https://forums.unrealengine.com/community/community-content-tools-and-tutorials/1533041-free-ue4-multiplayer-template-project-listen-server-steam and I was wondering if you guys could recommend some content that helped you learn multiplayer bp whether it's a tutorial/book/marketplace asset pack anything will be appreciated
UE4 Multiplayer Template
Hi All.
I made this project because I think multiplayer games share most menu features.
I thought it would
here's the project we made https://el-fideo-rubio.itch.io/magnetwo
To be honest, I would not suggest trying to do multiplayer with just Blueprint. Thereās a lot of MP functionality that is not exposed to Blueprint
I feel like making a more complex game thatās multiplayer and only in Blueprint will have you running into some walls at every turn
For a CurrentRound int in a game that has rounds like CSGO, should that be maintained / updated in the GameState or GameMode?
I'm leaning towards the GameState, but there's also part of me that thinks each round is its own thing which would make the GameState only relevant for a round at a time
Will put it in the GameState actually just because it's accessible from the client!
For UI stuff