#multiplayer
1 messages · Page 646 of 1
any tips/examples of letting CMC player controlled characters push each other when they collide?
You probably don't want to do it that way. Do a multicast event that plays a montage
well that did occur to me, but what if i have like a continuous animation?
that loops and stuff
You can make looping montages. Include the duration in the event.
thanks for the tip
i was actualy thinking of doing that for shooting but i wasnt sure it would work for all animation kinds
i felt like animations that are more a "one shot" would work but stuff like continuous shooting would not
Is there a continuous reload tho?
by the way, if im gonna call a multicast im gonna need to call it inside a "server" rpc correct?
no
Ya for continuously firing I'd make it state driven. I'd do a reload by event tho.
it varies greatly from character to character in my game
so i have to get my head around this no matter what
Anim BP wise you'd probably have a few slots for one offs and continuous. Although playing a one off montage over and over accomplishes the same thing.
so if i call a montage over and over in tick for example it wont reset the animation?
i still cant get the damn animation to play in the network
{
//set the reload flag if the player state allows
if(isStunned == false && isAsleep == false && isDead == false && ammo < MaxAmmo)
{
ReloadMulticastCaller();
isReloading = true;
reloadTimer = reloadTime;
}
}
void AProjectArenaCharacter::ReloadMulticastCaller_Implementation() //this is a "Server" function
{
ServerReloadAnimationRPCMulicast();
}
void AProjectArenaCharacter::ServerReloadAnimationRPCMulicast_Implementation() // this is a "NetMulticast"
{
Mesh1P->GetAnimInstance()->Montage_Play(ReloadAnimation, 1.f);
/*if (ReloadAnimation != NULL)
{
// Get the animation object for the arms mesh
UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
if (AnimInstance != NULL)
{
AnimInstance->Montage_Play(ReloadAnimation, 1.f);
}
}*/
}```
what am i doing wrong here? the fuging animation doesnt wanna play for some reason
but plays fine on the cliet what gives?
doesent want to play where ?
is the animation defined before play ?
i think i know what im doing wrong
ok
gimme a sec i might be an idiot
ye i got it
i was calling the thing in the wrong skeletal mesh
ohh
I'm trying to make it so my server has max bandwidth of 40mbps while clients have max bandwidth of 2.5mbps. Do these settings seem correct?
How can I set a blueprint to run on the server only?
And then replicate to clients
im having an issue that gets exponentially worse based on how many clients are connected. any ideas of where to start troubleshooting this?
can anyone help me to get ghost console command to work in a multiplayer session? i have custom events set to multicast and it works when i preview on a listen server in editor but not after packaging
@fallow vergeWhat is the issue? I mean without additional information, it sounds like you simply have too much networking going on.
I think that's the case. Thanks.
If you haven't done so yet, you might consider upping your project networking limits. They can be a little strict to begin with.
4.26 is 100,000 bits per second, 4.25.4 and lower were all at 10,000 by default.
is there someway for me to check multiplayer sounds in PIE? It seems like if I have 2 windows open I'll just hear the sound from both windows, so I can't verify if sounds are being properly replicated.
How can I prevent actors created during runtime from not being seen by late joining players?
set them to replicated
and use a server rpc
as Im guessing ur using a multicast if ur not seeing them
which u definitely dont want to do when spawning actors😄
I did both a server and a multitask, i'll delete the multicast and set them to replicated! (which i probs missed) thanks!
@eternal canyonit worked! thanks a ton!
There's not really a good way to do that since PIE uses the same config files for audio outputs. I would package your game and set it to a different device for testing. Worst case just log it
I keep forgetting about this, but if I do Deferred spawning on server, set the value of a replicated variable, then do FinishSpawning, will the client's Beginplay already have this replicated value?
@dull lance I doubt it. Even if it might be, I still wouldn't trust it. Beginplay in networking should mostly just be used for things that need to happen when the actor becomes relevant. So if it already has the value, good, but it should also handle whatever that was doing OnRep most likely.
Do you need to do Run On Server on the GameMode? or do you only need to do Run on Owning Client and Multicast since its assumed that everything on gamemode is running on server.
No RPCs at all in the GameMode
The gamemode only exists on the server. RPCs would do nothing.
wouldn't they technically fail travel? I've never tried
I was under the impression that any replicated variables set on creation would replicate in the initial bunch to all relevant clients. When the client calls BeginPlay() on the replicated actor the replicated vars would be set.
You don't **need **to use DeferredSpawn either, but it can simplify your logic if you are using BeginPlay().
Of course it does get confusing when relevancy comes into play so you need to be careful and code somewhat defensively.
i want to clear a players viewport in the OnPossess of an pawn
what is the best way to go about that
Remove all Widgets doesnt work well
@viscid bronze pawns have the ReceiveControllerChangedDelegate which is triggered on the server and clients when they are possessed if you wanted to use that.
Does OSC plugin related question belong to this channel?
My question is how i can set a spesific index for a spesific value in the message i send through OSC?
I see that the client can fetch values per index, but i cant see a way to set a value per index. Am i missing something?
probably #plugin-dev
Or does it require the use of adresses to sort messages?
not sure what the OSC plugin is
Sorry, ill redirect myself over there, thanks!
but i wanna know what it is 😛
Open sound control, basically networking audio data, but im using it for something else 😄
An overview of how the Open Sound Control (OSC) plugin works within Unreal Engine
def #plugin-dev or OSC support
Not sure if that fits better into #animation , kinda affects both:
If an Animation (not a montage) needs to either move the character (climb up) or isn't always "max speed" (so the speed would better be defined by a curve), would one use Root Motion (heard that's not so nice in Multiplayer?) or utilize animation curves?
Hey, I have a small project in which I realise the character movement comp. is having trouble to replicate rotation when using "Orient Rotation to Movement". Basically it work fine when you have no latency, but as soon as you have 30-60ms it behave badly by: jittering for other client, getting out of sync from your perspective compare to the other client perspective. I'm wondering if someone came across that and have a solution
(just to make sure they're is no confusion, I'm not trying to replicate that variable, it is turn on by default in the CMC)
to give more output, it seem like the server is not getting out of sync with other client, it's the owner of the pawn that has different value
I remember we had a similar problem a while back. I can suggest these things based on our current code:
Enable bUseControllerDesiredRotation on the CMC
Call Controller->SetControlRotation() on local client to set rotation.
hum, that sound like a nice trick, trying it now, I guess you suggest me to use setControlRotation on each tick?
okay, not very optimise, but I could deal with it later I guess, sound crazy to me that this is not well replicated, my only question is if I do it on local, I would need to get the value from the server in order to make it no go crazy right
for us the local client sets his rotation each frame, I'm not sure how the value is replicated to Server and then to other clients, but it must be internal to Controller.
I wish I could remember but it was a long time ago, I just remember it being tricky to get right. We tried a lot of things.
but you might want different behavior, if you're trying to use Orient to movement
Doing it from the client doesn't seem right has it give me the same issue
I'm going to try it from the server, I don't know if the setControlRotation work when using Orient rotation to Movement
The CMC sends the players' local "control rotation" to the Server as part of the movement update anyway, it might be a bug that Orient Rotation To Movement isn't properly handled when playing client moves on the server, but that is odd.
It actually look like it doesn't work correctly when using Orient Rotation to Movement, without it, it's quite smooth, seems like the local control rotation is not handled with this behaviour
My guess is Epic don't use it for network stuff which is probably why it's never been bugged
Which would make sense in a way, it's most likely won't be use in a network context
I'll have to make my own sauce here I guess, thank you for the tips @silent valley and for the support @chrome bay
It could be worth digging through the CMC code and see where it differs.. in theory the rotation of the character should all be being updated with the timestep of the movement, maybe it's missing somewhere
Or maybe even it's the network smoothing that interferes..
Yeah I will take a look at it, it's a small project, was hoping to do everything in bp but might have no choice
EDIT: Multiplayer might actually be very wrong for this haha. Moving.
Should I be using components to split up login instead of having it all in the one place? For example I want to setup some logic for the inventory system, I know people have done an inventory component on the actor. Does this work in multiplayer/is it best practice? Previously I have just had the relevant RPCs on my player controller communicating with the UI. Downside is it clutters up the player-controller having basically all the logic.
There's not really any downsides to using a component on the player character for Inventory management. A replicated component can use RPCs without cluttering the player controller.
Bonus to the above comment, is also that if you create the component correctly, you can put inventories on all manner of things, not just for the players, all using the same component with easy code to handle it all by simply adding the component to an actor and not having to clutter the actors with any unnecessary code.
There is only one small caveat though, properties/RPC's on components cost a tiny bit extra - but it's very smol
teeny bit of extra data in the packet to identify the subobject
but tbh the engine has only needed to circumvent that once with characters, and only to reach fortnite numbers
I have a fairly complex question to ask and still need to do more research as well, but maybe you can point me into the right direction already:
We're using nDisplay with quite a few nodes, and want to get this to work in a multiplayer setting now. Current idea is to connect the master node via regular multiplayer system to an external server/host, while the nDisplay nodes just load regularly. Naively there are now two approaches: Somehow forward all replication data that arrives at the master from the host/server to the nDisplay nodes automatically (this seems like a rough task, especially then interpreting that data), or manually forward application specific replication and RPCs to the nDisplay nodes via their internal events. If anyone has some insights or can directly point out obvious flaws or a direction to look into for more info that would be really appreciated 🙂
Wait so CMC is what's automagically keeping Control Rotation in sync? I thought it was PlayerController or something else.
@dark edge yeah control rotation is almost entirely a local thing, but because characters use it to determine which way to face the control rotation is sent as part of the movement, and the server applies it to the controller on it's end too
So, I got my own PhysClimbingUp in my own CMC and all I do is set the capsule (only the capsule) to the root bone location. So basically some "fake" root motion.
It works nicely for the Server, but it seems to multiply for clients.
I'm not sure if this is generally just a bad idea. I need a way to move the player up from the wall ontop of whatever they are hanging on, without Root Motion.
void UPSCharacterMovementComponent::OnEnterClimbingUp()
{
const FVector newLocation = ClimbUpResult.ImpactPoint - CharacterOwner->GetBaseTranslationOffset();
const FScopedPreventAttachedComponentMove preventMeshMove(CharacterOwner->GetMesh());
UpdatedComponent->SetWorldLocation(newLocation, false, nullptr, GetTeleportType());
}
void UPSCharacterMovementComponent::OnExitClimbingUp()
{
// Make sure the Mesh is where the capsule is
if (USkeletalMeshComponent* mesh = CharacterOwner->GetMesh())
{
mesh->SetRelativeLocation(CharacterOwner->GetBaseTranslationOffset());
mesh->SetRelativeRotation(CharacterOwner->GetBaseRotationOffset().Rotator());
}
}
this seems to fix the weird "client flies off into space", but there are still issues. Very open to suggestions for different solutiosn
why can you not use root motion?
Well, because all I find on the net is "Don't use Root Motion in Network Games".
Also not the best in animation stuff. Should this just work, can it only be used in Montages or also in the StateMachine of the AnimBP? Any pitfalls?
Well I have animations that generally support root motion
I actively turned rootmotion off on them
So how does one do animations that don't move linear?
Like i have two animations, one for each direction of move left/right while hanging
They are not linear in motion
never done anything with climbing etc, but i have done vaulting where a static animation uses a root motion source to move the capsule across the vault
they also support networking (as long as its running on both autonomous and server)
is this for like pulling yourself up on to a ledge?
For example, yes
It's that and the moving left and right while hanging on the ledge
But two different issues I guess
The pulling up could be a montage with root motion if that solves my problem. But not sure how to sync that. Probably through the CMC too
The other things, not sure, right now they don't fit to the movement speed at all
i mean pulling up should be fine as a root motion montage (as you could guarantee the platform is smooth after)
Where would one execute that montage? Can't really do a server RPC, etc. that goes out of sync
we created a PlayReplicatedMontage system
its basically a replicated prop, but yeah needs to be server rpc
i try not to do too much stuff inside CMC, if i was doing this kind of system, i would likely make these abilities (for jump grab ledge, climb up from ledge)
and just a custom movement mode whilst hanging on ledge
Yeah that's all there is, but calling anything movement outside of the CMC will give me corrections
If the timestamps of the CMC and the Montage replication aren't in sync, the CMC will correct the client I guess
i have never had corrections with root motion montages (maybe the initial frame)
unless lag was super bad (+500)
So I guss that system is more or less just working like the sequencer does
Where it onreps the changes and keeps stuff in sync with that
Hm yeah
but i think as long as your sending the correct stuff through your saved move
No idea how RootMotionSource works. Will try to google a bit
corrections should not happen often
Saved move only has "Do you want to climb up?" boolean
Yeah I couldn't find anything useful :<
Wow, epic online services offering voice chat and easy anti-cheat for free? I guess free at least for unreal engine lol idk..
Does anyone have suggestions to handle movement of non-characters?
Can you add replicated functions in AnimNotify class?
From AnimNotify, you can call a function from the parent and the parent does the replication
What parent? Anim Instance?
quick question: I thought this was the way to check if the player is Local? (Clients and Hosting server P2P)
if (GetLocalRole() == ROLE_AutonomousProxy || GetRemoteRole() == ROLE_SimulatedProxy)
Hi! does anyone know how I can replicate a floating variable in real time?
that it replicates all the time without affecting the network bandwidth much?
Oh, did not know, I misunderstood the documentation, thanks!
Help! pls
Yep, already reading it :)
Just mark the variable as replicated, that's it.
that easy?
Yep
i go to try then
I guess I'll also bump myself 
Clients are running what's inside this if, but the Hosting Player isn't
I want that when moving an object from a client, this movement is reflected in all the other clients, passing through a dedicated server, in this case, it is the client who has to send the position of said object in real time to the server all the time right?
What I'm doing inside this if is fetching a LocalPlayerSubsystem, so it must only run on the owning player's machine.
There is AActor::HasAuthority. Is this what you looking for?
not really, because the characters are spawned on server 
I just ended up doing cpp APlayerController* NewPC = Cast<APlayerController>(GetController()); if (IsValid(NewPC) && NewPC->IsLocalController())
I think so
@dull lanceYou can do that without the controller too if you need to. Just use the same checks on the other actor.
I want a gameplay data shared with every players in p2p scenario
Where should I put it ?
Like a game play time played on the host or something
Unreal doesn't use P2P networking.
Well it does with listen server
No, it doesn't.
The listenserver is just both server and a player on one machine instead of a separate executable for the server. Clients still cannot contact other clients as P2P implies.
whatever...
GameState
Thank you
Why is it that when someone joins the session while it’s in progress, the camera gets stuck in a weird angle, I have a camera component in a pawn with a strategic view and that pawn is set in the game mode
And also the same happens when I make a server travel to the same map
need help with this please
Guys, I read Cedric's tutorial about GameSession in the UE4 Wiki and I'm trying to solve an issue. My GameInstance has methods to host, find, join and destroy sessions, using IOnlineSubsystem and IOnlineSessionPtr, but, somehow, the connection just timed out and close, everytime, and both clients don't travel to the PongMap. I can see this in the log. In the code, I'm using FOnlineSessionSettings and FOnlineSessionSearch to configure the session initialization and search, and setting the map I should travel to. Isn't working. Here is the APongGameInstance.cpp:
And here are the images
And here is the log:
I just did a package and execute the .exe twice, one for the listen server, one for the client. Should I use the console command, even when working with sessions, when the OnlineSubsystem is set to NULL? I mean, these commands? I'm calling the functions StartOnlineGame, FindOnlineGame and JoinOnlineGame in the ApongPlayerController
Hi, anyone here understands how EOS p2p works. As in will multiplayer games still be client-server where a peer behaves as a server for the sake of replication?
Im curious on how the game clients will keep everything in sync via p2p (in case there's no longer a centralized server)
I doubt that's the case.
I also suspect they use p2p only for NAT punchthrough, no port forwarding needed
yeah that's the domain of the online subsystem, it does'nt really come into play for the actual game networking
sounds logical otherwise their netcode needs to be very different
This is what I want to do, another system I am setting up is like an ATM kind of thing. And for that I would ideally want to keep all the logic for the ATM inside the actual ATM actor its self expect for an interaction system which it inherits from. I'm not quite sure how I would keep these things fully modular without specific code on the client PC since I need to have the interaction with the UI as well as calls to the server, which I'm under the impression a client can't make that call on an actor it doesn't own. (more applies to the ATM than the inventory)
Really stumped on this one, how could I update my config file to set dedicated server bandwidth to 30mbps and each client to 2mbps?
guys how i can see the packed the ping of my game in unreal
Ser the statistics Oficina all the multiplayer lost packages etc
interaction should be an interface not a base class
or a component
Yeah I have the interface but its a base class that implements that interface for all the static interactable objects (atms etc)
that kind of defeats the purpose of using an interface imo
just implement the interface on your controller
Not all intractable objects will be the same base class though
That's ass backwards lol
Hum. I'm trying to figure out why the map where the gameplay happens isn't being loaded: the log says that the map is loaded, but the client is not travelling to it```in the JoinSession: FString TravelURL;
APlayerController* PlayerController = GetFirstLocalPlayerController();
//Creates the connection information necessary to travel to the server
if (PlayerController && SessionInterface->GetResolvedConnectString(SessionName, TravelURL))
{
GEngine->AddOnScreenDebugMessage(
-1,
10.f,
FColor::Green,
FString::Printf(
TEXT("Travelling to %s"),
*TravelURL
)
);
PlayerController->ClientTravel(TravelURL, ETravelType::TRAVEL_Absolute);
}``` and in the HostSession: ```UGameplayStatics::OpenLevel(
GetWorld(),
"PongMap",
true,
FString::Printf(
TEXT("listen?%s"),
SessionSettings->bIsLANMatch ?
TEXT("bIsLanMatch=1") : TEXT("bIsLanMatch=0")
)
);```
having implementation of interface on a base class is aight if 99% of the interactable items sorta do the same thing and can be based on a class
Yeah I'm not really sure how to go bout structuring it
ie:
Controller:
// Calls interact on interface object
void Interact();
Object with Interface implemented
// Do stuff with this object when interacted with
void OnInteract();```
Currently I only need interaction with things like ATM machines, Store Clerks etc. But will also need picking up items, vehicles etc.
Yeah you'll need at least 2 interfaces, one for interaction, and one for transactions
Passing items between inventories
although you could easily just do it on the inventory component
Interact -> Get InventoryComponent -> ??? -> Profit
Hmm ok
the only thing is that the player inventory behaves differently than an inventory in a vehicle or crate might function.
Why would it?
Actually
I guess the code for viewing the inventory can be in the component but just not run on things that aren't players
Viewing should only be on the widget IMO
inventory should just be inventory
the widget can call GetContainedItems or whatever and construct itself accordingly
so the key to open the inventory will go to the player controller which creates a widget. That widget then gets information from inventory component?
Right, how about in multiplayer though, since I don't want inventory to be stored on the client.
the client will have a copy of it
just replicate it
^
Currently I have an array on the gamemode which stores all players and their information (inventory etc)
You should already have that built in (PlayerStates)
depends on if you have Player Inventory or Character Inventory. I have both in my game
Player Inventory being the bank, Character Inventory being what they have on them at the time.
Its only items they have on them currently
I'm not really sure how player states work in the whole equation.
I'd just store it on Character then. Depends on your desired setup
Also wouldn't the fact that the actor is possesed by the player mean that the inventory component would be owned by the player as well? Letting them change things when they should't
You can still gate by authority, its not like just owning the pawn lets you set your hp to 1,000,000
ownage is mostly for client-server rpcs
not letting you make another player drop an item etc
I see
player state is also the best place to store this kind of thing in a MP game
Yeah alright, how does that work exactly?
I've never used player states before
think of it like a replicated actor info class
I mean it depends. I'm working on a multiplayer Roguelite so player characters and enemies are not much different at all. you drop all items on death
sure, but enemies would have them on their pawn instead i imagine
Yeah but why the exception to the rules, just put it all on pawns.
what if you change pawns?
I could see inventory on PlayerState for a League of Legends, but for something where your character is more disposable putting it on pawn is fine.
In my design you lose your items anyways. You drop all on death.
sure, but changing pawns doesn't necessarily mean death
I guess the main thing that I'm trying to work out is where to store/how to use things to ensure that the player can't cheat. For example just adding a component on the player which stores their inventory, how does that work with checking that what I'm getting is what its supposed to be and things haven't been changed?
There's no case in my design where your pawn is destroyed where it hasn't died. If that were the case I'd probably put stuff on Playerstate. I actually do, the bank inventory is there.
you could just replicate your component
Do everything serverside, all the player does is say "Try pick up that item" or "drop the item in slot 3" or "trade 300gp for that apple" etc
So would that mean that any changes to the component is happening on the server, and then being passed back to the client?
yup
Yeah alright, and I can write that code in the component tho? Just using run on server?
it also means the server will correct anything the client does
ie, cheats
if it doesn't mesh up when the server checks, it'll chuck the data
Alright, appreciate the help. Sort of diving head first into multiplayer here so its a bit of work to get my head wrapped around it all. Doesn't help that the kind of game im making isn't really the kind that the engine is designed for either.
inventory component on the pawn, playerstate, or even the hat actor on their head it doesn't matter. it follows the same rules. nothing is more "secure" then the other
when your client runs a server rpc, equip this item, the rpc checks if the player even has the item in the inventory to equip
that is your security
by default no one else but the owning player can call their own rpcs.. what i mean is player2 cant call rpcs on player1s pawn
@glad fiber
Ok, but can player one manipulate their inventory in a way that lets them cheat? @half jewel
you call rpcs to make changes.to the inventory
manipulating the inventory to cheat doesnt make sense
I mean like players being able to give themselves items etc
it doesnt work that way?
i dont know what your making but it sounds like 3 server rpcs the client can run
drop item, equip item, and use item
the client just cant run any code on the server they want
Yeah similar, drop, use and give to another player. I'm still getting a grasp of the whole multiplayer setup. But I could put the logic for those in a component for example and just have them run on server. And then the inventory WBP could call those depending on what happens?
only the ones you choose, you cant "hack" it in a sense
And thinking about it yeah it makes sense that I couldn't actually give myself an item since the only thing the player can influence is getting rid of them.
the grant or give item function of your game would never be marked as an rpc
it would just be game logic that the server is running
Yeah alright, so say for example I have a BP_Store actor that is not possessed by a player. That could then handle the logic to give a player an item?
Sorry to bother you guys, but do you have any advice to give, about the question I made earlier?
so for store, you would have rpc buy item or trade item or etc.
any player can call or run this rpc whenever they want, aka hackers
in this rpc you must check, is the player near a store, can the player buy this, do they have enough money, etc
Right, and that check can occur on the BP_Store actor? Or would that need to be on the GameMode or something.
i would imagine the ui buy button would call the buyItem rpc on the actor
since it is server rpc it is a function that the client has asked the server to run.. so you get to do the checks right there
bpstore buyitem rpc works and is easier to understand for code readability
Yep that makes a tonne more sense. Thanks for the help.
Sorry for pushing your question all the way back. Probably just repost it now. I should be out of your way for a bit until I break something else 😂
Hum. I'm trying to figure out why the map where the gameplay happens isn't being loaded: the log says that the map is loaded, but the client is not travelling to it. In the JoinSession I'm doing this snippet: ```FString TravelURL;
APlayerController* PlayerController = GetFirstLocalPlayerController();
//Creates the connection information necessary to travel to the server
if (PlayerController && SessionInterface->GetResolvedConnectString(SessionName, TravelURL))
{
GEngine->AddOnScreenDebugMessage(
-1,
10.f,
FColor::Green,
FString::Printf(
TEXT("Travelling to %s"),
*TravelURL
)
);
PlayerController->ClientTravel(TravelURL, ETravelType::TRAVEL_Absolute);
}```
and in the HostSession:
GetWorld(),
"PongMap",
true,
FString::Printf(
TEXT("listen?%s"),
SessionSettings->bIsLANMatch ?
TEXT("bIsLanMatch=1") : TEXT("bIsLanMatch=0")
)
);```
Also, here are the logs:
Listen server:´´´
Client
And here is the Build.cs ```// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class PongOnline : ModuleRules
{
public PongOnline(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(
new string[] {
"Core",
"CoreUObject",
"Engine",
"InputCore",
"OnlineSubsystem", //This is necessary to create session through OnlineSubsystems
"OnlineSubsystemUtils", //This is necessary to create session through OnlineSubsystems
"UMG", //This is necessary to create UMGs
"Networking",
"Sockets"
}
);
PrivateDependencyModuleNames.AddRange(
new string[] {
"Slate", //This is necessary to create UMGs
"SlateCore", //This is necessary to create UMGs
}
);
DynamicallyLoadedModuleNames.Add("OnlineSubsystemNull");
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
The client tries to enter the PongMap, it spawns below the scenario, and returns to the MainMenuMap
Isn't supposed the listen server to join the session when it opens a level? Or must I manually travel to the map after doing a OpenLevel?
doesnt the server also have to use travel functions?
Open Level afaik can break connections
You're not actually joining the session there either
you're just opening the level on your own client
Hello @dull lance! Yes, I was asking myself about it, since the listen server is a client itself, if I should call a JoinSession
You should not
the listen server can open level just fine
it just needs to append ?listen at the end of the level
so other players can join
Well, using ?listen is not working
but if you run OpenLevel after clients run ClientTravel(), doesn't that cause issues?
Yeah but did anyone say that he does that?
if you're connecting to a server for the first time, you use JoinSession. If you're the server with clients, you execute ServerTravel
also, the server doesnt travel to the map after calling OpenLevel
if you're opening a level for the first time as a server, you want to use ?Listen
hang on a sec
let me open my P2P code I have
because Mine works just fine
xD
not a case of it works on my machine I promise
lol
Your code snippets are missing all the session code
So it's hard to say if you do everything correctly
Let me post it here
From a connection point, openLevel with ?listen and client Travel with thd connection string is all it needs
There is also #online-subsystems which is for session stuff
he's asked in a couple of channels today, we just pointed him here
since it wasn't necessarily a session issue
@twin juniper let me see your HostSession functionality from your game instance
GameInstance constructor is missing the super call
Have you put break points in your HostSession function?
to ensure the session is getting created on your server?
well, actually you can find your session from your other client correct?
Yes I can
ok
Is creating the session with success
is finding the session and joining too
if you read the logs, both client and server said that the PongMap was loaded
Session code looks fine
add a Super(ObjectInitializer)
The client disconnecting again could be multiple reasons
UPongGameInstance::UPongGameInstance(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer) ... rest of the ctor stuff
Fails to spawn, wrong usage of rpc and what not
Oofff
Might be worth enabling other log like LogOnline or LogNet to be veryVerbose and checking if you can see any issues
Shouldn't the machine that host the session travels automatically to the map after calling OpenLevel?
OpenLevel is traveling
ummm
Hum, but the server says it loaded the map, but nothing happens in the screen. it stays in the same MainMenuMap
if you're asking about unity test, I didn't do yet
no
Not sure why it would do that.
uni
how are you testing the entire process right now
This should work in PIE too
he's using steam
If that's what you are aiming at
No
Doesn't matter it would use null which still works
The onlineSubsystem is null
ah fair point
is set to null in the defaultengine
side bar, neat little trick to edit things s/mispelledword/correctspelling
I0m just debbuging and looking inside the log
ok sorry, I misread you were using steam
I would try to figure out why your server doesn't open the map first
First thing you can try is doing the hosting in bps
To rule out that your cpp code has issues
So simple create session node and open level with listen
how reliable/accurate is the ping in the player state to use for things like lag compensation?
depends on the online subsystem that you're using
It's also compressed sooo
i know i need to multiply by 4
There should be better values available maybe
divide by 0.25
Would beed to see what cmc uses
@dull lance am i better off just bouncing unreliable RPCs in the player controller every now and then to get my own ping value, or is it still going to be better than doing that?
Wait, I guess I misunderstood something: are you guys saying that OpenLevel() with ?listen should work, and the OpenLevel 4th parameter is the options, so instead "listen" as the 4th parameter, should I use "?listen"? That would be the cause?
Because I used ```UGameplayStatics::OpenLevel(
GetWorld(),
"PongMap",
true,
FString::Printf(
TEXT("listen?%s"),
SessionSettings->bIsLANMatch ?
TEXT("bIsLanMatch=1") : TEXT("bIsLanMatch=0")
)
);``` Offf
I thought that the first ? ws implicit
kk let me try
this is the exact command i'm using:
Yeah I was thinking to code it this way too, using ````APlayerController* PC = GetWorld()->GetFirstPlayerController();
const FString URL = FString::Printf(TEXT("ServerTravel WaitingRoom?listen"));
UKismetSystemLibrary::ExecuteConsoleCommand(PC, URL, PC);```
But right now I just put the : Super(ObjectInitializer) like @dull lance and @thin stratus said and ```UGameplayStatics::OpenLevel(
GetWorld(),
"PongMap?listen",
true,
FString::Printf(
TEXT("?%s"),
SessionSettings->bIsLANMatch ?
TEXT("bIsLanMatch=1") : TEXT("bIsLanMatch=0")
)
);```
see if that works
also the ? is applied
FString Cmd = LevelName.ToString();
if (Options.Len() > 0)
{
Cmd += FString(TEXT("?")) + Options;
}```
But isn't the same as using the fourth parameter?
however, using OpenLevel removes the listen element from there.
as it triggers ClientTravel in the engine
lol
void UEngine::SetClientTravel( UWorld *InWorld, const TCHAR* NextURL, ETravelType InTravelType )
{
FWorldContext &Context = GetWorldContextFromWorldChecked(InWorld);
// set TravelURL. Will be processed safely on the next tick in UGameEngine::Tick().
Context.TravelURL = NextURL;
Context.TravelType = InTravelType;
// Prevent crashing the game by attempting to connect to own listen server
if ( Context.LastURL.HasOption(TEXT("Listen")) )
{
Context.LastURL.RemoveOption(TEXT("Listen"));
}
}```
🙃
Ah, I already look this procedure today
Wtf
So you have to add the "?listen?options manually, always, directly in the map name, if I took this right
honestly
for hosting a level
I would just use open MapName?Listen
as a console command
create your session prior to that
I do this:
there's probably a "proper" way to do it, but this is what works for me.
It is much easier for sure, so approved for me
I code I posted earlier was taken from Cedric's tutorial, I just modified it
but I will try your way too
squishy bois 
hehe
Does anyone know how to setup multiplayer movement for a default pawn? I am using blueprints to grab user input and to move a player's pawn using AddMovementInput, but I cannot get the client's movement to replicate in the server. Only the clients can see the server move
movement is replicated by default
check your setup to ensure you're doing it properly
It doesn't remove the listen
It removes the listen if you are already hosting
LASTURL
Actually pawn movement is not replicated iirc
Only the cmc character movement is
yeaaa pawn movement isn't replicated by default. I tried using a multicast and I got the same result again.
Should I just switch to using a character? My player is just a simple gunship that moves and shoots asteroids
It's easier to just use a character, yes
You can set it to flying as movement mode
It's only a bit tricky with the collision
If you use PlaySound in the animations, does it get replicated?
Well. UPongGameInstance::UPongGameInstance(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)and ```UGameplayStatics::OpenLevel(
GetWorld(),
"PongMap?listen",
true,
FString::Printf(
TEXT("?%s"),
SessionSettings->bIsLANMatch ?
TEXT("bIsLanMatch=1") : TEXT("bIsLanMatch=0")
)
);```didn't fix the issue, I will try to use ServerTravel and ExecuteConsoleCommand to see the resutls
Anyone know how i can check how many bytes a variable is? 🤔
I'm relatively sure that this is not your issue anyway
Please try to use the native CreateSession Node in BPs and use the OpenLevel node with ?listen
And check if that works
If that works, then maybe there is a problem in code, if not, then you have a different issue far away from your join code
I'll try, thanks 🙂
If the Animation plays on everyone, yes
It's not really replication then though
It's just a sideeffect of someone else replicating that triggers your anim
@glad fiberI didn't read down too far after you tagged me. Don't know if you solved your issue. But I've always found the easiest method for that kind of thing is to do your traces and such on the client. Let them decide what they want to interact with at the Actor or Component level. Use the player's Character or Controller and have an RPC with those generic inputs. Send that to the server, and let the server call the interface events on those actors. It'll allow you to keep both your interaction selection code, and the actual interaction code very clean and easy to work with many different types.
usually googling it if you don't know off hand. You can dig into the engine to see what each vairable is. int32 for example is 4 bytes. You can look in GenericPlatform.h for all of them.
Gotta ask you about this for a second: is that just an OnRep AnimMontage or some struct with additional info? I tried it with Client and Server, which works fine, but of course needs the additional replication for simulated clients. I wonder if it's enough to just OnRep the montage and play it or if I need some ping stuff to let clients sync the montage.
EDIT: Theoretically, for starters, it might be enough to multicast the montage and filter server and owning client. Blindly assuming that no one will join or get into relevancy while the anim is playing.
But if it was to play, I would need to update some info struct every frame from the server to make sure things are kept in sync.
Thanks but didnt find anything that helped on google, but the thing is it itsnt a standard variable, its a world save variable that got a array inside it and i would like to know how big it is after its array is filled 😄
Voxel Compressed World Save
But I have a suspect: I'm overriding the ChoosePlayerStart, inside the GameMode, and the way I'm doing could be completely wrong, since the first map, the MainMenuMap, has no PlayerStart. Coud this be the culprit?
that's only responsible for spawning the player
if you don't have a pawn in your mainmenu map, that's fine
kk thanks
Just to make sure, I'm talking about adding the PlaySound notify to the animation with a sound.
Yeah
If the ANim plays it will trigger it
Your replication has to make the animation play
Not the sound
The sound will by played as a sideeffect then
My animation is part of BlendSpace in the AnimGraph
Yeah of course, one of things can be that the client isn't spawn properly.
Might also be worth to replace this with just calling super again and seeing if that fixes it
Should still be fine if the anim plays on everyone :D
Thanks
Ah! lol, so based on the same logic, if a Pawn is given, locally, to a client who haven't joined a session yet, and if the APongRacket, a class derived from APawn, has a ServerRPC and the same procedure is called inside the Pawn's Tick method, that would cause an unusual behavior, since the client is ticking when the MainMenuMap is still open?
Two fucking dumb decisions inside my code I guess
There are also situations where people called Reliable RPCs on Tick
Which is a no-go
Or Reliable Mutlicast in the PlayerController
And stuff like that
I would try to get this to work with a minimal setup first, cause I don't think your session code is at fault
A pawn be fore joining the session doesn't makes ense though
Joining the session is a hard travel
Nothing survives that
(despite the gameinstance)
I'm sincerely thinking to create a small teste project just to see it
Just make a new GameMode
And use that
That should remove all your custom code from gameplay
kk thanks
Ah ok Joining the session is a hard travel, do you mean a non-seamless operation?
For the first time that a client connects to a server
Besides that, I will try to find the real culprit later, since is 05:am here... Thanks @thin stratus @dull lance @fading birch
Yes
We use a version of the rep montage from ability system component
Inspiration was from that
Yeah okay, then I will look through that again
Right now I just ServerRPC + Multicast, not caring about syncing and it works for now
For a first iteration that makes me happy enough
I have two questions:
-
How can we create a loading screen that will display progress of players who are connecting similar to games like league of legends / dota 2. How would we even measure "connection progress?" I want matches to not begin until all players are connected. However, I am not aware if the GameState->PlayersArray is simply "a scoket connection was made" or if it's "hey a connection was made, AND the player is fully setup and able to walk around"
-
How can I set up a system for my game servers which works in a DevOps fashion as such that a game server is setup when a match is requested and destroyed upon closing. This part is easy, the hard part is that I want players to be able to do the following.
- Create a match using Sessions (this already is setup)
- When the session is ready to begin, all players must select a hero
- Upon the countdown (to select a hero) completing, the data should be sent somewhere.
- I've looked into Epic Online Services - Player Storage, but this is client sided and would allow players to modify their hero selection upon waiting for loading
- Online Beacons are also not a good solution due to the fact that they require a server to already be booted up.
- What I need is a solution where the "session" itself makes a request to some sort of tool, perhaps an AWS Lambda which will then request a new server to be spun up with a given list of heroes/player UIDs. The problem with this is that this needs to be done in a server-authoritative way.
@sand iris
I'm not sure how to accomplish your first question.
As for your second question, you'll need some kind of authoritative server to handle this stuff if you don't want the player to be able to change stuff. If you're already using AWS I would look into Gamelift and just have players connect to one of your fleet instances in a lobby and have them do all of this there.
Question 1 sounds more like a loading screen based on map load percentage than connection progress. How to achieve that largely comes down to your level creation process I'd assume. In general though I'd guess it's just a simple matter of finding out how much of the level the client has loaded, have them upload that to the server and replicate it for the load screen to update.
You could probably use beacons inside of an async task that runs in your loading screen module
that's the route I would try
it sounds like you want players to select their heroes on one server, then spin up a new server for the game, is that right? why not use the same server and just change levels once everyone has picked? then you can use seamless travel on the client and the experience will be very smooth
Quick question about replicated properties and RPCs
I have a replicated TArray of UObjects. If I call a client RPC on one of these objects and then remove it from the array (on the server), is it guaranteed that the RPC will arrive before it gets removed on the client?
there is no guarantee. but rpc's are likely to arrive before a replicated property
you should always handle cases where the rpc arrives after the property replication.
I think FastArraySerializer might help you it has PreReplicatedRemove if that's what you looking for?
Fast array serializer only supports structs afaik
Does UObject have any method that gets called when they get removed via replication?
aaah maybe PreDestroyFromReplication()
guess I could handle it there
you can have array inside a struct
that's called before destroying the replicated object
that would suit my needs I guess
since server calls the RPC and then removes it from the replicated array
Is this normal that when i do SetStaticMesh on server it doesnt do anything (replicated actor), but on client its working
wdym
Idk, i can do a constructor which takes a UStaticMesh param and then setting the mesh in it
Instead of doing a multicast to set it 😐
Mmh
The variable is replicated tho
So that's weird
Its from UE source code
oh wait
it is?
huuuuh
well then, is your component replicated and owner replicated?
both, yeah
Btw my actor has no owner, i'm spawning it like that
APickup* SpawnedPickup = World->SpawnActor<APickup>(Position, FRotator::ZeroRotator);
In a UBlueprintFunctionLibrary and i get the world with GetWorldFromContextObject, my actor is not null since the code is working if executed client side but not working on server
Fixed it!
How can I make "inter-character-melee" combat where I have different characters but they can attack each other. I followed DevAddicts steam multiplayer series
Weird, almost like there is another form in the pinned messages, for those who don't want to read.
Almost...
Like if it was there, it would be at the very top of the list :D.
APlayerController: only exists on the server and its owning client. Clients only have access to their own PC. These also generally never change for a player unless you do funky things manually. Each player has one.
APlayerState: Each player has one, and clients have access to all player states. Good for replicating the state of a player like their score.
AGameMode: Not replicated, server only. Game rules and logic generally.
AGameState: Much like player state, allows to replicate the state of the current game. Time left, global score etc. Anything relating to the game would be good there. Only one exists, and is accessible by all clients.
Has anyone had a problem with steam not loading up in a shipping build?
The SDK never seems to be initialized
The issue is simplified with one single point. Clients never talk to other clients. Clients can only ever talk to the server. Clients send data to the server through actors the server lets them "own". The server can then spread data to other clients.
Launch your game from Steam
Hey guys quick question on where i should look to a solution.. So i have a multiplayer game and all players can use a special ability for example but im looking to have it on a global cooldown.. for example one player uses the spec it will start a cooldown displayed on all players not letting them use it until its finished... Any good pointers on what i should learn to help me with this?
You'll want the server to track that. Once it's used, just send out an RPC to all clients that it's been used and have them display the cooldown.
I would put that particular variable in the GameState
RelevantTimeout=2
Is there an issue if I change this to say 0.1 in the configuration?
if it's a player specific cooldown, then doing it in the player state might work better
or sometimes, you have "global" cooldowns that can be "owned" by players
Like Overwatch's ultimate abilities probably not an optimal example for this actually 😛
I was thinking of Limit Break from FF
@dull lance I would say the GameState is better since it's a cooldown shared by all players, and the GameState is replicated to all players as is. Having it on one player's player state just seems like more calls and tracking than necessary
As each client would need to check each Player State
Fair
another thing to do
is keep them in the playerstate and for visual feedback on the client side, World subsystem events

