#multiplayer
1 messages ยท Page 644 of 1
Like I'm genuinely super confused
I had changed a setting about a day ago but I completely forget what it was, are there any settings you know of that could do this?
@hasty reefWhat is this actor's root component?
Or what is the component hierarchy
Cause only three things will cause that to not call on a client. Relevancy(Like only being a SceneComponent), Not being replicated, and the actor not actually having replicated to the client yet.
So the problem isn't just the one actor, I've created new blueprints directly from the actor subclass and those won't multicast either
Yeah.
Try setting it to AlwaysRelevent. If that lets you multicast, consider changing the Root Component to some form of collidable object.
it's already always relevant
Found the issue lol, it was running before the clients connected
hello everyone! Does anyone have a cpp fps multiplayer tutorial?
try shooter game
@winged badger thank you
its not a tutorial, but its a working project that was a starting point for quite a few games out there
yeah... I'd like much more a tutorial, but truth is a project is better than nothing
Shooter Game was the template for Ark survival and itโs quite successful
and Valorant
Fuck valorant
Ark's exe was named Shooter Game for quite awhile.
it was also the template for Squad
there are quite a few big games it was the template for
i believe gearbox also used it to prototype borderlands 3
Setting replication at runtime hinders performance since the replication mode has to be changed to be dynamic (Correct me if this is wrong). I want to spawn an actor and have control over whether it spawns in a replicated or not replicated, so is there a better way to do this?
It still is lmao
It annoys the living fuck out of me how lazy they are
I still like the game tho
LMAO WHY CAN I OPEN THE GAMES UPROJECT
for ark?
mod tools etc?
oh ye forgot about that
leaving the executable as shooter game is still lazy as hell
but no one rlly goes digging through game files
in fairness changing the project name after the fact is no joke
I think the actual EXE can be set to whatever though iirc
yeah its in packaging settings and is very simple to change
but i mean it just shows how laZy wild card is
changing my project EXE to ShooterGame.exe despite not using shootergame just to piss people off
OWI is my company's publisher and I didn't know that. Granted squad started development over 6 years ago.
When I am picking up an item and adding it to my inventory, would you recommend that I do the adding in the item or the player
the player
with my inventory system, the player (by way of the inventory component) does all the mechanics
You can usually answer this by answering the question what is being modified. Because uuuusually you want the class to modify itself. So if e.g. the InventoryComponent has an array of items, then you want that component to modify the array, not something else.
That's at least how I usually structure my code.
If your item needs to react to being addee and removed from the inventory, then you can always forward data via OnAdded and OnRemoved events that you can create in your item class. And these then can modify the item itself.
@digital current
@gleaming vector @thin stratus thanks for the advice guys
did you happen to design squads inventory?
no
when i was there, it was basically shootergame
i built my own inventory system since, Arc Inventory (it's on the marketplace)
it uses GAS
Oh nice!
I built my own as well for a side project using data assets. It's managed via GAS though.
ya, i started with data assets
ended up making some weird struct system, gave up on that and did uobjects + a subclass for static data
i want to change it to uobjects + data table for static data now that you can easily modify data tables with modular gameplay
There are probably a million and 1 ways to make inventory systems in ue4
yeah
If a system works and feels good for the purpose it was created then it's probably better than any other solution.
With which I want to say: Don't blindly implement and inventory system based on suggestions alone. It needs to fit your project and scale well
How about every stored item is a child actor, where item definitions are singleton actors (joke, probably don't do this)
E.g. No need for GAS if you don't intend to use that :D
How about every stored item is a child actor, where item definitions are singleton actors (joke, probably don't do this)
There's a use case for this actually. Especially if you have generic items and you're just using inheritance
probably horrendous for performance though
I think FN uses data assets. I vaguely recall a dev blog about it
shootergame doesnt have item definitions (unless you count item classes as a kind of item definition)
no, they have an actor per weapon
there static data comes from data assets i think
Ah yeah
I think you have to have an actor per weapon
trying to make an inventory without that is just insane
the basic idea is you need to figure out what is "static data" and what is "per instance data"
that's really the core of inventory
Yeah
I mean ChildActor in the runtime attache sense, sorry
static data being stuff that is shipped as data in your game, and per instance data being what each item needs to replicate/instance
I've been toying with ideas/methods for creating an inventory that takes multiple spaces in a UI
that works with my system
do u mean like those puzzle inventories?
more similar to Path of Exile's
oh yea I have seen some stuff on that
is there any way to see cpu usage , ram usage, disk usage, bandwidth usage on a dedicated server?
hey guys any idea why calling SetIgnoreMoveInput(IgnoreMovement); from the game mode on a Playercontroller is failing to disable movement on clients?
That is a custom method you wrote, right? Does it simply set a boolean to true/false? Do you set it on all player controllers that you wish to disable? Is it setup to replicate?
that's a built in player controller function... so when the game mode spawns a character (server side as it only exists on the server) it also tells the player controller to do this (stops the spawned character moving) seems to work fine for listen server but not for the clients
Oh damn, I didn't know that is default, thanks! Pretty sure for clients you need this:
UFUNCTION(Reliable, Client)
void ClientIgnoreMoveInput(bool bIgnore);
yeah i've tried that```void AIGCPlayerController::DisableMovement(bool IgnoreMovement)
{
if (!IsLocalController())
{
ClientDisableMovement(IgnoreMovement);
}
else
{
if (IgnoreMovement)
{
SetIgnoreMoveInput(IgnoreMovement);
}
else
{
ResetIgnoreMoveInput();
}
}
}```
thats the function the game mode calls... so tells the client to disable it's movement.. but the client can still move around
no probs knowledge sharing seems to be a good way to learn this engine ๐
You're calling ClientDisableMovement(). What is called inside of it?
DisableMovement(IgnoreMovement);
so basically calls that function on the client again
Makes sense. Then IsLocalController returns true and it should SetIgnoreMoveInput.
Did you debug and confirm that SetIgnoreMoveInput(true) is being called on client side?
just trying once more
yeah this is weird.. it hits the message correctly, the ClientDisableMovement() is called
the value passed is true
but the client can still move around
Is it possible somewhere else it's quickly being overwritten with SetIgnoreMoveInput(false) on the client?
yeah i'm wondering that
let me breakpoint on that call in the engine code
ok looks like there is actually a call ClientIgnoreMoveInput built into the engine playercontroller.. although it's not called anywhere from that cpp file for playercontroller.. going to try a direct call to that
Yeah that's the one I meant when I asked. But it works exactly same way how you did it. It doesn't do anything extra. Just calls that same method on client side.
i really don't know what this is so complicated.. i must be doing something wrong somewhere
nope still doesn't work
i can still move the client around
just cause the value is set
does not mean input will be ignored
if you pass in true to force (in AddMovementInput)
it will ignore it
hey i am using blueprint system on my game and i want to know some tips to host a client server in a mac
the game i am working on is in mac but it will be available for windows and mac both
please help me
reply me
I have an issue. The following delegate that initializes UI called when am playing as a server and does not called If as a client.
The question is why OnNewPawn is not called on the client's controller?
This function is inside my class that inherited from AHUD. It called to display the UMG HUD and subscribe to updates when the controller posesses pawn (to display UI updates).
Perhaps I ran into some kind of bug? How do you usually subscribe for Pawn parameters changes for a HUD?
I also want to add that other networking stuff works correctly (spells, attributes) and replicated from client to server.
Hello, I have problem with loading client save as client. I have explained my problem in this forum thread. https://forums.unrealengine.com/t/why-client-loads-server-save/235081
My character is trying to read variable from save but always load save from server not local.
Can you help me?
could you explain?
It loads Directly from save wrong variable
Save is not replicated
Double checked, it looks like OnNewPawn is not called on clients. Is this expected?
Hi, I'm unable to connect to Steam with my game any more. it's really strange, even the option to join another friend's game when you right-click on them in the Steam Friends list is gone; I can only 'Invite to watch'. Any idea what could be causing this?
Has a new SDK come out or something?
This is my DefaultEngine.ini (the app ID is correct, just blacked out
is steam running on your machine?
(that can happen sometimes), check to see if a steam_appid.txt file gets created in the same directory as the exe
remember you cant connect via PIE, only standalone
Yes it is @meager spade
I can't find steam_appid.txt, where should I see that?
the installation folder in Steam?
I see it now, it does get created
Something to do with this maybe? "Shipping Builds
In shipping builds, the engine will check to make sure that the logged-in user is properly subscribed to the game and will shutdown if the engine's test returns false (this is one way to help secure the game). Additionally, using Steam DRM (see the Steamworks SDK) should further protect the game from being tampered with."
Does Steam need to approve the game before a Shipping build will work?
Nope
Shipping builds just need to be launched from the Steam client, or have an appid.txt file next to the binary (under project/bin/etc; not the root one)
If the Steam overlay works, you're good
So the steam overlay appears, I can see on Steam that I'm playing the game, but the Invite Friend overlay doesn't work, and I can't add anyone to the game by inviting them through Steam (the option doesn't exist, as if a Session is never created)
Does this look OK as a Create Advanced Session node?
Would not having "GameServerQueryPort=27015" in the Engine.ini stop it from working?
Anyone has some experience using FFastArraySerializer? My PostReplicatedAdd/PreReplicatedRemove don't seem to get called on clients for some reason
Hello, can anyone tell me how i get "Convert to Mouse Location to World Space" Variables to the server and Update them like a "tick event"?
i tried passing them trough the "Run on Server Event" and "set" them with a "timer by event" but for some reason the variable will change between 0 on XYZ and the actual mouse postition every 0.01 second instead of just updating the mouse position.
@ancient badge Maybe because you're running that timer on both client and server accidentally
use something like IsLocalController before starting the timer
Starting the "Timer" through the Server Event make it automatically only run on the server?
but i will check
@ancient badge I assume you are looping the timer on the client only and have him call ServerUpdateMouseLoc() event each timer elapsed that passes the mouse location to your server
The "Update World Location" and "Update World Direction" i need for a Function that i use inside a "Timer by Function"
Do I need to use Steam 1.47 with Unreal 4.26? I've been using Steam SDK 1.51 and wondering if that's why my project won't work?
So I should use 1.47?
Sorry I'm puzzled, is this guide old/wrong then? https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/Online/Steam/
An overview of Online Subsystem Steam, including how to set up your project for distribution on Valve's Steam platform.
It's never been applicable to packaged builds
The "Steam App ID" is the first real step
Check the "Configuring your Application's Settings" section for the important parts
The "End Result" part is basically the only required work for Steam
If it doesn't work it might be a problem on the Blueprint side
Destroying the session before seems weird, and the destruction is asynchronous, so the result code does not indicate that the session is done destroying,; just that it was requested to
Make sure you follow the examples
ah right, so perhaps it's destroying the session that it's making?
I'm trying that now, but also noticed this in the logs: LogSteamShared: Display: Loading Steam SDK 1.47
LogSteamShared: Steam SDK Loaded!
LogOnline: OSS: Creating online subsystem instance for: Steam
LogOnline: Display: STEAM: OnlineSubsystemSteam::Shutdown()
LogOnline: OSS: Unable to create OnlineSubsystem module Steam
LogOnline: OSS: Creating online subsystem instance for: NULL
I'm guessing that's not normal?
@dry cloud figure out your array serializer issue?
@meager spade Nope!
Hi everyone, what is the purpose exactly of the AGameSession class? All the tutorials I've seen online regarding creating sessions and hosting online tend to do all the work in the game instance, so is the session meant to just hold info for convenience's sake? Also, does it persist across the entire duration that the server is running, or does it get recreated during a server travel (e.g. when changing map)?
whats the issue?
@meager spade More just interested in how this class should be used properly
I'm also finding some conflicting info on it, including documentation that says the "RegisterServer" function is only called on dedicated servers, but my testing shows it is also called on listen servers too
Basically, I just want to make sure I understand what the class is for and what it is designed to be used for in case I'm missing a trick
The fast serializer has 3 functions available including PreReplicatedRemove to be triggered on clients so they can react to add/remove events in the array. Those functions do not seem to trigger on clients for me. the array is replicated properly on clients however
can you show the code? can move to DM if its easier, like show your setup.
Yes I'll DM those
I currently am creating a multiplayer chess game, and I store the locations of all the pieces in an array to know where other pieces can attack. When I move a piece, I call set array elem to update a piece location, and I call that event on the server. It does not seem to be replicating though, so can set array elem be replicated? (the array is currently replicated and adding items to the array does replicate correctly, but set array elem is seeming to not replicate)
It is kinda a mess rn, but what happens (when doing it on a client) is it updates the array (from an event called on the server) and the item in the array seems to be updated on both client and server, but then if you update it on the server, then I realize that it actually didn't update.
i use launch character , when i packaged as dedicated server and connect with clients, luanch character goes in inverted direction, but it works fine if a client connect to a client using listening host, what can be wrong?
Guys, I need some help. The people from #cpp advise me to ask the same question here, since I'm planning to code a listen server. Please consider that I'm still fresh. I'm trying to make two players to see through the same camera perspective, so, initially, I placed the code inside the PlayerController, just to see if would work from a standalone perspective. It didn't work: the players are still seeing the world from their Pawn's camera perspective, not from the static camera I have placed in the world . If you can help me with this issue in a standalone perspective, I would be appreciated too. But I believe that, to make it worl in a multiplayer perspective too, I must or to make a RPC to the server (from the PlayerController?), to call the SetViewTarget, or to call the SetViewTarget from the GameMode and do a multicast to all the players (I'm not sure about how to do this)? Any help will be appreciated. Here are the snippets:
#include "ActorUtils.h"
#include "PongCamera.h"
#include "Kismet/GameplayStatics.h"
APongPlayerController::APongPlayerController(const FObjectInitializer& ObjectInitializer)
{}
void APongPlayerController::BeginPlay()
{
Super::BeginPlay();
APongCamera* MainCamera = Cast<APongCamera>(UGameplayStatics::
GetActorOfClass(GetWorld(), APongCamera::StaticClass())
);
if (MainCamera)
{
SetViewTarget(MainCamera);
}
}```
APongCamera::APongCamera(const FObjectInitializer& ObjectInitializer)
{
Camera = ObjectInitializer.
CreateDefaultSubobject<UCameraComponent>(this, TEXT("Camera"));
Camera->SetProjectionMode(ECameraProjectionMode::Orthographic);
Camera->SetOrthoNearClipPlane(0.f);
Camera->SetOrthoFarClipPlane(5000.f);
Camera->SetFieldOfView(90.f);
SetRootComponent(Camera);
}```
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
bReplicates = true;
static ConstructorHelpers::FObjectFinder<UStaticMesh>
RacketMesh(TEXT("StaticMesh'/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube'"));
Racket = ObjectInitializer.
CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Racket"));
Racket->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
Racket->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);
Racket->SetGenerateOverlapEvents(true);
Racket->SetSimulatePhysics(false);
Racket->SetStaticMesh(RacketMesh.Object);
Racket->SetWorldScale3D(FVector(.2f, 2.5f, 1.f));
SetRootComponent(Racket);
CameraBoom = ObjectInitializer.
CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
CameraBoom->SetUsingAbsoluteRotation(true); //Prevents the arm from rotating with the racket
CameraBoom->SetRelativeRotation(FRotator(-90.f, 0.f, 0.f));
CameraBoom->bDoCollisionTest = false; //Prevents the camera to be pull when colliding with the scenario
CameraBoom->TargetArmLength = 1500.f;
CameraBoom->SetupAttachment(Racket);
Camera = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("Camera"));
Camera->bUsePawnControlRotation = false; //Prevents the camera to rotate relatively to the arm
Camera->SetupAttachment(CameraBoom);
Speed = 3000;
}```
I didn't replicated anything yet, just set the editor to Play as Listen Server
What's the trick to connect multiple computers?
I thought it was just open IP and that would connect?
I just build a standalone of the Play As Listen Server for the host
and the clients run the open command with the intent to connect to it.
But it's not connecting
This is 4.26
This is still the process right?
Alright, I may have made some terrible errors if this doesn't work like I thought it does.
If I have a replicated variable, I'm under the impression that I need to tell the server when a change to that variable occurs. (non-repnotify)
RPC->run on server reliable-> switch on auth -> set replicated var
And that's enough for me to update the server on what the client tried to do. My long winded questions is: if I wait a really long time to do that RPC, will the server eventually send its version of the replicated var to the client (based on net update freq) and overwrite what I was eventually going to send to the server in the RPC?
I read a couple sentences about replication that hinted at this happening
server will update the clients only if its variable changes
Dope
and auth switch is redundant on the far side of the server RPC
I was horrified for a moment
yeah, I've done it as a best practices thing cuz I don't think and just follow tutorials sometimes
ty for the answer!
Hi! I'm new here. Does anyone know if it's possible to program a game with UE5 that can connect to a server and download files. Like game levels for example. If so then do you perhaps know where can I learn more about it? Like different solutions or methods that could be used.
For me, I'm doing my learning in UE4 right now, but figure I'll end up translating it all to a fresh start in UE5
Question: Can someone help me understand why, when playing as 2 clients, clients 1 and 2 see each other's Print String output on the Controller's BeginPlay event.
PlayerController's BeginPlay I mean
I suppose actually, it's more than that. When player 1 triggers an event that has a Print call, it shows up on Client 2 as Client1:whateverwasprinted. I guess it just seems like client 2 shouldn't know about client 1's output unless it's specifically being multicast.
Hmm. Maybe Print itself is just always multicast because it's a developer function. I don't know.. I guess I'll move on.
Is there any reading materiel out there on custom delta serialization using NetDeltaSerialize()?
Just noticed that FNetDeltaSerializeInfo has both a "Connection" property and an "Object" property, which would theoretically allow for connection-specific replication of properties.
Quite interested in exploiting that
Please do share your findings!
Also never occurred to me before but NetSerialize also has the UPackageMapClient, so long as you aren't using shared serialization, which could maybe be abused to do the same thing. Innnnnteresting
@astral perch prints go through the engine, if you test in pie you normally have Use single process ticked. This is the reason. Nothing more.
Ah, that makes sense. Thank you!
Hello! Hope everyone is havign a good weekend
I have a weird issue I could use some help with!
As you can see in the video, this is a CLIENT player connected to a distant server.
It seems that when I walk around in some very specific places, I somehow get TP'd to 0,0,0 coordonates, and as soon as I walk out of that specific point, I get re-TP'd back to where I was as if nothing happened (It's very snappy but you can see in the video at some point I manage to stay there in the exact point of TP-ing)
What could cause such odd behaviour? Thanks !!
OK it seems to happen when I step on a plant or any small object suck as rocks, also the TP happen client only, not on the server where the position is just fine. Also this doesnt happen in singleplayer.
Bonus question if you know why some plant randomly stay at 0 0 0 on the client
@peak sentinel yep
Thanks to those who answered and sorry for the late reply ๐
Ignore my last comment about size -- it seems to be an issue where the client think its not allowed to step on those items, even thought it is
Those 2 actors share the same Blueprint, with the flag "can step on" to true.
I can step on the oven on the right, but not on the tall grass on the left.
I cant make out what the difference is
OK I got the difference: one is replicated the other one isnt, but then they still exist at the same place at the same time, why does it break the collision ?
Which one is replicated?
What is when you set the grass one to replicate too?
Then it's fine for the long grass
And if I disable replcation on the oven, it breaks
so set both to replicate and it works? or do you have a reason to not replicate the grass?
No I dont want to replicate it, because there are a lot of plants
Well, i'm new to multiplayer stuff myself, but if im correctly. if you don't replicate the grass to your "client". Your client will not know that here is something to step on.
Yes it does because the client spawns it too
ah ok
If the client spawns it locally then the network ID's will not be synced up, so you can't use it for movement etc.
If you're using character movement, then this will break the "based movement" part
If a client spawns something locally, it should never have collision
So you mean it will break the character to step on 2 actors with different network ID ?
The character can't walk on an object unless it's net-addressable
If you spawn stuff independently on the client, it's not network addressable
Why do even want the player to "step on it" would'nt it be better if he can walk into it.
There are many items such as rocks and fences Daikota
Can I force the network ID ?
nope
Surely i can do something else than just blindly replicating thousands of static blueprints
You can't, but you shouldn't replicate them
Procedural generation of levels is very difficult, Zlo found some methods for syncronising network ID's between server/client and fooling the network system to allow for it
I have unique identifier already that is consistent between client/server if I can enforce the netid that would solve the issue
I see
If you need those spawned actors to be used by the networking system in any way, they have to either be:
A) Part of the serialised map
B) Spawned and replicated from the Server
C) Spawned deterministically from a seed, and with some trickery to fool the networking system into thinking it was serialised from the map.
And walking on stuff does count as using it with networking, because character movement needs to be able to resolve what it's walking "on" exactly
D) Can I change the character movement maybe to not do that this way ?
What is it using the actor for ?
If the object is dynamic of moving then no
In which case AFAIK, it doesn't use the "based" movement
So long as the primitives are not "movable" it should be fine
When you stand on a movable primitive, character movement switches to a "relative" system to avoid jitter etc.
Right now the flag isnt set
They should be either static or stationary
Good morning! I'm trying to do a RPC to the server, but I'm getting a crash, where is said that it failed to find a specific function . I will post the snippets, but should I move the logic to the GameMode instead, storing the players controllers in the PostLogin and setting the PlayerControllers view targets in the HandleMatchHasStarted? Also, the camera component of the target camera actor must be replicated, using RepOn, etc., right? Here is the snippet:
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PongPlayerController.generated.h"
/**
*
*/
UCLASS()
class PONGONLINE_API APongPlayerController : public APlayerController
{
GENERATED_BODY()
UFUNCTION(Server, WithValidation, Reliable)
void ServerRPCChangesTheCamera(AActor* Target);
protected:
virtual void BeginPlay() override;
public:
APongPlayerController() = default;
};```
#include "ActorUtils.h"
#include "Kismet/GameplayStatics.h"
#include "Net/UnrealNetwork.h"
#include "PongCamera.h"
bool APongPlayerController::ServerRPCChangesTheCamera_Validate(AActor* Target)
{
return true;
}
void APongPlayerController::ServerRPCChangesTheCamera_Implementation(AActor* Target)
{
SetViewTarget(Target);
}
void APongPlayerController::BeginPlay()
{
Super::BeginPlay();
APongCamera* MainCamera = Cast<APongCamera>(UGameplayStatics::
GetActorOfClass(GetWorld(), APongCamera::StaticClass())
);
if (MainCamera)
{
ServerRPCChangesTheCamera(MainCamera);
}
}
I just removed the SetViewTarget RPC call from the player controller, but now I'm getting the same "failed to find function" error in another RPC I'm making, from the Pawn to the server, to set his location. It wasn't happening yesterday thou =\
@twin juniperI personally feel like you'll have a lot easier time making each client handle their own camera stuff. You should just replicate the simple conditions. In this case. If you have two cameras, one before game start, and one after. You would simply have a replicated state value of like.. EGameplayCurrentState or something. Enum with some simple states. Gameplay tags could work too but might be overkill for pong. Playing, Finished, Starting, Lobby, etc, or whatever you want. Put it in the Gamestate, Make an Onrep for it. And the OnRep can have clients locally find correct cameras based on your game's current state. Now all you're replicating is the match's state, no extra actor or component replication, no need for pointer resolving, etc.
Thanks for your reply! Yes, its a good idea to code it this way, since, inside the scope of the OnRep method, you should, if I'm right, get the PlayerController and set its view target? I will try that. But do you know why I'm getting this failed to find function error, related to the other RPC I'm doing?
I'm pretty new to multiplayer but can someone give me a specific instance where multicast would be used? I have built a large part of my project and haven't used it once so i was wondering
Like?
Oh, I have been using forloops in gamestate
Oof
Multicast is just a way to tell UE "send this RPC to everyone connected to me"
Can u use multicast to control umg changes that affect everyone?
Personally. I feel like the majority of things you'd use Multicasts for, are better off in Replicated state variables. The only usecase that comes to mind that really is useful are small notifications that don't need state. And even those can be done via replicated joining function overrides.
Exactly ok
Maybe things like "Player "Dudebro" reached level 12"
I just use component replicates for most things
Fire and forget stuff.
Ah ok
So multicast is for things everyone needs to see but it doesn't really matter
Two major difference between OnReps and Multicast RPCs are
1- OnReps holds the data for hotjoiners too, while RPCs are fire and forget as Authaer said
2- RPCs are fast, they work like "hey send this, now, dont wait" but replicated variables work in different way
Ok
Thank you
I knew what multicasts did, just thought they were pretty useless
But I think I get it now
I was looking the GameState.cpp code, and it uses the state machine inside the GameMode.h, so I guess I don't need to create a new enum at all, and I just should, inside APongGameState, override the GameState OnRep_MatchState, since the FName MatchState is already being replicated, and set the PlayerControllers view targets there?
I mean, I believe I need to, somehow, in the GameMode PostLogin, store the PlayerControllers, and, inside the APongGameState OnRep_MatchState, access this custom game mode container and set their view targets?
? Useless?
I mean I never used them ๐
lol
im doing UObject replication and i want to predict the creation of the objects
is there a good way to make sure that these objects will be named exactly the same on the client and server?
the uobjects are owned by the player state if that helps at all
actually nvm i don't think i have to worry about matching up the names
you don't, netguid will match if they ar erplicated
i was worried that if i allowed the client to predict and create objects then the names might not match up
not about the object creation being replicated from the server to the client
you need to ensure the names are deterministic
and can never go out of sync, then sure.
yeah that's what im worried about
we do this for our random semi-procedural levels
client and server spawn the map, independently, but everything matches
also i didn't know if there would be name conflicts between different players spawning objects, but since they have different outers it seems like the names can be the same
nope name has HAS to be unique
regardless of outer
in the level ofc
as the outer will technically be the world
for a multiplayer game, where would you store things like the spells that a player has unlocked, or their action bar setup (which abilities are in which action bar slots) so that they will be the same every time a player plays the game? I know ultimately you want either some kind of file locally for the action bar or a database, but when actually loading into the game, would this go in the GameInstance so it can be retrieved in any level, or would you load it in something like the player state every time you go to a new map?
it seems like there can be two objects with the same name and different outers
and it works
oh thought you was on about actors
sure components can have same name with different outers
the player state is not name stable for networking, if that is what you are asking
player state is fully dynamic, it cannot be referred over the network by name
yeah
it must have a net id assigned to it
how does that work?
the net id?
yeah
when you go to replicate a UObject over an actor channel, the actor channel hands the object to the PackageMap to assign it a network id
if the name is stable for networking, it uses the name
if it's not, it creates one
is there anything associated with the player that is stable for networking?
generally no
hmm
keep in mind
name stable is a very minor feature
all it does is rather than send the network id in the initial packet, it skips that initial identifier packet and just starts saying "yeah this object is being updated now"
no book keeping or handshaking to establish what object it actually is (or creating it if it doesn't exist)
the server just starts talking about it and the client is expected to know what that object it's talking about is
that is what name stable for networking means. the name is already agreed upon before the client connects to the server
if the name is not stable, the server negotiates with the client to create the object and assign it a network id
is there a way i can do creation prediction?
nothing that is spawned dynamically is name stable
on the client side?
uh, boy
probably not
you'd have to dive deep into actor channel to make that happen
you'd have to have some kind of prediction key to send to the server, and then the server send that prediction key back with a new object creation packet
then migrate your predicted object's network id over to the id that the server sent you
that would be a big engine edit
okay
i think im just gonna rewrite this system i got to not use object creation prediction then
unreal tournament has a method to do something similar
they create projectiles on the client
and then when the server replicates the authority projectile back
they hide the authority projectile and bind the client predicted one to the server
like, make the client one be at the server's position, but simulated forward for Ping seconds
well, predicting object creation is so much more effort, Epic went with that strategy haha
Can anyone tell me why this is only working on the server not on the client?
is there anything special i have to do for replicating an array of structs containing a uobject
vs an array containing uobjects?
I have ReplicateSubobjects overridden in my actor containing the array
and i was using ReplicateSubobjectList before
I don't get it. Well, I tried to code something similar to what @kindred widget said, but, apparently, isn't working. Inside the GameMode PostLogin(), I stored all the PlayerControllers in an array, and, in the GameState OnRep_MatchState(), i got the static camera actor I have in the map and set the view targets for these Controllers. Their view targets didn't change.```#include "PongGameMode.h"
#include "GameFramework/GameMode.h"
#include "PongRacket.h"
#include "PongPlayerController.h"
APongGameMode::APongGameMode()
{
DefaultPawnClass = APongRacket::StaticClass();
PlayerControllerClass = APongPlayerController::StaticClass();
}
void APongGameMode::PostLogin(APlayerController* NewPlayer)
{
AGameMode::PostLogin(NewPlayer);
if(NewPlayer)
{
APongPlayerController* PlayerController =
Cast<APongPlayerController>(NewPlayer);
PlayerControllers.Add(PlayerController);
}
}```
#include "GameFramework/GameMode.h"
#include "GameFramework/GameState.h"
#include "Kismet/GameplayStatics.h"
#include "PongGameMode.h"
#include "PongPlayerController.h"
#include "PongCamera.h"
APongGameState::APongGameState()
{}
void APongGameState::OnRep_MatchState()
{
AGameState::OnRep_MatchState();
UE_LOG(LogTemp, Warning, TEXT("The game state has changed."));
if(MatchState == MatchState::InProgress)
{
const APongGameMode* GameMode = GetDefaultGameMode<APongGameMode>();
if(GameMode)
{
APongCamera* MainCamera = Cast<APongCamera>(UGameplayStatics::
GetActorOfClass(
GetWorld(),
APongCamera::StaticClass()
)
);
if(MainCamera)
{
TArray<APongPlayerController*> PlayerControllers =
GameMode->GetPlayerControllers();
for(APongPlayerController* PlayerController : PlayerControllers)
{
if(PlayerController)
{
PlayerController->SetViewTarget(MainCamera);
}
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("There is no camera in the level."));
}
}
}
}```
I put an UE_ LOG there
isn't executing the OnRep?
You're expecting GameMode to be available in an OnRep. GameMode only exists on the server.
Since you're using C++. In the OnRep. If you don't allow multiple local players, just do GetGameInstance->GetFirstLocalPlayerController or whatever it is.
Hum, shouldn't use the GetDefaultGameMode then?
wait
But the OnRep isn't called in the server, when he is about to replicated the variable that changed, in this case the MatchState, to the clients? I thought that , when I called GetDefautlGameMode, i would get the reference to the GameMode located in the server
GetDefaultGameMode does not give you an active gamemode object, it gives you the CDO which is not the actual gamemode.
Anyway, OnRep is running on the client and the gamemode doesn't exist there so even using the correct function (GetAuthGameMode) wouldn't work.
If you want to iterate the list of local player controllers you can use GetWorld()->GetPlayerControllerIterator()
You cannot get anything other than local player controllers on a client - controllers exist purely on the server and the owning client, not other clients.
Thanks for the reply! I really thought that OnRep was supposed to run in the server during the replication act, just like an event. I tried to use the GetConstPlayerControllerIterator, didn't work. Also I have changed the code to```#include "PongGameState.h"
#include "GameFramework/GameMode.h"
#include "GameFramework/GameState.h"
#include "Kismet/GameplayStatics.h"
#include "PongGameMode.h"
#include "PongPlayerController.h"
#include "PongCamera.h"
APongGameState::APongGameState()
{}
void APongGameState::OnRep_MatchState()
{
AGameState::OnRep_MatchState();
UE_LOG(LogTemp, Warning, TEXT("The game state has changed."));
if(MatchState == MatchState::InProgress)
{
APongCamera* MainCamera = Cast<APongCamera>(UGameplayStatics::
GetActorOfClass(
GetWorld(),
APongCamera::StaticClass()
)
);
if(MainCamera)
{
APongPlayerController* PlayerController =
Cast<APongPlayerController>(GetGameInstance()->
GetFirstLocalPlayerController());
if(PlayerController)
{
PlayerController->SetViewTarget(MainCamera);
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("There is no camera in the level."));
}
}
}``` Just like @kindred widget said, i still got this, the player views are from the cameras attached to them
Nope, same result as before, when i used the iterator: ```#include "PongGameState.h"
#include "GameFramework/GameMode.h"
#include "GameFramework/GameState.h"
#include "Kismet/GameplayStatics.h"
#include "PongGameMode.h"
#include "PongPlayerController.h"
#include "PongCamera.h"
APongGameState::APongGameState()
{}
void APongGameState::OnRep_MatchState()
{
AGameState::OnRep_MatchState();
UE_LOG(LogTemp, Warning, TEXT("The game state has changed."));
if(MatchState == MatchState::InProgress)
{
APongCamera* MainCamera = Cast<APongCamera>(UGameplayStatics::
GetActorOfClass(
GetWorld(),
APongCamera::StaticClass()
)
);
if(MainCamera)
{
//APongPlayerController* PlayerController =
// Cast<APongPlayerController>(GetGameInstance()->
// GetFirstLocalPlayerController());
FConstPlayerControllerIterator It = GetWorld()->
GetPlayerControllerIterator();
for(It; It; ++It)
{
APongPlayerController* PlayerController =
Cast<APongPlayerController>(It->Get());
if(PlayerController)
{
PlayerController->SetViewTarget(MainCamera);
}
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("There is no camera in the level."));
}
}
}```
What is strange is that the first UE_LOG isn't printed in the Output Log at all, like any method that isn't called
Can anyone tell me why my client can't see the colors?
@twin juniper I'm actually a little confused by this at the moment. default match state is a string. How are you comparing it with an enum?
Well, I saw, inside the AGameState, the way that the engine does the OnRep ```void AGameState::OnRep_MatchState()
{
if (MatchState == MatchState::WaitingToStart || PreviousMatchState == MatchState::EnteringMap)
{
// Call MatchIsWaiting to start even if you join in progress at a later state
HandleMatchIsWaitingToStart();
}
if (MatchState == MatchState::InProgress)
{
HandleMatchHasStarted();
}
else if (MatchState == MatchState::WaitingPostMatch)
{
HandleMatchHasEnded();
}
else if (MatchState == MatchState::LeavingMap)
{
HandleLeavingMap();
}
PreviousMatchState = MatchState;
}```
They're FName
And the enum is inside the AGameMode
But I think I found the reason behind my problem, let me check first
Is there any reason for a client's controller not to possess its pawn. I mean, my "OnPossess" function is never getting called.
Research on the internet made me figure that I should override the Restart function of the Pawn blablabla, but isn't the Possess function supposed to be called in a first place?
๐ฆ
Yeah, as always, the issue was caused by a dumb act of mine: please discover who doesn't set the GameStateClass inside the GameMode? Well, using GetGameInstance->GetFirstLocalPlayerController "worked", but there is another problem: the second player, apparently, doesn't spawn in the PlayerStart. Should I, inside the GameMode, retrieve all the PlayerStart and, inside the PostLogin, assign and pop an PlayerStart for the controller that was passed ?
Hum, it seems that is the same problem that is happening to me: no Pawn spawns in a PlayerStart for teh second player, maybe is my case too, the game starts with the two players, but only one of them possess a Pawn?
Well, it seems like both my controllers are spawned in proper instances.
I think server is having all player controllers and each client has its own player controller.
I'm playing in listen server (no dedicated server) so one player is also the server.
So I don't get why the client's controller would not autopossess its pawn
The weirdest is that each pawn has its controller referenced with the function "GetController" not returning null. So it doesn't make sense that my controller hasn't possessed it yet right?
Yeah ๐ฆ
Any clues? I didn't find anything in the internet?
Hey Guys, I am trying to setup a basic system where two players can load in and the server sets up some basic info about them such as setting their username that displays above their head. I have a function in the Character which is a multicast and sets the text render object. I call this function from the gamemode after getting their username from an external API. My issue is that the username is only changing for everyone on one client. On the other client it only changes for the player themself, not other players.
Code on character:
Code on GameMode
I'm trying to figure out why, in my game, I have two PlayerControllers, but only one Pawn spawned. I mean, since the GameMode only exists in the server side, who is responsible for spawning a Pawn for the PlayerController? Why it doesn't work, I didn't find an answer in the internet
Game Mode is where you typically would spawn your pawn. So long as the pawn actor is set to replicated, then it'll spawn on clients as well. If you also set a default pawn on your game mode, then one would be spawned for each player by default.
Don't multicast this. Use a repnotify variable and the function that gets created should be used to set the value in the text render.
Thanks for your reply! If you're talking about the bReplicates = true inside my Pawn constructor, yes, it has. And this pawn is set as the DefaultPawnClass in my GameMode
But only one of the players has an Pawn spawned for him
To be more specific, it doesn't spawn a Pawn for the Client. The window located in the left side is the Client, the window located in the right side is the listen server
Do you maybe have only one spawn point and the second pawn fails to spawn due to colliding with the first one?
Your log should show a warning if that happens.
Hello there! No, I have multiple PlayerStart, but, since someone told me that the engine has some issues when the number of PlayerStart is equal to the number of players and that I should place more PlayerStart actors than the number of players, I put half of them in the same place (dumb move, I guess) and the other half in the opposite side
So what you said makes sense, I have to test it
BUT
I have stored all the PlayerStart actors inside an array, in the GameMode, and, in the HandleStartingNewPlayer method, I have assign a PlayerStart to the PlayerController through the usage of the SetSpawn(SpawnPawnFor(PlayerController, PlayerStart)). It "worked", but now both players, client and listen server, don't react to the PlayerController inputs T_T
You don't need to use HandleStartingNewPlayer for that
There is FindPlayerStart and ChoosePlayerStart
Which you can use to return a PlayerStart for the specific Player that tries to be spawned.
This will also call when you try to respawn a player.
Ok, but I was reading this topic here, where people discuss where the ChoosePlayerStart is called https://answers.unrealengine.com/questions/699036/whenwhere-from-is-chooseplayerstart-called.html
Here you can see what method called ChoosePlayerStart and so on. But should I call it directly in another place, like PostLogin()? Also, doesn't ChoosePlayerStart choose a random place, and SpawnPawnFor allows to choose a specific PlayerStart?
That's up to your code if it's random or not
You go over your player starts and then you decide which one you want to return
And you would not call ChoosePlayerStart on PostLogin
You use RestartPlayer to spawn a Pawn for a Controller that has none.
Hum
Thanks @thin stratus , I will try to figure out based on what you said. Also, your compedium is great! But I didn't finish to read it T_T
Glad it helps (:
Well, it was a collision, like you said. I didn't look the Output Log, but there it is
Will an actor created through NewObject replicate?
So recently I was tracking down a bug that turned out to be caused by failed replication. This error was printed out and the actor on client did not have any replicated members set.
LogNetPartialBunch: Error: Attempted to send bunch exceeding max allowed size. BunchSize=72770, MaximumSize=65536
The only custom replicated members the Actor has was a TArray<bool> with 28'000 + members. It got me thinking, how does the bool array with 28000 items translate to an initial bunch size of 72770? Does anyone have a rough breakdown of base Actor replication size before adding derived members?
I would suggest using the NetProfiler and/or Unreal Network Insights.
That might help you a lot more than anyone here can
Good idea, thanks ๐
UE tries to replicate actor properties atomically IIRC, especially if it's a spawn/open packet. Combined with all the other props it might be pushing it up over the limit
How can I load save from client save? I want to load variable and i always end with server save
Sorry, I know that I'm noob.
But I really need help with this. I have tried many ways to load client save, but i allways end with server save
You can't load a client's save file on the server - but you can tell them to load their own save file
and perhaps send the server some info back once that's done
Something like this?
Clients can't set replicated variables
You have to send Character ID back to the Server via another RPC
Create new event with "Execute on server"?
And also bear in mind, this will all happen asyncronously
So it won't be available immediatelly
You can't send an RPC or two and immediatelly use that variable, it won't be correct
So what should I do? use delay between events
Set the variable as Rep Notify. You'll get a function created which you can then use to update whatever you need to with the updated value.
Saves aren't replicated at all. No point in changing the replication values.
Correct. You should see a function called OnRepCharacterID
So that function is executed when the replicated value of Character ID is changed.
Are you doing this in game mode?
No This is character
Ok. So then what will happen is that when that value is replicated, all clients that have their copy of that character will receive the update and run that function.
So after the replication, you use that function to do whatever you want any clients (and server too) to do when they receive the value.
It executes on any relevant clients. Ie. a Rep Notify variable on Player Controller would only ever execute on the server and the one client as other clients can't see other player controllers. A replicated character would exist on all clients, so a rep notify variable on a replicated character would execute on the server and any clients that have a copy of that character.
So Spawning player can be connected to this function? It executes only one time, after spawning player orginal actor will be removed
It is closer
When I'm joining game it seen Douglas C but there is still Megan_C (Server)
It executet 3 times. I have 2 prints
1 In Event and 2 in function
This value is outdated
I think that LoadSave can't keep up
Value that I'm looking for is Douglas_C
this executes only one time and works without problem
So here's the thing... If this is on a character blueprint, begin play will fire on:
- The server.
- The owning client that controls that character.
- Any other client that has a copy of that character spawned.
So if I'm player 1 and you're player 2, and we both join the game together and get our own copy of the character that means:
- Server will fire begin play 2 times (one for each of our characters)
- My client will fire that begin play 2 times (one for your character, and one for my character)
- Your client will fire that begin play 2 times (one for your character, and once for my character)
What's worse here is that the server will be asking the owning client to load the value for that character, so the server would be asking me to load the value for your character that exists on my computer, and my own character, and it will also ask you to load the data for my character that exists on your character and your character.
That being said, the print value on Begin Play will never be valid - everything executes immediately (effectively) when you're on an execution path that is not delayed or held up by a huge loop. When you call "Load Save" you're calling to the client to do something, but it doesn't wait for that event to finish - it goes on to the next step immediately, so you'll be printing whatever the default value is of that variable as the new value would not have been RPC'd back yet from the client to be set on the server - and that's why you have the OnRep function - once the value is changed, you can do something with the new value.
I highly recommend you read through this, and look up some tutorials on replication within UE4.
https://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf
Ok I will check this tutorial out.
Thank you very much for explaining me this
One more question. Does this wait until it's executed? Or immediately goes to next step?
Immediately - the value being set is being referenced so there wouldn't be a problem here. That's why your other example worked without issue - you're on the RPC back to the server setting this value, so the server is going to have the right value.
Something broke, last time I was using this script all player could possess
But now only host can posses
Now I get
"Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetInstigatorController_ReturnValue". Blueprint: SpawnCharacter Function: Execute Ubergraph Spawn Character Graph: EventGraph Node: Possess
"
I have a question. All the items in my inventory are contained in an array of structs in an actor component. This array is a Replicated variable. I have a problem now though. The inventory I am making is a jigsaw/spatial inventory (each item takes specific space on a grid)
Now the way I am handling the inventory UI is whenever the inventory is updated, I regenerate all the tiles in the inventory (thereby keeping the chances of something being off to a minimum). The problem I am facing is, when I pick something up and drop it somewhere else, I have to run the code that adds the item into the inventory on the server (because the array is a replicated variable) but the refresh I do immediately. This causes the item to not show up because I regenerated the inventory before the client received the updated array. What workaround could I use to solve this?
How would I go about updating the actual UI?
Has anyone made some "Player A grabs Player B and from there on Player A moves both of them" stuff? Most basic idea I would have is to define a location in front of Player A and if Player A has Player B in their hold, I set the Location of Player B to that.. on Tick?
Kinda still need collision to work, cause you should be able to push Player B through the wall.
I assume the whole issue would also apply to simple Singleplayer and an AI
I think it just depends on how you want the carrying to handle. If you want PlayerA to stop with PlayerB between them and the wall, you'd probably want to affect their movement and just attach PlayerB to PlayerA temporarily. Which would make it much easier on replication. I assume the issue with ticking PlayerBs movement to that spot would be that it'd probably end up acting more like a physics constraint. You'd have cases where PlayerA could walk up and face a wall while holding PlayerB, but PlayerB would kind of jitter off on the side.
Assuming it's a rigid grab and not articulated or hinged it would just be an extension/modification of the CMC to work with multiple colliders, OR you could probably make a custom movement mode that allows you to use both CMCs in tandem. Depends on the desired behavior and how important prediction is.
Ah you can imagine a simple grab from behind like in Splinter Cell
If it's slow paced enough I'd probably go down the custom movement mode or Lorashs idea
Doubt that fits both without being too wide
THICC BOI
Right so cmc basically handles it by knowing who to follow via custom mode
Makes sense
Shit show to setup i guess haha
A nice intimate supple grab would maybe make for a 50% bigger capsule I'd guess
If that's the type of game you're making
Yeah it would be slow movement and probably always backwards directed
Plus minus some steering
Hitman could also be an example
When he grabs people from behind and walks a bit with them before snapping the neck
But okay. Will try the cmc road
Maybe first try just turning off the victims CMC and collider and attaching. For single playeryer I'd think it would work fine
hello, so im facing 2 specific issues with the current build. The reload animation of the client is not showing up on the server side. Also the up and down torso movement is not showing up on the client side even though the server side is clearly doing it. The opposite of this is working
Sadly full Multiplayer hehe
@plain elkIt's very hard to say with that information. There are dozens of different ways people can set up animations based on networking. In short though, your animating shouldn't care about networking, it should only care about what is on the local machine. Your networking should set those values, and animation should simply update itself based on the values it can retrieve locally.
Hiho
Unfortunately, I don't know exactly what topic this question fits into. I'm currently translating my game but it doesn't work that well ^^
What does the UnrealMultiplayerGamemode class have more than the Gamemode one (regarding multiplayer)?
Hello guys , im new to unreal engine , and new to multiplayer but want to create a 1vs1 game just for fun and have some cool idea ๐ Im an old guy with many ideas , i saw lots of tutorials etc with unreal and thats why i chosen it ๐ So i have some basic question with it when you create a game you start from Hud ? or LEvel ? or characters 1st ? or anyway you can ? just curious what way its optimal maybe ! i have a full plan for the game so i know what i want. just not sure where to start XD most important question im interested is is it posible to create game where 1vs1 you play randomly against others ? Or for that i have to pay for a server ? Or what platform to chose Epic ? Steam ? im sure some of you have more experience with those ๐ Thanks ๐
@alpine crest What is your general background regarding coding, or design work?
I would say i know many things about design work and have brains for visual coding ๐ Im Solidworks expert XD i know thats not unreal but to me its pretty same , And i know CNC coding XD yeah i know its not C++ but again im easy learner ๐ And will visual code some stuff ! Just need some basic info never tryd programming in such powerful engine ! Long time i learned Basic XD and PAscal XD i just wanna do it its like i didnt had a chance , and now i see many great assets to help in market ๐ i will start tomorrow anyway ๐
Lets move this conversation/question to #lounge as it is not really multiplayer related, more of a general game development advice
How do I fix this error: LogOnline: Warning: OSS: Failed to send discovery broadcast SE_EHOSTUNREACH
I don't know what other detail I should give.
@alpine crest make something small and fun and single player first
Guys, please, correct me if I'm wrong, but the call order InitNewPlayer->FindPlayerStart->ChoosePlayerStart happens before the AGameMode::MatchState::EnteringMap, right? I'm asking because I'm overriding the AGameModeBase::ChoosePlayerStart_Implementation, but anything I do inside its scope is empty. If I call UGameplayStatics::GetAllActorsOfClass() inside its scope, the OutArray has no actor inside. So is safe to assume my assumption, right?
@twin juniper EnteringMap is the default state of MatchState. At least it's set that in the GameMode's constructor. Not sure what that has to do with actors existing in the world though? How are you using the get all actors call in the ChoosePlayerStart?
I got a bit of an odd question, I've never really done Multiplayer before and i've been setting up a Sessions class for my game so I can handle rudimentary lobby creation/joining and have been checking the ShooterGame example in order to get a grasp on how the OnlineSubsystem interface works
I noticed that when a client disconnects he should call DestroySession, however with my current setup my client can't do that as the client can't access the GameMode in order to grab a reference to the GameSession (And therefore the session manager)
Is there a better way to handle this? I've seen in some examples people put the Sessions code inside of their GameInstance so they have access to the OnlineSubsystem there, but I wanted to keep the Sessions/Instance code separate
I'm using a listen server setup if that makes much difference -- I think i'm probably just missing something simple 
Thanks for the reply! Here is an image of my GameMode
But I believe that, besides what I have said above, my main problem is that I have no GameSession created, as you can see in this picture.
Since I'm still fresh, is there a good source explaining how to create, find, join an destroy a GameSession?
I don't believe a client needs to destroy the session as it is not their session, they are joining to the hosts' session.
Oh? Hm.. Maybe i've read these examples wrong -- I'll look for some other way of leaving sessions sanely, thanks @sinful tree!
Well like if you're going through your UI and selecting something like "Leave Session" then you can make that open the main menu map for them which would disconnect them.
Ah, I wasn't sure if just travelling to another map would disconnect them properly, i'll try that ๐
Is there a server side call for AActor::NotifyHit? I'm seeing that the RemoteRole is Role_Authority but the local role is a proxy.
Should I use an rpc on the server there?
So does Get Game Time In Seconds automatically update correctly for everyone? Regardless of joining late?
I cannot test it currently in my build so if anyone knows it'd be helpful
sec my IDE is having an aneurysm
World is technically local to each client
as they create their own
you'll want to get the time from the server
right, currently I have get game time stored in game state. I was just wondering if it was necessary
Thanks for letting me know
np
If you're worried about late loaders, you can override the match started functions, to not actually start the game until people have loaded. The server should have an idea of incoming connections.
This is just a concept build, no time to try hard it lol. Thanks though I actually didn't know there was dedicated game start functions
It's a bit out of place. It's actually normal c++ for some reason.
I was reading the Cedric's Compedium, and in the last pages, he says that you can connect directly without GameSessions, calling OpenLevel (but where? In the GameMode? In the GameInstance?) and ClientTravel (from a PlayerController). But isn't working for me, here is the snippet
#include "GameFramework/GameMode.h"
#include "GameFramework/PlayerStart.h"
#include "GameFramework/PlayerState.h"
#include "Kismet/GameplayStatics.h"
#include "PongGameState.h"
#include "PongPlayerController.h"
#include "PongRacket.h"
APongGameMode::APongGameMode()
{
DefaultPawnClass = APongRacket::StaticClass();
PlayerControllerClass = APongPlayerController::StaticClass();
GameStateClass = APongGameState::StaticClass();
UGameplayStatics::OpenLevel(GetWorld(), "PongMap", true, "listen");
}
void APongGameMode::BeginPlay()
{
Super::BeginPlay();
}
AActor* APongGameMode::ChoosePlayerStart_Implementation(AController* Player)
{
if (!bIsStartSpotsCached)
{
UGameplayStatics::GetAllActorsOfClass(
GetWorld(),
APlayerStart::StaticClass(),
StartSpots
);
bIsStartSpotsCached = true;
}
if(StartSpots.Num() > 0)
{
return StartSpots.Pop();
}
UE_LOG(LogTemp, Warning, TEXT("The PlayerStart array is empty."));
return Super::ChoosePlayerStart(Player);
}```
#include "ActorUtils.h"
#include "Kismet/GameplayStatics.h"
#include "Net/UnrealNetwork.h"
#include "PongCamera.h"
APongPlayerController::APongPlayerController(
const FObjectInitializer& ObjectInitializer
) : Super(ObjectInitializer)
{
ClientTravel("127.0.0.1", ETravelType::TRAVEL_Absolute);
}
void APongPlayerController::BeginPlay()
{
Super::BeginPlay();
}```
how does GetPlayerName work from the player state? specifically, i'm trying to load a savegame object using the player's name as the name of the save. this is happening in the InitializeComponent function of a component, both on the server and on the autonomous client. I'm not sure where player name is determined, or where I should be setting it so that it will be correct before BeginPlay (if that's possible)
Anyone knows why my project still cannot open open source file Online.h, when I have added, in the Public DependencyMouleNames, the OnlinSubsystem? I read in the UE4 forums that the addition of this module name should work fine. Also, UnrealNetwork.h had the same problem, but I added the Net/ยด
is there any open source server framework or free plugin for UE4? Thanks
Hello everyone currently i am developing a shooting game where the shooting is completely server authoritative.But sometimes the gun location is not syncing b/w client and server.Is there any way to visualize how my client looks like in server??.Thank you
hi
can we use shared server for multiplayer
in unreal engine
Not out of the box.
You can only go and send the server the data of the client when they tried to fire
Or print it and compare
Hello Mr. Neukirchen! Is this tutorial yours? https://ue4community.wiki/legacy/how-to-use-sessions-in-cpp-eyad3cu0#author-link
Yeah but pretty outdated in terms of compilation
Because I couldn't find the one that were linked to your compedium
Yeah cause epic took down the wiki...
Nice! But your TSharedPtr is missing the type ^^
in the HostSession
Right feel free to edit it if you can
kk
I'll probably rerelease one on my private blog in the future
Nice to know ๐
Not sure what you mean.
@thin stratus Can we implement multiplayer functionalities in shared hosting server instead of dedicated or listen server?
UE4 only offers these two. Everything else is up to you to code.
That said, not sure what you mean with Shared Hosting Server. I only know that term from WebDev, where it means that you use a shared hoster for your website which distributes the required resources among its users.
Which in that case would go hand in hand with Hosting a Dedicated Server on that?
But not sure you would want that. Depending on your Game it's probably better to have full control over the resources required for your DediServer
you have to look into lerping or client server prediction
did you add the module to the build.cs file?
Hi, I have a question โ
I am just starting development in UE4. If I wanted to make a multiplayer game where a person has their cash balance, game currency, and some other data needed to be stored, would I be creating an online subsystem? Can it be done via blueprints, or do I need to utilize cpp? Do I need a dedicated server with a database?
Yeah okay but i just want to know can we see how server state looks like i mean players moving those stuff..
hey do you guys know any video about random player types with 2 random color depending on the types that support multiplayer
Guys does anybody know where i could learn how to improve the physics simulation ? i tried to tweak some variables in the physics simulation settings but the objects still moving like they are in the moon
I was trying to make something similar to a Domino chain reaction, when i change the linear / angular damping i get some extra speed, but some point things starts to go really crazy
I also tried changing the gravity in world settings, nothing that i tried seems to work =/
Anyone know why this would throw an error?
UFUNCTION(Server)
void ServerOnFire();
if I remove the UFUNCTION(Server) it works fine
when implementing the function ur using _implementation right
You need to replicate the server state to the client to visualize that if you are using dedicated server.
You need more specifiers
Reliable/Unreliable and WithValidation
@wise zephyr Sorry for answering so late. Yes, I did, mad don't worry, was just a false positive
alright cool
what fixed the issue?
Hello,
A game like Satisfactory for example, where you join a "Singleplayer" game and can host and invite people while never leaving that map, is that done by having all games launched with "?listen" + always hosting a session and controlling whether it is public for friends or private?
Most likely
I assume if everything is P2P there is no real impact for the host when no one is in the session with him
Can someone confirm, you can replicate UObject derived objects with ReplicateSubobjects, but you can't seem to network a reference to that sub object(via RPC, etc)?
AFAIK you can, if it is null for you are you sure that the object had time to actually replicate to the client when you receive the RPC?
Yea pretty sure. This was many seconds later
You can, the object will be replicated via the owning actor which must also be replicated.
Hmm. Ok, I'll double check my work.
Cause all the client controller have a mirror on the server.(think of them like remote control emit and receiver)
I don't know what cause the 3rd hello from server maybe some sort of echo from how you set up print?
You can go to blueprint and have a drop down see a list of compatible controllers
can you hit the drop down while you have it playing in editor windows?
It will list the controllers you have.
Yeah, so like I said, there should be 3 print
One for client, one for server, and one for clients mirror on the server(the receiver)
So I also said I don't know where the 3rd server print is from.
Did you happen to have some server module that have the same print node attached to begin play?
Cool, mystery solved. :+1:
It's a nice habit to attach the classname when you print though
(or the instance name )
That's not really an online subsystem. You can make a game instance subsystem which handles storing this stuff in a backend for you. Personally I use a REST API to store data in a sql database. I run pretty much everything from the dedicated server. I have the server send the client the information after it gets that info.
Thanks for your reply! So, can this be done with blueprints for example using VaRest plugin? And can I build the dedicated server using AWS?
it's a different type of server that you're thinking
honestly I host my API on digital ocean for $5 a month
along with my database
granted, i'm not in production stage
but i've stress tested my setup and I can handle around 10k requests per second without load bearing which is fine imo
@twin juniper i don't see the issue
server has a copy of every clients controller
and client only has his own controller
so on listen server you get 3 server prints (1 for server controller, 1 for player 2 and 1 for player 3), then the 2 clients, (1 for player 2 and 1 for player 3)
which == the 5 prints you see.
so will your method of using a REST server get my job done? I just need to retrieve a database on user's info like cash, in-game currency, clothes they are wearing...all while maintaining simplicity
Hello, I'm working on a Game with a Listen Server.
I call an "Event OnPostLogin" in my GameMode (whats only on the server right?) and after some conditions i call an Event that is inside my "PlayerState" but that Event only fires on my Listen Server not on my Client. Any Idea why?
gamemode does not exist on client
try looking into gamestate instead
Thats the point why i used the gamemode
build the database? there is a plugin for UE4 i found called VaRest
https://www.unrealengine.com/marketplace/en-US/product/varest-plugin#
Thats not a database. That's connecting to the database
Yeah I meant using blueprints instead of code to connect to the database
I think I will just use a mySQL database on a simple hosting platform that also runs apache so that it can also serve as a registration/login page
does that sound logical at all lol
they dont
where does it show that?
those prints are perfectly valid
2 clients on a listen server, would be 5 begin plays
3 server, and 2 client
for the player controller.
what part are you not understanding? maybe i am not clear enough?
Is there any free option for hosting a server? For example if I want to play a game I have made with friends do I have to pay? I have seen hamachi but I am not sure.
can just run the server on your own pc
or get a cheap VPS
if its just for you and friends
How would I run the server on my pc?
well either do listen server (where one player is server also) or build the dedicated server, which requires source engine.
you can get a free tier ec2 instance on amazon aws
maybe that will clear things up.
Yea the listen server idea sounds good. Where a player would just host the game. But how would the others join?
you would need to use some nat punchthrough like steam
or open the ports on your pc and firewall to allow connection
I don't like that idea
you need to do one or the other
isn't that not safe?
open the port 7777 (default UE4 game port)
and make sure your router forwards that to your pc
your friends may also need to open port 7777
Natpunch through solves this by configuring your router dynamically
its a complicated matter, https://forums.unrealengine.com/t/how-to-do-without-opening-port-7777/231665/2
i replied here
unless you are directly connected to the internet and not via a router, you need to do something
Can I use hamachi?
that's what I saw being used in a udemy course
though I was always afraid of how safe it was
people use it, i have never personally used it.
do I have to pay to use the steam stuff?
I'm really lost right now... The "GameMode" only exist on the server right?
The Server knows about all PlayerController and i call an Event from a Player Controller over my GameMode, shouldn't that work?
clients would need to send a server (event) rpc
so the server can update the game mode
as you rightly said, GameMode is server only.
if you want to send an event to clients from GameMode, you would need to call a Client (event) RPC from the gamemode
What is a Client RPC?
A Normal Costum Event?
What im trying to do is. I have the "Event OnPostLogin" in my GameMode, when 2 Players Login it should start an Event that is located in my PlayerState
Does anyone know a better explanation for the FOnlineSessionSearch::PingBucketSize? The objective is to cluster sessions in specific groups based in the ping value?
@wispy elk Yes you can do it through BP entirely if you want. Personally I find coding it much easier.
it's an event marked as Run on Owning Client in BP or UFUNCTION(Client, Reliable/Unreliable) in code.
Game mode functions only run on the server as the game mode only exists on the server. If you want to call a function in your player state to run on clients in your OnPostLogin function, you'll need to mark it as a client RPC.
Ok, im trying this another way. But still have a problem. ๐
I'm using the "Steam Advanced Session" Plugin for Host/Join Stuff.
After i press Host or Join a widget loads with "Waiting for Players"
and after all Players connect to the session, the game start with game level.
Until now i just used "Open Level" right after "Create Advanced Session"
But how would i tell the game to wait until the second player is connected to load the new map? How do i do this?
you should look into the GameState class
and read through those functions
you can check the number of players in the map, using the gamestates players array too
I believe a function gets called on the gamestate after a player joins as well
to set them up
I actually got that now and the "Waiting for Players" is working too. Found a way around it.
Instead of Loading the Map after all Player Connect, the Host is opening the Map, a Widget blocks the view to the map and he waits there for the other player.
Only problem is still that my client player won't start the event that starts a part of the game.
your client doesn't start the game, your server does. You need to call the Server RPC to start the game
Not the game itself
Before i set up this whole "Waiting for Player" Stuff i used "Begin Play" to Spawn "Cards" that the player use to play.
And i need the Server to spawn this cards now
Okay so. A player wants to place a barricade on a wall it does a line trace and then when you click it spawns at the location. Replicating the location works perfectly (before the client only ever returned a 0 Vector) However when spawning the board it does not show up for the Client. The mesh and its actor is set to replicated
Okay debug shows even though the location of the replicated variable location is correct its still spawning the board at 0,0,0
wtf?
Ah crap. The print string is running on server..its what the server sees not the client....but then why wouyldnt it work...massive head scratching
Okay so this straight up doesn't work. Having the server run a multicast works but then it spawns the boards twice...
Hm. Setting the variables of its rotation and location to replicated dont work...Whyyyyyyy
Okay just watch this clip I uploaded. I am trying to replicate this action. https://streamable.com/v6n5t6
I've tried doing the server to run a multicast when the player clicks to spawn. This ends up spawning the plank twice..one plank in correct rotation, the other zeroed out
So the server does the final line trace (on click) ..which makes sense in my head..but it doesnt actually work..
sort of... quick question: what is an optimal way of creating lobbies on the main server, and only until the lobby creator decides it's ready, do we actually set a lobby hosted by the lobby creator and get all in the lobby to travel to that session?
like say in the main menu you select the lobby but don't actually travel; that way you can quickly drop in and out of lobbies in case you change your mind without connecting to the host of that session (staying on the main server where all players connect to when logged in)
so far I've only worked with lobby systems like say Battlefield, where there is no intermediate lobby. You're either on the main server allocated to your player pool or in the game session, and not entirely sure how to approach this
I see. I only have SteamCore:: atm; I'll take a look at that.
@dull lance beacons and setting your session as visible for searches.
You are setting the location on the client when you're pressing the input. This does not set the value on the server.
It doesn't work. I've done the trace from server and still doesnt work
What does your trace look like?
trying back to the server calling multicast to see if I get this to work. It does spawn it in the correct place but the rotation is always set to 0
server rotation is different than the client....hm
sigbeiugbiregnekrjgnregjngejgnergergnregoireigoirongreg
Don't multicast that. You should have your actor set to replicated and then all you should need to do is spawn it on the server. Multicasting makes every single client (including the server) execute what you've put.
that doesnt work though
That means you don't have it set up right.
something to do with how line trace is handled
I know what you mean..I could all day everyday do this with any actor but the line trace location/rotation is totally not working
The two "Rotation Board" values (Y and Z) are probably values that you're also manipulating on the client, these would need to be passed to the server.
Hi! Is there any standard for datababase when using dedicated servers?
Like, do you have to connect the server to a sql database or does it come with one already?
you'll need to make your own and a way to communicate with it
I use a REST API and persist my data in a SQL db
Ya still no bueno.........................................................................................................................................................
Great, im familiar with sql cause of my work. Still, any tutorial, guide or documentation you recommend on this topic? (hooker ue4 dedicated server with a database)
I created my rest api in Java using spring boot as my boiler plate. There are several options you can use. You can technically interact directly with your db via ue4 but that can cause a ton of issue if your source ever gets out
Why would thst be a problem unless they have the credentials for the db?
thanks for the insight
however, I think I'll stick to interacting with it via BP
I don't trust players. I trust hackers even less. Having direct access to your database in your source code is asking for trouble. Using an API gives you an extra layer of security as they can't track what the API is doing other than sending data back.
has anyone had issues with dedicated servers built for linux on 4.26? i can get it to compile just fine, it starts up fine & looks like everything is working, but the client gets a timeout while connecting and the server doesn't log anything about the client trying to connect. windows servers work just fine. i've built dedicated servers for linux a bunch of times before on older versions, and never ran into anything like this.
yup that is also correct @twin juniper
playerstate is replicated to everyone
so should be 9 prints
client will have one copy of each players playerstate
server will also have a copy
@thin stratus I was reading your tutorial about Game Sessions and there is a point I'm trying to see if there is a corner case you have thought that I haven't ```void UNWGameInstance::OnStartOnlineGameComplete(FName SessionName, bool bWasSuccessful)
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::Printf(TEXT("OnStartSessionComplete %s, %d"), *SessionName.ToString(), bWasSuccessful));
// Get the Online Subsystem so we can get the Session Interface
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
// Get the Session Interface to clear the Delegate
IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();
if (Sessions.IsValid())
{
// Clear the delegate, since we are done with this call
Sessions->ClearOnStartSessionCompleteDelegate_Handle(OnStartSessionCompleteDelegateHandle);
}
}
// If the start was successful, we can open a NewMap if we want. Make sure to use "listen" as a parameter!
if (bWasSuccessful)
{
UGameplayStatics::OpenLevel(GetWorld(), "NewMap", true, "listen");
}
}```
Shouldn't be the if(bWasSuccessful) block inside the if(OnlineSub) block? I'm asking because I know we have to check it anyway, but you only have a successful session start if you have an non-null OnlineSubsystem, right? In this snippet, the if(bWasSuccessful) condition will be checked even if the OnlineSubsystem is null, am I missing something? Is there a corner case where your IOnlineSubsystem pointer is nullified between the Sessions->StartSession() execution and the OnStartOnlineGameComplete?
the online subsystem would never be null if it wasn't at the get go. It starts when the game does.
Thanks for your reply! Well, this answers the question: the second if should be nested inside the first one ๐
Shouldn't need to no. Those if's are doing 2 different things.
kk
No, there is no edge case here. This is just how I coded it.
I think my thinking back then (and also now) was never "If the subsystem is valid, check the boolean."
What I did was "Even if the callback was not successful, we want to kill the callback binding.
@twin juniper
You could probably wrap the bool check into the subsystem check, but I don't see much value. The Subsystem won't be null if the callback happened I assume, cause the subsystem triggers it after all
Would even go as far as not nullcheck the sub at all now adays
Let it crash if the subsystem is null, cause then sh't is going on anyway
Hello, Cedric! Thanks for the reply! I'm just modifying what you taught us in the tutorial, and I'll probably test it today (actually, is 03:42 am here T_T)
Because the clients were getting a "LogOnlineSession: Warning: OSS: No game present to join for session (GameSession)" in my Ouput Log, I thought I should connect through Game Sessions. I have to test it btw
The way you could change what was presented in your tutorial, to run a dedicated server, is related to the way you call those functions? For example, to run as dedicated server, I should use the HostSession(), while the clients would use something like if(FindSessions()) { choose the session that has the lesser latency call JoinSession() }
? Or should I go beyond the engine and learn how to code a master server? Also, the GameSessionName is stored in a variable to be used as a cache, and making possible the session destruction? This was the first thought I had when I saw it. Another thing I saw is that ULocalPlayer->GetPreferredUniqueNetId() returns a FUniqueNetIdRepl, and IOnlineSessionPtr->FindSessions (for example) only accepts, as the first argument, an int32. Is there an alternative or should I start overloading/overriding things?
Hey, i have a question regarding the net dormancy of an actor.
-- We can only change net dormancy state on server ?
-- does net dormancy state effects the RPC
-- If i have scenario where spawned actor is initial state, then i do something with actor, once done i change its
dormancy state to dormant all. Next time it does nothing, because some code which are check is on server.
is it because of this ?
Can someone tell me why this is not working? I'm calling this in an actor that is placed in the level in editor so it exists for both client and server
Sucess Server never fires
-- We can only change net dormancy state on server ?
yes
-- does net dormancy state effects the RPC
no, only replication
-- If i have scenario where spawned actor is initial state, then i do something with actor, once done i change its
dormancy state to dormant all. Next time it does nothing, because some code which are check is on server.
is it because of this ?
you can simply lower replication update frequency to lower how often object is considered for replication
or yes, waking up object after interaction and forcing net update
Sometime you can choose what to replicate:
- Replicate a actor reference and read values from actor after replicating the actor-ref on each client.
- Or read values from actor on server and just replicate the values itself and not the full actor reference.
- Or do not replicate actor reference nor single values, but replicate actor class reference and read class defaults (of course only possible if class default properties are the one which needed on clients).
Do you know any good topic about the overhead/difference on replicating values, actor reference or actor class reference? I did a web search but do not find some content, what uses more replication bandwidth/size. Would be cool to know, what is the "cheapest". Or any idea how to measure?
you can use Unreal Network Profiler and several test cases to measure
https://docs.unrealengine.com/4.26/en-US/InteractiveExperiences/Networking/NetworkProfiler/
Tool for displaying network traffic and performance information captured at runtime.
ah, good idea
On my test conclusion, that it is way more economic to pass object reference. Even 2 floats are much bigger as replicating the full reference:
Would you guys had expect this or is it more a suprise?
Well, it doesn't pass the whole object
It passes a unique id
All the data inside of that Actor replicate on their own
If you have 4 floats and a String in there, you actually have more stuff replicating than just those 5 values.
@sleek elk
Learn about Ownership please (e.g. via my Compendium).
Actors that are placed in the Level are not owned by your Client.
A ServerRPC requires that however.
Ownership can also only be set to one client at a time and has to happen on the server, so move the RPC into something that is owned by that client, e.g. Character/Controller/PlayerState.
yeah i used the player state and it works thanks to your compendium ๐
Awesome
Hi Exi, great Compendium! Of course I am not surprised totally, and my question and test was just about "how many single values replicating are using more bandwith as replicating the full refrence". #multiplayer message
But, yes, for me it was surprising how early it makes more sense to replicate full actor reference: Already a RPC with replicating a float used more size as a RPC replicating the reference to the actor. Seems referencing ID is smaller as I thought. ๐
I don't understand what you are comparing there then
If you need 2 floats replicated to Clients, then replicating them directly is better than replicating some Actor Ref
Because the Actor Ref still has to replicate those two values
So you only add onto the bandwidth, you aren't saving anything
Is there a way to filter the sessions that are coming back from steam? I use the free port 480, and I cant test all data
I think there are many examples. A trigger per RPC by an event from server to the players player-controller to message something on their hud (event based, not permanent) and with text content including some default/static actor values (perhaps max-health). You can replicate values per RPC or actor reference.
Like in my example, only for one time event RPCs, of course not for values you replicated by property replication anyway. Then you could simply do it on change by rep notify or whatever.
yes, you need to populate the filters for SearchQuery before calling FindSessions
the only thing im setting is this SessionSearch->QuerySettings.Set(SEARCH_PRESENCE, bUsesPresence, EOnlineComparisonOp::Equals);
do I need to put all other setttings?
The first few times you reference an actor (a map-serialized one) or a class, the full FName will be sent until a NetGUID is acked
So it could be vastly more expensive the first few times, because it's akin to sending a full string with unknown length
But yeah either way, using an actor to replicate two floats by proxy isn't saving you anything
depends on what kind of filtering you need. There are many parameters in OnlineSessionSettings.h plus there are session extra properties
i mean i dont want other people's who are currently testing as well, I want results only from my game executable
You can add a special key, value pair to your session when you create it and use that in your search to filter out other games.
I always get a ping of 9999ms !
and sometimes other sessions appear too
By default you'll only get a valid ping to a dedicated server with the Steam OSS
Ping to listen servers aka "lobbies" will always be 9999 since AFAIK Steam doesn't give you a method to ping lobbies, though even if it did those pings are very inaccurate
@violet sentinel For some reason, if i keep actor in dormant all state, one of its comp does not do RPC to the server.
if it is active in any way you shouldn't have it dormant
are you having thousands of them ?
not thousand but they can increase and decrease
if there is small amount of actors just let them be in normal state
i have reduced the net update frequency to 10
i can go lower though right, making it 1 , can optimize things better
if it is object that changes its replicated variables rarely then yes. even 1 (1/1 = 1 update per second)
object only changes value, when i interact with it, otherwise does nothing, only render stuff with data it already have.
so my plan was to make it dormant, which i think wont work, unless i pass it through PC or something to change its state to awake, before sending RPC , i think.
we can update the rate at runtime on server right, like do force net update, before changing the amount of updates, when we start interact with the object, but once done change it back to 1 or even lower, can we do (0.1) ?
i wouldn't try to play with dormancy unless i find that object high in network profiler chart
okay i see
get too hard to support later
thanks, make sense, will do profiler first then do the optimization.
oh okaaaaaay
Net update frequency can also be misleading
while it'll update at w/e rate you do
it still falls into the net priority
if it's bottom tier in priority, you can have it update every frame (not advised) and it would sitll get misses.
we just call FlushNetDormancy
if server need to replicate a property
this puts it back into dormant after sending an update
dormancy does not affect RPC's
@tranquil yoke
@meager spadeyou call this on server ?
from client yes
yeah actually, i had issue where i was not even able to send an RPC from cilent to server ,it was inside a component, which is inside the Actor, whose net dormancy state is dormant all
the best solution i can think of right now is, have a server event on PC, and change the dormancy state for any actor, before sending an RPC from that actor itself.
NetConnectionClassName=OnlineSubsystemSteam.SteamNetConnection
RelevantTimeout=2
bNeverApplyNetworkEmulationSettings=true```
Is there any issue if I change `RelevantTimeout` to for example 0.1, the issue is that I'm overriding AActor::IsNetRelevantFor and it takes like 5 seconds for the actor to stop being relevant on certain conditions, and that happens even when I'm calling ForceNetUpdate
and I need the net relevancy to look seamless
In BP Multicast event, is there a way to get the player pawn/controller that's executing the event? (Like, Multicast executes on all clients, so I would want to use the client as a variable when executing)
each controller is executing the event
the server version is the one that initially executes the event
and then the client version execute the same event
@tranquil yoke Dormancy should not affect RPCs
RPC is nothing to do with dormancy
complete separate systems
okay thanks, my issue is something else then, i will try to debug that
Im having a bit of a weird situation. The client is not being detected by collision but the server is. I have an enemy attack that will attack the player character using a box collision or a sphere overlap actors (I have one of each). Neither of them are detecting the client, only the server. This is a recent issue and it was working fine and I am not sure what I changed to make it not work now.
quick design question (divided into two): Say that your multiplayer game as a turn system.
- Would it be better to make this a UComponent (and say have it in the Game Mode / GameState) or as an Actor?
- Would it be better to keep the Turn System strictly on server (Say GameMode / Actor existing only on server) and then have another actor that broadcasts results to clients?
I've never done a turn based project but my first guess would be to do it through Gamemode/Gamestate
Gamemode controls the turns, GameState is where the turn state lives so clients know about it
Playerstate being where your individual turn state lives like whether your turn state is ETurnState::MyTurn or ETurnState::OtherPlayerTurn etc
depends on how it's done
the Player State part is done, and it's what controls the Character.
I was initially thinking to not have the Turn System be replicated, but can't really think of a reason why to not have it; All I'd have to do is to block any function calls from the Clients and keep almost everything private with the say the GameMode being the friend (for instance) and update the variables using ReplicatedUsing (or even FastArraySerializer because of the call back functions) and have that call back function update the players locally.
But I also understand that that might not be fully optimal, hence the question
I'll take your suggestion into consideration. Thank you for your answer ๐
There's actually a pretty good one in ISteamNetworkingUtils, I just don't know that the OSS utilizes it because I think it maybe relies on SteamSockets:
int EstimatePingTimeBetweenTwoLocations( const SteamNetworkPingLocation_t &location1, const SteamNetworkPingLocation_t &locatio
I have a 3d widget in my world that all players can use. How do I get a reference to the player that is interacting with the widget currently? (Pressing a button)
from the widget? its all local, meaning the widget only exists on players machine
if u want the world widget to do stuff, try calling server rpc on the actor the widget belongs to @heady python
widget andriodkeyboardarrow the widget actor ref andriodkeyboardarrow server rpc
that's for Steam Network Sockets
if you are on SDR, that will work, but you need to opt in
We're trying to replicate visemes from OVRLipSync across a network reliably, has anyone successfully done this?
I'm at a point where it crashes if I send it all as a Json string or individually as Floats on device, sending it unreliably ends up causing it to send in a random order and adding a time to make sure it only got the latest packet still caused issues with morphs.
SDR?
steam datagram relay
hey i want to make multiplayer soccer game with listen server but why when player 1 kick the ball the in player 2 doesnt got kicked and when player 1 pick up a hat player 2 cannot see player 1 using the hat, waht should i do?
ah cool. Ty
Does Player 1 see Player 2 doing the same thing?
no
player 1 kick the ball but player 2 doesnt see player 1 kicked it
and player 2 doesent see player 1 pick the hat
is there any network multiplayer demo example? cpp better... found one blueprint in the tutorial, https://docs.unrealengine.com/4.26/en-US/Resources/Showcases/BlueprintMultiplayer/
Breaking down the Blueprint Multiplayer Showcase and how it was constructed.
How to compile to VR(default 1stPerson view) & Mobile(3rdPerson view) from one same project and source code? is there any demo or tutorial?
Sounds like its not replicated
You can take a look at ShooterGame
^ It's old but still valid.
The only example project Epic made with multiplayer was the "Multiplayer Shootout" demo, but that's about it.
Blueprint doesn't have the majority of multiplayer tools, only the basics.
Does anyone know if ue5 will improve on large player count in multiplayer?( Not sure how to word the question properly)
If not, can anyone link resources on how to implement and optimize server maps of greater than the standard 100 players(in ue4/5).
PS. I'm not making a MMO. Lol
There's little reason for it to
And there's no way anyone can link you a resource on >100 players, since 100 is nowhere near standard, no one has done more in production, and so no one has resources on it
100 is completely insane already
Hmmm. I hear rust does 200 but I'm not too sure.
Rust is Unity
Lmao. Maybe.
Yeah. I know. I assumed you were speaking generally.
100 online players means you have insane player counts for the average PC game
But what if you have a small player base and want to save yourself instancing more worlds than necessary
Assuming 5 servers geographically, and no concept of matches, that's 500 online players, a lot more if you have matches
500 games on Steam can do that
True. I wonder when it'll be possible to achieve greater. Dual universe claims to do 30k
By 30k, I mean 30k players in a shared server/world
It's an MMO, so yeah, sure
So let me get something straight. It's possible to achieve such numbers but not with ue4 and possibly ue5
I would love to get my hands on their tech.lol
What would you do then ? Ask someone to give you the $100M in marketing to actually get the 30k players ?
No, Unreal cannot do that
C'mon man, at least try to give me some hope here.๐
But seriously. I really want to know how they do it.
Using Unreal as a renderer and having a completely different server stack, is how
But no, there is no hope for that, reasonable people hope for 20 online players
So that they can matchmake 3 players cooperative games
People don't make MMOs, publishers do
Dual Universe has been at it for very literally a decade and fired the entire company twice
Yeah. It's a lofty goal
Owning a publisher sure is
Wow. That's intense.
Lol. Wanted to send a DreamWorld joke here. But I dunno who is watching.
Indie MP Todos:
10-20 Player Servers Max, Listen Servers if you can, Add PVE, keep it simple.
Just a fun fact we've shifted >1 Mil copies on Steam (with publisher) - and even with that number our peak 24hr concurrent player count is like 2-3K at the most. Consider that the vast majority games on steam barely even scrape a few hundred sales, it's suicide to do anything else commercially.
If you can't support listen servers for any reason, ship the dedicated server binaries and let people host wherever they want too.
Simple dumb cooperative PVE multiplayer is stupidly hard enough.
yeah definitely
I like (sort of) the challenge of MP but the market is something else ๐
Is it normal for RPCs to get called even before GameInstance has called Init() ?
no, and they dont
in editor they do
I store my gameinstance a static singleton in init.
However that singleton sometimes can be a null if Beginplay rpc looks it up on the client
GameInstance is created way before any BeginPlay happens. Don't store it, just get it when you need
well what I mean is , the client seems to receive the RPC from server before the gameinstance for client has called its init.
No, the game instance is created way before a client can even connect to anything
Remove the singleton first and call GetGameInstance<myclass>() directly when you need it
Does AIPerception/AIPerceptionStimuliSource not work over network? ๐ฎ
I have set both components to replicated and it works as intended in singleplayer, but as soon as I host an online game, the perception isn't working.
Neither on the server nor on the client that is
Never reaaaally worked with it, but I would assume all of that should run server side
Is there a reason to not use the singleton if it is created way before anything else? With respect your reasoning is a bit contradictory there.
My point is that you probably messed up your singleton
Now with PIE everything's possible, but I'm guessing what happens is more "singleton is messed up by the double windows thing" and less "actors exist before game instance"
Hm
All the behavior is server side sooo
My patrol set up seems to work on the server (and is replicated). Just the perception isn't kicking in for any side
lets chalk it up to PIE weirdness since it never happens on packaged game
Hi, does someone knows if blueprint interfaces run on server when i call the interface event?
Can i do this?
Or it will only change the boolean on client?
It's not a ServerRPC, is it :P
call another Event from it that has replication mode set to client or multicast
{
#if WITH_EDITOR
UWorld* World = WorldContextObject->GetWorld();
UKMGameInstance* KMGS = World->GetGameInstance<UKMGameInstance>();
return *KMGS;
#else
return *MySingleton;
#endif
}```
That;s a good fallback
its just personal convenience for shorter code
Ok I think I am a step closer with my ai perception issue.
It appears it has nothing to do with network/server/client but rather with standalone vs. editor.
It works fine in editor, but does not work in standalone game (which is where I happen to have tested always with network)
i posted it cause he goat clept again and he thought he was immortal. i bet he stil think it right
I think I found a fix. I checked "Auto register as source" on the stimuli component. For anyone that might be interested.
If this works it's also confirmation than your singleton system is the issue. Just drop it and use GetWorld()->GetGameInstance<UKMGameInstance>() instead of UKMGameInstance::Get(this)
are you sure there is no out of order events in PIE?
Your fix proves there aren't
Assuming that WITH_EDITOR part was added to fix the issue
In any case the singleton pointer is completely pointless
Caching pointers, especially UObjects, is a bad idea
Especially in single process PIE
Isn't is the contrary? in a packaged game that fix isn't needed. since init() that caches the singleton ,is called before any RPCs that lookup that singleton in a packaged game
You can have multiple game instances in PIE
^
PIE does many sp00ky things
Each window has one
Has anyone had issues with the Client just not getting its ViewTarget changed to its Pawn?
Kinda stomped atm, as I don't get any warnings or errors. Just remains on the previous camera
Just don't do singletons with UObjects is my straightforward advice
Hm, seems to be something in my PlayerCameraManager... checking that first
Does ue4 keep all replicate actors on client at all times?
Is there a way to have a vertical box automatically place it's child at the top? I think it's so weird that it's only changing the location of X
Question:
Multiplayer with level(world) streaming.
If playerX at the one end of universe will create a box
will server command to create a copy of this box to
playerY at the other end of universe(at another level)
?
How should it work?
there is a special channel for that #umg