#multiplayer
1 messages · Page 141 of 1
Sorry, I'll ask there too, though someone here might have done that for multiplayer already
I couldn't find a way to do that, I see that SkinnedMeshComponent feeds it delta time, but it never "seeks" the time. I'll try to dig further into it, maybe there is a way
Yeah it probably accumulates time from whenever it "starts" playing
might even pause when not used at all, like how audio pauses when silent
not sure
If you can figure out a way to feed an actual time value to an animation, which it'd sample by Time%AnimLength, then you'll be on track
I should try feeding it negative delta time lol 🤔
I need help figuring out why my component will highlight for player 1 but not player 2. It had been working for a while, but now the client never calls the part of the code (shown below) where it sets up the mouse over events. The actor itself is spawned after both players have entered the game from the game mode, but having it placed in the world produces the same results. BP_Tile and SM_stone_02 (the component I highlight) both replicate.
Just looking for some general advice from people who have experience with Netcode in shipped games:
- Where do most indies make critical mistakes when coding multiplayer FPS games? I'm trying to tidy up my netcode and would love an external opinion about what to optimize first
- What are the most important config variables for a networked game? Are there any values or settings that aren't initially obvious and need focus for optimum performance?
- How much does the 'Waste' factor in the Network Profiler actually affect net performance? And how does it affect net performance?
- Any other thoughts anybody wants to throw in? Please do!
Try setting the event replication to multicast in the details section
Should look like this
Just a side note on this - Epic recommends avoiding Reliable Multicasts at all costs. They actually almost removed that functionality from the engine all together because it can destroy network performance for everybody if it gets abused.
none of that should be networking aware
The highlight is local right? I don't see anything if YOU hover an object, right?
nvm i'm dumb 😄
@dark edge I’ll go try that now, but the highlight is ONLY local, when I highlight my opponent does not see it so I don’t believe that should be replicated.
I mean do you intend for it to be local or not?
if it's meant to be local then multiplayer has nothing to do with it
Well, the object itself is replicated, and the client isn’t running the code that enables it.
you're telling me the client isn't running Begin Play?
I was debugging, and never saw the client go through it.
That'd be a but sus to me
How would you recommend going about resolving this type of issue?
I'd start by trying to figure out where it's breaking
I just need the actor to highlight when the client mouses over it.
Well, and the server. Both players should see their own highlight and not the other players to be clear.
Print the net mode on begin play
make sure begin play is running everywhere, then make sure the mouse hover events are running everywhere
My money is on the mouse hover events not being triggered
Does anyone know how to make a torch replicated? Because I added a spotlight and sent on server wheter to set it to visible or not with rep notify and that works but cant find a way to set the Y-axis rotation to replicate...
Okay, I’ll focus on that. Thank you.
GetBaseAimRotation will give you a replicated pitch
I'm guessing this is a torch held by some character right?
yeah actually I just set it up as spotlight directly in the character
as component
so drive its pitch with GetBaseAimRotation
Guess I found out to do this and set the spotlight to component replicates:
seems to work fine, hopefully no hidden issues
You shouldn't have to replicate the spot light
but it depends on what else you're doing with it
i tried without and somehow the spotlight was backwards
I mean it's just inheriting the rotation of the capsule right?
or whatever it's attached to
yeah
are you doing anything to it on begin play or is this literally the only time its transform gets changed?
sure go for it
Is the 100 players limit a myth?
for dedicated server
I tried 11 players and it was using 1% of my server cpu
Could probably handle 1,000 playing Chess, and 3 playing Factorio
all depends on how the demand scales per player
I mean 100 CMC
if you gotta ask, probably not
For a game like fortnite is 100 players the limit?
I`m using full c++ optimized and not playing animations/bones on server
it should handle even 200, right?
Still using CMC
and gameplay abilities
i will try but 11 players using (CMC) and gameplay abilities was barely hitting my server, it was at 1% (a weak server)
You gotta remember it scales worse than that, depending on the density
11 players in 1 place is much worse than 11 all spread outside of relevency range of each other
No way to know but testing
Looks like the CPU hog is TickBones and TickAnimation not the CMC by itself
There is no single answer to this question.
CMC is not particularly fast. 100 is not an upper bound, just the most anyone has reasonably done.
You can do more, you might be stuck doing less. It depends entirely on the game, how much time and effort you have to spend on optimization, and how much money you're willing to throw at server costs.
I have flashlights as a separate actor in my game because of my pickup system. because of this I'm running into some issues. When one player picks up a flashlight it works fine, turns on and off fine, but once the second person picks up another flashlight the first one stops being able to be turned off, or sometimes player 2 can turn off the flashlight player 1 is holding. I'm guessing I'm missing something to iterate them but I'm not sure what atm
i dont think begin play is executed on the client if the client joins later and the begin play has been executed on the server already, right?
it is
actors run begin play when they are spawned in the world, on all game instances that know about them, regardless of whether you are a late-joining client or not.
it'll even get called multiple times on a client if an actor goes in and out of relevancy over and over again (because as far as that client is concerned the actor is being deleted/created again)
though in that case the client is seeing them as separate actors, so it's not like beginplay is called multiple times on the exact same object on that client.
On unreal can we have components that are client side only? visual things that don`t need to get created on dedicated server?
yes
If it's a component created at runtime, just don't create it in situations you don't want it.
If it's a custom actor component, override NeedsLoadForClient/NeedsLoadForServer
If it's a primitive component (any kind of geometry, mesh, etc) set AlwaysLoadOnServer to false and disable collision on the server.
It does not exists
Should it work for SkeletalMeshes?
it cannot be set in blueprint
I see
also note that this only affects packaging, not runtime.
packaging for a dedicated server will remove the component entirely from content. It does not affect code otherwise creating a component or object, and if you want to avoid creating something in a dedicated server config you will have to change your code to do that.
Yeah, makes sense
Ty, this is exactly what i need
Hi guys I have an issue where when I package my MP project as a development build it works fine and connects over steam using my steam online subsystems plugin but the joypad doesn't work.
So I looked up the issue and people said the joypad will only work if I package the game as a shipping build. So I tried this and the joypad does now work fine but I can no longer connect over steam.
I looked up this issue and it said I must add a file in the binaries folder of my packaged project to remedy this. But it didn't work for me and the directions were a little vague for this fix. Has anyone else encountered this issue and if so could you explain how you fixed it or where you found the fix please?
Hey i have a question. Say if i have a = 0 in my player controller by default, then i set a = 1 on client side, would a = 1 on the same controller but server side?
Client is not replicated to the server, you will need an rpc to do this
Sorry fell asleep. If you are familiar with it and know how to do this I would be willing to pay for your help. Let me know. Feel free to dm.
^ This goes for anyone that would be familiar with how to do this and willing to help out and build a system to handle it. I would be willing to hire and pay for your assistance.
It would still be inefficient even if every client saved the game state. Which client would recreate the session? And what if that client left the game or wants to join another session?
Maybe it's better to use a dedicated server instead, or use the unity engine for this I believe it supports host migration because among us is using that
I have a replicated Int array (ressources the players is gathering) with a length of aprox 200. Changes to it I want to be reflected in the clients UI asap. Changes to it may happen once every other minute or every 0.3 seconds. What would be a reliable efficient way in BP to tell the client to update their UI with the most recent value?
I was thinking instead of replicating the Array, reliable RPCing the changed Index and Value, and adding a delay of ~1.5sec for any following change of the same index. Or just running the whole "gathering" logic on Client and server, but i'm afraid of the values jumping back and forth then.
If you have access to C++, you'd make that Resource Array into a FastArraySerializer
That way you get per element callbacks and overall a more performant setup
If you only have BPs available, you can probably just use the Array as RepNotify and use the OnRep to update your UI
Only BP in this case unfortunately. I kinda hate the idea to having to go through the whole 200 array elements every repnotify, but that would be the best approach for this case?
I don't think you have a lot of options
Reliable RPCs aren't really the way here
If you aren't using C++, you will have to live with whatever BP offers
Multiplayer without C++ is a bad idea. Probably wrote this 100+ times in this channel already to others :P
alright, thanks 😉
maybe you can compare your old array with the received array and retrieve the changed elements?
That still requires to loop the whole array
Only FastArraySerializer would do a delta comparison and do what Maeloth wants
I need to wrap my head around combat in Network scenario. How to find compromise for smooth experience.
The issue that come to my mind is that the Attack by A.I is already initiated before the information can reach the player. So essentially the "real" (Authorative) attack have come ahead before the A.I in client machine visually launch an attack.
For like 100 ms, won't this posses a problem? How can I for instance apply a parry mechanic given the situation?
what all does the client need to be a host?
In the end it doesnt work... it was kinda working but the aim offset was way faster than the camera, so basically when watching up and down it was going too up, not following the camera
By compensating for that delay.
You need an improved net clock, which there is an article pinned about
And then you really just need to work with Timestamps and giving the player some slack
If the AI attacks at Timestamp 1000(ms) and the attack takes 100ms to reach the client, and the client then sees it and presses parry, then the Parry event will reach the Server in Timestamp 1200. You will have to basically open up the parry window by adding the ping/rtt to it.
You'd let the player parry based on its local information, then send the timestamp they parried in to the Server.
If the Server agrees, then that's all fine, if not, then the Client will be corrected by getting damage.
@thin stratus 🗒️
This make perfect sense, thank you!
so.. you cant send maps using an RPC? Just got this error in my CPP code when trying to compile 😦
Error: Maps are not supported in an RPC.
Is it granted
Oh yeah i forgot to grant it, thanks a lot.
Hi, how can i replicate Set View Target with Blend properly? essentially what i want is for any spectating players to also update their view target when the player they're spectating interacts with the draw, ive tried putting the set view target into a multicast event but that didnt work for the spectator either
aren't widgets supposed to not replicate? if I run 2 clients testing by play in editor, it shows up on both
i've tried both a branch that checks player pawn index and created a custom client event. still shows up on both
They don't replicate, you probably just run the create widget on every machine
not sure what player pawn index is
How do I set up 2 local players playing on the same keyboard with their own controllers and pawns? I'm setting them both up like this in my gamemode
if (ACustomController* Player1Controller = Cast<ACustomController>(UGameplayStatics::GetPlayerController(GetWorld(), 0)))
{
UE_LOG(LogTemp, Warning, TEXT("Player 1 controller found"));
AMyPawn* Player1Pawn = GetWorld()->SpawnActor<AMyPawn>(PlayerClass, FVector(-80.0f, 60.0f, 21.0f), Rotation, SpawnInfo);
Player1Controller->InitializePlayer(0);
Player1Controller->Possess(Player1Pawn);
}
if (ACustomController* Player2Controller = Cast<ACustomController>(UGameplayStatics::CreatePlayer(this, 1)))
{
UE_LOG(LogTemp, Warning, TEXT("Player 2 controller created"));
AMyPawn* Player2Pawn = GetWorld()->SpawnActor<AMyPawn>(PlayerClass, FVector(-80.0f, -60.0f, 21.0f), Rotation, SpawnInfo);
Player2Controller->InitializePlayer(1);
Player2Controller->Possess(Player2Pawn);
}
and they use 2 different mapping contexts
lol tf is that? you should not use the same function for ReplicatedUsing
and you need to remove Replicated if you want to use OnReps
afaik the only parameter passed in to the OnRep function is the last value known, right before the replication
if that can help
if you have a OnRep_Notify(var) the var is the last value before being changed by the replication, and you don't pass it.
That's certainly true but what if it's a struct
then my knowledge ends here
same 😔
anyway, there should be caveats for "replicating" the struct, I actually don't know if that can be replicated
for example, in my case, I have a TMap, that can't be replicated, so I use aux variables in order to simulate a replication
yes that's what I told you earlier, you can try that
Yeah I guess you can check if the Old struct is different with the new struct
sound kind of like a pain tho
well maybe because I am clueless
Ahh ok, that should do then
Sorry don't understand the term
my cpp is beginner level
I know operator overload but not sure what you mean with reckless abandon
I'm more confused than before 😄
lmao
ye I told you, with on rep notifies u do this stuff for getting the last known value before getting changed 👌
Can I see how you do the delta?
Like the system you mention that detects if the struct isn't the same
do you just do if SomeStruct.Member1 != NewSomeStruct.Member1 ?
sorry if it doesn't make much sense, really new at this
ty
Hi guys I have an issue where when I package my MP project as a development build it works fine and connects over steam using my steam online subsystems plugin but the joypad doesn't work.
So I looked up the issue and people said the joypad will only work if I package the game as a shipping build. So I tried this and the joypad does now work fine but I can no longer connect over steam.
I looked up this issue and it said I must add a file in the binaries folder of my packaged project to remedy this. But it didn't work for me and the directions were a little vague for this fix. Has anyone else encountered this issue and if so could you explain how you fixed it or where you found the fix please?
I posted this yesterday but it was late would love to know if anyone else has experienced this
Does anyone know how lyra replicates player's camera pitch?
you should not use the same function for ReplicatedUsing
@twin juniper That's not true.
Yeah wasn't sure if you took that advice or not
Also the param in the OnRep should be const&
In case it's not yet
But since it's working, I assume it doesn't matter too much
A client possessed pawn/character is automatically autonomous proxy
Everything else is usually simulated
Not sure about Lyra, but pitch is already replicated via GetBaseAimRotation
You can't change it anyway :D
it's not like you magically change the old value
I think the two main issues are:
- Steam dlls might not be in the Binaries folder
- steam_appid file isn't generated cause it's expected to be downloaded via Steam
oh thanks! I just needed that.
The dlls are somewhere in the ThirdParty folder
C:\Program Files\Epic Games\UE_5.3\Engine\Binaries\ThirdParty\Steamworks\Steamv153\Win64
Something like this
Should be enough to move them to the packaged Binaries folder of your game
Not sure if needed
The Steam app Id file should theoretically be added when downloading from steam
if you aren't doing that, you'd need to manually add it
I'm really not sure why you ask so much about this. Are you controlling that one Character/Pawn directly or are these many pawns that are controlled RTS wise?
If you are controlling the Pawn/Character directly, then you shouldn't have to worry about this.
I think this might be a bit of a rare question, so not sure someone can easily answer that. You also didn#t really post any problems.
So is that Character possessed by your PlayerController or not?
Then it's more like an RTS Character
And then it's more or less what Kaos already told you
You'd need to do quite some changes to get that to be an Autonomous Proxy
Yea I've been trying forever but I can't get more than one controller to work with my keyboard. I'm sure it's the tiniest little mistake somewhere that makes it not work, cus I've searched everywhere but haven't found anything that helps
Depends on if you can live with the delay the player will feel when doing literally anything
The only pro and con is that the Player will either have direct response or will have the ping as a delay to see their actions
I really hate that tmaps dont replicate 😦 just screaming out to the void right now.
Why? Just create a struct that has an identifier in it and use a TArray
Because maps are tidy. I'd rather not have to create a struct with an identifier for every property that could be grouped together in a map
What channel is best to ask people if they want to join in for a playtest?
That makes no sense, you only need an identifier for the element itself, not for each property of that element?
Wouldnt I have to have struct1 struct2 etc.. for each key:value?
Uhh no?
Maybe Im smoking crack then haha.
struct FMyStruct
{
int32 MyStructId
SomeType MyStructData
}
TArray<FMyStruct>
MyStructId would be used to identify the element in the TArray.
You would use that as if it was the "key" in a TMap
I think Im just sleep deprived. I get what you mean. But you still have to loop through an array and check if the struct is the one you want though, right?
Right now I have my gamestate using a struct with int32 to represent resource amounts/store team ID's/store all that in a TArray. Then on the client side I store that info on a map on the gamestate <Resource enum, int32> to be represented in the UI/used for other things. I think my point is that its annoying to workaround when I could just have a map
Is this a good way?
There is nothing stopping you from putting the data back into a TMap after its replicated by the TArray.
The fact remains that TMaps are not replicated (they dont need to be).
And thus you need to find alternatives.
I was only providing you an alternative.
Yeah I gotcha. Thanks
What do you mean? In relation to what exactly?
Prediction is a mechanism you apply to individual things in an attempt to mask the effects of latency.
You as the developer choose what to predict, so your question is extremely broad and difficult to understand exactly what youre looking for in an answer.
My guess is @whole grove's answer isnt what you were hoping for.
AFAIK Overwatch doesnt predict their Grenades. That might be a good example.
Neither does halo reach, but they hide it with a predicted animation.
Which I'd assume overwatch does too
We dont either, we predict the anim yes, but not the projectile.
Its not worth the trouble as Clients dont even notice the difference.
the always relevant video about prediction and the complications thereof https://youtu.be/h47zZrqjgLc
In this 2011 GDC session, Bungie's David Aldridge discusses the programming that drove Halo: Reach's online networking.
Register for GDC: http://ubm.io/2gk5KTU
Join the GDC mailing list: http://www.gdconf.com/subscribe
Follow GDC on Twitter: https://twitter.com/Official_GDC
GDC talks cover a range of developmental topics including game des...
You're not going to find any
not without turning off prediction entirely (for games that allow it)
which would be... very few. Maybe source-based games.
Arent we all
If a lack of prediction feels bad then a game isn't going to ship with it. You're not going to find any games that have shipped that both feel good and avoid using prediction when they should have.
I see little to no code in UBehaviorTreeComponent that requires it be used with an AI controller
I'm not sure it needs to be on a controller at all
Problem with it not being on a controller though, there may be some built-in tasks that expect it to be on a controller. MoveTo does for example.
I was about to mention that some tasks may need updating
but that's not really a big deal
MoveTo isn't hard to copy and fix
most tasks should be fine - luckily a lot of AI stuff deals with components on the controller rather than assuming the type of the controller.
UBrainComponent has the GetAIOwner method, which, maybe that could be a template instead; to use it to return t instead.
You don't need to use that function
that function is just a utility to create a BT component and run it
You can create one yourself.
it also doesn't actually do anything with it. As long as the functionality you write yourself doesn't call it then it doesn't matter
worst part about the MoveTo task is it doesn't even need to be grabbing an ai controller specifically :/
looks like there's exactly one very minor thing specialized for AI controllers
I think it's more for other things to get the aaicontroller instead of using it internally in the brain comp.
Create the BT component. Set it to use a certain blackboard. Add to w/e class you want.
or just look at the source to RunBehaviorTree and copy what it does
it may be defined on AIController but it doesn't do anything that wouldn't work on a player controller.
Aside from already having a BrainComponent property to store the BT component in, but you can make that yourself.
I know that's a complaint Eren has about the AIModule - how much it relies on the AAIController
ye it's dumb, there's very little functionality specific to AIController
lots of things would be simpler and better if they weren't specialized and accepted any kind of AController
I have a public repo with a node compatible with player controller
https://github.com/Vaei/PlayerMoveTo
You are right, there's not much reason it needs to be tied to ai controller
anyone have an idea why as soon as i set up steam integration my demonetdriver stopped getting loaded by the engine :((
theres some sketchy stuff going on inside BaseWebSocketNetDriver.ini? which I assume some steam type extends, so maybe that's why the definition is getting cleared?
I tried to-add it inside DefaultEngine.ini, by copy pasting a line that's already very much in BaseEngine.ini
surprisingly this worked once - right after I packaged it, but after that, it stopped working :(
Hi, One question, I am destroying an actor, but when I test it on the client side, I get an error when I want to destroy it, I think I know the reason and it is because it is destroyed 1 time on the client and 1 time on the server, how do I do that? be destroyed on the server? with a has autorithy?
if (Actor->HasAuthority()) Actor->Destroy();
It doesn't work for me, no one has authority
@torpid whale Destroying a networked Actor on the Server will automatically destroy it on Clients
So when your call to Destroy happens on the Client, the Actor might have already been destroyed automatically.
Thus leading to an access none error (assuming thats whats happening, since you didnt actually specify the error).
If you want the Client to keep the Actor around, but have it destroyed on the Server. Call TearOff first on the Server, then Destroy.
Tear off will cause the Actor channel to be removed without destroying the Clients version of the Actor.
Does anyone know how to make local multiplayer work? Apparently it's been broken for a while because of something to do with the enhanced local sub-system. Tried all the common forum suggestions and no dice
Thanks Devils!
nice pfp
Thx, I animated it in photoshop (kind of a mistake, it has no curve interp)
It didn't work, the actor is only deleted from the server side, but I don't know why after deleting and stopping the execution, it tells me that it is invalid
I'm trying to get local multiplayer working. I've tried manually setting local controller numbers without success, and I've tried adding my own game viewport class but it doesn't seem want to work. Here is the code. Anyone have any ideas?
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameViewportClient.h"
#include "MyGameViewportClient.generated.h"
DECLARE_MULTICAST_DELEGATE_OneParam(FOnInputKeySignature, const FInputKeyEventArgs& /*EventArgs*/);
DECLARE_DELEGATE_RetVal_FourParams(bool, FOverrideInputAxisHandler, FInputKeyEventArgs& /*EventArgs*/, float& /*Delta*/, float& /*DeltaTime*/, int32& /*NumSamples*/);
UCLASS()
class MYPROJECT3_API UMyGameViewportClient : public UGameViewportClient
{
GENERATED_BODY()
public:
virtual bool InputKey(const FInputKeyEventArgs& EventArgs) override;
virtual void RemapControllerInput(FInputKeyEventArgs& InOutKeyEvent) override;
virtual bool InputAxis(FViewport* InViewport, FInputDeviceId InputDevice, FKey Key, float Delta, float DeltaTime, int32 NumSamples = 1, bool bGamepad = false) override;
private:
ULocalPlayer* GetLocalPlayerFromControllerId(int32 ControllerId) const;
/** A broadcast delegate broadcasting from UGameViewportClient::InputKey */
FOnInputKeySignature OnInputKeyEvent;
/** Delegate for overriding input key behavior */
FOverrideInputKeyHandler OnOverrideInputKeyEvent;
/** A broadcast delegate broadcasting from UGameViewportClient::InputAxis */
FOnInputAxisSignature OnInputAxisEvent;
/** Delegate for overriding input axis behavior */
FOverrideInputAxisHandler OnOverrideInputAxisEvent;
#if WITH_EDITOR
/** Delegate called when game viewport client received input key */
FOnGameViewportInputKey GameViewportInputKeyDelegate;
#endif
};
#include "MyGameViewportClient.h"
#include "GameMapsSettings.h"
#include "Engine/Console.h"
#include "Framework/Application/SlateApplication.h"
#include "GameMapsSettings.h"
bool UMyGameViewportClient::InputKey(const FInputKeyEventArgs& InEventArgs)
{
FInputKeyEventArgs EventArgs = InEventArgs;
if (TryToggleFullscreenOnInputKey(EventArgs.Key, EventArgs.Event))
{
UE_LOG(LogTemp, Warning, TEXT("Try toggle full screen on input key success!"));
return true;
}
if (EventArgs.Key == EKeys::LeftMouseButton && EventArgs.Event == EInputEvent::IE_Pressed)
{
UE_LOG(LogTemp, Warning, TEXT("Flash Indicator Success"));
GEngine->SetFlashIndicatorLatencyMarker(GFrameCounter);
}
//if turn on skip setting and using gamepad, increment controllerId
RemapControllerInput(EventArgs);
if (IgnoreInput())
{
UE_LOG(LogTemp, Warning, TEXT("Ignore input"));
return ViewportConsole ? ViewportConsole->InputKey(EventArgs.InputDevice, EventArgs.Key, EventArgs.Event, EventArgs.AmountDepressed, EventArgs.IsGamepad()) : false;
}
OnInputKeyEvent.Broadcast(EventArgs);
#if WITH_EDITOR
// Give debugger commands a chance to process key binding
if (GameViewportInputKeyDelegate.IsBound())
{
if (GameViewportInputKeyDelegate.Execute(EventArgs.Key, FSlateApplication::Get().GetModifierKeys(), EventArgs.Event))
{
UE_LOG(LogTemp, Warning, TEXT("Set up key Debugger"));
return true;
}
}
#endif
// route to subsystems that care
bool bResult = (ViewportConsole ? ViewportConsole->InputKey(EventArgs.InputDevice, EventArgs.Key, EventArgs.Event, EventArgs.AmountDepressed, EventArgs.IsGamepad()) : false);
// Try the override callback, this may modify event args
if (!bResult && OnOverrideInputKeyEvent.IsBound())
{
UE_LOG(LogTemp, Warning, TEXT("Sub-system notified!"));
bResult = OnOverrideInputKeyEvent.Execute(EventArgs);
}
if (!bResult)
{
ULocalPlayer* TargetLocalPlayer = GetLocalPlayerFromControllerId(EventArgs.ControllerId);
if (TargetLocalPlayer && TargetLocalPlayer->PlayerController)
{
bResult = TargetLocalPlayer->PlayerController->InputKey(FInputKeyParams(EventArgs.Key, EventArgs.Event, static_cast<double>(EventArgs.AmountDepressed), EventArgs.IsGamepad(), EventArgs.InputDevice));
}
// A gameviewport is always considered to have responded to a mouse buttons to avoid throttling
if (!bResult && EventArgs.Key.IsMouseButton())
{
bResult = true;
}
}
return bResult;
}
void UMyGameViewportClient::RemapControllerInput(FInputKeyEventArgs& InOutEventArgs)
{
const int32 NumLocalPlayers = World ? World->GetGameInstance()->GetNumLocalPlayers() : 0;
if (NumLocalPlayers > 1 && InOutEventArgs.Key.IsGamepadKey() && GetDefault<UGameMapsSettings>()->bOffsetPlayerGamepadIds)
{
InOutEventArgs.ControllerId++;
}
else if (InOutEventArgs.Viewport->IsPlayInEditorViewport() && InOutEventArgs.Key.IsGamepadKey())
{
GEngine->RemapGamepadControllerIdForPIE(this, InOutEventArgs.ControllerId);
}
}
ULocalPlayer* UMyGameViewportClient::GetLocalPlayerFromControllerId(int32 ControllerId) const
{
if (UGameInstance* MyGameInstance = GetWorld()->GetGameInstance())
{
const TArray<ULocalPlayer*>& MyLocalPlayerArray = MyGameInstance->GetLocalPlayers();
for (ULocalPlayer* const MyLocalPlayer : MyLocalPlayerArray)
{
if (MyLocalPlayer && MyLocalPlayer->GetControllerId() == ControllerId)
{
return MyLocalPlayer;
}
}
}
return nullptr;
}
I threw in some print strings to see if this is even running because I'm not getting any errors and it's set to use this in the project settings but it doesn't seem to wanna work for me.
Please @heavy gorge If you have any ideas
Should I try to be selective about what I do in the OnRep_MyProperty handler, such that it only performs cosmetic things (vfx, abp, sounds, etc)? For example, in my OnRep_CurrentWeapon, I could choose to call weapon->SetInstigator(x) on it, however technically that might only be necessary on the server/owning client? If that makes sense
You can do whatever you like in an OnRep.
Just wondering what is a good separation of concerns. It would be convenient to lump it all in one place
Its a function like any other.
Can you be more specific about what concerns you with OnRep?
I'm trying to get my head around what should happen on the server vs what should be replicated to clients where this actor is purely simulated. Since those clients don't have authority over the actor, I don't think I strictly need to initialise backend variables like "ownercharacter" which would only be used within an HasAuthority check
Though the OnRep function seems like a handy place to kick off all of those backend variable initialisations
So I can just do it in OnRep and at worst it'd waste a couple of CPU cycles on clients that don't have authority, but it would make my code cleaner?
There isnt really a general rule of thumb when it comes to these things to guide you, since a lot of multiplayer networking scenarios are surrounded by huge amounts of differing context that affects the path you might need/want to take.
@twin juniper https://wizardcell.com/unreal/multiplayer-tips-and-tricks/#2-beware-of-getplayerxxx0-static-functions
Hey I just read this again and found out a call back for a struct per member element if we use Fast array
You should be less concerned with bandwidth (within reason) and more concerned with CPU overhead when it comes to the network.
At least from the perspective of the Server.
Right that makes sense. Ok so I will just aim to just keep my code readable. At least things are replicating is the goal!
@dark parcel Fast Arrays are very useful if you want per element notification.
Early optimization can be the devil. Get your thing working first, then take stock of its implementation and how you might improve it with a new iteration.
Each iteration of a system should be faster and more network efficient.
As you gain hindsight from the lessons you learned building the previous iteration.
You run the command on the client side, so on the server the character remain stationary.
You get rubber band because the server keep correcting the location (which is where it stands on the server)
So you are running the command on both server and client, this might seem to work in Pie with no lag but when you add a lag I don't think you will get your desired result (gonna get rubber band again imo)
The CMC sends movement data which will simulate the movement on the server. The server then will check if the move are valid and correct the client if necessary.
I don't know anything about simple move to, maybe it doesn't send the needed FMove data?
It will given the correct function. Like Add movement input should be okay
but yea don't know a lot about this subject maybe someone with experience can give you answer with doing top down movement
If i want a RPC from a client to the server and all other client, i would have to call 2 RPCs, one "Server" from the client to the server and one "Multicast" from the server right?
imo there isn't many instance where you should do multicast
especially for replicating a variable
You just send a Server RPC from client that update the server variable and that's it.
The server will replicate the variable to all client on the next netupdate
That only happen if you mark the variable as replicated right?
The variable needs to be marked as replicated for it to replicate to clients
It's like an auto multicast, i get it now
don't know if that's how it should be viewed 😄
Lets say you have a replicated var called myHealth(float).
If you are the server you just change the value
that's it, it will be replicated to client eventually (How long it reach the client will depend on ping)
Since replication only work from Server to Client,
If you are the client. You will need to run a Server RPC to tell the server, Hey Change myHealth variable
So Player 2 (client) -> send a server RPC -> Server Change My Health
-> All clients will update their MyHealth when the information arrived from server
I'm trying to design some networked melee combos. State machines make sense in my mind to represent flowing sets of moves, but the available plugins do not have client side prediction. So I've been trying to make my own state machine and it occurs to me that this may be misguided task. Making a generically predictive state machine is probably on the same order of difficulty as that abandoned Network Prediction plugin because prediction is not something easily solved generically. Every predictive task requires its own unique implementation, which explains why nobody has been able to put out a plugin yet. It's just too hard. Am I on the right logical path here?
Nice 👍
Hi guys, anyone have experience with implementing 150-300 roaming NPCs in a multiplayer game open world map where they can be visible from afar? Our game kinda require this but im not sure which is the best approach
Kinda looking for battle tested methods, so any reference to GDC or similar talks are much appreciated
Anyone know how to make it so players dont cause physics interactions with each other [my suspected culprit]? My characters can crouch and end up "launching" each other just by walking into someone standing.
Is the level blueprint executed first before all character blueprints?
You can test it with print statements, although if you're spawning characters at a later point then level BP will be called first
However, as far as im aware you shouldn't be using the level BP for multiplayer anyways
Why is that?
Im trying to initialize teams on my gamestate and I keep getting this. I'm calling an RPC on my character to initialize the team but keep getting this. Any advice with regards to this?
Originally I did this in my level blueprint but tried switching it to my character.
LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor WeatherReportGameStateBase_0. Function InitializeTeams will not be processed.
I cant remember the exact reasons off the top of my head, some of the other smarter people in here will be able to give you a better answer but any logic you're trying to run in there is prolly better suited to be done from a different class
Are you trying to assign the player a team?
I'm calling an RPC to initialize resources and teams on the gamestate.
I think I fixed it. I just had to check the authority on the gamestate and now it runs smoothly
Check this before using level blueprint in multiplayer: https://wizardcell.com/unreal/multiplayer-tips-and-tricks/#26-avoid-using-the-level-blueprint
what are you trying to do?
It would "work" but probably not as you intended it. You can't be sure that player index 0 is the one you expect it to be.
it only print 1 person
well, it is working because everytime someone enter, that trigger
but it will only print the same thing
what should i put in the get player character?
you could get the class and if its another player character then do it
instead of getting it from the index
You just want to print the name if you collide with another player character?
what would i do for the player?
I dont know what you're trying to accomplish
Are you trying to print the display name out of player characters you collide with?
to do the action only if its a certain player...
Do you have some sort of identifier for that player? Like a team ID or a name?
yea later, I'll add that
You could check if you collided with a player then use that identifier to determine if its that certain player.
what node i would use to get the players
You're already doing it. That "other actor" is the one you collided with then you have a reference to it
use the function under utilities called GetClass then select your class on the bottom node which would be your player character class
utilities?
Sorry doing multiple things at once rn. You're using the right get class node just delete that stuff on the bottom, get player character and get class
Keep the == and the other get class you have at the top
You're welcome. I think you can figure out the rest from here
yea
Guys Im spawning a replicated actor from server and with a repNotify I get its ID and set it up, the thing is that my actual actor has a widget to show interaction info which is presetted to a specific widget (image1), when I try to cast to that on client it return empty... but still when I go near there it shows it but can't cast and call a function on it to modify its info, why is that?
So you have a RPC you called and then you're using repnotify on the client to get the values you want and set up your actor? And when you try to access the values on that actor after this has occurred you're unable to?
Basically what I do is gamemode spawns items at start game, those items have ID integer variable set to RepNotify, based on that ID i get the info on datatable and set it up (only 1 item to manage all pickups, easier and faster), the thing is that the widget which is already setted to that on the actor seems to be null on client
Hmm Im not sure then. Do you have an event when that rep notify hits the client so you know all that stuff is populated?
Yes, GameMode is server only and that includes all it's properties.
Print the display name of Get Widget
Is it just not being created?
What is max players count and how to change it in ue5 ?
You specify max players when creating a session
its empty, the mesh is correctly updated but the widget is the default so like if actually it is there but not when i call the cast
nono on gamemode i just get the itemspawner from map and spawn the items individually on the start of the game
the only way, even tho seems not clean, to fix that for me was to connect the not valid to create widget and assign it then go back to the cast
It's 16
Found in BaseGame.ini
[/Script/Engine.GameSession]
MaxPlayers=16
You can change it in DefaultGame.ini
[/Script/Engine.GameSession]
MaxPlayers=10
Another way to "change it" while in PIE is via the console command net.MaxPlayersOverride 10 (but this is not a perma change, but just for testing)
does that mean that setting up a session for 4 players could let in more players if that setting is different?
How did you set up a session for 4 players?
If it's via the NumPublicConnections whatever then, it means that the session won't be advertised anymore, but the server can still perceive players, so if a client was able to find that server somehow then yeah they might be able to potentially join
It's always good to stay consistent
How can you increase the value of RELIABLE_BUFFER to prevent disconnects when many RPCs happen in a single frame? Do you need to change it via source or is there a .ini somewhere that changes it? I'd like to never disconnect if possible and would rather drop packets than auto disconnect clients
Oh ok thanks, in that case any way to just increase the reliable buffer limit past 256?
So that clients don't just fully disconnect
Guess you could just modify it and rebuild the engine in NetConnection.h
Thanks, was hoping it'd be an .ini but looks like a source build is needed. Will look into it now 🙂
Or if it's feasible, defer calling your RPCs: https://vorixo.github.io/devtricks/data-stream/
Is it as trivial as simply putting this enum { RELIABLE_BUFFER = 256 }; // Power of 2 >= 1. up to like 4096 ?
In NetConnection.h
Or are there data size limits that would prevent this?
Thanks, I did see this but it goes a bit over my head. If it's possible to just increase the limit in that .h without any issues I'd probably opt for that first
I can't vouch for increasing it, never done that 😛
You can always try and enlighten us xD
Ok thanks. From a general C++ point of view, could enum support values greater than 256?
Will report back if it works
Seems like it's just a regular int as there are values greater in the lines below, should work ok!
So i can set it to like 60?
@grizzled stirrup i have to question, WHY
i have never had reliable buffer overflow
Rare case in PvE game with a lot going on (no limit on player power), would prefer no client disconnects if possible instead of people randomly dropping out
seems like your abusing Reliable
we have tons of rpc's every frame
and never overflowed the reliable buffer
it seems like you have reliable rpc's on tick
which you should never do
I don't, it's more one off events where players might spawn 1000 bombs in a single frame
And each one has a single reliable RPC
normally this never happens
You talking about SteamAdvancedSessions right? Also I've had issues where refreshing session lists, the session popup, but if the session gets destroyed and the user didnt refresh and try to join it just doesnt give error and tries to join, if the old guy creates the session again since it was trying it automatically enters in
but players can push things to extremes after hours of play
this is a design issue not an engine limitation
if its spawning 1000 bombs in a single frame
then you have underlying game issue
It's more for the 1% cases that manage to push the game that far, if I can simply increase the buffer without any consequences then that's great
Most people don't spawn more than say 10 bombs in a frame
have you overflowed the buffer?
Whatever makes sense to you
if they are going to spawn 10 bombs in the same frame (which i highly doubt a player can click 10 times in a frame)
then batch it to a single RPC
instead of 10.
like i said
this is your GAME CODE issue
not an engine issue
I can definitely look into batching but it's a lot of work for an edge case, if increasing the buffer limit would solve it and not have any other negatives (as it seems more of a sensibile limit) then I'm more inclined to fix it that way
increasing the buffer is a scapegoat for bad game design
This bug happens very rarely I'd just like it to be covered
like i said
i have never in 5+ years
overflowed the reliable buffer
and we have a ton of stuff happening in Red Solstice 2
Is there any callback when a AActor is tracked by a network connection? Start/end
what you mean "tracked"
It started to get replicated to that connection
question is, what are you doing (and why do you need it)
cause there maybe another soloution
Most games wouldn't run into it as they have sensible limits to things. For my game, it doesn't limit your power so you can spawn absolutely insane amounts of things with enough loot (bomb that then spawns 3 bombs on exploding that then spawn more things on them exploding etc.) and that's part of the fun. It'd need a rewrite on how things are spawned / designed just for this rare edge case that doesn't affect most players when a single int could be changed instead, must prioritize
There maybe but not at same performance and for free like that
It is so sleep actors when no one can see it
It seems most players have the bandwidth but are running into the RPC limit more often than actually disconnecting for connection reasons
again, this is a game design issue
Keep in mind if you have to increase the buffer you're probably gonna run into other issues
Players with less than perfect networking conditions are not gonna have fun
Any to look out for in particular? Fine with increased latency rather than complete disconnects
what you mean Sleep actors
You're in unexplored territory hah
I don't think anyone else here has increased the buffer
My mmorpg has something like 5000 mobs on server but if players can`t see them they should not tick, etc
Generally you optimize your netcode to stop it from overflowing
EndPlay will be called on client if an actor goes out of relevancy
This affects 1 in 10000 games so it's more to fix a niche bug than being lazy, most players won't ever get near these kinds of disconnects but I'd like to just raise the limits if they do
It is for server not client
yes but what is this to do with networking
Well I'm mainly curious if it's just a sensible limit for most games or an actual reason to be capped at 256. I expect it's also a protection mechanism for bad actors sending too many packets in a frame like cheaters
What is the best way to do that then?
sorry not fully understanding the issue here
Hmmm what exactly are you doing with the RPCs that causes an overflow?
you want to turn stuff off if the actor is not replicating to anyone?
Sensible limit because at a certain point you're basically gonna DDoS players, the server or both
Especially on lower end hardware or bad network conditions
It's akin to playing a game with someone in your household downloading something when you have pretty bad internet
i am not really sure there is such a callback or something for that
There isn't, been looking for something like that.
You have to implement your own logic for that
Just in a simple case, bomb explodes and an RPC is sent with data about the explosion (I could do this via a RepNotify var but it needs to be timely and is gameplay relevant so must be reliable but I do need to investigate a ForceNetUpdate approach instead and it may be optimized enough). Now a player picks up an upgrade that spawns 3 more bombs on explosion and another upgrade that allows their bombs to break off into smaller bombs mid air, and then another upgrade that throws 5 bombs at once. So now the RPC cost is exponentially higher. Now say 5 players all have these upgrades and all happen to throw them at the same instant, this leads to a situation where they all disconnect
I may be able to move back to onrep here though
On closer inspection
If it's reactive enough
ForceNetUpdate is a trap
It resets the replication interval so the engine considers the actor for replication asap - but the engine may still push it back
If you force net update a lot of actors you're basically doing nothing
Ah ok good to know. Well in that case, there's an edge case that allows players to stack so many bombs on one frame that it'll overflow
The engine will consider a lot of actors and decide it's too much at a time and defer some
But I'll see if OnReps without ForceNet is enough to do it
again, this is a design issue
And then can skip the RPC entirely
if you have so many bombs in one frame
then you have bigger issues than just replication
Yeah if it's in a single frame you should pack everything as much as possible
Well it's on purpose to "break" the game, works great in single player and if it's a matter of raising a limit in multiplayer, that's fine?
If it's only cosmetic info consider making it unreliable
Raising the limit is a risk
In most cases it's just a single bomb but this is just an edge case that players may run into if dedicated enough
Opens to malicious actors spamming huge RPCs with the engine accepting them because they fit in the buffer
That's fine in this case, PvE game, they can cheat or spam or whatever
I'd prefer to just not have people disconnect
Until someone actually manages to break it, you should probs ignore it
They do which is why I'm looking into solving it. Rarely but it does happen
like i said, we did this with batching, you dont need to send a single rpc for every bomb
And if they do, there's a ton to do before increasing the buffer is the solution
even if they explode, you dont send a multicast out the same frame
for every bomb
player cant perceieve one frame
split stuff over multiple frames
Yeah batching sounds like your solution here
Is there a way to query the current buffer and then split the RPCs over different frames?
I can definitely look into that, does sound cleaner
no
for example, we have a damage gameplay cue
So I'd need some kind of manager for all stuff that can call RPCs for a connection and then limit them if it breaches a limit?
which is a multicast from Damage Gameplay Effects
we batch all of these (if they match) to the same RPC
Something of the sort yes. That manager can handle batching.
so for like weapon firing, where we fire 5 RPC's, i only fire 1
and i didnt change anything
except put a special FKaosDamageCueScopeBatcher before doing the stuff
See, the only issue I have here is that if simply increasing that int in NetConnection.h would solve this, it takes 5 mins and works. I can completely rewrite my system for this very edge case but it does seem like a lot of work for something that provides very little tangible value if that makes sense
I do like doing things the right way but also time is very valuable
And you have to pick the right battles in terms of what you are working on
but 1000 bombs in a single frame? that is a recpie for disaster
i bet your frametime jumps also
For 1 in 10000 players on one occasoin where they decided to go for the limits
Frame rate does jump
Even with the buffer increase you're gonna have players drop
Not because the engine kicks them but because their pc or router kicks the bucket temporarily
Well I'd say it's worth testing before rewriting the whole system
Executing RPCs also takes time
A small amount of RPCs is probably fine but they do have overhead before you even reach your RPC implementation function
I'd say increasing to 1024 would solve it in pretty much every case
Just have to weigh the work / time for the end result as part of the equation
Up to you in the end, we just give our opinions ^^
I do greatly appreciate it
And thank you for taking the time
Was interesting to learn about it
@meager spade do you think OnSerializeNewActor is good for that?
Edit: I have tried and it works great for me
It is called only first time it serializes (i tried)
But yeah, i need the other way
I will check virtual void OnNetCleanup(class UNetConnection* Connection) {};
Do u have jump,e tc?
Or only walking?
Are u colliding with physics objects?
Are u simulating packet loss? how much?
Hello Guys, i am making a multiplayer game with EOS, my game right now works as p2p, so somebody host the game, and others joins, is a team deathmatch game, and i have a separate backend http api in other language, so when the match finishes the host (the server authoritive) sends a request /match/finished with the stats to the api, basically which users won the match, the backend can update the stats like exp earn, etc, all this is fine, but my concern is, since this is ran from the client side, i dont know if is there a way to doble check this info from the backend, like check if the session is running, who is the host etc, from an api call, or any way to communicate with EOS to get this info, the only way i can think of , of make this more secure, is by just hosting dedicated servers, but i would like the players just host their matches,
any ideas? any experience of working with multiplayer with a separate backend?
Do it works with something like 30ms latency?
Looks like u have wrong movement cod
How do you move your character?
I don`t think it is locally predicted
You need to move on server only
for click to move
This little tutorial is to help people who wants to use ue4 Topdown template on multiplayer, as the base template does not have any code allowing this task
Try this
In blueprints. I'm spawning an actor on the server and passing the playerstate of the client that spawned it. The variable is set to replicate. If my client connects after the actor is spawned, the actor shows up on the client side but the variable isn't replicated, and after a delay it still doesn't replicate. The client should have an actor with the server's playerstate.
Everything works fine if the client connects before actors are spawned.
Okay. The playerstate isn't initialized until after the actor is spawned. Solved-ish.
So was the problem that the reference was correctly replicated, just the actual PlayerState wasn't there yet when you tried to read it?
I'm still debugging but I'll let you know. Thank you.
Yes I think that's right.
Im confused about when the gamestate is replicates to the client. I assume it would be extremely often? I have an onrep method for changing variables on the gamestate.
Would it be redundant to have an event called in the onrep when the gamestate is updated?
Hello @latent heart I discovered Nakama recently and read you are using it. I was wondering do you use it for dedicated servers? and if yes do you use heroiclabs cloud solution or another provider like aws
I have 2 problems with this blueprint. 1. The input doesn't activate on the client; it only activates on the host and doesn't deactivate. 2. Casting to PlayerController returns Cast Failed.
Sounds like you only have 1 problem: the cast is failing
yea but why
Idk, but I helped you cut your problem in half so I am content 🙃 (smarter people might know the answer)
hah thx
Could it be that the player controller is not yet assigned on overlap?
Like is this just after spawning or something
Or rather it’s not possessed by a PC yet
Plug the controller into your cast failed print string.
you mean that?
idk what you mean
Is there any point to use UFUNCTION specifiers BlueprintCosmetic or BlueprintAuthorityOnly if function isn't exposed to blueprints? I believe it's still letting cpp calls to work without issues even if the conditions aren't met, right?
Why does a door care about a player controller?
The player won't own the door anyway so it can't call RPCs through it.
Your whole setup is borked
I'm just starting to learn, and that's what I did, but I'll try to modify it.
Is GameMode guaranteed to exists on the server when a level is loaded and placed actors are loaded?
How can you calculate the size of a struct to make sure it can be sent in a single RPC? (seems to be 64KB limit in NetMaxConstructedPartialBunchSizeBytes which I think I'm well under, but would like to see how much the current struct actually takes up)
great, and I assume that actors placed on level get constructed on the server and then replicated normally on clients right?
I've only ever heard of it once in this chat. Never used it or even looked at it.
It was advertised as a backend to use for Godot users. Because open source and all
They were even a sponsor for Godot for some time (don't know if they still are)
No. They get loaded on client as well, and then they start replicating (actor channel gets created and they get linked)
I see, is there any special consideration when dealing with such actor initialisation? I am rewriting our entity initialisation code because it was a bit complex (used timers to wait for properties to be replicated etc 😅), and want to be aware of any gotchas ahead of time haha
hey guys Im trying to create a multiplayer game on unreal engine, net mode play as Client, so it will have a dedicated server. It works good if I open the level and I can see the other players, but if I need to load a new level, for example going inside a portal or clicking a button, the other players dissapear, lets say each players should belong to each level, and when traveling shouldnt travel all players but only this which triggered it. Okay after this I tried to use command servertravel without success, and set up travel map with gamemode seamless travel without success, I've tried many tutorials
Most of the gotchas I'm seeing these days are coming from net startup actors (replicated placed in level actors). Don't rely on BeginPlay being the function where your PODs will be replicated and ready. Usually they will replicate much much after BeginPlay was called. Also if you are using level streaming, then you might come upon a very rare issue where these net startup actors get destroyed on clients if you stream out and in levels real quick.
Rider will just tell you
I see, is there any special consideration when dealing with such actor initialisation? I am rewriting our entity initialisation code because it was a bit complex (used timers to wait for properties to be replicated etc 😅), and want to be aware of any gotchas ahead of time haha
Wh...why did you reply to the same comment with the same reply Max? 🤣
hey guys regarding to my question before, I have 2 levels on my project, when I try to open a new level, or come back to previous level, its like I lost the connection with the server, cant see the players anymore, it seems it creates a new instance of the level and thats not what I want to achieve
You mean that when the Server transitions to a different level, you and all Clients get disconnected from the Server?
No, I dont get disconnected neither the clients, they are still connected, the problem is I cant reach the same level the other player is connected, it seems the unreal creates a new instance of the level
I see, is there any special consideration when dealing with such actor initialisation? I am rewriting our entity initialisation code because it was a bit complex (used timers to wait for properties to be replicated etc 😅), and want to be aware of any gotchas ahead of time haha
Dude stop spamming this message.
Youre not making much sense with this, can you explain in a little more detail?
My bad, sorry for the ping, I misunderstood
Well, better to understand the result I want to achieve > having a level which a player can connect, and will be able to see everybody who is already there connected, so this level will be always running on the server. Then when the player travels to different level or come back to previous, is possible to see who is in the previous or next level
? It's the first time I ask that question that I am aware of
No intention to span whatsoever
Its not
This sounds like you want to move between Servers that are running different levels?
yes but not all players just the player who triggered
I think Max's discord is actin' all funky
Damn, I am sorry. I am in a train travel and got intermittent internet
I mean, it's cool, if you have a question, just ask it. Somebod will be able to help...
Maybe he just wanted to be really sure that WizardCell read his reply 🤣
I cannot see the duplicated messages, so didn't realize. Feel free to delete one of them if necessary
Yeah well you have to Hard Travel between Servers. Just simply opening a level doesnt make you connect to a Server.
Is it possible to hard travel in the editor standalone playing mode ?
or I have to be packing and cooking stuff ?
Depends on what version of the Engine you are on, as I think UE5 supports Seamless Travel in PIE now.
I'm really interested in someone's experience with Nakama, seems like the combo DigitalOcean + Nakama could be a great way to build matchmaking/dedicated server easily for a very good price
But generally speaking you shouldnt be using the Editor to connect to Servers in PIE.
should be able to do it without any problem, from going from map to map or connecting to servers
yes Im trying to achieve a seamless or hard travel at least, but without any success
with console node or open level nothing works
I got similar issue in the past, it was my ipnetdrive that was nulled or something like this
check that netdriver are configured correctly in DefaultEngine.ini
have you tried in a blank new project first?
yes I just created a new project
having the same issue
Im doing something wrong still didnt figure what
OpenLevel should work perfectly fine when yo play in editor
related to column client
is this saying to me that if the instance (say a character) is the server, then the code is executed on the server, but if the instance is the client, the code is executed on client side of that particular instance?
so a settings maybe
If you run an RPC from the server instance, it shows you where it will run, depending of:
the type of RPC for each column
Type of actor ownerships for each row
the column client means you call RunOnOwning client type of RPC, so if from server you call that RPC, it will run only on the owning client
it says if the actor is owned by the server, the code is ran on the server
eg: if clientA is the owner of a specific character, the RPC logic will only run for that client
yes because the RPC RunOnOwningClient needs the actor to actually have an owning client, if it dont it will simply run like a normal event
its used when you want to target a specific client only from the server
so if the owning actor has the authority ( server ) the code is executed on the server, but if the owning actor is just a simple client (doesn't have authority) the code is executed on client-end ?
imagine the clientA just make a kill, you want to show the UI that shows who you killed, server send the RPC with the killed player with his username as argument, so you can display "You killed XXX"
yes that's clear
the doubt came in my mind when I realised that this client RPC (invoked from the server) is also executed on the server
that's why I went to the docs and checked it out
should only fire on the owning client, unless it has no owner or server is owner
but the doc says if "server owned actor" -> runs on server
so if I invoke a Client RPC server side, I get that code executed aswell on my server side
I mean, that's correct as intended
that's why I said should only run on the owning client, UNLESS it has no owner or server is owner
then it runs on server
like a normal event
"UNLESS it has no owner or server is owner"
I'm not understanding this, can you elaborate further if you dont mind
this should be the expected behavior, because this is the reason why you call that RPC
are we talking about a specific actor?
this if the actor is owned by a client, and that's alright, it means that every actor instance on server side that are owned by a client will get the code executed on their end, right?
imagine a replicated actor, it has a synchronized copy on:
Server
Every other client
one of the clients is the owner, the local client from that client's perspective
so it will run only for that specific targeted client
if I shouldnt be using the Editor, the standalone counts as Editor ?
yes I get it
it's all clear, only needed to talk about it in depth
thank you mate
sure no worry
its a matter of time before it becomes obvious
just need to get use to think in terms of server, clients, local client and how code should run differently in all those cases
i learnt RPCs using blueprint, it's very visual it helped a lot
yes, that's what I'm doing while following a course
yea? might take a look into it aswell, I'm doing c++ side
could help yeah, easier to navigate
you can be less overwhelmed when you have many new concepts to learn
will keep it in mind
@round yew is not necessary to join or create session maybe that is the problem ?
Any easy way in VS even juust to log?
Generally it's at runtime
And there are arrays so the size varies wildly
Well someone just deleted a question but I’m guessing the answer is that input is not replicated, only effect
not sure what you're referring to but yes input is not replicated
if you were to like get the controller and try to receive any type of inputs it wouldn't be replicated anyway
I think they meant the movement input on the character movement controller. Like not the controller stuff but the cached store of movement input
But I think the answer is the same
oh, yeah it is. the cmc does it's own replication stuff if you have replicates movement to true. but otherwise the answer is the same
It should return false on client side
AI are locally controlled by the Server.
There is also a function IsPlayerControlled which should help you identify the difference as well.
I have this AI mob spawned on game map and i`m using ReplicationGraph Grid system.
The grid is working for my Players but nor for this AI (never removing it from Map).
I think it is spawned by default on client also somehow. Is there a way to spawn only on server and make replication graph also work for him?
This is what is happening
Both pawns are using same class but has a different Controller (one of them is using AIController)
Is using a Respawn and instantiaing it only on server the best way?
Ive been reading old posts about Splines not replicating, is this still the case?
Is the best way around still arrays of points?
How does ABP worked in replication? Does it worked just like PlayerPawn, where there is a different version on the client and on the server? What if i store a = 1 on the client, and then change a = 2, what would it be like in the server?
Guys, how did you learn how to do multiplayer in unreal ?
Idk about u, but i don't :))
This stuff is so undocumented i'm just shooting in the dark
I learned it the hard way and then I wrote the pinned Compendium so the basics are easier to learn.
After that you are on your own more or less
ABP aren't replicated. Their instances are local only. You need to drive replication through the pawn.
So does that mean each machine only have 1 ABP even though the game have 100 players?
No
Anim Blueprints are per SkeletalMeshComponnet (if the Component is set to use ABP instead of single Assets).
But those AnimBluperints have no replication, they are just instanced locally
I read it some time ago, but I think I will read it again. Could you answer this question I have that I discussed with Zino more than 2 years ago, and tell me if I'm correct or he's correct please ? 😄 #multiplayer message
Replicated Variables are synced when someone joins late.
If you need a callback for the data reaching the Client, you can mark them as RepNotify in addition to the Replicated part.
Then you get an OnRep_VariableName that calls with the newest value
What doesn't "sync" are RPCs, cause they only call in the moment, Someone who joins later won't receive older, already fired RPCs.
Yeah that's what I understood, but after understanding that, somehow to me everything I'm thinking about have to be done through RepNotifies and not RPCs, so I'm now confused on what's the purpose of Multicasts and RPCs 🤔
RepNotifies are for STATE
RPCs are for ONE TIME ACTIONS
yeah I know but I can't think of One Time Actions (examples) 😄
If you want to tell the Client to do something, then an RPC is used.
If the color of a Character changes, RepNotify is used.
Hm, an exmaple could be an exploding barrel, if assumed to be fully server authoritative .
Oh true, because using RepNotify for this will make the animation of the explosion play again when a user enters the relevancy range
Do you got an example or something to differentiate ABP and Pawn replication behavior? I tried to test but in ABP we have no node "Has Authority" so idk how to test.
Its Health could change the material over time, this is a State, needing a RepNotify.
When it explodes, you might want to set a bExploded boolean with a RepNotify so that you can change the Mesh and turn a little Fire on inside of it.
But the explosion itself only happens once and only for the people around it, so here you could use an RPC to trigger the explosion.
AnimBlueprints aren't replicated. There is no connection between any of the Instances.
Your replicated Character exists on every Player and is connected via a NetGUID.
The AnimBP that each of those copies has is not replicated and not connected.
You can't replicate stuff in it.
Oh so I have to use both RPC + RepNotify, like RPC for the explosion and RepNotify for the new VFX of the barrel ? I thought usually VFX and SFX are used through RPC and not RepNotify to prevent the repetition of the SFX and VFX 🤔
RPC and RepNotify have nothing to do with FX
Like, that's not the thing you use to decide which of the two to use
I'm not sure to understand 🤔
The point is State vs non-State
Yeah
State is persistent. New players or people who come late should still see that the state changed
The Barrel being broken with fire on it is a State
The Explosion is not
So the first goes via OnRep, the second via RPC
Oh yeah I see
That's a simplified example of course.
makes sense
yup thanks.
I think you should do a video tutorial about that could help alot of people, because alot of youtube tutorials usually use RPC for states thing too
and they don't think about people joining later
And I can't blame them
They think they know what they do cause it works for them
And then they take the time to share it
And that's noble
But also spreads the false info like sh*t
Yeah that's what most people say but the issue is, people understanding subjects in depth don't make tutorials to help people learn from them 😄
Even Epic Games own Lobby Tutorial is the biggest crap out there
How's that possible ?
That's cause I work 40 hours on clients every week, then have to also handle internal stuff for my company and then somewhere hope to have a private life in between the free time Discord stuff I do
And that's the same (minus the company stuff) for a lot of people
The people who get good have a lot of work to do and not the freedome to just write some articles anymore
I wouldn't have the time to write the compendium again today
No clue. The people who made it had limited Multiplayer knowledge
mhhh, what if you get hired / paid by Epic Games to do good tutorials / blogs / documentation for it, would you accept ?
As a contractor, if the payment is right, maybe.
But that exists/existed already
Ouuhh maybe you can ask them, or open a donation paypal / tipee, etc... and when a certain amount is reached to help you cover all your financial needs (let's say for months), you can start that to help thousands of people learing multiplayer properly ? 👀
Na, probably something like paid seminars in the future or something like that.
Epic already hired community folks to help with the docs and write stuff for their training page. There are a lot of tutorials on their tut page by now since they opened up that learning platform
Not sure if all of those are still there after epic yeeted so many employees
paid seminars won't help the whole community and it's for a specific period of time 😦
Or wait, Epic Games provide MegaGrants for people contributing to the community, maybe you can get finances like that ? 😮
Buddy, trust me, that doesn't pay the bills
I wish there is some millionaire just donate to BRY rn 😂
Either way, that's going pretty off-topic by now. Let's keep room for peeps that need help with #multiplayer
😭 But it goes between 5k to 250k, and something like teaching multiplayer properly to the whole community deserves at least 50k 🤷♂️
Ahhaaha I learned alot with him 😄 But he doesn't want to do the last part of the tutorial series on multiplayer 😭
I mean there is only a few amount of people learning multiplayer out there, most just learn casual things. That's why teaching multiplayer is not worth it.
I disagree 👀
Damn we can't create threads in this channel 😦
Not sure I would agree with either, cause neither of you have actual numbers on that
There are a lot of companies that internally do multiplayer, that learn from my compendium
Which you will never hear of
True, but what's for sure is that there will be always new people who wants to do games and at some point they need to learn skills to do multiplayer
yeah
no it's not necessary to use the sessions
try to see if you don't have any errors in the console when you try to use the node
can you show a screenshot of how use the node as well?
so I was figuring out some concepts, in my case I have 1 client and 1 server (2 characters total), I put a simple print on screen in the begin play, and I get
Client: BeginPlay
Client: BeginPlay
Server: BeginPlay
Server: BeginPlay
so this means that for every viewport (client/window, whatever) I print twice, since in each viewport I have 2 actor instances, now, in the begin play I tried to send a Server RPC, in the Server RPC I simply print based on authority, if has auth print server otherwise print client. All I get is 3 logs, I don't understand why 3 and not 4, the RPC is supposed to be fired from every actor instance no?
Because the Clients don't have authority to call an RPC on something they don't own, so it's not sent. If it does manage to get sent, the server will ignore it
what are you referring to when you say "something they don't own"?
ok nvm, I connected the points, it's 3 because it's for the 2 instances on the server (one owned by server and the other owned by client) and 1 from the client (owned by invoking client)
Yeah, the 'Owning' client can call the RPC on it's character, but not any other character
yea it's all clear, thanks 🙂
Hey ya all 🙂
I have my ThirdPersonCharacter thats shooting at another player and invoking:
{
HitCharacter->TakeDamage(WeaponInstance->Damage, FDamageEvent(), GetController(), Cast<AActor>(WeaponInstance));
}```
So far, so good, - that works.
Now when my TakeDamage realises, that the player died it invokes a method on my GameMode `GetWorld()->GetAuthGameMode<ADefaultGameMode>()->PlayerKill(GetController(), EventInstigator, DamageCauser);`
This than invokes a method on the GameState, setting all the kills in a struct:
```if (GetLocalRole() == ROLE_Authority)
{
FPlayerKill PlayerKill;
PlayerKill.Victim = Victim;
PlayerKill.Killer = Enemy;
PlayerKill.Weapon = Weapon;
PlayersKilled.Add(PlayerKill);
OnRep_PlayersKilledUpdated();
}```
Now, after replicating the Killfeed variable, my Killer entry on that struct is somehow empty. It works on the player that kills the other player, but the killed one does not get the killer.
I think it has something todo with me using GetController() to reference the killer - but I have no clue whats really going on there as any steps before have the Killer filled as predicted
PlayerControllers only exist on the server, and for their owning client
Players will not have access to the controllers of other players but themselves
In this scenario, you probably wanna reference the player state of the killer
same for the victim
But isnt the player state only present on the player itself? Right now in my Game instance etc. I reference by the AController - that does work as I would expect it.
Nope - player states are available to every player
Ah ok, I thought I read somewhere that the GameState is available for everyone but the player just for that one player
Nah
GameState and PlayerState exist for everyone
GameMode on the server only, and PlayerController on the server & owning client only
Ah ok, that explains it than. Thank you A lot!
this might help btw
This compendium is meant to give you a good start into multiplayer programming for Unreal Engine.
How do i use console command when play using "New Editor Window"?
I want to use slomo.
try this
I wrote "slomo 0.1" and works for all windows
oh i got it, i didnt click on the window thats why
thanks
Is it possible to say the same about ShooterGame and Lyra?
I'm still looking for a confirmation for this
I didn't realise it was you, good job 🙂
Does anyone else have that strange behavior, that when you fresh start the UE Editor and imidiatly start with 2 players it just freezes with no output whatsoever? Even when I'm debugging in Rider I get nothing at all
Does server and client have a delay when testing on the same machine?
If there is, how long is it approximately? Like 0.1s, 0.2s?
Sometimes, partially, sure. But so is any other over-engineered project. They are good examples though.
Probably not much. Few ms
.2 would be 200ms. Which is across the ocean
Ok guys i actually figure it out after 5 mins posting here (worked on it for like 5 hours straight). Damn posting here is like a mass buff of luck or something.
Turned out the attack animation is the only one with Root motion enable so it worked, the other don't. I still don't understand but it is what it is.
it happens to me aswell and then I think I'm fucking dumb 😭
Any idea why on my animation it doesnt update the variables on client? I set them to replicate since the server only have the controller of the ai... the is following is a basic one on AIController and works on server
I'm using a transition map and I set it inside the Project Settings and also made sure that bUseSeamlessTravel is set to true, but if I try to load a level, it doesn't actually use that map (with ServerTravel), but all I get is a freeze for 2/3 seconds and then the loaded map
Clients don't get any controller replicated except their own. It means that your IsValid fails client-side. If you need any AI related data to be present both server and client sides, make use of the pawn or character (whatever you're using for your AI) properties to store and replicate that data.
fixed, I forgot I switched the GameMode in the world settings to the default one
You should drive your animation by state within the pawn, and also those replicated bools are doing nothing.
hello c++ developer here
making an enquiry on best practice to implement a voice chat...am using a plugin and can seem to get it working ,it stated if seamless travel is used ll controllers should be gotteen and each voice chat actor should be spawn for each controller did that anf notihing
any one with experience on this plugin?
I'm getting a nullptr from
UGameplayStatics::GetPlayerController(this, 0);
Does the client potentially start receiving actors before it even has a playercontroller? 
@lucid badger I've experienced problems in the past with Pawns not having all their controller info initialized on the first frame. Most people seem to get around this by putting all their player-controller logic behind a timer with a small delay, which gives everything a chance to initialize before getting/setting player controller data.
Your player controller should always exist on the client whenever a game begins, but the possession of pawns happens on the server, and that takes time to replicate over to clients.
For some reason the 1-frame-delay strategy gives me the heebie jeebies. But I can just have the two parts check for the presence of the other, so that whichever one arrives last executes the init code
Ahh that makes sense
hey guys, I have an issue I cannot seem to resolve
My game uses a single topdown camera, like Overcooked, so I want when players join to use that camera. Initially when I tried that, the Server was working fine (the camera is set to Auto Activate for Player 0), but all the other actors would spawn a camera (I think?) inside the Character (like the image).
So I found out this function in GameMode: HandleStartingNewPlayer_Implementation(APlayerController* NewPlayer), that I used then to do:
if (SharedCameraActor) { NewPlayer->SetViewTarget(SharedCameraActor); }
with SharedCameraActor being the only camera that I get in the level during InitGameState() and that made the rest of the players use the camera(I also do this on each controller bAutoManageActiveCameraTarget = false;). The issue is that right now, when the game starts and a Client joins, at first they spawn at 0,0,0 location without a character or anything, and then they start using that camera. And I do not know when this actually happens. I made a long delay of 10 seconds in the GameMode, so that each Client has time to start using the camera, but I would like a more controlled approach, so that either they immediately use that camera, or there's a way to let me know when they start using that camera, so I can start the game then(rather than an arbitrary timer). I don't know if anyone has experience with that type of game.
when activating/ deactiviing say a niagara particle FX component* in multiplayer, would you need to activate and deactive on the server? this would only be for visual effects but not sure if it would work doing a multicast or anything like that to show/hide it w a activate/deactive
Do you use a loading screen? You could do posses player pawn -> pawn on possesion -> posses shared Camera on GameMode::PostLogin - hide the loading screen after the camera possession
in short, do components need to be activated on server? and then visibility can be set to visible or sometihng?
Sorry, can you explain a bit more?
This is how i'm doing it
So you could make a call newPlayer->SetViewport(YourSharedCamera) after possesing the pawn
However, this will probably not fix your issue of the static screen, especially in debug. But this should be fine in test / shipping.
I have the same issue of this limbo camera view when joining while being in debug, but it's fine in test and shipping
Not saying its the correct way though, but this works for me 😂
Well, I think currently when the amount of players needed to join, I change the MatchState to InProgress, which automatically spawns the Characters and the controller possess them. I think you are doing the spawning of the character manually?
Hello I'm facing a weird behaviour is someone can help me ?
I'm using a gamemode that inherit from gamemodebase --> my field begin played are rightly fired on both clients and server
but if i am using gamemode parent class, this event is only fired on server. Any idea of why ?
Any recommendations for an in-game chat SDK on a dedicated server? Or does Unreal have something out of the box that would scale well with user count?
Ah okay, yeah i'm not making use of the waitforplayers / InProgress server state. Else you could just keep it in Progress when the first player joins and do you own waiting logic
That still might not solve the actual issue. The thing is that I am wondering if there's a way to get a callback when a new player has possessed a camera.
I am wondering if using an Interface with the Camera in the game would help with something like that. So that when the player possesses the camera, I get a notification
Game mode doesn't exist on client somehow was it firing on both?
i mean, field is an actor that is replicated on clients. So il should call begin play on both clien and server right ?
What's that got to do with the game mode then? What is the actual problem?
One thing to note tho, you need to match your game mode and game state
Both need to be base or not. Can't mix gamemodebase and GameState or gamemode and gamestatebase
when im using gamemodebase class client side event of field is properly called but not when im using gamemode class
I have a loading screen system in place. The loading screen will only be removed once the clients posses the pawn. Called via Aplayercontroller::acknowledgepossesion
Using delay is not really a fix imo
Do bAllowPhysicsRotationDuringAnimRootMotion works on multiplayer games? can it breaks simulated proxies movement?
How is the rotation computed for simulated proxies? during root motion
Replication Consistency:
Enabling physics rotation during root motion can introduce subtle variations in character rotation across clients due to physics calculations not being fully deterministic.
This might lead to visual inconsistencies, especially with fast movements or complex animations.
Is that true?
Simulated proxies are rubberbanding but not the player itself or server character
bAllowPhysicsRotationDuringAnimRootMotion is always true
Are not rotations replicated directly to simulated proxies at any tick?
Or will it compute its own rotation using ComputeOrientToMovementRotation?
But do you use Matchstates? Because I guess that's where one of my issues comes from that currently I switch the match state to InProgress when the required players join, and that state spawns all the characters, so it's a bit late.
Or I guess maybe I can try switching the match state to InProgress, the players will spawn, the possession will happen and then the actual match can begin 🤔
Okey i found why, when using game mode you should use player state and not base one
I didnt touch match states and just simply keep the loading screen on the viewport until the player have valid pawn
You can call your set view target with blend there too i suppose?
The match can begin when all players connect and ready
if (GetMesh()->GetAnimInstance() && GetLocalRole() == ROLE_SimulatedProxy)
{
GetMesh()->GetAnimInstance()->SetRootMotionMode(ERootMotionMode::Type::IgnoreRootMotion);
}
This fixes my issues
if (GetMesh()->GetAnimInstance() && GetLocalRole() == ROLE_SimulatedProxy)
{
GetMesh()->GetAnimInstance()->SetRootMotionMode(ERootMotionMode::Type::IgnoreRootMotion);
}
else
{
GetMesh()->GetAnimInstance()->SetRootMotionMode(ERootMotionMode::Type::RootMotionFromMontagesOnly);
}
Final fix is this is weird why it is not the default behaviour
What's the concept behind Absolute when in the Open Level call? I see in the code it mentions whether it selects TRAVEL_Absolute or TRAVEL_Relative based url.
In a video by Epic the host mentioned that you should always set it to true, though didn't give much of a reason why outside of efficiency.
However in my experience it breaks seamless travel in a multiplayer game.
Is seamless travel a time when you shouldn't be using this?
does anyone have any advice for this
currently have it set up to sync based on the time between the first client and second clients shooting time
yeah, but having a valid pawn happens during InProgress is what I am saying I guess. Because currently I have MatchWaitingToStart and when players reach 2 numbers, it goes to InProgress, the pawns spawn and the game runs. So it does need to go to InProgress, I just need to delay the actual players being able to start playing when the pawns spawn and are a valid. So I will try what you suggested with Aplayercontroller::acknowledgepossesion and see if that works
Thanks!
What class is your game state?
Hi!
Does anyone know if it's possible to turn on/off replication of some properties?
I have some properties that are only used on server side for stat calculation, but when the player opens some UI, i want him to be able to see those properties at their updated value, and when they close the UI stop replicating to save bandwith
DOREPLIFETIME_CONDITION( AActor, ReplicatedMovement, COND_Custom);
thanks!
anyone?
how can i send rpc to server from ui
i know widgets only exist on the client
But do I always have to create all the RPCs that I want to run on the server within the player class? How do I proceed when I want to make changes to an actor belonging to the server via the UI?
Use a controller to interface between. The server sees the controller, the controller is connected on the client to the UI.
thanks for reply bro. For example, I want to run a function in an actor belonging to the server from the client side.Do I need to define RPC within the character class?
because my interaction RPC works fine this way.
I have an actor called Generator, by interacting with this actor I affect another actor on the server. Example: Turn on the lights, but I cannot do this through the generator's UI. Is it right to write RPC in the Player class for a function belonging to the generator?
Or I want to increase the value of an actor on the server side via the UI, do I have to make this dependent on the player class?
I wrote too much sorry about that
Sorry, I'm distracted by trying to fix another bug so my brain isn't cleanly thinking of a response. I don't have any reference code to hand that I can step through to replicate the setup of having one actor communicate through to another synced.
Actually, if I have to explain what I want simply: I open a widget with the client player, I click a button on this widget, and the value in an actor on the server side increases.
Do I need to send all RPCs from the player class? I want to understand the logic of this?
Any replicated value must be changed server-side. To achieve that being client-side you would need to send a server RPC doing the change you want. In your case all you need to do is increase the integer by one. The value then will be replicated back to the client.
Let's say I will increase this integer with a function in an actor class named X.Everything is working fine on the server side, the value increases, it is replicated, and the client sees the increase. note: we increase this value with a button on the widget.But what should I do if I want to increase this value from the client side when I press the button with the widget?
To achieve that being client-side you would need to send a server RPC doing the change you want. In your case all you need to do is increase the integer by one. The value then will be replicated back to the client.
Create a server RPC in your player controller, and call anytime you press that button.
Tanks for reply Tony. Let's say I have 500 different actors. Do I need to write 500 special rpcs in the player class.
Wouldn't all actors depend on the player class?
What do you mean? Do you mean 500 different instances of a certain actor or 500 totally different actors? Also do you mean "character" or "pawn"? If so, as long as you're using the same player controller for your character it's going to be the very same RPC
500 totally different actors
All right. Is it just an actor that is unrelated to the player? Like a wall or anything really
For example, we have a generator class, that is, it is an actor, that is, it inherits from the actor class and is physically present at the level map. and I created a special widget for this generator actor and I run the functions in the generator class through this widget.Let's say I have another phone actor and I have a special phone widget for it, and I run a function within the phone actor with this phone widget.In order to run these functions within each actor's widget, do I need to define an RPC in the Player class and then call these RPCs from the widgets?
If you need to do anything server related with the generator or the phone then yeah, you do need to create a server RPC that you'd call by pressing the button. Maybe I'm getting you a bit wrong, but as I understand the generator and the phone are totally different actors, and they do not share any common functionality
Yeah, you would need to create an RPC for OpenLight, OpenDoor, CallSomeone, PhoneLight (?) separately. One thing that I forgot to mention is that the RPC has to take the object you're interacting with.
Depending on the design you might bring all these objects under one single interface called Interactable or something, which under the hood would do a specific action -- OpenLight, OpenDoor etc. In that case you would need one single RPC instead of N, where N is the amount of available interactions.
There are different approach to that, and you might want to go one way or another depending on your particular project.
Thank your effort Tony . Thank you very much. As far as I understand, SOLID principles cannot be applied in multiplayer.
setting net mode to "play as client" and moving a replicated actor in the editor moves it on the other client too, shouldnt this not happen since neither are the server?
net mode stuff is so janky to me
I have flashlights as separate actors in my game, they turn on and off when the player left clicks however the issue I'm having it responds to ANY player left clicking even if they aren't holding anything or they are holding a different flashlight, can somebody please help
It depends on how you setup them. Most likely you somehow made the flashlights listen the inputs rather than making the player that holds the flashlight to turn it on/off.
Most likely that's related to the PIE. You wouldn't be able to do something like that in a packaged game.
Sometimes gamedev is not a place for academic approaches 😛
Hey everyone, I have a bit of a common issue and I'm looking for some best practices:
I have a multiplayer game where my clients are using AddForce or AddImpulse to fight gravity and hover like a helicopter / jetpack. I'm getting some awkward server-client correction jitters that I just can't seem to smooth out.
I have a server RPC (that works) which is making the jetpack "thruster" fire an addforce (or addimpulse depending on what I am testing). I figured if the server is the one handling the RPC call, the client should just assume the position through replication.. but the jitter says otherwise. The force being applied is calculated correctly neutral hover
Any recommendations would be helpful. Hope I explained my issue well.
wtf happened?
Look for the plugin Smooth Sync, fixes most jittering issues for multiplayer, and it's pretty cheap
Cool I'll give it a shot, thank you. A small fee is worth a fix like this
Just checked it out, looks promising
I use it myself a lot. It's a literal 2 click setup. It's honestly like magic
Hello, is there a secret UE function I can call for reliable/unreliable RPC's from Server to Simulated Proxy? Before somebody suggests just doing multicast and then adding a gate for sim proxies only, I'm not asking for design help. Mainly asking for this one specific thing if anybody knows of it
What do you mean only to Simulated Proxies?
Do you mean you only want to send an RPC to a specific connection?
Yeah pretty much haha but all Simulated Proxies of an actor, and it is coming from the Server
That doesnt make sense, all Actors (except NetOwningConnection Actors) will be Simulated Proxies
What part doesn't make sense? There's a multicast that includes the owning client connection... why shouldn't there be an option to just not send it to that connection?
Unless Im missing something and need to dig into the net driver stuff more?
Your usage of the Term Simulated Proxies in this context isnt making sense from what you are asking to achieve.
If you want an RPC only to a single connection, you must send it via the PlayerController.
The PlayerController embodies the actual connection to a single Client
So if you want an RPC to all other Clients, except one, you need to send an RPC to each PlayerController except the one you dont want.
Yes Im aware of that, and I would be calling this on an actor that has an owning client connection that is connected to the player controller
That doesn't seem optimial to what Im talking about because that means I have to make an dummy owning client RPC function on the player controller so when the RPC is received on the remote machine, it then finds the actor and then calls the function locally which is a lot of boilerplate for one function
Well out of the box thats your only option.
gonna keep investigating... because there's no way I cant just push my own packet across to the remote machine's and do it the same way that normal multicast does it while skipping the owning client connection...
Like I totally understand if its requiring more lower level engine calls and stuff that would scare most people but still...
@magic helm Look into UNetDriver::ProcessRemoteFunction
The unfortunate reality is that an Actor making an RPC must have a NetOwningConnection owner.
Yeah no this is actually perfect, thank you! I can strip it for parts to do what I need to 
So far works 10/10 wow thank you I spent hours today tinkering
worth every penny and more
I see it is causing a bit of goofiness in my other replicated pieces but I'll dig my way out of those holes
I have actors to represent items that have been dropped on the ground. I've got everything working in MP except this last quirk:
ItemActors that are loaded with the map are not replicating position even though they are replicating properties 
Meanwhile ItemActors that are spawned later replicate both 
Is there something unique you have to do for actors that load with the map to sync movement correctly? 
Spawned later meaning, if you drop an item from your inventory, the actor that is spawned by code replicates properly
Yeah hmm, if I put them in the air a bit, server loads, items fall to ground, then client loads in and items start in the air still 
@lucid badger Are those items set to Replicate at all?
Is bNetLoadOnClient set to true?
The ones that spawn after map loads all sync fully
Probably not what's that 🙂
Will try 
It should be enabled by default
So unless you specifically disabled it its probably fine
Yeah it's true
So if I load in and drop an item before the client joins, THAT actor will also sync correctly
It seems to be specifically that the map-loaded ones are desyncing movement somehow 
Desyncing in that they dont do anything on the Client?
But the Server sees them working fine?
Positions don't match
All other behavior is normal
They carry a Guid value that replicates, and that is working even when movement isn't
ONLY position is desyncing 
Do they start out at the correct position?
No, they start in their 'original' positions as defined in the map
Thats what I mean
Err, what I mean is, I have 4 items all spawn on top of each other midair so they scatter a bit with collision. When server loads, they fall to the ground, and when client loads, they are in teh air again and fall differently
Yeah well thats just because Physics in UE is not deterministic
And I can pick them up and tehn if I drop again (which spawns a new actor) that will be working perfectly
Is the item "mesh" the root component?
Meaning you will get different results from Physics interactions on Client and Server for the same Actor
But I thought replicate movement meant the position would just always be matched 
How high is your NetUpdateFrequency?
Okay so that's why I was getting confused. It APPEARED that the ones dropped after were syncing but they just aren't being subjected to something as random as spawning 1:1 with other colliders and pushing out
NONE are syncing position
On the ITemActor it's just default
It just means the Server sends its location/rotation data to Clients at the NetUpdateFrequency rate.
but it seems like it never snaps to the correct spot
If you are using Physics to move the Actor, then the Client can still change inbetween updates
Okay lemme crank frequ
On item's begin play, check for authority and if client turn off physics on the mesh. You need to simulate physics only on the server, then update transform on clients via multicast
You mean manually calling a position update multicast on tick? Or will turning off physics on the client be enough for Replicate Movement to sync it for me?
Replicate movement should work if the simulate physics is turned off on clients
Assuming your NetUpdateFrequency is high enough
Even without turning off phys on client?
But you want to be careful with that
It's at default 100
Default should be enough
Not if the mesh is not the root component, that's why i asked before
So something else must be going on.
Yeah I don't need it to correct that frequently I just don't want items getting crazy far from each other
Root component is a "DefaultSceneRoot"
Should I put the mesh there instead? 
Yes.
You need the Mesh to be root
Ok that alone fixed it
Frequency unchanged, client physics unchanged, when client joins now they are just on the floor already
You probably would want to disable physics on the Client if the Server is managing it