(that's why I included the elmo burn emoji)
i'm not sure of the meaning of that
I usually use it as sort of a "pandora-box" type of action, or like "for the hell of it" / "half-evil"
ah ok
and if that's not enough overengineering, make a world subsystem that keeps your other world susbystems in check 
just throw it in a plugin for maximum versatility
don't forget to abstract away all the code hooking into unreal
just in case you switch engines mid-project
gotta keep things as easy as possible to swap out on a moment's notice
ah, so just like EOS then
no. don't limit yourself like that.
gotta abstract away the language too, write everything as a code generator so if you want to swap languages you can
and do it so it's also natively compatible with ARM processors
in case you ever want to switch entire platforms
even better: write all the code in a language for a custom VM that can easily be ported anywhere.
Which was actually done for the old game "Another World"
Thanks so much i was not sure the best place to store it. ill look into game state
and everyone else
don't thank @dull lance it just goes to his head 😛
haha 😉
do I need to put RelevantTimeout under [/Script/OnlineSubsystemSteam.SteamNetDriver] even if I use don't steam? or can I put it anywhere?
what is the max concurrent user limit of the engine?
(ignoring game implementation and data just connected users to a listen or dedicated server)
There's no real hardcoded limit afaik
it's going to be limited by performance long before you hit any actual hard limit
generally people would want to have it at 10kc then distribute the load
and it would probably depend on your network hardware buffer i imagine?
but i'm assuming unreal would support somewhere in the thousands right?
As I said, there's no hardcoded limit. You'll be limited by performance on a single server long before you hit actual limits.
distributing players across servers (or clients - unreal doesn't have built-in true P2P networking) isn't something unreal handles itself and is dependent on what system you use or build.
obviously most of would depend on the game implementation sure
yea... and they would do a hard seperation of servers with each server having like 1k ~ 2k user limit
was just wondering if anyone has done a siege on unreal lol
Pretty much everything you've just mentioned is well outside the realm of unreal itself - any limits there aren't going to be around unreal but instead around the server tech you're using (client perf aside).
yea just.. curious mostly i'm sure unreal can do hundreds easily
You could theoretically have thousands of players on a server, your perf would just be horrible. And possibly crash just due to the sheer load. But unreal itself isn't going to limit that.
as ut and as you mentioned unreal would have 100 ~ 200 players
fortnite*
well in fornite anyway
some of the 100 user ut games were ... pretty laggylol
especially the box one
ok thanks i was just wondering if there were any tests done on it before cuz i came up with no official answer on this
thanks!
there is no hard coded limit to number of players
you'll run into your first major hurdle around 80 players
as there is a rather nasty loop in the engine's replication code where it loops through for-each player, for-each replicated actor, for-each replicated property to determine if the player should receive an update
this was the big hurdle that Epic had to solve with Fortnite, and they did that with ReplicationGraph, reducing the number of replicated actors in consideration
they also partially solved it with PushModel (which reduces the replicated property consideration) but the gains there from what i hear are not as big as they expected
that will probably get you to 120 players or so
until you hit the next hurdle, which is that same loop but on the player side
rather than the actor side
SpatialOS solved that problem, but their service is very expensive
from there, you just hit limits of computing power
I think very informative ^
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
RelevantTimeout=0.1
I changed RelevantTimeout in DefaultEngine.ini but it seems to have to effect
We ended up using the Significance Manager. The Replication Graph wasn't as fine tuned as we wanted for our game, which has 100 players in it.
thankfully it's very very rare that all 100 players will ever be in the same space at the same time
RelevantTimeout=1
It seems that you can't have values below 1 for the RelevantTimeout hmmm
I am creating a hybrid FPS/RTS, and I'm wondering how I should tackle net relevancy for displaying FPS players to the commander player, when they are out of relevancy range.
My current considered solution is to have proxy actors that are always relevant, and are only relevant to owner, that are attached to the originals and when the original actor is netculled, they are used instead.
These proxies simply listen and copy values from their main actor as well*
fun fact, this is actually the worst case for that big nasty loop
if your players are all clustered together, it means it can skip considering replicated properties for actors far away
but if they are spread out (like in fortnite), you can't
Gross
replication graph solves that problem rather well
i think with push model it's better now
it's not like, as significant as repgraph
but still, i wouldn't be shocked if you can squeeze out like 20 more players
thanks for the insight
why custom functions is important for multiplayer !?
what?
have gamestate do it
^
gamestate has an array of all player states
you just iterate through that
you can also keep a running tally of the total score there
and just swap to EndMatch() when that meets the threshold value you want
Unsure where this question belongs but, Is there a way to run a windows script to add firewall commands to open ports to the packaged game when installing? 🤔
That's a responsibility for the platform installing and updating the game
That's not what's being asked - the firewall doesn't have ports, and it does not default to open
add firewall commands to open ports
"opening ports" cannot be done on the computer itself anyway
am I misreading that?
It's an access point thing
i'm not sure what they're asking then
The question is confusing because "firewall" and "ports" are completely unrelated things
Firewall = Windows thing to access network, ports = access point thing to host games
Ah so its a steam issue, well it is that i need to open 2 ports one UDP and one TCP
I understand the difference lol
I figured they were asking about ports specifically
not firewalls
If you have Steam, you need neither firewall, nor ports open
Both things are handled by Steam
even if i have a separate TCP socket?
Depends if you use the UE4 net driver
Which goes through Steam if you do
In any case, you cannot open ports from the computer
You can only use NAT punch instead or tunnel through an already open port
(Steam can do both)
aha well thanks for the info
how can you achieve a smooth replicated push-back effect like on bumper car games when 2 cars collide?
physics + force?
I tried applying impulse but it feels kinda laggy especially if you try it on 100+ ms
it may be because the server is trying to correct the position of the player
maybe check in the #legacy-physics channel to see if there's something you can do for replicating it
or fixing that issue
store it in the player state, not the controller
only the owning client and the server know about the player controller
all clients know about each other's player states
which will be easier if you plan on doing a scoreboard or something down the road
for your BP stuff
you can use the node Switch Authority or something like that
and put that before your loop
you don't need the bServer bool at all
You can also just mark the points as replicated
no need to store a local/server version
if it's replicated, it's server authoritative
so the server will update the player state and the gamestate values, then it'll get replicated to the clients
I would give @thin stratus 's Multiplayer Compendium. It'll give you a great overview of multiplayer and how the different classes interact with each other
you can find it there ^
I am stuck on quite an interesting problem. What would be the cleanest way to implement team highlight/ping system (same as in Apex Legends). Basically you can ping an object, it gets highlighted for the team.
I can't figure out a way to store and replicate that info from the actor itself... Any thoughts?
the first picture is a widget blueprint, second is actor
when I call Change Sight Attachments in the widget blueprint, the first print string works, but Server Sight Attachments (runs on server) is not called. How can I fix this?
Is the log saying something like "No owning connection found to actor ...."
it is not
there are no errors apparently
maybe you can spawn another actor for the ping, and then write the type of actor that is pinged to the ping actor
I can have a team specific actor that handles that, but it felt like a dirty solution
Are you sure the ownership of the actor doing the RPC call is correct?
Keep the "pings" data in the players' playerstate
I.e. the player which did the ping, that is
Hmmm.. But when the playerstate is replicated, "pings" would be replicated to all teams
You can just filter them based on the player's team
Alternatively have a "TeamState" actor similar to PlayerState which is only relevant to the matching team, and store the data there
Filter them out on client or server?
Client side
An alternative would be a "TeamState" actor of some kind which is only relevant to it's team, and the client HUDs pulls the info from there.
In HLL we just store it on player states
I think I will go with the TeamState approach. Thanks for you input
not sure
it works if it is the server btw it doesnt work on clients
how do i check the ownership
Simplification - RPC calls are always routed through Player Controller. If the actor "weapon" is not owned by that Player Controller, it cannot do any RPC.
Why is that? It is to prevent Player A saying to the server that Players B weapon fired. You need to be the owner of the gun to tell the server it fired. In other words, local player controller needs to be the owner of an actor to execute RPC calls.
When you spawn the weapon, there is an extra input Owner. Set that to your player controller
It is very important that ownership is set and changed on the server, not the client
That said, you can also pass ownership by a chain of references. If you have an actor that is owned by a player, you can use that actor too. E.g. the Character after being possessed.
Hello!
Could somebody explain to me the logic of meshes in multiplayer?
It seems to me that the client is not able to set a mesh, set visibility or materials on it either at all
Is that correct?
And BTW I mean setting the visibility locally, as in for that particular player
its a child actor on my player pawn
i just set the child actor class in my player blueprint
though i guess i could set it at the begin play of the weapon bp
That seems to be the issue, as that process does not set any ownership.
Feel free to print out GetOwner() of your child actor on server, and I suspect it will be nullptr.
That means, you need to set the ownership yourself, preferably on begin play.
Gimme a sec and I can send you the bp
ok
This should work
Basically we set the controller of the pawn to be the owner of the child actor
The delay there is needed to wait for the Player controller to possess the pawn, because that does not happen instantly.
There are cleaner ways to do that, such as listening for possess events and setting it upon new possession, but that is getting a bit more complex
ok this should work
i think it works its printing PlayerController, PlayerController1 PlayerController2
yep i think the system works now
thanks
can I put a 0.0 second delay since its like a one frame delay
Also is that a good place to set the variable that is a weapon reference
I do not believe PC can be reliably accessed on the next frame. You can check every 0.1 sec if PC was set or not.
Or do a custom logic upon possession
ok guess ill do that
thanks for the help
@brazen sluiceI haven't witnessed that I don't think. At least regarding materials. In fact I do that regularly with materials by changing them via onreps.
Hmm weird
My items keeps old materials
on client
But I am definitely setting it
I've had some oddities like that. Try using other materials, and also try nulling them before setting.
And whatever you do, don't read the code for the StaticMeshComponent. It's terrifying.
Ahahahahha
Yeah that last one is my exp. with most of the code in UE tbh
So for example here I am tinkering trying to get that offset to work in the network.
On the server it works, I set the mesh to replicate
but on the client it does not?
OK that's a bad example
BEcause this is probably related to the character movement component
You'll have a lot better luck just not replicating stuff like MeshComponents, and just replicating simple properties in the actor to affect them onrep.
Do remember that component replication is semi new in the scope of UE4, and most of their default components have been around forever, most of them don't actually handle replication well, or at all. Much easier just to assume they don't and use their actor to handle it or subclass them and do your own component code.
thanks for the tip
It's just very random what will or wont work one way (multicast set property) or another (replicated component)
It's a bit of a jungle
Die and retry
Any idea may be why this particular one would not work?Tried with both localOffset and RelativeLocationj
I'm unsure. I've never used default replication for component movement. I've always handled it via OnReps.
oki thanks!
OK I found the issue it's a weird one.
In a nutshell, Unreal in the Character class caches the relative offset of the mesh in a variable..... So even if you change it and replicate, it will still be wrong
There is a function you can call in that class, called "CacheInitialMeshOffset".
If you call it after changing the value, it will work even throught network
So the CMC has code to sync RootMotion Montages for Simulated Clients.
But as far as it seems, it only does that if you actively play the Montage on the Simulated Client.
Is that correct? I would have hoped that if I start a RootMotion Montage on a Movement Replicated Character, it could figure this stuff out itself.
Simulated Client calls const FAnimMontageInstance* ClientMontageInstance = GetRootMotionAnimMontageInstance(); which returns a variable that is only set if you call Montage_Play.
Yeah okay, so for that I do have to setup something that triggers the SimulatedClient to start the Montage.
Has anyone done a Vault Montage Animation like that? I'm a bit struggling with what I should put into the CMC and what not. For Vauling, I do need to change the MovementMode, even if it's just into Flying (as opposed to my own movment Mode for vaulting), because otherwise the Walking mode will cause the Vaulting to fail/stuck in place.
I thought about highjacking the CheckJumpInput function and checking if I can vault and thus call DoVault on the MovementComponent, but that function only runs on Autonomous and Server, so the Simulated Client are lacking the Montage_Play call. Guess DoVault could set some OnRep_CurrentMontage variable that causes simulated clients to play?
Also how many custom flags can one pass along to the Server in the CMC? Seems like 4 are available, which is... not really a lot. Otherwise I wouldn't need to highjack jumping (same key)
So for whatever reason, not doing a jump when jump is pressed breaks the CMC. :D
Suddenly the Serve doesn't know about the jump anymore, even though the flag should still be send. Fun times. I might as well as just send a Server RPC that I do a vault.
The CMC is sooooo time consuming
iirc if you want more than four flags you need to fork CMC and change the protocol
i have seen this done elsewhere for this reason but i can’t turn up an example atm
Yeah I'm just driving it through the character for now.
Detailed explanation of Character Movement Component
This also explains
near the end
how to send custom data
You can give AI Player State, not sure if you should tho
I believe you can send a custom flag plus an additional variable denoting which custom thing you want to do with that flag, rather than having a dozen custom flags for every option
But you have to mess with saved moves, network prediction data, and a few functions to handle using your custom struct and unpacking your custom variable
Guys I am struggling quite a bit on this. How do you create a widget for a specific player. for example a player dies then he is prompted with a game over screen without showing this screen to other players
use the player controller
@sudden geyser View managers will help a lot with stuff like that. AHUD can serve as that a little bit as well if the game is simple enough. But in short, you just need a local only actor that keeps track of the state of the game, and displays your correct UI based on it. A few simpler states for example might be.. PlayerAliveAndPlaying, PlayerDeadAndSpectating, PlayerDeadInfoScreen, MatchEnd, PreMatchScreen, etc. The manager can rely on the state of the server Via Gamestate's data and then get other data locally like whether the local player has a pawn and if that pawn is dead, etc.
Are UFUNCTIONs with client attribute also executes on server ? Or do I have to execute on server explicitly ?
I mean it doesn’t make sense but for some reason I see functions with client attribute also executing on server
in ai controller there is a bool to give them a player state
and they have a controller
an ai controller that you can get by using get controller and casting, or get ai controller
Anyone have any tips or articles on projectile pooling for multiplayer ?
Having done it, my advice would be not to
for example on this scoreboard "harry" is an AI
why tho
I thought it could work if you used some minimal projectile logic, pooling and some net relevancy stuff
Because most of the time you're going to be trading bandwidth for runtime cost
And bandwidth generally is more scarce
But it really depends on a lot of things like how many projectiles, how often are they spawning etc.
If your projectile logic is very minimal, my suggestion is to not even use actors.
then what would I use ?
Depends, what are the projectiles exactly?
If they're just bullets, all you need is two bits of data to represent them, position and velocity.
but then I would still need something to keep track of all that
I could handle it in the gun but would that really be ok
or maybe a standalone actor to manage projectiles in the air
We use a manger for it
oh
But none of the projectiles/bullets are replicated
They're created and simulated locally
their just spawned locally ?
yeah
then the server does some god-level calculations?
Well it's actually even simpler than all the overhead from actors etc, and very cache-friendly and performant
Every weapon in HLL for e.g. is a projectile/bullet weapon, and we have up to 100 players in the game.
say there are like 3 bullets currently in the air
Actor pooling at those numbers is totally unfeasible
do you just calculate their position and velocity in the manager every frame ?
then use that to decide collisions ?
im basically asking if the server just has numbers and no actual actors
yeah, weapons create a bullet "instance" - which is essentially just a small struct of data, and the manager simulates them all, and that's about it
ouuuu
does it work out ok
yeah works great
because that is feasible for my IQ
aiit then
It works for our case because all projectiles/bullets are basically the same, just bullets with slightly different properties
did you come up with custom projectile logic or do you just use something like the logic in the projectile component ?
Well it's custom logic in a sense, but it's essentially doing the same thing.
If you're doing crazy counts of projectiles that's how I'd do it anyway
If it's only a handful at once, I would just use regular actor spawning
i have a gun that shoots 1200 rpm
Obviously you lose a lot of flexibility not using actors but that's the trade-off
Yeah, answered yourself then really 😄
but wait what about the bullet on other clients
if client a spawns a bullet locally
what will client b see ?
In our case, each weapon has a replicated "last shot" struct
When that replicates, the client spawns a projectile locally
ohhh, I already have that for my hitscan weapons
Everybody is out-of-sync slightly of course, but it doesn't matter that much - you can't really see other bullets anyway most of the time.
I think Ill just use that
yeah , its just so they can see the cool bullet tracer
It's worked out well for us anyway. Projectiles are then just data assets with some properties that can be tweaked
I'm working on the same system. How do you visualize bullets or do you do that at all?
just particle systems
spawn a particle for each bullet, then move it during the projectile update loop
I'm working on something completely insane with @nova wasp
ECS-based projectiles
no actors
Don't you still end up with an actor per bullet or can particle systems operate without actors?
megafunk posted this morning
@dark edge particle comps can exist without actors
they get stuck into the world settings actor or something
yeah, that's similar to what we did. Just no ECS as such, since all the bullets are the same thing
Sweet, I hadn't tackled the visualization yet but I was trying to think of maybe having a global particle system. But if particles are basically just data in some sort of particle system anyway, that makes sense.
pushing bullet positions directly to a niagara system is really easy
saves a LOT of uobject creation
That sounds like a tree worth barking up. Right now I'm just visualizing with showing the line traces LOL
but, yeah, im close to having this working in multiplayer
So what are you, just send the initial position and velocity to everyone and have them simulate independently?
nah, i'm going to sync the whole bullet
i created a custom network channel
and im sending custom packets to the client with positions
at this point, I just need a way to refer to entities and components across the network
since while flecs has an entity id system, the order in which entities are created is unknown and not reliable, so I have to tag each entity with a number to refer to them over the network
tho
since this is deterministic, i could just send key events
emission, impact, etc
How are you going to do prediction?
probably have the client send a prediction key-like struct. maybe "my client entity id for this predicted projectile"
then have the server send back "this network id N is your entity id E"
I guess for favor the shooter you could just Mark certain projectiles as the authoritative ones on each machine, with the server spawned ones being authoritative from AI shooters and each client marking their own projectiles as authoritative
assuming determinism makes sense, but i guess anything that causes those events then also has to be deterministic
right
always the gotcha about determinism.. it's all or nothing 😄
yeppp
When i run 2 windows i can host and join my game ,at first when i built the multiplayer system i sent it to my friends and test it and it worked we connected just fine but after i progressed the game and built it again without changing anything in the multiplayer stuff it doesnt work , my friends are on the same country and if i close steam and open 2 times the game i can connect to my host but with steam it doesnt
please help
okay I'm pretty sure that's at least 4ms on my machine
I don't think we are that crazy yet, still have to get cute with the async traces
yeah, the point is that the slowdown is the interaction with unreal engine's world
for sure, yeah
You're meant to set that option in the ai controller's defaults, not in a blueprint graph.
look at the image you replied to.
you don't give AI a player controller... you give it an AI controller
You're structuring your code wrong. You don't give player controllers to an AI.
If there is shared logic, there are plenty of other ways to go about this
custom components, putting logic on the pawn/character instead, etc
There really shouldn't be that much shared code between them though - a controller is meant to be the "brain" behind a pawn/character. In the case of a player controller that mostly means responding to player inputs - something that an AI doesn't have. An AI controller would have logic related to its own decision making - something a player controller wouldn't have. They might both interface with their pawn in the same way, but the code calling into the pawn would be entirely different.
the Player Controller and AI Controller really makes me wish we could do multi inheritance in UE4
Why, what would you need both in one class for?
it's more of I would want to override some functionality from AController that would be shared.
To add to what siliex said any logic you have in your player controller should only concern the player/humans. If you want to do something like store score in the player state you should implement that logic in the player state so ai can also use it if not you will have to do some custom logic in the ai controller
I use that approach in my own setup and my ai controller is practically empty as kills and score are stored in the player state
Hey, Im having issues with replicating paper sprites
The client is able to change from walking to idle, but cant change from left to right while the server has no problem
it has just occured to me that it may be a problem replicating the direction so ill look into that
oh wait no because the server can do it. I dont know
In theory you should only have to update the direction
So I don’t know how flip books work but I would ensure that the direction is being updated properly in clients and the server
Replicating just the direction has the same effect as before ( So I didnt need to replicate the sprite ) But Its not changing it either
Does set flip book just change the sprite animation ?
If so then plug it directly to tick
Also you aren’t actually updating direction based on the direction the client is moving
One last question does the flip book character have its movement replicated ?
yea
Ok then
Search for get velocity
And then search for unrotate vector
Then use the characters rotation to unrotate it
So we can get the characters velocity in a specific direction
If you don’t understand I can show you but it would have to be in a bit because I’m not home rn
@ripe ravine
The character doesnt rotate though, when swapping direction its changes the sprites ( I have a left and a right sprite )
But the character does have velocity ?
Yea it moves on the x and z axis, then based on whether theyre moving positive or negative I can tell what direction theyre moving
Ok, even though the character does not rotate can you search for the get rotation node ?
I want to tell what the characters velocity is on the x axis
Based on if it’s positive or negative we will know if the character is moving left or right
Do you want me to just print string that?
Have you unrotated the velocity ?
yea
Can you print the x value so you can know what direction is positive and what direction is negative
Then now just do a greater than zero from the x value
If it’s greater the character is moving right
Else the character is moving left
Then use that bool instead of the direction to select the correct sprites
And plug the set flip book node directly to the tick node ,since velocity is replicated we don’t need any server events
alright give me one moment to set that up
Aiit
Yeah no worries
As a rule of thumb I always try to do things by deriving them from other properties to reduce RPC’s
Ill try to remember that in the future
is there something extra required for this? when attempting to call an server rpc on the client, the client gets kicked off
works in the editor, but in a packaged build across the lan, there is a lognet error that goes: client attempted to make subobject
Could someone help me with a ready system, I'm having some issues trying to see how many people have readied up
We can but you have to ask a question 😄
True xD. How could I do a ready system to check if every player in the server is ready? Because I've tried replicating the int variable and setting it and when the client clicks he adds one but then when the server clicks ready he also adds one but it's seperate
If I'm not being clear I'm sorry I'm a bit new to unreal and I'm trying to get better
For example a replicated bool indicating if player is ready in PlayerState would do the case.
When player clicks Ready button we do ServerRPC to inform the server about that, which changes the boolean to true.
The bool is replicated so players can see who is already ready and server just waits until every Player have that bool set to true
Oh ty, I'll try it in a bit I'm doing smth right now.
If I put GetLifetimeReplicatedProps in my ActorCOmponent and from blueprint make that the parent class. THe UE4 editor crashes. Any idea?
Debug it
Can't help without any debug/crash info
I am using the Steamworks default AppId and when doing the search. I found a session that I didn't open and I am guessing it's from someone else. Is this normal? I mean Steam and Unreal think it is a valid one. It is also playing a Windows sound when finishing the search that I didn't add.
If you use AppID 480, you'll see everyone using it too, even if different projects
oh yea but it showed up in my server list that I have made that only shows my games.
normally it just throws a warning in the logs and then doesn't show up when I do the search because it isn't my game.
maybe it just got confused I guess. I hope at least
anything goes without your own App ID really.
how often should you update player data if you want to save it to a database ?
[2021.06.25-12.04.54:257][152]LogWindows: Error:
[2021.06.25-12.04.54:257][152]LogWindows: Error: Fatal error!
[2021.06.25-12.04.54:257][152]LogWindows: Error:
[2021.06.25-12.04.54:257][152]LogWindows: Error:
[2021.06.25-12.04.54:458][152]LogExit: Executing StaticShutdownAfterError
[2021.06.25-12.04.55:606][152]LogWindows: FPlatformMisc::RequestExit(1)
[2021.06.25-12.04.55:607][152]LogCore: Engine exit requested (reason: Win RequestExit)
[2021.06.25-12.04.55:671][152]Log file closed, 06/25/21 08:04:55```
I don't see much
{
return Health_c > 0;
}
void UWWSActorComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(UWWSActorComponent, Health_c);
}```
THis is the code
These are in my ActorComponent.
Did you hot reload? If no, comment out the DOREPLIFETIME macro and remove replicated from the property macro, see if it'll crash then.
wait what ? how do you know the replicated variable is causing the crash there's no info in the logs ?

