#multiplayer
1 messages · Page 698 of 1
yeah, I am aiming for physics a bit similar to rocket league I guess. Vehicles are made out of destructable voxels. There should be no input lag heh
@thin stratus the funny thing is.. ive burnt out on this dream idea of mine before. it was incredibly fun in playtests (its a smash bros style FPS game). problem was, back then i couldnt model or rig/animate at all. now i can. and the last hurdle at this point really was just the netcode. and i wanted to tackle it again, id stay up 20+ hours straight reading doccumentation on netcode/rollback netcode, network fundamentals. have been the last 2 weeks or so (which is roughly how long it took me to learn to animate/rig skeles to the level that i wanted to do. and then.. reality set in, and netcode turned out to be infinitely harder
ironically the last thing i had yet to be able to tackle, is the most important in a multiplayer game lol. the world has a sick taste of irony like that lol
Yeah, NetCode is quite tricky.
yeah its pretty brutal. but i guess its better that i realize it was a dead end now, then spend another 2 weeks trying to figure out how to pull it off in BP
Can someone explain the magic behind the bAllowAutomaticWeaponCatchup in ShooterGame?
I just implemented it to my own custom weapon system and it solved the sync issue between server and client
From what I can see if current fire time - last fire time is higher than time between shots it fires the weapon instantly 🤔
Damn its clever
I assume it's basically so that you don't have to time the press as a player that much?
Haven't looked at it though
I guess it lets you fire the weapon instantly if you are still shooting the weapon but lagging behind the owner controller's burst counter so you catchup to its counter
Like this
In the end, both authority and autonomous proxy fired same amount of bullets
Sometimes when releasing the trigger server goes out of sync and fire an additional bullet that autonomous proxy didnt, but I dont know how to solve that yet
Will be CDO object pointer properly resolved if replicated?
Should do since it's stably named
@thin stratus sorry for the dumb question, but are there any particular ue4/ue5 c++ courses/resources you think would be particularly useful for this whole ordeal for me that i could go check out? im not ready to give up quite yet . ill humor my attempt at this lol
can anyone explain me why this isn't working?
When a client shoots, the server and the rest hears it, but when the server shoots, only the server hears it
Can you check it without the weapon attenuation?
ok wait
it still doesn't work
Not sure tbh. I rarely use any courses
So anyone has any idea for this? I'm trying to understand how ShooterGame prevents authority to fire more bullets than owner client when fire input is released, but could not find how that magic works yet
When ping is higher than fire rate of the weapon, server always goes out of sync and fires additional bullets which makes ammo different in client and server
Can someone shed some light on how root motion sources work when networked. I know the saved move system exists, am I correct in assuming the server doesn't extrapolate in normal motion but will only ever move based on received moves from the client? Is this also the case with a root motion source, or does the server actually "simulate" the root motion source?
Say a client has really high packet loss but manages to initiate a root motion source, will the server actually simulate out this source or only update the pawn if it receives new moves from the client?
you could tell me this in #cpp as well 😛
Exi, before you said you use an invincible tag for ignoring damage like iframes for a dodge. Does this just entail every Gameplay effect checking if player has tag or not in the damage calculation?
I have an actor that rotates at a slow rate. Because it's slow, the client rotation updates seem "jerky", as opposed to other actors that don't rotate slowly. Singleplayer doesn't have this problem.
Is this some sort of bandwidth saving mechanism that limits the frequency of movement updates?
If so, what is the best way to solve it? Should I lower the sensitivity somehow, or should I replicate the new rotation to all clients, and lerp it over the delta?
on ReplicationGraph at RouteAddNetworkActorToNodes is it normal for ActorInfo.Actor->GetNetConnection() to return nullptr for Player Pawn and Controller?
GetNetConnection returns nullptr when called from local players on server
We check that in the damage execution via the target tags
hey guys i am trying to spawn a dice on a player pawn it was working fine but now it just stopped working idk what i did
ok just started to bug test more the spawner only works on standalone and not client, assuming the pawn isnt replicated for its location anyone know how to do that
GetPlayerPawn(0) will get you a specific pawn, probably the Servers only
If you need this to spawn on each player, then you need to make sure you also reference each player
I think it depends where this code runs.
On the server I think its the order of players joind, but not sure if the order is preserved.
On clients I think that GetPlayerPawn(0) should give you the local player, but I'm not 100% sure, there just something in the back of my head telling me that ^^'
Hi, I'm making a basic Unreal multiplayer game.
- Check if any session is found, if not create a new one.
- If any is found, join it.
First player starts the game and a new session is created. Second player joins it.
Problem is, this works totally randomly- sometimes the second player finds the existing session and joins it, sometimes it doesn't find it and creates its own making both players in different sessions of their own.
Surprisingly I fixed this problem temporarily by switching to a different WiFi on both devices. It worked twice. Then I switched back to my original WiFi and it worked again. But then the next time it didn't. And now it doesn't work on the second wifi either. It's very confusing. Any idea whats going on?
I have the client call a server RPC through player controller, and inside that server RPC I'm calling a multicast RPC but it doesn't get called on all clients? I think I'm missing something trivial
Player controller is not replicated to other client's aside from the client that controller belongs to
but shouldn't the server RPC execute on server send to all clients?
Sure and it does that, but there is only one client that has this actor, so multicast is like single cast to client
Oh okaay, so I should move the multicast to the character class for example?
and the server RPC as well, right?
Depends on the usecase^^ but if it is smth that should run in context fo the player character, yes. But don't forget the player char is only replicated if in range
depends >.>
it basically triggers a celebration animation which I want all players to see the scoring character playing that animation
the server RPC is to inform the server which animation the player chose and then the server sends to all players
then the RPC To client should be on the system that is responsible for the your reward system.
Then this system should trigger the client feedback on the character^^
but actually it doesn't matter which system sends the RPC to the server, but it sound's like a PlayerController job
I'll think about it, thanks mate xD
^^ any time
Can someone please help?
race condition? do you connect them at the same time?
Can't be, I am the one using both and I do it one by one. Also worth mentioning that these are 2 VR headsets, I'm doing VR multiplayer. However whatever I have done seems to work and not work randomly.
I don't think it has anything to do with WiFi
are you using UE sessions interface?
Probably, I just thought I would mention that it works randomly if I switch wifi, but then sometimes it doesnt
Let me show you
Is there any way to upload blueprints somewhere without having to take 10 screenshots of it?
Do I have to make the whole blueprint on this?
Sorry never used it
Figured it out
Thanks
Forgive the mess.
no problem, so you're using a plugin and I don't know if there's something needed for it, but I can give you a link that will give you an idea of the whole thing
it's in c++
This post shall give you a short introduction to handling your Multiplayer Sessions via your own C++ code. Most of you probably either started with...
thank you very much!
Hm, it seems like enabling Ragdoll Physics while running doesn't carry over the momentum to the Ragdoll Mesh on Simulated Clients.
So I basicaly fall just downwards instead of foward in running direction
Hello, i have a problem where i can equip (spawn) a gun with "UPROPERTY(ReplicatedUsing=OnChangeWeapon)" (and it works perfectly fine on all clients), but when i try to destroy the gun, it only get's destroyed on the local client.
How can i make it that it get's destroyed on all the clients? Here is my code:
- DestroyActor should only be called from ServerSide for replicated Actors.
- Use
Gun->Destroy()instead of asking the World.
still doesn't work
Then you are relying on the OnRep for the Server
Which is wrong
At least by default
OnRep does not call for the Server
You have to do that manually
In line 98 basically, after you set the enum value
oh. how do i do that?
Just call it manually
OnChangeWeapon
Furthermore, why are you spawning the Weapon in the OnRep?
The Weapon itself is replicated or? Then it should also only be spawned on the Server.
If you want to use the OnRep to attach it, make the Gun variable replicated with an OnRep
it's cool, because whenever i change the enum to for example "currentGunEnum = EGUNS:Rifle", it automaticly tells the other clients
i'll try to code it and come back to you later
// Header
UPROPERTY(ReplicatedUsing=OnRep_Gun)
AGun* Gun;
UFUNCTION()
void OnRep_Gun();
// Cpp
void ACPlayer::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ACPlayer, Gun);
}
void ACPlayer::OnRep_Gun()
{
if (IsValid(Gun))
{
if (IsLocallyControlled())
{
Gun->AttachToComponent(FPSMesh, FAttachmentTransformRules::KeepRelativeTransform, TEXT("SOCKET_Weapon"));
}
else
{
Gun->AttachToComponent(GetMesh(), FAttachmentTransformRules::KeepRelativeTransform, TEXT("SOCKET_Weapon"));
}
FPSMesh->SetAnimInstanceClass(Gun->AnimClass);
}
}
void ACPlayer::Equip_Implementation()
{
if (static_cast<int>(currenGunEnum) + 1 >= GunClass.Num())
currenGunEnum = EGuns::None;
currenGunEnum = static_cast<EGuns>(static_cast<int>(currenGunEnum) + 1);
if (IsValid(Gun))
{
Gun->Destroy();
Gun = nullptr;
}
Gun = GetWorld()->SpawnActor<AGun>(GunClass[static_cast<int>(currenGunEnum)]);
Gun->SetOwner(this);
}
Something like this
You can still replicated the enum normally if you need it for UI, but I would probably also handle that all through the Gun that is spawned and replicated
The spawning works with your code, but the Gun doesn't get destroyed
Then debug it a bit more please. It should hbe fine destorying it on the Server
Given it's marked as Replicated
so im trying to replicate my spectator pawns but im unable to control my spectator pawn at all. in PIE it spawns 2 pawns and i dont control either of them. it does the same behavior in packaged but i cant see whats being spawned. in the logs on the client i get [2022.03.07-13.54.26:490][151]LogPlayerController: Verbose: NULL GameState when trying to spawn spectator! ... [2022.03.07-13.54.26:492][151]LogPlayerController: Verbose: Spawned spectator SpectatorPawn_2147482378 [server:0] after joining my server, and the server says ```
[2022.03.07-13.54.26:393][431]LogPlayerController: Verbose: Spawned spectator SpectatorPawn_2147482471 [server:1]
here is a link to my `PlayerController::SpawnSpectatorPawn` which removes the `IsLocalController` check to try and get the pawn to spawn on the server too. https://gist.github.com/GamerGambit/c8b97ac851e18cf0f89e6d7216546b00
So this seems to solve my issue for now. Velocity variable is an additional impulse. Taking the lastupdate velocity and overriding the mesh velocity solves the "drop dead" behavior on simulproxies
Just in case someone else has issues with this in the future
May I ask why you are trying to force this?
Because iirc it's supposed to be local only
fair question. id like spectators to be visible to other spectators
specifically, if a spectator is.. spectating another player instead of free-roaming
You don't have to use Epic's Spectator logic
You could basically make your own system
ah this is so your ragdolls are similar on every client end, right?
"Similar" yeah, I mean, I don't mind if they are largely different, but the SimulatedProxies just didn't carry the movement speed over into the ragdoll
So when you run and then die, the SimulatedProxies just fell to the floor, without any forward momentum
It is for the Autonomous one apparently
Not even the Server carries it over properly
Probably some super annyoing line somewhere in the CMC :P
😩 hahaha
has any1 here had problems with "Set view target with blend" in multiplayer. If someone joins the session after i have set view target, the camera offsets a little bit.
How would i go by doing that
So looks like desync even happens in ShooterGame implementations. I guess there is no way to prevent it right? Server or owner client can always fire more bullets than each other and no way to prevent this?
If this is the case I'm wondering how competitive games handle this situation?
Hello, I need to replicate the array of vectors TArray<FVector_NetQuantize> but I often get the stack overflow error (or others). How to do it properly? I tried to do serialization but nothing happened, there is very little information about this on the Internet. Thank you in advance.
Anyone know how to get player pawns if there are mutliple of them
hi all, I took an insights profile of 2 locally simulated players in a co-op level, I'm not sure how to interpret the values. I'm assuming I need to optimize my replication but I'm not sure how bad this is or what my goal should be
I'd appreciate any comments on the profile! thanks
this is a wide topic by itself, just be sure you know the features you can visualize with networking insights
such as RPCs, properties and such
once you know what insights can offer is just a matter of empirical observation and analysis
say, you notice you have some properties that replicate very often that add a minimal tail latency that you could simplify
ie velocity, acceleration...
you'd say - hey, this is constantly replicating thus adding n bits constantly to my bandwidth
you could simplify this by applying aggresive optimisation techniques such as converting these values onto simpler data types that can me mapped in the clients to the target values. But this adds obfuscation onto the source code, so apply wisely.
or batching rpc's or applying more aggresive relevancy techniques
But optimisation is an art...
the important thing here is that you understand what every field if insight means
Let's say you have an actor with a component. When a player overlaps with that actor, you display a widget. Could it be possible without adding anything to the player BP? I only want to use the component.
Can clients set non replicated variables regardless of ownership? If not how can I allow them to do so?
Clients can set any variables on their side, but it will only remain on their side. In order for a variable to replicate to all clients, it must be set on the server.
can the same be done for a function?
For instance a non-replicated function that sets a texture based on a non-replicated variable.
That is my setup and I'm trying to figure out why it isnt working
I am trying to set material instance values on client side. In this case I dont want to replicate
Say you're making a game like counter-strike with two rounds during a match. Would the gamemode contain logic that handles the round timer or would that be part of gamestate? I'm trying to have a synced round timer show up on the HUD for all connected clients in the session.
If you're running on client, then the function executes on the client - anything that it may change would only be on the client.
Gamestate
thanks
Do I need to set it to run on owning client or is non replicated ok
It depends on where you're calling it from.
Eg: Any player input (like keyboard or mouse buttons) are all executing from the client already - you wouldn't need to do an "Executes on Client" event for this.
If there's something being run on the server, and you then want the client to do it, then you'd do an "Executes on Client" event.
Hmm my function should be running then but I don't see any change
Just to make sure i'm on the right page:
Actor A is in the scene with an oncomponent begin overlap, with a switch has authority->remote because I want to display a visual change to a client.
That remote will actually run on any client that is connected right because they are all remote? so if I only want to display that visual change to the client I should either further filter that pawn by 'is locally controlled' or go to that pawn and run on owning client?
Instead just check IsLocallyControlled. No need for the switch.
Good point. And can I make an RPC from there if I need to get some info from the server? or will an RPC only work on the player controller/pawn?
If the actor is not owned by the client performing the overlap, then no, you cannot RPC through it - you would either have to use the Authority execution path from HasAuthority which would mean the server can detect the overlap, or yes, RPC through the player controller, pawn or playerstate.
Yeah the only thing we need the server to do is provide a string from an array it's keep track of. So I'll just go back to the pawn itself and get it there since that is where we're going to use it.
Usually how do mmo implement pre-computed movement replication? Like during a short period of time the exact delta location of each tick is pre defined?
I tried to force set actor location inside of onMovementUpdate. Works fine on autonomous proxy, but on simulated proxy, as long as the period is finished, it tries to smooth out the location with last sever update info, causing a replay.
Guys, do I need the Oculus build of Unreal Engine to use Oculus Multiplayer features or is it not essential?
Hi there! I created a timeline to change the progress bar in the HUD, but the timeline should change on the server, and the HUD only on the client. How can I replicate the timeline for playback position selection? (my method doesn't work)
.h
UFUNCTION(NetMulticast, Reliable)
void TimerTimeLineFloatReturn(float Value);
UPROPERTY(Replicated)
UTimelineComponent* BoosterIndicateTimeLine;
FOnTimelineFloat BoosterIndicateInterpFunction{};
UPROPERTY(EditAnywhere, Replicated, Category = "Curve")
UCurveFloat* BoosterIndicateCurveFloat;
.cpp
AKT_BaseLyingObject::AKT_BaseLyingObject()
{
BoosterIndicateTimeLine = CreateDefaultSubobject<UTimelineComponent>(TEXT("TimerTimeline"));
BoosterIndicateInterpFunction.BindUFunction(this, FName("TimerTimeLineFloatReturn"));
bReplicates = true;
}
void AKT_BaseLyingObject::BeginPlay()
{
Super::BeginPlay();
if (IsValid(BoosterIndicateCurveFloat))
{
BoosterIndicateTimeLine->AddInterpFloat(BoosterIndicateCurveFloat, BoosterIndicateInterpFunction, FName("Alpha"));
BoosterIndicateTimeLine->SetLooping(false);
}
}
void AKT_BaseLyingObject::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AKT_BaseLyingObject, TimelineTime);
DOREPLIFETIME(AKT_BaseLyingObject, BoosterIndicateCurveFloat);
DOREPLIFETIME(AKT_BaseLyingObject, BoosterIndicateTimeLine);
}
void AKT_BaseLyingObject::TimerTimeLineFloatReturn_Implementation(float Value)
{
if (!IsValid(PlayerCharacter)) return;
if (!HasAuthority())
{
PlayerCharacter->OnBoosterTimeIsUpdate.Broadcast(BoosterIndicateTimeLine->GetPlaybackPosition());
}
}
Set the actual health on server & run the timeline on the client to interp the value to the target.
but in this way the client can receive inaccurate data
Play the timeline in OnRep_Health. How can it be inaccurate?
Hmm, perhaps you are right, but I'm still wondering how I can replicate the timeline, for example, for cases where the function should only be processed on the server. Unfortunately, there is no example in the documentation
You don't replicate the timeline. You replicate the values that it change.
I meant values
Just found out that there is a replicated option in the timeline. That might help.
Yes I am looking for this in C++
I think Timlines had terrible replication features
Whenever I have to deal with this I simply use a Struct with some information and interpolate the value on tick.
Not sure how you can exactly set it but it is present on the UTimerTemplate class.
If this doesn't work you can just directly set a replicated variable value on server in timeline and that would replicate just fine.
I did exactly that, I just thought there was a more elegant way
uh.. so you want to smoothly set a value in the server, or you want to smoothly interpolate the value delta in the client?
because if its the later.. don't replicate the timeline, you just don't need that
Is there an event that triggers when PlayerArray or its count is changed? I tried to check array num on GameMode::LogOut event to see if there is no more players to close the game server. But apparently disconnected player is removed from the array after the GameMode::OnLogout call
So what I do right now is is waiting for a frame after OnLogout is called to check if I can close the game server
It doesn't feel right
there are add/remove player functions in GameState that can be overriden to add it
but note that player array in gamestate is not an ideal way to track num players for the game mode itself
Is there a better way than doing it manually (adding controllers to another array on GameMode and removing upon disconnection)?
Well, in this case, I can interpolate it on the client, because it's just a HUD element. But I have a function of running along the walls, which is now written not quite correctly and I want to fix it, and all calculations should take place on the server.
Right then since you only want that for visuals then forget about replicating the timeline and fire it locally wherever you find a delta change (onrep)
you can check during logout if there are any controllers left that are not equal Exiting parameter
replicating a timeline would be awkward indeed
yes its just - don't x'D
Ok, thanks for help
btw just in case (probably you know this already). In onreps you can pass in a parameter of type which gives you the old value
with that you have A and B for interpolation
the interpolation method is up to you
I didn't quite understand about the old value, do you mean that if I replicate the variable, the server might pass a non-actual value to the client?
nono when you implement an onrep for a replicated variable
you can do
OnRep_Blah(mytype oldvalue)
and automatically unreal will provide you the oldvalue that said property had before updating in the client
so you have both your updated value, and the old value provided by the function
it's a pretty nice feature of onreps
hmm, I thought that he passes the updated value of the variable to this function
no the parameter passes the old value
no, i messed up everything, maybe you are really right
and then the priperty you have is the updated one
haha
unless i had a very big brainfart, but I'm pretty sure about this
sorry i was thinking of something else
Hello, i have a question. How should i do shooting (with linetrace / raycast) on multiplayer? Should i do it in a Mutlicast RPC? or should i do it with property replication or something like this
you can shoot in the client and send the shooting information to the server to later verify it and do the damage
so the linetrace stuff on client?
On both, first check on client then on server
alright, but where do i spawn the particle systems? Like muzzle flash and impact effect
on client ofc. You can do multicast event from server after hit
oh right, thank you
I'm working on an app game that involves players playing in an 'event' at the same time, but they aren't all playing on the same level per-se. I mean there is really only the one level in the game, but the players aren't interacting at all with one another.
What I am sort of looking to do is have the server start the game, and then periodically send out one piece of data every few seconds or so to all of the players. The players do their thing, but not sending any information back to the server until they meet a certain condition and then send a piece of data back to the server.
So I'm working through a server tutorial right now that is like a standard ue4 tutorial about a shooter game using replication to determine whether things are shown between players. But is there a better way to go about what I described? Or is basically having it send all that data with every player at the same spot but nothing being replicated to the server, the only way to do this?
i dont really understand your question completely, but it sounds like you want to give each player their own [different] task/goals (which dont require them to interact with each other), then only notifying the server when the player has completed their task/goal?
if so, then yes its 100% possible
i cant help you with any implementation though since im still learning the networking stuff myself
Thanks for the quick reply anyway lol.
They will all have the same task/goal in the game, but yeah only to notify the server when they have met that goal. But the server will feed all the players more information periodically
If that makes sense
ye makes sense. definitely doable but like i said i unfortunately cannot help with any implementation
All good. I still appreciate the input
well, if nothing on the level is replicated, except GameState and PlayerStates, and you do not have a listen server host
it should pretty much work out of the box, with exception of being very susceptible to various cheats
extra work if you're using any AIControllers, as those would have to run locally as well
hi all, guys
I wanna ask you, how i have to replicate my widgets? It seems like they don`t have any of replication options
What are you trying to do? Widgets don't replicate - they only exist clientside
UI is not repliced because UI exist only in client... because there no need for that, What UI does (should?) it only displays state of gameplay data, that data is only thing that needs to be replicated and UI that display that state will change accordingly without need of replication there. So you should keep data sepretly from UI and replicate only gameplay data, if you make UI display it and edit it, it will just work.
In Slate/UMG you can directly bind widget content to varable somewhere else which can be replicable, so make textbox edit varable that you replicate.
U can’t
I am still having trouble with getting my variables set client side. Basically I've got a material instance that needs variables set, but I don't want them replicated so the clients each set them when they join a server. For some reason that doesn't seem to be working at all.
Is there any straight away manner to skip the owner replication for a replicated actor?
IsNetRelevantFor will do I guess
There are some more if I remember correctly
Tho I’m not home so can’t rly verify
Had a quick look, couldn't find anything - I'm in a component so the concept of ownership is not so obvious. Although couldn't find anything either for actors xD
uh, don't think actors have that, although it would be convenient
I'm implementing some sort of projectile prediction
Actually Jambax, I think you smashed your head a bit with that topic, right? 😄
All actors have it. It's a part of the replication system.
what's the property name?
hello, is there a step 1 to folder design / project design for multiplayer?
ive been in single player land for a while, so doing a quick check as I setup a new project
COND_SkipOwner is a per-property rep condition
yeap
If it's the entire actor that shouldn't be relevant then yeah IsNetRelevantFor is the only option
yes that's what I believe I want
but I'm mostly researching different ways I'd have to implement projectile prediction, so maybe this isn't the way
I need some help thinking through some logic. Player uses a container (actor), container has an inventory (array of structs). Player gets widget displaying contents. But then the inventory contents change. I could replicateusing/onrep the container actor's inventory.. but where to go from there?
I could have the container actor track all the players that have the inventory open and when the contents changes it could force them all to rebuild their widgets. But for some reason that feels messy to me.
I'd make the inventory array an onrep. The onrep should call an event dispatcher. The UI that displays the contents of that inventory binds to that event dispatcher and refreshes the display of the contents when its triggered.
Thank you. I think it's finally time I learn how to use event dispatchers
Can you tag me and reply when you get this message?
I have a pickup item and when the player overlaps the box component, it displays a HUD for picking up the item.
So in my multiplayer project, I need to replicate the item so once it's picked up. It gets multicasted to different clients as well but i dont want the widget to be displayed on different clients. I am using c++ for it. How am i supposed to hide the widget?
You had a delegate. I bound to it, you sent out the message.
Hmmmmmm I see.
this widget is a component in PickupItem
guys, could anyone help me with animations? even give a suggestion would be great: how some animations work in multiplayer?
Hey I need some help. so i got the community ocean project version 4.25 for the boats(https://github.com/UE4-OceanProject/OceanProject/tree/MASTER_LEGACY_FINAL_4.25). Is there a way to make the harpoon gun replicated for multiplayer? I searched for an answer for so long so any help would be appreciated.
any idea why user widget is getting replicated on different clients?
well a user widget wouldn't be replicated to begin with
?
i guess this means it is getting replicated?
this is not enough context and user widgets are not replicated
if a player overlaps the item's box comp then a user widget pops up to pick up the item but I can see the pop up on different clients as well
@lost inlet
can you not @ me for every message, thanks
and this is nothing to do with replication, you're probably using a widget component on each pawn for some reason
I have done UFUNCTION(client, reliable) for overlap
Working on my first multiplayer project and doing everything in blueprints. I am building doors that open when interacted with a line trace and close when stepping out of the box collision. I've set it up so the door will rattle when its closed as a player passes by and through the same trigger that closes the door if the door is open. However, the door will only rattle once and then I can't get it to trigger again. Anyone have a possible idea what I might be missing?
also, when I pick up the items from the client. It disables the visibility but the box component is still active. This doesn't happen in the server side
Also how do i make a reel function on this?
Any ideas why this isn't running? the first is a widget button and it calls the function on the pawn associated with the widget
the second function doesn't seem to get called at all
added a print string in the first pic to make sure the button was getting clicked and it is
https://media.discordapp.net/attachments/221798862938046464/950839788766896228/unknown.png
create session isnt working
this error msg is from the output log
does anyone know whats the problem?
I would start by using "Get Owning Player Pawn" instead of "Get Player Pawn" - I think it will be more reliable. Second .. I could be wrong, but I don't think you can call server functions directly from a widget. I think you may need to call a function on your pawn first then call the RPC from there
I see thank you
Having an issue refreshing a player's inventory widget on changes. I have a drag and drop operation implemented. When the player starts to drag a widget, the original item is set to not render with a flag and only the widget representing the drag is shown. When the item is dropped, the flag is cleared then the inventory is updated and refreshed.
The end result is the item shows at its original spot for a small duration before the server updates the data. It looks .. super messy. Was hoping someone might have a cleaner way to handle this
hi people, how to i fix that my recoil is playing for all players?
and I'll x-post my reply, never use this node in MP
use something else, I'm assuming the weapon has an owner property
ye i have a owner pawn refrence
that is a ref to the player bp
so why not use that instead
still does it for both players
then show more of what you're doing
and usually recoil like this is pretty clientside
what ya wanna see
fire event starts in main player bp, then fires a event in the base weapon to do the recoil and some fx
yeah so show that
and this is before the block, the other pin form the seq goes to the fx
this is the bath, first one is in player bp, second one in weapon bp
and the shoot func in the weapon bp calls the Shot Fired(EBarrel)
@lost inletany idea?
Shoot -> Shot Fired
what happens there
not like I really like network things happening BP at the best of times
me neither lol
its a function from the Easy Ballisics plugin. It gets the EBarrel (from the plugin) and does the fireing, cant open the function so i dont know whats exactly happening
the plugin is saying its multiplayer setup
when it fires at basicly spawn a projectile at the barrel and does the ballistics things
shot fired sounds like it probably arrives on the client as a multicast then
though I would only bother with applying recoil on the client and if it's the owning client of the weapon
i see
oh oh i kinda fixed it
ive put the recoil code behind the fire_weapon piece and now its only for the client, but now its only playing once what is logic since its only called when i click
pohhhhhhh
i think i found it
no ok that didnt work
@lost inletso i found this in the barrel settings, if i turn it of it does get called but nothing happens
https://media.discordapp.net/attachments/221798862938046464/950839788766896228/unknown.png
create session isnt working
this error msg is from the output log
does anyone know whats the problem?
or atleast know anything i can try
Would recommend looking at https://cedric-neukirchen.net/
this for some of the basics of multiplayer in unreal
is there a function thats called when an actor is replicated? im trying to check when AGameState is replicated to the client
anyone here use steamwerks sdk?
ask your question
Thats fair. I'm starting a multi player game, pretty decent with single player and the game will be on steam at some point. Does it make sense or hurt to go ahead and use the sdk now for foundation of auth, lobbies, etc.. or is there a basic way of doing it to 'fake' things during development until I need to bring it in. (i.e.) how hard to add later on. My first mp game so I'm trying to think about how to start. Game is 2d async strategy. So I need a server.. but clients aren't really connected in real time.
there might be like 2 solid q's in that puking of words
really depends on what platforms you want to support. if you are 100% sure you are only going to use steam then it doesnt really make sense to worry about other platforms so id suggest to just lock in steamworks. however, if you plan on supporting other platforms like EOS or whatever, there exists in unreal OnlineSubsystems (like steam and EOS) which abstract functionality into a nicer API which will allow you to basically swap these subsystems in and out. of course, these abstractions will not contain all features from every sdk/subsystem (as an extreme example, steamworks allows you to join steam groups and message other steam users, the generic abstracted OSS API will probably not support this since other OSS's probably dont have steam integration)
Could you build to the OnlineSubsystem api to get the game up and working then add steam later?
yep. thats literally the point
In order to distribute through steam you need the steamwerks stuff?
big q as my single player game will go there as well
afaik you dont actually need steamworks to distribute your game on steam (see factorio in the very early days). you only need steamworks if you want steam integration. with steamworks you can make sure that there is a logged in steam user running your game, and that they actually own your game on steam (eg to prevent piracy)
ah k that makes sense
any clue the $$ per app?
i guess i'll go find that out
where are the EOS Online subsystem docs?
hahah probably in the #online-subsystems channel
..
are you asking how much it costs to put your game on steam?
the last sentence isnt entire true. you can use steamworks with the 480 (Space War) steam app id and it will work fine, but for multiplayer sessions it will pick up literally every server running this app id
afaik the fee is negotiated between you and valve
ohrly
Whether you are completing the Steam Direct signup process or are already an established Steamworks developer, you can now simply pay a $100 USD (or equivalent) fee for each new app you wish to distribute on Steam.
someone who has actually released a game on steam might have more details about this
ah ez
looks like they didnt change it from greenlight
ha top line
thx
k let me see about those subsystems first
this other stuff seems like a lot my lawyer will want a peek at
Hi everybody! i'm having a trouble with something and i was hoping someone could give me some pointers on where to search for a solution.
Currently i'm gathering some data on the server with Json calls, this is triggered and handled with events (exclusibly)
The problems is that the events don't wait until the previous one is finished, and since i require some Api calls to be finished before execution the next one, it's generating a mess with the load of the overall data.
I was thinking on the following solutions:
- Create some variable bool Replicated and change the state of it after LoadPart1 is finished, and trigger LoadPart2 on the OnRep of that variable.
- Using Tasks, but i'm not sure if this is ideal on MP, i'm open to suggestions.
The problem with the first one is that i need as many variables as steps on the process, sounds stupid.
Thanks in advance
there's an additional detail that if you're a trusted steamworks partner, you accumulate free app credits as well
so you don't have to pay the $100 per title every time unless you're just constantly uploading shovelware
Ah very nice. I'm keen to get my "game" on steam but I'm worried that since it's still basically just an idea/concept it will be rejected
Is there a way to do per-connection replication? I've seen IsNetRelevantFor, is this the correct way?
Who sends these events? are the events in the correct order? If so: Create a queue and process them one after another as I assume you do some rest calls these give you a "done" callback and if one request was done you can continue with the rest.
Not sure if this is the case, but if your requests have some specific requests to send, maybe put all this logic in one request, so you can execute any request at any tíme and the backend ensures everything is executed correctly and if needed calls some other stuff.
But maybe I don't get your architecture right^^
That is one way to do it. Useful if you need only a select few people to know about an object. Like a "TeamState" maybe. Realistically if you're only trying to talk to one client, it can be easier to drop an actor component on the controllers to route data through. Both work. Technically using an actor is cheaper net wise I think but requires a little additional setup. Depends on your use case or preference.
Hello guys, I really need some input from the experts over here. I am pretty new with both Unreal and networking and there are a few missing links in my understanding.
Here are my multiplayer setting. I assume with this setting there won't be a player playing as server. So most of the events that happen, I need to pass them from client to the other client. I read somewhere that you first need to send things to the server first and then to the other clients. I am doing things with c++. So i have tried a few things which causes error. For eg.
To pickup an item I am first made a function binded to an action key
here it is
UFUNCTION(NetMulticast, reliable)
void InteractWithItem();
void Aaissgnment51FarmCharacter::InteractWithItem_Implementation()
{
if (currentIteminRange)
{
currentIteminRange->PerformActionInitial();
if (!currentIteminRange->isDamageable)
{
if (currentOwnedItem != nullptr)
{
currentOwnedItem->positionWhenDropped = GetActorLocation();
currentOwnedItem->PerformActionInitial();
}
currentOwnedItem = currentIteminRange;
auto temp = InventoryHUD->GetUserWidgetObject();
UinGameInventory* infoWid = Cast<UinGameInventory>(temp);
infoWid->SetCurrentItemInInventoryInformation(currentOwnedItem->itemType);
currentIteminRange = nullptr;
}
}
}```
void APickableItem::PerformActionInitial()
{
if (HasAuthority())
{
PerformAction();
}
else
{
switch (currentState)
{
case ItemState::LAYINGONGROUND:
if (isDamageable)
{
FVector explosionLoc = GetActorLocation();
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), DamageEffect, explosionLoc);
currentState = ItemState::BROKEN;
SetLifeSpan(1.0);
}
else
{
currentState = ItemState::PICKEDUP;
PickUpMeshComp->SetVisibility(false);
SetActorEnableCollision(false);
}
break;
case ItemState::PICKEDUP:
{
currentState = ItemState::LAYINGONGROUND;
PickUpMeshComp->SetVisibility(true);
SetActorLocation(positionWhenDropped);
}
default:
break;
}
}
}```
I can pick up the item through the client but the box collider doesn't get disabled for the pickup item
and the widget attached to the item gets displayed to all the clients
also, the multicast function is being called only once 😦
Multicast is Server Only
So you need an Server RPC first
Also a lot of this stuff doesn't need a Multicast
The Server should be fine handling 90% of this on their own
The only thing you need to tell the clients is if the picking up actually worked
And that depends on how you manage picking up stuff.
Or rather, what it means to pick things up
E.g. destroying the Pickup when it's picked up
And then there is 2 things that can happen:
- One Time Actions
- State Changes
One Time Actions would be playing a Pickup Animation, spawning a Particle, etc., which can be done via a Multicast. E.g. on the Pickup itself.
State Changes, if you don't destroy the Pickup, need to be handled via RepNotify variables, because hot joining players or players that are out of relevancy range, won't get the Multicast and will not see the changed State.
An example for a State Change is visibility or collision.
@grand mica
@grand mica you have a few structural problems there that will bite you in the arse later on
Thanks for the help. I'll try it right away.
Also, there isn't a player which is the server. So how can I do things from the server
never manipulate UI directly from game code, UI gets changed 10 times during development of the game, you don't want to have to change the game code every time that happens
For Multiplayer you need a Server. either ListenServer, so a Client is a Server, or a DedicatedServer, where the Server is not a Client iself.
also, for things like interaction, its better to make a more generic interface, so that you can pick up an item, fire a cannon or open a door with same set of RPCs
So either way you have a Server
by dedicated server you mean doing all those lengthy setup to make a server without a player?
yes that's an inventory state update
you are right
game code just needs to instantiate a widget and push it a reference to the object its displaying
it gets altered many time during development stage. Actually it's an asssignment stuck up on my ass. So I thought of doing something simle
UI can manage itself from that point, c++ just needs to fire an occasional MC delegate to notify it to update
you are right. But sometimes I am just not very comfortable with c++ in unreal. It has many macros I need to take care of. I am missing native c++ 😭
one thing i really don't miss is std 😄
@thin stratus btw by dedicated server you meant this?https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/HowTo/DedicatedServers/
cos according to the assignment the dedicated server is easy to set up lol
that kinda depends on your hardware spec
ah you can use boost instead 😛
wdym by that?
you need to download and compile the source engine
while a newer high end CPU can do that in 20 or so minutes
you really don't want to be doing it on i3 mobile
according to this, I should have got the option for dedicated server in the drop down menu
ah i have 5600x
not with binary launcher
so i have to link up the source code now
you literally have to download the UE source from epic github
u gotta have it running I think
then build that
so that's a bad way to get multiplayer working
correct me if I'm wrong tho
also, after you download UE source
I had reached till this point until a few members of this group told me they dont mean this dedicated server
build UE and not the entire solution
this one is tougher to build and setup
you'll need about 150GB
they told me a few things have changed from the menu. The assignment is wrt to 4.23.1 version. I think they had different names at that time
it brings the difference in levels tbh 😛
what did you mean by it?
This is to test in the Editor
This is not for actually distributing the game
You can test Dedicated Servers in the Editor with Play As Client in the Dropdown
Or on Older UE Versions it was something something Dedicated Server
But if you actually want to build a standalone DedicatedServer, you need to download the Source code of UE, compile it and then you get the option to actually build a standalone Dedicated Server
i think this is what they meant.
Which you then have to host somewhere so that others can reach it (aka cloud servers that cost money)
Or you provide the players with the DedicatedServers if cheating is not a topic for you
ah, not this I am pretty sure of.
So the tips you shared above for the game. I hope they will work on this "play as client"
Yeah the point is, the Editor stuff is only for testing
You won't get around the source code part
Eventually you need to actually build and ship a the DedicatedServer
Which is not possible with UE downloaded from the Launcher (Or Epic Games Store or whatever they call it by now)
I have downloaded the source code as well but I doubt the requirements. They just want me to test it on editor
Right, if you just need to do something for some test, then it's probably not needed to do the Source Code part
I don't know why you are doing what you are doing, so I expect this to be a project that is supposed to be released in the future
and it came with some awkward keyboard shortcut so you could toggle dedicated server on or off without noticing 😄
ah no, job test assignment
they know I dont have any professional experience with unreal.So, I really doubt setting up dedicated servers is a requirement
o.o luckily never had that
@thin stratus just a small doubt. If I am playing with one of the clients and I call a function which is tagged as UFUNCTION(server, reliable), it never goes inside that function. How can i even multicast if it never enters the server RPCs?
You can only perform ServerRPCs in Actors that are owned by the Client executing it
E.g. PlayerCharacter (Possessed), PlayerController, PlayerState, Components that are replicated on those Actors, or other Actors that the Server spawned and have the Owner property set when spawning to something that is already owned by that player
Otherwise it will drop the call
So an Item in your level can't have a ServerRPC
Or at least it won't work
@thin stratus so if I set the owner before calling this function in PickUp, I guess it should work?
Has to be set on Server side
yeah, through the character
Yeah, but at that point you are already on the SErver
Which makes it redudant to change the owner on the pickup
Cause then you don't need the RPC anymore to begin with
For Interactions Systems you usually RPC in the Character or whatever components on the Character handles this
+- some differences that others might now point out, but Character is a good start for an interaction system
So the Key Press for Interaction would already peform the ServerRPC
And the Server would then handle the Interaction
I see, thanks for it. I'll try a few things out and see how things need to work. Thanks for the help
Your interaction needs to be replicated before passing to the trap. So right after your linetrace, you can check if the actor implements the ObjectInteraction interface, and if it does, RPC to the server there. Once running on server you can pass the actor reference to the interface. You may want to check on the server if the player is actually close enough to perform the interaction as well prior to disarming the trap.
Also, you do not need the Get All Actors of Class or the second interface call - your logic that is in the TrapDisarm interface should be what is contained on the ObjectInteraction interface call.
Hi everyone hope every one is good. Well I have a question I have a multiplayer Hud which displays the health of both players. But I cannot find a way to display real time health of both the player. I would appreciate any help.
Thanks for your reply. To RPC I should create a custom event that runs on server, right?
Not sure if I understand this second part completely, could you share more details, please? Should I keep it all in the same interface function?
I'm just re-sending the message, as I've deleted by mistaken 😅
Hello everyone! I'm stuck with something with Replication and seeking for some help - most likely newbie's mistake 😅
I have a game trap (BP_Trap) in the world, and it can be disabled by a lever (BP_Lever). The lever is activated via Interface from a Linetrace that comes from PlayerController - and it requests the trap disarm through interface as well.
My problem is, if it's the client that disables the trap, the variable is not modified on the server. How can I fix this? I've tried changing image 3 to CustomEvent RunOnServer, but then the client can't disarm the trap.
I'm uploading these images:
(1) LineTrace on BP_PlayerController
(2) BP_Lever casting Traps to disarm
(3) BP_Trap checking and disarming itself
Yes, RPC to Server = Run On Server event.
Your interface itself would be running on the actor needed already (or at least, I would hope so) so there's no real point in getting all actors of class and running the interface on all of them.
So if the actor you're interacting with is a BP_Trap, then it would disarm it.
Thanks, @sinful tree! 🙇♂️ Following your tip I was able to do that first interaction. 🙌
That's the thing I'm getting it. The player interacts with another actor (BP_TrapDisarm), and then this actor requests the BP_Trap to disarm based on its ID
Ah ok, that is a bit different then. I suppose you could still work with what you have for the interface then.
Yeah, I'd love to find another alternative for that cast, but couldn't think of a way 😅 And since this is the prototype, it will work for now.
If you have other suggestions, please point the way so I can research for the future 🙏
Right now, what I was thinking was to use Tag instead of a variable, so I'd "Get All Actors with Tag", which I think could reduce the amount of actors request
https://media.discordapp.net/attachments/221798862938046464/950839788766896228/unknown.png
create session isnt working
this error msg is from the output log
does anyone know whats the problem?
or atleast know anything i can try
Going to check on quehes, thanks!
The events are handled on the player controller as regular events, and they do have a "response" to signal they are done.
if I'm replicating a UStruct and I change only one property in the server, does the entire struct replicates? Or only the changed property?
Changed property
Hello, So the pick up of item worked well on all clients. I made a server call on the character and through that call I called a multicast function on the item.
Right, there's only one issue which is left. It's the user widget. I read user widget don't replicate at all but there are two things which are happening atm.
- the inventory widget which I have added to the view don't update the item's text into it.
- when the overlap event triggers, the items switches on a hud. For eg. "Press F to pick up Statue" but this gets replicated on all the clients. I don't even know why. I have made these calls as client only but it still happens. Here is my code:-
UFUNCTION(client, reliable)
void InteractAtm();
void Aaissgnment51FarmCharacter::InteractAtm_Implementation()
{
if (currentIteminRange)
{
InteractWithItem(this);
}
}```
UFUNCTION(server, reliable)
void InteractWithItem(Aaissgnment51FarmCharacter* pawn);```
void Aaissgnment51FarmCharacter::InteractWithItem_Implementation(Aaissgnment51FarmCharacter* pawn)
{
if (pawn->currentIteminRange)
{
pawn->currentIteminRange->PerformAction();
if (!pawn->currentIteminRange->isDamageable)
{
if (pawn->currentOwnedItem != nullptr)
{
pawn->currentOwnedItem->positionWhenDropped = GetActorLocation();
pawn->currentOwnedItem->PerformAction();
}
pawn->currentOwnedItem = currentIteminRange;
ChangeInventoryText(this);
}
}
}```
UFUNCTION(NetMulticast,Reliable)
void ChangeInventoryText(Aaissgnment51FarmCharacter* pawn);
void Aaissgnment51FarmCharacter::ChangeInventoryText_Implementation(Aaissgnment51FarmCharacter* pawn)
{
if (currentOwnedItem!= nullptr)
{
auto temp = InventoryHUD->GetUserWidgetObject();
UinGameInventory* infoWid = Cast<UinGameInventory>(temp);
infoWid->SetCurrentItemInInventoryInformation(currentOwnedItem->itemType);
}
}```
UFUNCTION()
void OnOverlapWithItems(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION()
void OnOverlapEndWithItems(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
void Aaissgnment51FarmCharacter::OnOverlapWithItems(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
auto InteractableItem = Cast<APickableItem>(OtherActor);
if (InteractableItem != nullptr)
{
currentIteminRange = InteractableItem;
InteractableItem->ShowHUD(true);
}
}
void Aaissgnment51FarmCharacter::OnOverlapEndWithItems(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if (currentIteminRange != nullptr)
{
currentIteminRange->ShowHUD(false);
}
}```
sorry for bothering you guys
For #2: Not 100% sure, but if OnOverlapWithItems is being detected when a player's character is overlapping with an item, then all clients could also see that overlap happening, which means "InteractableItem->ShowHUD(true)" would trigger on all clients. This could potentially be fixed by adding a "if (IsLocallyControlled())". You'd probably want a similar check on the OnOverlapEndWithItems check too, otherwise the UI element may disappear when you don't want it to when another player leaves.
thank you so much. It's fixed. Now just one of them remains 😛
any idea why my widget isn't getting updated?
My guess would be that currentOwnedItem isn't replicated. Updating the inventory display shouldn't even need to be handled as an RPC, let alone a multicast. If currentOwnedItem was set up as an OnRep variable, then with the OnRep function you could again do a IsLocallyControlled check, and update the inventory from there.
why does it need to be replicated. It's a class member, it should be a separate variable for each client
If you're setting a variable on the server, and you intend for the client to use that variable in some way (including for displaying information) then it needs to be replicated.
is there a way to set a variable on the client itself?
By setting the variable while running on the client.
But by doing so, no one else knows thats what the client has.
if you want to trigger the OnRep, you can do struct = struct.
so they can't even render it the item is visible in their hands?
Is there another term for "quehe"? cause i can't find anything about them
Each copy of the character will have its own value set. Replicating is meant in terms of copying the value that the server has of this specific instance of the object and letting clients know that the value for that particular instance of the object has that value.
So you have a character, I have a character. We both have our own currentOwnedItem variable.
You (through a server RPC) let the server know that you want to pick up the stone sitting on the ground. It sets your currentOwnedItem to stone. If it was marked to replicate, then your client would then know that your currentOwnedItem is stone, and my client would know that your currentOwnedItem is stone.
I still haven't picked up anything on my character, so my currentOwnedItem is still nullptr.
queue.
gotchyaa. I should first replicate these variables now.
In a very basic sense, your queue could just be an array of "requests" that you want to make.
When you want to make a request, you add it to the array, and check if a "request processing" boolean is true.
--> If so, don't do anything further for now
--> If not, set your "request processing" boolean to true, get the request data at array 0 and submit the request with that data.
When you receive the response back, remove the item at index 0 of that array.
Check the size of the array is > 0.
--> If so, make an event that triggers the same "get the request at array 0 and submit the request", basically looping it.
--> If not, set your "request processing" boolean to false and no further action required.
i was thinking in something like this, but i tought maybe there was already a function in UE4 for things like this.
Thanks!
That one did the trick and it was really simple, thanks!
Having a listenserver issue. In my playerstate, I have an RPC to update a variable. This variable is set to replicate with ReplicateUsing= (repnotify). Works fine for clients but this function doesn't get called serverside when the listen server is running it.
I could manually call the replicateusing function which DOES cause it to execute on the server .. but it also executes TWICE on the clients now.
Any good way around this?
You should have an updating function or binding to call. Call that from the OnRep, and call it after setting the new variable. Clients run it from the OnRep, server runs it right after variable set.
The problem is determining if this is the server updating a value for itself or the server updating the value for a client
How so? The OnRep is for the client. The Set function is for the server.
Ohhhh ok, I think I see. Let me give that a shot.
Basically you should have....
void SetSomeProperty(ValueType NewValue)
{
SomeProperty = NewValue;
DoUpdateStuff();
}
void OnRep_SomeProperty()
{
DoUpdateStuff();
}
void DoUpdateStuff()
{
//Called from OnRep on client.
//Called directly after variable set on server.
}
Gotcha. Turns out I was doing something like that already .. but with an extra step that called a Client function which then called DoUpdateStuff. So even when I called it directly on the server, it then ran it on the client again. It needs some cleanup.
So im spawning a vfx on a server and client through a multicast rpc thats being called from the locally controlled player. The spawning of everything works just fine. But how would I go about being able to deactivate that same vfx so that it deactivates on the server and client?
That sounds very state based, good case for a simple replicated boolean or something.
Alternatively, could change the multicast to have a boolean.
Depends on the case and how long this vfx is. If it should turn itself off don't worry about turning it off. If it lasts for a few seconds, maybe change the multicast parameters to be able to call it with a "Turn on/TurnOff" state. Else I'd probably do a replicated property to keep track of it if it lasts for some time. Newly joined, or newly relevant clients can be updated this way.
So the vfx is a flamethrower and it just needs to be turned off when the player lets go of the fire button. Which all that architecture is in place for that to be able to happen I just need to vfx to turn off for the server and client. The vfx component that gets spawned in is itself replicated. The basic flow is Weapon Actor Wants to fire -> vfx gets spawned on server and client through a multicast called from a server rpc -> that multicast spawns and sets the replicated vfx variable which should get replicated down to the local/client machine (which it seems to not do). Then for turning it off there is a multicast function that uses that same vfx component spawned and set from the previous multicast and dactivating that. The issue seems to be that when that multicast runs on the client it has no reference to that vfx component spawned originally
Not sure I'd even despawn it personally. I'd just make it a part of the weapon. Enable it or disable it based on the fire state. Reliable RPC the firestate from the owning client to the server. You can possibly let firestate be set on the owning client locally along with the RPC to server and firestate can replicate to non owning clients and enable disable the effect on any non owning machine that way.
That previous message probably didnt make much sense, so I'll try and do a better job of explaining with pictures and whatnot. The first image shows the replicated vfx that I mentioned. The second is how the multicast gets started when the player fires. The third image shows the actual multicast function that ends up getting called where the vfx gets spawned and that replicated variable gets set. I think my issue here is that this will only ever let me have reference to one of the vfx that end up getting spawned and not the client and servers.
So okay i think i see what your saying conceptually. But I also dont think i see how you do that. Since from what I understand to be done correctly a vfx needs to spawned in a multicast to show up on the client and server.
This is a specific implementation. I'd probably run this through some base classes. But the basic straight forward idea is this.
.h
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
UNiagaraComponent* FlameThrowerEffect = nullptr;
UPROPERTY(BlueprintReadOnly, ReplicatedUsing=OnRep_FireState)
bool FireState = true;
UFUNCTION()
void OnRep_FireState();
void UpdateFiringState();
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UFUNCTION(Server, Reliable)
void ServerSetFireState(bool NewFireState);
void StartFiring();
void StopFiring();
.cpp
void AMechBase::OnRep_FireState()
{
UpdateFiringState();
}
void AMechBase::UpdateFiringState()
{
if (FireState)
{
FlameThrowerEffect->Activate();
}
else
{
FlameThrowerEffect->Deactivate();
}
}
void AMechBase::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION(AMechBase, FireState, COND_SkipOwner);
}
void AMechBase::ServerSetFireState_Implementation(bool NewFireState)
{
FireState = NewFireState;
if (GetNetMode() != NM_DedicatedServer)
{
UpdateFiringState();
}
}
void AMechBase::StartFiring()
{
//Call this on owning client to start shooting
ServerSetFireState(true);
FireState = true;
UpdateFiringState();
}
void AMechBase::StopFiring()
{
//Call this on owning client to stop shooting
ServerSetFireState(false);
FireState = false;
UpdateFiringState();
}
To sum up; when I do the spawning of the vfx this way and I go to deactivate the vfx through a multicast like shown in the image then it only turns off the vfx on the server side and doesnt ever on the client because the client only ever has a NULL reference for its "ProjectileVfxNiagaraComponent"
oh wow okay I'll definitelly pick apart that file and see whats different than what im doing
Have a property. Let it replicate to anyone but the owning player. Use that to enable to disable a default system on the weapon. Set this locally on the owning client when telling server to change. Tell server to set it and also to update it's state. Everyone gets updated, it's stateful for newly relevant clients. And it should feel reactive for the owning player.
Mostly sure I got all of that correct. Not in a networked project at the moment. 😄
So in this case is the FlameThrowerEffect being initialized in the constructor..?
Yeah, Default component on the flamethrower. You can set the particle emitter it uses from BP.
No point continually destroying and respawning an emitter that is consistently reused.
So youd be setting that component in the constructor with the usual spawnDefaultSubObject method to give it that component?
Yeah
and then set the emitter in that created blueprint in there.
okay that makes more sense now
Like I said, I'd probably do half of this in a base weapon class like the start and stop firing, and the firestate, etc. mark them virtual. Might not even make a flamethrower C++ base since the UpdateFiringState can just be a BluepintImplementableEvent to start and stop the emitter.
Depends what else you need I guess.
Yeah it definitely does, I appreciate all the input though, I'll adjust our imlemimentation of how the "on/off" logic to match your example since it makes much more sense to do it that way since even spawning it over and over doesnt make much sense to begin with
Are you not able to deactivate the component in the constructor right after creating it?
Your component doesn't actually exist at that time. That call is more of a registration to create a component.
It does, but doesn't, so to speak.
If you want to disable it early, consider PostComponentInit or OnConstruction
Thank you! I wasnt actually aware of PostComponentInit
just to clarify one last piece c++ if (GetNetMode() != NM_DedicatedServer) { UpdateFiringState(); } This chunk here is meant to update the firing state on the server side if we arent a dedicated server correct? Aka this is what will be responsible for turning the vfx off on the server?
On/Off, yeah. Cause server won't fire the OnRep
In my game mode OnPostLogin, I'm spawning a player and possessing it. Then I'm getting all my Player Controllers and telling each of them to update their hud with the new pawn that I spawned via client RPC. Clients are getting an invalid object. Do I need to have the game mode get the PlayerStates and tell them to update? How do I get the new pawn ref to them?
RepNotify my man
Wait I'm actually a mental brick
Feel really stupid for asking this, but why is it that we don't use a ROLE_Authority guard when we call CreateDefaultSubobject in the constructor.
People always teach that you always only spawn stuff on the server and have it replicate down (unless prediction), so why is is different in this case?
In my Event OnPossess inside my PlayerController, I have a value that is RepNotify. On the RepNotify I'm getting my GameState, but it's invalid. How could a client's GameState be invalid?
I'm looking at the Network Compendium now and it seems to me like the GameState is owned by the server, all the clients can see it but don't have ownership.
I'm not sure if this helps at all but my guess here is that the GameState is invalid because the local PlayerController doesn't actually have one to speak of.
Does the Host player also return invalid?
GameState is how a client interacts with a game mode. Any info that needs to be accessible to clients about the overarching rules are supposed to be here. If I throw in a delay, it works. But the game state should exist/replicate before a random value I set inside the onpossess of my player controller replicates.
Right. Wasn't sure if you were just accessing it in a weird way or something.
If a delay makes it work then my best guess here is that you have some order-of-operation issues.
Like trying to access it before it is actually created, which would naturally make it invalid.
How can a PC exist and replicate to a client before the game state does though?
Though I'm pretty sure stuff relating to players should be made afterwards anyways.
I mean that's what I thought but if a delay makes it work?
Although
From what I was asking in #blueprint it does seem like the host player is made before any OnBeginPlay triggers in gamemode/gamestate stuff.
So... depends largely on what you're doing.
I believe it's because the player controller needs to exist before the client "joins" the game. Once it joins, then the gamestate can replicate to the client.
I could be wrong tho 😛
I'm testing with a client joining through steam. so the host player already exists, the controller has to exist for it to possess something.
My logic to get game state is triggered on that repnotify
I think Datura might have the answer there. Host' controller is constructed resulting in its pawn being constructed and possessed which would trigger the OnPossess event before the GameState is constructed?
So we've already possessed a pawn. and our game state still isn't valid yet?
This feels stupid, but maybe I should just make a rep notify bool or something inside gamestate and on that notify then do my game state check/logic that i want to do.
Okay test failed, I can't print from a construct. I wanted to see what triggered first, a host OnPostLogin or the GameMode constructor. I know the OnBeginPlay starts after PostLogin
Oh wait
Are you working with GameMode or GameState here?
"Play as Client"
Player controller exists before Gamestate.
LogBlueprintUserMessages: [BP_MyPlayerController_C_0] Client 1: Client Playercontroller
LogBlueprintUserMessages: [BP_Gamestate_C_0] Client 1: Client Gamestate
"Listen Server"
Gamestate exists before Playercontroller
LogBlueprintUserMessages: [BP_Gamestate_C_0] Server: Authority Gamestate
LogBlueprintUserMessages: [BP_MyPlayerController_C_0] Server: Authority Playercontroller
GameState, because GameMode isn't valid to clients
That GameState is for the host though right? Don't they have both?
I'm running a listen server with a host player and joining that server through player input. That should mean gamestate exists before right @sinful tree ?
I'd go with what Datura is suggesting honestly. You might want to test this with an actual build as sometimes the engine can be a bit funky with this stuff.
I'm testing with packaged game
Aah okay
The gamestate may exist on the server, but it has to replicate to any clients when they join.
And player controller exists before gamestate on clients.
Are there like...async tasks that can loop until my gamestate is valid? or do i need to write that myself?
or a not crappy way to wait until my game state's valid
So here's the thing that I'm not entirely sure about....
When you normally possess a pawn, the player controller already knows the pawn they are possessing. This can be accessed easily at any time by doing GetControlledPawn. It may not be the type, but it's not something that you would need to replicate from the server.
Out of curiosity
So that OnRep of the pawn isn't really necessary as the playercontroller will already have easy access to the object it is possessing.
What is it in the gamestate that you're trying to do when the client joins?
Would the Delayed Start thing help here?
I don't know if Delayed Start prevents players from possessing their pawns
But it might be worth giving that a shot?
Yeah the OnRep of the pawn was just a trigger to let me know that the client side possession has finished and that I can attempt my game state stuff
since we've established that the gamestate won't be valid yet, i reverted it
Ok, so the thing is, you shouldn't have to care about the client receiving the replication for things to proceed really. Your gamestate should do as it needs on the server without input from the client.
Unless of course, you're wanting client input for something 😛
What I'm trying to do is get the player pawns of each other character in the game. To do that I need to get the game state and get everyones controllers(through player states) and then their pawns. Which requires the gamestate to be valid.
To do that I need to get the game state and get everyones controllers and then their pawns.
This would not be possible on clients as player controller only exists on owning client and the server. So this sounds like it would be a server-side operation, no?
I edited my comment, I'm getting everyones player state, then their pawns through that.
You still say controllers though
I'm not getting controllers
Okay so to repeat my question since it was ignored in Blueprints.
Is there a way to delay a host player's OnPostLogin to only fire after GameState has done its OnBeginPlay stuff?
Each player (human or AI) has a faction associated with it and I want all the AI ones (determined by the map selected) to be loaded into the list before players.
Human players are added on PostLogin which means host always goes to top of the list 😦
Is reordering the list a possibility? Or is there some other functionality that is required?
I could maybe do a reorder. Its a list of structs so I can just add in a "is human player" boolean I guess
Set Array Elem should work pretty well for it
Ok, but then that should be easy as just using Begin Play on GameState with a HasAuthority switch and running on the Remote path - that path would indicate the GameState is valid on the client. You could do something like this even.
Yeah I guess I'm not sure why I decided to do this inside my player controller
Welp, tried adding the player factions to the end and
Tbf I was doing it through one of the Match Start or something like that funcitons
Could do a queue for the players.
Yeah that's probably a better way to do it
So far so good, will need to do more thorough stress testing later to see how consistent it is over a network though.
I duplicated this and somehow I'm getting 0 valid playerstates. I ended up solving this with a timer in the player controller that checks until the state is valid
Has anyone tried something like Networked Object Pool? Any idea about that?
Somehow..my player controller's Event On Possess is no longer firing for clients, but they're able to possess the pawn and control it...
missing super call somewhere in your c++?
There is no C++ 😦
wrong controller bp?
Nope. I've been working in the same file. basically just changing what happens after my authority switch..and suddenly it stopped working
You're probably no longer around now, but I was able to implement the design idea you laid out earlier with how turning it off and one for the server and client worked and it worked flawlessly, so thankyou very much for that knowledge. My only other question is that that lets say the client picks up the flamethrower and that player has the appropriate reference to that flamethrower it picked up. The vfx still spawns at the origin when its fired and i've been struggling to figure out how to tell that vfx move to the player's who picked it up muzzle location and show up there for the local machine and the other player. I've been playing around with the attachToComponent for the niagara component and I've only been able to get it to show up in the correct spot on the local machine while the other player always sees it at the origin.
Are input events replicated at all?
No input is on the client side
I'm convinced unreal hates me. So we've packaged our dedicated server and quest client numerous times. We've been doing it for two weeks without issue. After setting up a video chat plugin that has nothing to do with the server, we can no longer join the server. We just join the server with an IP connection. This has worked flawlessly well over a hundred times. Now when I go to join I get "no game present to join for session" and it immediately crashes the app.
Server log just says join request, no game present, join succeeded, then closing open connection and disconnects
You generally shouldn't need any extra setup for this unless you're dynamically changing meshes in the skeletal mesh on the weapon. Once the mesh is set , you just have to call attach to component once with your socket name for the muzzle.
Sorry for the crap no discord on this machine.
@somber glade if you only use IP connection, then the session stuff should be unimportant
Also the client log would be important
So any idea what's going on here? I haven't messed with anything related to the connection.
Client is a quest
Let me see if I can find a lot
Log
Need the log, otherwise I can only use my crystal ball
Any idea where those are kept on a quest?
Nope
Found it I think. Let me see if I can get it off this machine
I will have a look at it once I'm in the office. Just woke up and only on the phone
Maybe you can see something in it yourself already
Ah. Hmm... It may be a sound field
Yeah I've got a bunch of exceptions about binaural spatialization not found
Yeah not sure what that is hehe but glad you found a starting point
After about 10 of those it starts throwing the no game present error
We went back to an older version for now. And still same game session
If you aren't using sessions then just ignore it
But it works.
IP connections dont need those
So it must be the audio crash
Yeah it is
how would you go about adding features to the example ue4 shooter game? I mean, let's say you add something "simple" like wall jumps or jetpack movement, how do you make sure it's handled correctly multiplayer-wise and especially in case of network lag?
I don't think it is related to shooter game at all except for understanding how it works before adding your own implementations over it. It is more related to how things are actually done in multiplayer and that you will eventually learn by practicing. For efficiency you will have to follow best practices like minimum data transfer over the network and less use of multicasts by more focusing on replicated state for various events. You will eventually learn on the way so just start playing with various things and see how it works.
https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/Actors/ReplicationPerformance/ You can check this & find various other blog posts for what best practices you should be using.
Thank you, I've never done anything multiplayer and I was trying to figure out "quickly" what are the key parts you have to add to "normal" code to make it multiplayer, I read a bit of the basics about replication, but still I have to understand if ue4 handles automatically errors at least for movement, or if you have to do your custom checks for everything
If you are beginning up with multiplayer then I won't recommend making a project over Shooter Game as it uses replication graph which might confuse you with some stuff like weapons added as depended actors over the player. I would recommend setting up a new project and try to make the shooter game on your own taking its animation and other stuff, that would help.
A simpler form of shooter game*
You can check ReplicateMovement on any replicated actor and it's location will automatically be replicated to all the clients. Also the character movement component specifically for character have some extra inbuilt client prediction stuff which handle much on its own so you don't have to worry much about it when you are starting out.
@fathom tinsel Thank you, I am trying get up to speed as fast as I can, I got this task for an interview so I have not much room to learn at a normal pace. And they specifically asked to handle server-reconciliation cases, that's why I was asking about any particular pitfalls on the topic
hey, does anyone know how to get the MaxNumber of players when you play in editor when you play as listen server/client with more than 1 player?
I tried checking the AGameModeBase::InitGame options param but that's empty
There isn't one in Editor
Can try AGameSession::MaxPlayers but it'll just be whatever the config default is I imagine, and probably won't even be respected.
I guess I'll just wait a few seconds before changing the match state if it's play in editor then
Are 20 replicated variables (replicating to all) bad for a game which wants to have 60-80 in game players?
How many replicating variables(without replifetime condition) should make me worry about it?
Depends how often they change and their size
Size in the sense whether they pointers or primitives?
If you have to tell in general. What number of replicated variables won't worry you at all?
There isn't one
And generally speaking if you need them, you need them
Don't replicate anything the clients can compute themselves and you'll be fine
Hmm you are right. And setting up a replication graph can further help right if there are a lot of variables?
Helps with server CPU time, IIRC
Thanks
Hey,
Something weird is going on. My character's basic movements have stopped replicating on other clients. What could be the issue?
I think the basic movements are replicated by default. Here are the properties
weird, when i run the game through "Debug Editor" mode, it works different from running it from the editor. I have compiled the latest code in editor as well. This is weird
how are you starting the editor?
if you made any changes, I think you need to compile Development Editor | win64
I think the launcher one or uproject runs Developement editor
but things are running differently
change the build configuration to Development Editor in VS and run debug from there? see if you get the same issue as you when you run from launcher maybe
let me try
this one runs exactly like the one I was running from VS
so I can assume this is the right version of my work?
try running the one from the launcher again
ah they are working in the same way
and the basic movement of the character is not replicating 😦
did you mean that the Development Editor version runs the same as Debug Editor and the movement is replicating fine?
also, anything in the logs?
yes both are same now. Both from VS and launcher.
NO the movement is not getting replicated on other clients 😦
did you override anything in your movement component class?
thanks for the help tho
does anyone know a good tutorial/blog/wiki that explains Beacons and sessions and how to use them together. I want to create a party system and lobby system, multiple parties (i.e. a party of 5, a party of 3, and a party of 2) can join the same lobby (if it was a 5v5)
Possess is meant to be run on the server and it is what calls OnPossess and looking at the engine source code, there's nothing indicating that OnPossess event gets replicated to the client.
I tried this before too lol, I think you can know when the player possess pawn with OnRep_controller on the pawn or OnRep_Pawn (I think, might be something else) on the controller
Hello,
https://blueprintue.com/blueprint/gacuue7p/
I have this blueprint for an actor with 4 triggerbox, the code itself works fine.
For each triggerbox (down, up, left, right) i have the same code. For all 4 they work on the server and client,when only one is triggerd, but when two triggerbox are triggerd, for example up and down then only one works on the client, on the server both work. Someone an idea why on the client only one?
Hi Guys, I have multiple "Player Start" set in my topdown level. But only the server spawns with the camera facing the correct orientation, all the clients spawn in the correct location but facing directly towards their fronts. How to fix it?
Hey folks. When using Fast TArray Replication (with NetDeltaSerialize), it's possible to override methods for client side notification of changes (PreReplicateRemove, PostReplicatedAdd, PostReplicatedChange). However these methods are part of the struct itself (the one derived from FFastArraySerializerItem). If an Actor class implements a fast array serializer, can the actor class be notified of these changes? Since the struct has no concept of owner, it doesn't know who the owning actor is, but I need the client side rep notifications to be accessed by the actor
Hello there, could anyone please help me. I'm developing a dedicated server using third person template, but every time when the second player joins the server, it sees 2 characters overlapped for all the other previously joined players like the screenshot. Could anyone help or point me some documents about this issue please?
You can add a property to your struct and have your PostInitComponents set it. Then your struct has access to it's owner.
Alternatively, I'm semi sure you can add delegates to structs that the actor could bind events to.
do you mean just adding a UObject* property and manually assigning it to the owner?
UObject*, AActor*, whatever you need.
I ended up realizing that later and used a client rpc to get what I wanted done. Thanks for your help last night.
How accurate is the ExactPing from the playerstate for prediction calculations?
Ping isn't accurate, so it's good enough
oh! I was thinking about sending the timestamp every time, but if this inaccuracy is somewhat acceptable... I can simply use it, or would you recommend something else?
Ping is inaccurate by essence
It varies a lot
ExactPing is thus good enough
Oh the variable is called ExactPing but I haven't seen how it is calculated
i know for a fact that this ExactPing replaced an old variable called ExactPingV2
so I believe the algorithm underneath has evolved quite I bit
Oh I see, you mean CompressedPing vs ExactPing, right? 😄
I mean ExactPing in PlayerState is good enough and there's no need to go into more details
right I got a bit confused by the statement of "Ping isn't accurate" 😄
thank you Stranger!
Ping is not an accurate physical value
It's a variable that fluctuates permanently and is the sum of multiple values
Both your client and server performance have a large and direct impact on ping for example
right, that I understand, thus asking if the UE implementation for pin was sufficient enough
it is good enough, just remember to divide ExactPing by 4 for the correct value
won't need to in this case, using directly ExactPing instead of CompressedPing
but good having it in mind! Thank you a lot Stranger
it's already dividing by 4 in the early calculation as far as I could see
I'm on UE5 BTW
I have multiple "Player Start" set in my top down level. But only the server spawns with the camera facing the correct orientation, all the clients spawn in the correct location but facing directly towards their fronts. Anyone knows a solution? I've tried several different approaches like possesion, forcing camera view, etc and nothing seems to work
Is this happening in play in editor?
hi all, lets say my rounds have a time limit. Is it ok to always replicate a float which represents time left in round? or is that a waste of bandwidth?
it's generally a bit better to use a time value of when the round time will expire
the game state replicates a server time value to clients by default
like everything: it depends™
but if there's a more efficient way of doing it then I would say avoid, like in that example
makes sense thanks
Whats the trick to getting the game mode to interact with clients properly?
I have my game mode handling team assignments and a lockdown event system.
I've basically set everything I can find to replicate everywhere, but I'm still not getting the same results on the client side as the server
How are teams assigned and where does that data live?
GameMode doesn't really interact with clients at all. If it has necessary things to display, it'll replicate them through GameState or other managers.
When each player joins it registers itself in an array in the game mode. Odd numbers are team one, even team two
Or vice versa
It's not really displaying so much as telling server owned actors to do stuff, but it isn't replicated on the client consistently.
Like one is a wall of cubes being scaled with the music spectrum frequencies. That replicates, but it doesn't replicate when the cubes are supposed to stop
Yeah, do you mean it will work in the packaged version?
The Clients do not have any copies of any game mode. Replicated events can never work there, and if you think they are working you mistook something.
What is probably happening here is that you are spawning replicated actors, in which case the actors themselves are sufficiently notifying clients of their existence
But you don't know how to send messages down to clients otherwise
Creating replicated actors is probably the easiest "replication" setup there is, but other types of messages will require a more elaborate understanding of Unreal's framework
Ok, so move everything to the game state instead?
And correct. I have a fuzzy understanding of how replication in unreal is handled
the spawning of actors can stay on Game Mode
that will work anywehere the server calls it
Sending information to those actors should occur on the actors themselves, or you could use GameState as a decent alternate
Clients would (generally) get those updates (Multicast events I presume), though replicated variables tend to be a better way to send messages when possible
My issue is I have several things that need to sync up for the lockdowns and I needed a manager to do that.
But I'll try game state instead and I'll make sure the events are multicast and the variables themselves set to replicate
Hey guys. On a multiplayer game how to a get the player? instead of it
this is just a checker to see if it is the a player.
To quote zomg
Some places have different ways of getting the relevant player```
In other words, we need more context as to where you're trying to get and use this value.
its a collision box, I want to check if it is a player.
if pawn == overlap actor do>
Do you want to check if it is a specific player, or any player?
So then you can check if it is a player by getting the "Other Actor" on the overlap, casting to pawn, and checking if player controlled.
You already have that array, its the player array
I wanted to avoid casting but its a good solution. Thank you
There are zero reasons at all why you should avoid casting to Pawn class for this check.
No casting required, but this is probably less performant than just casting to pawn 😛
Also worse in regards to the reason for avoiding casting. 😄 Cause now instead of just Pawn, you have Pawn, PlayerState an GameState involved.
yeah I did the first case. It is a movable object, it will track all characters all the time, thats why. But its a pawn cast, so, I think its all good.
Can anyone give me some insight as to why I don’t see this object on my clients?
It’s a skysphere, and I’m trying to spawn it from my level blueprint
Try using AlwaysRelevent.
Components may for some reason not allow it to be relevant by normal functions. Skysphere sounds like it'll always be relevant though.
I’m seeing it on the clients now! Thanks for the tip
When using Seamless travel, should the Transition Map be a completely blank level? What happens if you place a static mesh or actor to indicate loading? Would that be better as a widget instead?
im trying to make multiplayer game and this is the code for joining a session
i tried open level and execute console command and both of them are not working
idk what im doing wrong, in the tutorials they said to append "Open" and the "IP" in execute console command
or just open level and put the IP as the level name
The last node has to be a valid case-sensitive name of one your levels, not an IP.
Like this, I think.
you can also use Listen for the options if its not a dedicated server
it just opens the level
What are you trying to make happen?
joining a session?
^
Dedicated or listen?
uhhhh, a session that someone created? ¯_(ツ)_/¯
So if there's already someone else creating a session, you can search for available sessions then pass that session into a Join Session node.
Are you using the Advanced Sessions plugin? https://forums.unrealengine.com/t/advanced-sessions-plugin/30020
Advanced Sessions Plugin Updated 08/19/2021 Plugin now has two modules, one is AdvancedSessions and one is AdvancedSteamSessions, this will allow me to tie more Steam specific functions in without forcing the steam subsystem to be packaged out with projects that don’t want it. New Parvan/Metahusk has made a menu example project that also sho...
like this?
nope
It gives more options, but it isn't necessary.
it still does nothing
There's no incoming pin connecting to the Find Sessions so it won't ever start.
Which online subsystem are you using? By default you can't host a session over the internet without one.
but why does tutorials use this method?
and why isnt it working
I'm not familiar with that method, I'm using the advanced sessions plugin with the Steam subsystem.
I have a function that (when called in a BP) is only returning the expected value when called in a RPC
UFUNCTION(BlueprintCallable)
FORCEINLINE AEquippable* GetEquippedItem() const {return EquippedItem;}
🤦♂️ no reference to var in GetLifetimeReplicatedProps
Hey, anyone what the best way to get th number of connecting players to the server?
Pretty sure there's a property in the #online-subsystems that gives you that(Probably OpenPublicConnections or ask in that channel). Or you can return the size of PlayerArray from the GameState, but I would stick to first method, as that's what it's for.
Player 1 (host) can move but player 2 (client) can't - Hi, I'm creating a session with player 1, and player 2 joins that session. But upon joining session player 2 is unable to move or look around at all. It is not getting the pawn I believe
Start with your Gamemode and making sure it's giving everyone the right pawn
Should I change anything?
The host is VRPawn
But I think the client doesn't become VRPawn
@drifting trellis Please use the Job Board for things like this. See #instructions on how to post there.
Hello I have a question:
If I change the CharacterMovement's MaxWalkSpeed at runtime, does that mess with client prediction? Because that's what I'm doing, and client prediction should be smooth, but it's not 😅
Yes
Ok, so I should probably create another variable that's used for the same behavior instead right?
Thanks btw ❤️
That won't fix it, depending on what you're trying to do.
A long term change in max speed will be fine. A sprint won't.
I'm trying to get my character to start running at a certain speed and then gradually accelerate until it reaches a top speed
I'd just tune the acceleration
Or you can do this, which is way more involved
Support the channel through donations. Crypto accepted!
PayPal: https://paypal.me/reidschannel?locale.x=en_US
Patreon: https://www.patreon.com/reidschannel
Bitcoin: 1JFwWHr4X6uAeoZadukzqKjzFBj3Qjy7Sk
Ethereum: 0x2B2Bc108F1Cc0fF899959dEF3226637787d8C3dE
Dogecoin: DNQ33YnhpWoTBokBNVkZP5ub8KTLkpyjpv
Join our community discord!
Discord: https://dis...
Oh yeah I followed at least part of that video 😁
Ok, that won't mess with the client prediction?
No because it's the same everywhere.
Basically if you're trying to change movement stats at runtime that CHANGE has to be predicted
Hmm ok 🤔
@dark edge @still coral I actually wondered how one does networked "Idle to Walk" transitions, that are sort of RootMotion.
Because actual RootMotion wasn't supported unless it's a Montage, or? Maybe they are using Curves in the Animation to adjust the MovementSpeed, which could be synced, but not really predicted.
Yeah, by making that Struct RepNotify and setting it on the Server and then setting the skeletalmesh in the OnRep
You mean like this?
I have a replicated struct in my playerstate. Any idea why the struct isn't replicated to client when changed on server? The struct has one string field and many arrays of enums
UE_LOG(LogTemp, Warning, TEXT("Server switch trait"));
FString enumString = GET_ENUM_STRING("ERuneTreeTraitType", traitType);
FRuneLoadout newLoadout = OwnerHero->KingshuntPlayerState->SelectedRuneLoadout;
for (auto& trait : newLoadout.BrutalityTraits)
{
FString traitString = GET_ENUM_STRING("ERuneTreeTraitType", trait);
UE_LOG(LogTemp, Warning, TEXT("Trait before %s"), *traitString);
}
switch (category)
{
case ERuneType::Brutality:
UE_LOG(LogTemp, Warning, TEXT("Server switch trait brutality to %s"), *enumString);
newLoadout.BrutalityTraits[index] = traitType;
break;
case ERuneType::Willpower:
newLoadout.WillpowerTraits[index] = traitType;
break;
case ERuneType::Survivability:
newLoadout.SurvivabilityTraits[index] = traitType;
break;
default:
break;
}
OwnerHero->KingshuntPlayerState->SelectedRuneLoadout = newLoadout;
for (auto& trait : newLoadout.BrutalityTraits)
{
FString traitString = GET_ENUM_STRING("ERuneTreeTraitType", trait);
UE_LOG(LogTemp, Warning, TEXT("Trait after %s"), *traitString);
}
OwnerHero->KingshuntPlayerState->OnRuneLoadoutReplicatedDelegate.Broadcast();```
The prints tell the trait switch is made but setting the SelectedRuneLoadout to newLoadout has no effect
Found the problem...
The struct was COND_AutonomousOnly
Which is strange that the first time setting it doesn't have any problems
Not 100%. There is no need for the Multicast.
Does the blueprint node "is dedicated server" actually work when you have a dedicate server and how does it know that you are running on one?
it checks the NetMode
is that something that gets set automatically when you create a dedicate server or do we need to set that somewhere? We have a source engine that we're building a dedicate server on , but I think it's returning false on the server
so it should be automatic, not something we need to worry about?
It's automatic and works on my project fine.
okay. weird.
How do you start the server
yeah, you can check for Client (beats Authority checks when client spawns stuff locally), Standalone, ListenServer or DedicatedServer
We get a server crash if the server tries to start the agora plugin and we were getting a crash on that. So I assumed the 'is deidcated server' node wasn't properly returning true on it.
maybe something else.
Topos_RotundaServer.exe /Game/ProjectContent_Topos_Gallery/Level/CustomLevel/LV_Fair_Square/LV_Gallery_FairSquare_ActorType -server -log
well if the plugin can't be loaded on servers, you might need to exclude it from servers
batch file with that in it
As long as the server doesn't try to create the object associated with it (which clients do, its' for voice/video chat) then it has been fine.
but I found out that 'is server' returns true on the client in some situations .
so I switched the check to 'is dedicated server'
so goto c++ and use a preprocessor macro
if you suspect the check is failing
#if !UE_SERVER #endif i think
Thanks, if this doesn't work I'll try that
then the code inside won't even get compiled into server binaries
#if WITH_EDITOR
#define YGG_IS_SERVER() (IsRunningDedicatedServer())
#else
#define YGG_IS_SERVER()
#endif
#if WITH_EDITOR
#define YGG_IF_ON_SERVER if (YGG_IS_SERVER())
#else
#if PLATFORM_COMPILER_HAS_IF_CONSTEXPR
#define YGG_IF_ON_SERVER if constexpr(YGG_WITH_SERVER == 1)
#else
#define YGG_IF_ON_SERVER if (YGG_WITH_SERVER == 1)
#endif
#endif
#if WITH_EDITOR
#define YGG_IF_ON_CLIENT if (!YGG_IS_SERVER())
#else
#if PLATFORM_COMPILER_HAS_IF_CONSTEXPR
#define YGG_IF_ON_CLIENT if constexpr(YGG_WITH_CLIENT == 1)
#else
#define YGG_IF_ON_CLIENT if (YGG_WITH_CLIENT == 1)
#endif
#endif
We basically use this. IsRunningDedicatedServer is Unreal API and it works perfectly fine.
yeah, that code does not depend on NetDriver being instantiated yet
IsDedicatedServer() does
so the issue could be related to the init order
well this is clear as mud... ```[2022.03.11-12.21.24:498][388]LogNet: Welcomed by server (Level: /Game/ProjectContent_Topos_Gallery/Level/CustomLevel/LV_Fair_Square/LV_Gallery_FairSquare_ActorType, Game: /Game/ProjectContent_Topos_Gallery/Blueprint/Core/GM_Topos_Gallery.GM_Topos_Gallery_C)
[2022.03.11-12.21.24:521][388]LogHMD: FSplash::DoShow
[2022.03.11-12.21.24:521][388]LogLoad: LoadMap: 172.30.1.34/Game/ProjectContent_Topos_Gallery/Level/CustomLevel/LV_Fair_Square/LV_Gallery_FairSquare_ActorType?game=/Game/ProjectContent_Topos_Gallery/Blueprint/Core/GM_Topos_Gallery.GM_Topos_Gallery_C
[2022.03.11-12.21.24:521][388]LogWorld: BeginTearingDown for /Game/Levels/AvatarSelection
[2022.03.11-12.21.24:524][388]LogWorld: UWorld::CleanupWorld for AvatarSelection, bSessionEnded=true, bCleanupResources=true
[2022.03.11-12.21.24:525][388]LogSlate: InvalidateAllWidgets triggered. All widgets were invalidated
[2022.03.11-12.21.24:559][388]LogAudio: Display: Audio Device unregistered from world 'None'.
[2022.03.11-12.21.24:564][388]LogOutputDevice: Warning:
Script Stack (0 frames):
Hey, I am trying to setup a VOIP in my multiplayer project. (Steam works fine and all, players can join etc.) and it does not work at all. The debug texts shows that noone is talking, no mic is turned on and that it doesn't even work. In reality everyone can hear the host but the host is deaf and clients can't hear each other, furthermore this broken voice chat works in the lobby which is a separate map with a separate player controller and the voip gets initialized after joining the main map inside the player character blueprint. The VOIP is not even directional sound as all the clients hear the host regardless of distance always from behind. (I have attenuation setup and VOIP settings set.) I have been grinding the forums for 3 days now and nothing works. Does anyone has any idea how it is supposed to work? (UE4.26, AdvancedSessions plugin)
@soft trout as much as I can understand the feeling when you can't find out about a feature or a bug, please don't crosspost in 2+ channels.
Hello guys, I currently have an event that create a widget to every client if the server is actually executing it. Even if i set the event as Run On Owning Client this will be in any case replicated on Server+ All connected clients. Is there a reason for that?
What's the gameplay you're trying to do?
Keep things stateful. What is this widget and why does it appear?
The widget appears because you are in a computer, and to leave the computer you just press a button.
Ill show you the logic i currently have
This event is executed everytime my interaction system, overlap with the Desk.
So you press E, and you actually sit on the chair.
If i try to spawn the widget ad the end of the Multicast event IN Run on owning client, this will spawn the widget everywhere, ignoring the Run on owning client
What is the default dedicated server tick rate, and what is a good tick rate to set them to for the most smooth and stable experience?
^
Found a solution for what i was actually doing wrong.
Spawning the widget inside the player character was a stupid idea, since I was taking every Instance of the Character and spawning it.
This got solved by telling the controller with a cast to spawn it once i was seated, just with an event dispatcher
Hi all. When the client connects to the server, Actor calls Begin Play for the client, but the replicated values are not ready yet. Where is a safe place to get the replicated values?
for example
void AXFoliageActor::BeginPlay()
{
Super::BeginPlay();
for (int32 i = 0; i < InstancesDeleted.Num(); i++)
{
UE_LOG(LogTemp, Warning, TEXT("i = %d, instance index = %d"), i, InstancesDeleted[i]);
}
}
but at this time client don't have this variables
For example, can I do it in AActor::PostNetInit?
RepNotify?
@fathom aspen Yes, I'm using that now, I was just wondering if there was another way
Yea seems like a legit way. OnRep works per replicated property and not for all replicated properties combined.
PostNetInit does not seem to work for replicated properties. So I will use RepNotify
void AXFoliageActor::OnRep_InstancesDeleted_Implementation()
{
if (!bInstancesLoaded)
{
HideDeletedInstances();
bInstancesLoaded = true;
}
}
Hey guys, any reason why a replicated component (Decal) Won't show in the client side?
Could a widget reference exist on a player state?
Maybe but bad idea.
Why would a PlayerState care about a widget?
What exactly are you trying to do
What I'm trying to do is on P1 post login, send a message to all other players to create a health widget on their UI for this new player's character
What I tried was on post login ->game mode get all player controllers and client rpc(to player controllers) pass the new character but the character was invalid on clients
sorry not on post login, on possession. but i dont think that's much different
That's Repnotify territory. When at all possible, use STATE and not EVENTS. The state is the Player Array, which exists in Gamestate.
i don't think that the value isn't there yet, I think it's not valid ever
What value? Every players pawn is certainly replicated. That's what you want to keep an eye on
Gamestate has a Player array (array of PlayerStates), and each PlayerState has a ref to their Pawn
This image is from my player controller. If I repnotify Player Pawn, that will let Player 1 know that their pawn is replicated, but how would Player 2 know that Player 1's pawn has been replicated to them?
oh right, so that won't work at all
only the host sees all
yeah I'm just not clear on how Player 2 will know when Player 1's pawn has replicated to Player 2
Begin play on pawn -> Get local playercontroller or HUD -> register pawn? Not sure it's the cleanest but it'd work
I'm sure theres some onrep you can hook into that's cleaner
what is register pawn? is that a node?
That's what you'd make.
"Hey HUD, I'm here, show my HP to the local player plz"
"Hey HUD, I died, delete my HP bar plz"
not clean but it'll work
how can i get the local player controller? just get player controller 0?
This is what I'm looking at. (on begin play of my pawn)
Where are you setting HUD?
Why not just get HUD and do it
depending on if you need references to allies anywhere else
Hello, I have a question, for restricting chat messages to specific players should I implement a Client RPC inside the PlayerController or there is a way to provide a filter/mask to a NetMulticast ?
HUD is created and set earlier in this flow
I'm not clear on what you mean by get hud and do it. thats what im doing
HUD should be automagically created. Or are you calling some widget HUD?
are you using AHUD at all or just handling widgets in your PlayerController?
Oh, yeha I'm not using the default hud, I'm using widgets that I spawn
Where are you spawning them and what's managing them and holding their references?
player controller is spawning it and holding it but it also gives the ref to the pawn
hey, do you have to call BeginSpectatingState on both the server and the client or am I doing something wrong?
Just have the pawn call RegisterMe on local PlayerController at BeginPlay and DeregisterMe at its EndPlay. PlayerController can handle it from there. It's prolly better to use HUD but PlayerController is fine.
There's no reason for a pawn to know about the HUD or even what a widget is really
just needs to tell the widget manager that it exists or is about to not exist
In you widget manager, you'd add the pawn to MyAllies when its registered, then call UpdateUI
which would read MyAllies and add/remove widgets corrospondingly
So the image before the one i just posted work work?
I mean it might but it's gross
Whatever manages the widgets, let it manage them. Just give it the bare info it needs to work
i'm not really concerned with its grossness lol. I can clean that up
that bare info being notifying it when pawns are created and destroyed
Why is anything HUD related even being passed over the network
Oh do you mean it being an RPC?
You can just do this in PlayerController
Begin Play -> Is Local? -> Make HUD
Or do it state driven like I do in my projects.
OnRep HUDState -> Shuffle HUD around
Depends on if server should have any authority over the HUD or not
works GREAT for menus etc too. It's just a state machine.
Pressed Esc Button -> Select HUDState based on current HUDState -> Update HUD
that way Esc can close the open menu and open the main menu depending on if a menu is up or not
Update HUD just switches on HUDState and does its thing opening and closing widgets etc
that would all be dope to discuss about 16 months ago
Decals don't replicate. They are client-side only.
Hello everyone, I am working on a networked project where my decals are an important part of my gameplay mechanic. Let’s say we have a spell cast somewhere a decal is showing the affected area of this spell. I’m questioning myself about the proper way to manage my decals. What I am doing right now is that I spawn the decal on the server whic...
When in doubt, replicate the simplest amount of state. You don't replicate an actual mesh, you replicate its reference or name. You don't replicate a decal, you replicate whatever is driving that decal.
I'd like to tear off an actor on the server and then immediately destroy it on the server. But when I destroy immediately, client's don't receive the TornOff call, i'm assuming because the actor is no longer around for the net update. Is there any way to respond to some post net update event inside of an actor on the server?
I see all the pre net update functions, but I don't see any post net update ones
RepNotify?
It works replicating the actual Skeletal mesh
repnotifies won't be called after tearoff
Yeah you're right. You probably need to use RPCs. Check this: https://forums.unrealengine.com/t/onrepnotify-doesnt-work/356329
Hello. I have a projectile class and I need to let the CLIENTS know whenever an Explosive Projectile explodes. To do this, I decided to use a RepNotify variable bExploded and a OnRep_Exploded function Here is the code: .H UPROPERTY(Transient, ReplicatedUsing = OnRep_Exploded) bool bExploded; UFUNCTION() void OnRep_Exploded(); ...
You probably mean a reference to the skeletal mesh. You can certainly replicate a ref to the texture you're making the decal with, just not the decal itself.
Yes, exactly!
@timber anchor so what exactly are you trying to do? What are you trying to replicate?
Decals of the mouth i sent before, that was attached as a component to a skeletal mesh (Replicated component)
But that's fixed as well! Thanks a lot man 😄
How do i replicate Hierarcy instanced static mesh components?
for instance
i run this event from the server and it runs to all clients
this works perfectly fine on server,
however the client cant see the changes
the server however can see any of the clients run placed blocks
even if you dont use instanced static mesh components any general ideas on how this could be solved are welcome
the actor running these rpcs are owned btw
Make sure the target actor replicates
Hey guys, for a albion kind of mmorpg is there anything on unreal for hosting and traveling between many maps?
That's nothing to do with Unreal specifically. You need to have a backend system that can launch and maintain servers for you, and then direct players to the appropriate Unreal server that's running the map in question.
As far as UE goes, you just need to be able to launch a server build on a server somewhere and let it register itself with whatever system you intend on using.
Just return the ip from this service and use LoadLevel?
Effectively, yes.
Ty
Also if you have to ask, please don't waste your time trying to make an MMO
Make something small and fun, not something big, not even 1% done, and unplayable.