#multiplayer
1 messages ยท Page 130 of 1
Okay, that looks fine, what blueprint is that ran from?
Aha, I see. Thanks for the tips
that Bp is run from the "egeor" npc
whos parent is a "interact_Bp" that has a function for "interactions"*
or rather just holds a "Use event" thats run on the server
@queen escarp That seems correct, so the host is always starting the dialogue from the correct text, the client however is showing a different line entirely from the very beginning? I.E: Is it immediately running AddLine2?
hm
nah that cant be it
acculy when i display the text like this it fires like 1-2 seconds after the server displays it
like thers some delay ./
What is the callback for a client that disconnects from a server due to server crash or similar?
@queen escarp You mind if I DM you?
Sure
I've had to add you as a friend since server DMs are off
Did you check UGameInstance::HandleNetworkError() or UEngine::OnNetworkFailure()?
yes, just found them ๐
Welp, this elegant solution has been foiled by a replication race condition, specifically regarding JIP, the actors in the FFastArraySerializerItem have yet to replicate when the client receives the initial state so they're null pointers, is this comment on the forums (back in 2018) still the way you'd recommend solving this? Just have the attached actors call the necessary function client side from BeginPlay or is there a nice contained way within the parent actor to ensure they replicate out before the FFastArraySerializer?
https://forums.unrealengine.com/t/replicated-actor-passed-to-a-multicast-rpc-function-is-null-on-clients/111451/2
Not possible to garauntee they arrive first. If the actors are replicated, you will get PostReplicateChange() events in the FastArraySerializer
They are indeed replicated, would I be correct in assuming that removals from the FastArraySerializer would also fire PostReplicateChange or is that purely for when existing items are updated?
PostReplicateChange() is only when an entry that's still present is modified, so a replicated UObject going in/out of relevance would cause it to trigger
Remove is purely for removals
If you're dealing with object refs you pretty much always need to deal with Add + Change
Alright, that might work for me, I've just been using add/remove thus far.
Which part of the source code shows us that construction and destruction get replicated for replicated actors?
I am following the following tutorial and still confused, first why the author did not call Super::Destroyed(), second why the particle emitter was not conditionally spawned based on net role (spawning only on the clients because visual appearence in the server does not make sense).
why is this not working? The default bool value is false. The client sees when the server turns the light on but the server does not see it the client does turn it on or off.
server
client
this fixed it but why
aren't clients supposed to change onRep variables?
Replication occurs from server to client but not the reverse.
i see, okay. Thanks!
I am working on a multiplayer-online based inventory system. For items on ground, server finds the item from the DataTable according to the Item ID and get the widget class containing the inventory widget. Server need to know the slot sizes of the containers inside that widget to create structure info correctly. But server cannot access the widgets in any way. The only solution is for each client to perform these operations individually in begin play. But since it is related to the inventory of items in this place, I do not know if it is a reliable way. Does anyone have an alternative solution?
Why is the server touching the UI at all?
Server shouldn't know or care about it
Because as example i have backpack, vest etc... And all of them has their own inventory shapes
I dont think i can create every inventory shape with codes
I create a widget for every inventory shape, and i use them at data table
Above is vest shape and this is backpack shape
I can construct widget as valid at server side but values are not correct this time
Why does the server care?
don't do anything with widgets over the network
the server shouldn't care about widgets at all
As i said, these widgets hold values. There is no other way to get information about item's inventory
Then your design is screwed up
the item definition (not directly widget related) should store the size of the item
Axe:
InvWidth: 1
InvHeight: 4
Widgets should depend on other stuff, stuff shouldn't depend on widgets. They should just be the view of the game state, not the model
I need help understanding where to store a reference of a client chosen pawn class in a main menu level so that when spawned into the gameplay level it retrieves that reference to spawn that class for the client.
Setup:
1 - Client starts game in the main menu level, main menu game mode, with a main menu controller. Seamless travel is enabled in the main menu game mode.
2 - client chooses a pawn class, that will be the class we spawn for them in the gameplay level. I try storing that reference in the player state.
3 - Client travels to the gameplay level and the new gameplay controller requests for the gameplay game mode to spawn the pawn class that we stored in the player state.
Result = all clients are spawning with the same class despite having chosen different classes back in the main menu....
SaveGame or GameInstance
On join, client can load savegame and send the info to server, or just pull it from GameInstance
Yes, i built the system like that at beginning but then i couldnt know how would i give shape to inventory. I mean if i use Intpoint array to describe inventory shape, how can i get this inventory shape? Should i use widget class and intpoint array on datatable at the sametime?
Depends on if everything is a rectangle or not
If everything is a rectangle then its just width and height
if it's not, then it's more complicated
Everythings are rectangle which is made by slots(square). But it will be tooo complicated, i mean there is size, rotation, X and Y position. Creating inventory shapes with vector array wouldnt be easy to change somethings later
sad there isnt other way
DM'd you
in my AI class I have this in beginplay, but it works only in standalone game
APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
if (!PlayerPawn)
{
return;
}
SetFocus(PlayerPawn);
my bots only focus on me in standalone mode
UGameplayStatics::GetPlayerX should never* be used in multiplayer ๐
That's because you can't reliably get player pawns this way in multiplayer.
- Begin Play on the AI is likely to happen before the Player Pawn exists.
- It's not indicating which specific pawn you're wanting to get other than the first one it can find,.
APawn* PlayerPawn = Cast<AMyCharacter>(GetPawn());
so I need this one to use?
You need something to detect the player in question
some collision /overlap preferably
SetFocus(PlayerPawn); will not work?
You need something to provide the actual PlayerPawn the AI wants to focus
It's a matter of you're not getting the pawn to begin with as it doesn't exist when Begin Play on your AI is being called.
"Begin Play" doesn't happen all at the same time.
post beginplay need to be used?
or delay maybe?
OnConstruct = postbeginplay afaik
You have to think about the series of events that you want to make....
If all you care about for right now is just getting 1 AI to chase the very first player in the game, then yeah, you could delay on the Begin Play a second or two (though this is still not guaranteed to work in an actual real life environment!), then get the player pawn, then set the AI to chase it.
Ok, will try it now thanks )
not working
void ASurvivalAIController::BeginPlay()
{
Super::BeginPlay();
APawn* PlayerPawn = Cast<AMyCharacterBase>(GetPawn());
if (!PlayerPawn)
{
FTimerHandle TimerHandle;
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &ASurvivalAIController::SetFocusOnPawn, 3.0f, false);
return;
}
SetFocus(PlayerPawn);
}
void ASurvivalAIController::SetFocusOnPawn()
{
APawn* PlayerPawn = Cast<AMyCharacterBase>(GetPawn());
if (!PlayerPawn)
{
return;
}
SetFocus(PlayerPawn);
}
GetPawn gets the AIControllers's pawn
I have set my own ai controller for my base game pawn
void ASurvivalAIController::SetFocusOnPawn()
{
APawn* PlayerPawn = Cast<AMyCharacterBase>(GetPawn()); // You're attempting to get the AI controller's pawn rather than the player's pawn.
if (!PlayerPawn)
{
return;
}
SetFocus(PlayerPawn); // So then when this is reached, it's setting focus on itself.
}
AMyCharacterBase is not AIPawn
for AI I have a pawn with different name
AI Pawn is using ASurvivalAIController
AMyCharacterBase is using SurvivalBaseController
GetPawn() returns the pawn owned by the Controller.
So if you're calling GetPawn() within SurvivalAiController, it's attempting to get Its pawn, and you're then trying to cast that reference to AMyCharacterBase
yes and it convert it to pawn owned by SurvivalBaseController?
Casting is a type conversion, not a means of finding things.
GetPawn() is returning the what the AiController knows it has as a pawn, so it would be an AIPawn by your definition.
But it returns it as an APawn reference. By Casting, you're trying to see if that APawn reference holds an AMyCharacterBase reference, if it doesn't, the cast fails and returns nullptr.
if I set the ASurvivalAIController for the AMyCharacterBase AI controller class, will it fix it?
No.
You want to get the Player's pawn, not the AIController's pawn.
GetPawn() in this context would return the AIController's pawn.
how to get the player pawn then?
You can use what you were using before which should return the player's pawn, but again, this isn't what you'd use in an actual multiplayer environment.
UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
yes it works only in standalone game
It'll work if you have it on the timer.
Begin Play doesn't happen all at the same time in Multiplayer.
You're offsetting that, to then allow time for the player pawn to actually enter the game which can happen after the AI Controller's begin play.
yes but even if i make it work, this is not what i want
it will still focus on only player 0
Right, so you need to make some logic to detect a player if that's what you want.
You need a reference to the player in order to set focus on to it.
To get that reference, you need some means of detecting the player.
and store it to an array of detected players?
and if out of range, remove that player from array , right?
If that's how you want to handle it, sure.... You could use an overlap event to detect when a player enters range of the AI, add it to your array, loop through the list of players in the array and find the closest one and focus that target. If you use an overlap end event, you can then remove that target from the array, and again loop through the array and focus on the closest target if there are any, otherwise, do something else.
this gives more control on it, a decent solution
but no idea about performance
lots of bots is listening for overlap events
If I just want peer to peer connections without having to use Steam or EOS, what online subsystem would I use? Or do I need to make my own?
Unreal is build on server to client basis afaik
Beside wont it be an actual headache to do peer to peer
You can use epic online subsystem if you dont want to use the mentioned platform but it might be deprecated ,i dont know. I would use steam for exposure and just because a lot of ppl have it
The good old port forward and ask for their IP address
Or host your own subsystem
Do the eos/steam subsystems deal with nat stuff for you too?
EOS and Steam do NAT yes.
As long as you use the Session system.
Then you'd have to do that yourself with your own subsystem too. Not the best idea.
How do I connect with an IP address?
open ip
Is there a way to spawn something like a PlayerState on the server but not have the actor initially replicate to clients (to be replicated at some future time)? For clarity setting SetReplicates(false) doesnt seem to stop the actor channel from initially opening
Maybe if you SetReplicates in the gamemode OnPostLogin event
This isnt a playerstate being made for a connecting client, it's a playerstate the server is just arbitrarily creating for some later use (working on reconnecting feature)
Of course this question was cross-posted
Of course.
How does this make sense?
An actor created on the client has no replication
Why does this need to exist even?
Server RPCs called on server just run locally. On a client, the player calling must own the actor
You also have a bug there... Your cast only executes on the Remote path but you're trying to access the cast on the Authority path.
Nope because that would cause a whole host of issues
Again I don't understand the "stream in" thing
I am setting an On Rep notify variable inside a run on server event right now in which I attach an actor to a different actor. Both actors (Interacting Player and Self) are valid for both the client and the server but still this attachment is not visible on the client. What could be the issue?
Unreal already implements dormancy and I'm sure there are virtual functions to override for this
Though if an actor becomes irrelevant on a client after previously spawning in, iirc you don't get a second BeginPlay
Well here lies the problem with the limitations of networking in BP
Calling the server RPC on the authority does actually still execute on the server even for a client owned actor.
And C++ has a lot of virtual functions that are relevant to replication that aren't exposed to BP
Well you'd have to double check, I'm sure it just goes dormant instead. The server ultimately decides relevancy so I don't know why it needs to be informed about changes
I'm not sure how this is solving that problem
Do you only have access to blueprints?
Yea but how are you dealing with the "BeginPlay is only called once" issue?
There are potentially better ways to do it, but I guess I would try overriding OnActorChannelOpen or PostNetInit and see if either of those trigger in the case you want
I dont know exactly what kind of dormancy (or lack there of) you are using
Doesnt that just mean the actor is culled, resulting in EndPlay being called on the client, and then next time it's relevant again, BeginPlay reruns?
If you arent doing anything special, I am psure that is the case, although I use replication graph and at this point I dont remember how the normal relevancy rules work
In replication graph there is a frame timeout period, and if the actor isnt replicated for a duration greater than the period, the server tells the client to destroy the actor. I imagine some similar mechanism exists in the default replication route
Well I wouldnt use Replication Graph unless you have need for it (aka you are replicating thousands of actors and need the performance), there are likely better ways to solve problems without the additional complexity it might introduce to your project
Add a camera component to your plaeyr controller and set the pc's camera manager's view target to the pc itself.
Sure, why not?
There's a distinction between the 'player' and the 'character' in that case.
Probably a spectator pawn
bAlwaysRelevant
That's wizard! ๐
Guys I need a tip.
In case I want make multiplayer game where u press play or start game and it's searching match then put u in match to choose let's say hero and other stuff then u click ready and match will start .
So not searching for servers to join not server list nothing just one play button.
Would you use Eos sessions for this or something else ?
You can use sessions for this, but then you'd have to filter the list programmatically how you want to choose which session to join.
But you're a Black Mage ๐ค
hey guys I am on unreal 5.1 trying to get local multiplayer working
i have 2 controllers connected
both xbox 1 controllers
can confirm they both work outside of the game
but when i create my second player in the game, it doesnt get any input
it is being possessed by a player controller, printed the ID on possess and the first player gets player controller 0, then the second player gets player controller 1 when spawned
but it doesnt recieve any input from the xbox controller
any ideas
i have tried swapping the order in which i plug in the controllers, whichever one is plugged in first works fine controlling the first player
on my game mode:
You're creating a controller and getting its pawn (how does it have one? is one actually being spawned somewhere?)
I am what I need to be.
yes, create local player spawns a controller and a pawn with the default pawn class
which I have set to my custom character
Is there a reason you're storing the 'player 2' variable on the first player's pawn?
it's so the first player has a direct reference to the other one
What if they die?
thats not an issue because I check if the reference is valid every time I use it
Or their character changes somehow?
What I mean is, there's no real reason to store it like that.
And could lead to bugs.
since multiple controllers is not working, I use this to control both characters via the same keyboard, there are extra bindings for controlling the other player eg. arrow keys instead of wasd
which just calls the move function on the other player instead of the controlled one
it's just for debug and works fine
Fair enough.
so does anyone know why the second player might not be recieving input
Anyone knows the console variable to display location correction in client? It draws two capsules, one red and one green. I remember it exists, but can't seem to find it
p.netshowcorrections 1
Yup, that's what im looking for. Thanks
What's a good way of replicating data in a container where the container is not compatible with replication? I have a quad tree with data I'd like replicated and 2 options stand out for me. I could have an rpc for when an data is added or removed, or I could have an array which contains the same data but it's only for replication purposes. Option 2 seems pretty wasteful even with a fast array but I'm curious about how something like this would usually be done
This is for a spacial inventory and its been suggested that I replicate the data when I open the inventory which would be a good alternative
I heard also playfab and ports are okay but idk, now using sessions but have problem with registering players
Hi! Whats the best place to store player inventory in multiplayer game: player state or player controller? And why?
Hi all, I'm trying to get an animation to sync and look the same across all of the clients, does anyone know the reason my blueprint isn't working?
Guys what is right setup of having Dedicated Server in UE5, creating session after server start on map code or creating server via GameSessionClass when server is executed. in this class I am creating session I am not sure if it should be not in game mode ? or idk where to read about it
I am setting an On Rep notify variable inside a run on server event right now in which I attach an actor to a different actor. Both actors (Interacting Player and Self) are valid for both the client and the server but still this attachment is not visible on the client. What could be the issue?
I'm trying to connect to a listen server on steam but I keep getting this error
UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 20.00, Real: 20.00, Good: 20.00, DriverTime: 20.02, Threshold: 20.00, [UNetConnection] RemoteAddr: 192.168.0.151:0, Name: IpConnection_2147482373, Driver: PendingNetDriver IpNetDriver_2147482374, IsServer: NO, PC: NULL, Owner: NULL, UniqueId: INVALID
Define "working" and "not working"
Any idea why the session's BuildUniqueId is always 0 on a client? On the server it seems it's being set correctly
hello everyone! Ive been having this "hitching" problem when only using the mouse and turning when in a multiplayer session. Does anyone know how this could be fixed?? thank you!
as you can see, movement is smooth until turning the mouse. It also only happens to everyone except the host
Start by explaining the code path between your mouse inputs and something visible happening on the screen
Are you using control rotation?
@dark edge sorry sorry, im not incredibly adept with unreal just yet so could you explain a bit more what you're asking?
What exactly does moving your mouse do, directly?
Anything player data related that you may want to save when a player is leaving the game should be associated to the playerstate, and for an inventory, a component on the playerstate.
The reason for this is that the playerstate isn't destroyed when a player leaves the game, but moved to an inactive state, allowing time for saving that data, or even restoring what data is in the playerstate if a player was accidentally disconnected.
There is a caveat with this, and that's that you may want to use Owner Only conditions on any replicated variables so that the values don't get replicated to everyone if it's not needed. Like not everyone in the game likely needs to know about the contents of my inventory, only I do.
Thank you! Very helpful and detailed explanation
It is taken from Epic's official documentation. https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Networking/QuickStart/
Is it ok to check network role and bind function in constructor?
Should it be in BeginPlay() right?
If i call this in a Widget, should it return only owning player state?
Technically yes, so long as it's not a local multiplayer game. Your better path is to get owning player then get the playerstate from that.
hey guys i am having this issue with my character movement, bassicly when my server's character is going down, on the clients screen it stutters very badly, but all the other movement work fine, the client, heres a video for better clarity : https://streamable.com/21419i
i am using the character movement component that i tweaked a bit, but i have no idea why this might be occurring, thanks for your help
How to enable/disable input for multiplayer?
makes sense thank you atleastr now i can know the problem
like i said
Input is local. You'll need to disable whatever your input is doing instead
On server side if you want to block cheating
i mean this. i can't use index 0
yes my target is not the actor this logic is in
I already said that input is local only
You'll need to client RPC and use PlayerController0 or similar depending on where your RPC is in
do the client and server tick at the same time?
If all stars align, maybe
so the reason my bird is going down first could be because it ticks first?
I mean, there shouldn't be any "first" . They tick each individually. That's all
ya but if the tick sperately the client wont be synced with the server causing the server to try and correct it if im correct
The server is usually not moving client actors on tick if you are talking about predicted movement
server controls it automaticly in the movement component
Why not just use the character movement component?
all i did was multiplu7 some values with the veloocity like custom gravity friction etc
You can't really alter the movement in BPs
Just fyi
CMC requires almost always c++ to be extended
i know i made it in c++ lol
theres a built in function
called SafeMoveUpdatedComponent
If you do that in c++, shouldn't you know how the CMC works?
We have some pinned tutorials and resources for this
If you don't follow that stuff properly you'll get corrections
well what i did was copy how they did fly and edit that lol
also, i tried enabling ignore client error and i still get the problem
wdym
i set it in the editor
aight thanks for your help ill try debugging some more
"Ignore client errors" == Allow the client to move their actor freely.
You're replicating the server's actor's movement, but for whatever reason the client is also predictively moving the server's actor, thereby, the server is correcting the position to what it thinks it should but then your client is also correcting to what it thinks it should be.
ooh makes sense
you mean i put this in an owning client event?
Yeah you can't deactivate input for clients on the server
If you want that then you need to instead disable whatever the input is supposed to do
E.g. set movement mode to none on the server to stop movement
local is fine. i'm just disabling input temporarily for interaction
Disabling it locally via a client RPC also doesn't stop players from changing it back with cheats. Unless that's not a concern
Oki
Can also use an OnRep
Maybe be better cause input enabled or disabled is a state
So an OnRep boolean might be the best
okay thanks. will try
Does this actor not have a net relevancy distance?
A multicast sent from it should reach any clients that are within its net relevancy range.
I'm not really following what you're trying to do well.
If you're wanting to communicate to all clients are within net relevant range, that's what I suggested.
If you're wanting to communicate with specific clients that might be within net relevant range, you'd need to loop through them and send individual RPCs based on whatever conditions you need.
Unless you want to trust the client to figure out if it should respond, then you can just send the multicast.
Then no, you can't do a multicast for that.
how to randomly choose between multiple pawn classes for each client?
You can override Spawn Default Pawn For in the Game Mode and set up whatever logic you like to choose the class, spawn it and return the pawn that you've spawned.
so do i put spawn actor from class here or...?
What is the type of the return value?
pawn object reference
yeah so this function takes a player (state or controller, idk), a start spot, and returns a spawned pawn.
so you gotta do that bit
.
yes
i think it would be better if i were to use this
it does
if you don't override it
it'll just spawn the default pawn, whatever that is set to
you are saying "hey don't do that, I want to choose the pawn another way"
i understand the word override very well
If what you want is for the default pawn class (whatever that's set to) to spawn at the chosen start spot for the player then just don't override the function. That's the default implementation.
๐ i wanna do that
the scenario is a hide and seek type of game
If you don't have any way to change which class is considered the default pawn class for a given playercontroller, then your best bet will to do your logic in the SpawnDefaultPawnFor override
Not sure if that's overridable or if the default pawn can be set on a per-player basis
Hey first check if you can just set DefaultPawnClass on the controller
if you can, just set it and call RestartPlayer and it'll give them the new pawn
wait nvm its a property of gamemode
this works, but i realised my approach is wrong for what im trying to achieve
yes, i need to have a seeker randomly selected
but only once
You can just directly get a random element in an array but you don't want to do that if you want to guarantee only 1 seeker
instead you want to have some event that sets a class ref on all playercontrollers (one will be seeker) or some other data like a bool bIsSeeker
then read that in the SpawnDefaultPawn function
when I alt tab from a game as a host (make the game minimized) , clients get heavy network lag, how can I fix that ?
thats nuts ๐
Background framerate
Can you elaborate more ?
cant i do that with game state
Checkbox called LimitFPSInBackground or whatever
but that is for Editor only, right ?
You can just do it with game mode or state, have a playercontroller ref called Seeker.
GameMode.ChooseSeeker -> set Seeker = Some random connected controller
GameMode.SpawnPawnForController -> if Controller = Seeker -> yes -> give the the seeker pawn
-> no -> give them the other one
ooh idk
I believe it is for editor only, no idea how can it be solved in packaged games
which one do i choose
Base is the more basic version, the non-base one has additional stuff like the concept of rounds and matches etc
I'd lean towards base unless you're doing something that's match-based
so i should do this rather than use a game state, right?
you need to either use GameMode & GameState or GameModeBase & GameStateBase
you have both
i used the one that shows up first in the add new bp class thing
GameModeBase
thats fine
you don't need a custom gamestate for this
GameState is the public and replicated class, GameMode is on server only
ah thanks, good to know that
PlayerState Winner lives on GameState (You want people to know who won)
PlayerController Seeker lives on GameMode (You don't want people to know who the seeker is do you?)
You have both classes no matter what, you can make a custom GameMode but not a custom GameState, you'll just have the default one
oh yeah there's also the PlayerState thing
so... would it be better to make the isSeeker bool in that or the pc?
I'd have the seeker be a playercontroller ref in GameMode
then when spawning their pawn you can just check if the incoming PlayerController is the seeker or not
=
Either that or cruise the Player array
all actors of class will work
you need an event called ChooseNewSeeker or whatever that does all that
ChooseNewSeeker -> get actors of class PlayerController -> get random element -> Seeker = That Element
ye idk why i did that smh
I think that has a chance to fail though, the length is 1 greater than the max element
idk if random int is inclusive or not, just use get random element if you must do this
just drag off array and type Random
itz exclusive
i dont have that node i think
in mah engine versin
ue4.2X
too lazy to check now
Yeah I think the random from array nodes were introduced in 5.0
@dark edge i got another question. when do i actually run that though
if i do it on begin play, would it work? or nah because then the players would have been already spawned?
yeah, with a for loop in c++ and with a for each loop in bps
unless im not getting what ur trying to do
like run a func for each element...?
.
yup
for c++:
{
c.eat();
}```
bump
super newbie. Following a tutorial on running a server from CLI, it seems if I run with 2 players in editor it works great... if I run with server in the CLI, it starts the server. If I connect as a client to the local PC, it connects, but looks like a blank level with no lighting and the character just falls.
It's running the third person demo, and the correct map is in the default modes.
is there something missing?
I guess my question is more related to the nature of the map called Entry and why it would be selected instead of the actual game mode map.
this seems very bugged
Whenever you need to determine who's the seeker
My hitscan is hitting an actor that i am spawning somewhere, any tips to find what actor is being spawned in a replicated game?
its not suposed to be hitting that actor, its suposed to hit the player, just to clarify
what ive found so far: its a static mesh actor, name says its a cube, its not the decal
Does the OSS Steam/SteamSockets support NAT punch through for P2P?
It seems I finally have everything setup correctly but when trying to connect to the listen server, I get
Failed to respond IP: [MyPublicIP]
Thank you
I want to change movement speed based on a local predicted ability being activated (specifically it's weapon switching, different weapons have different move speeds), but I'm unsure how to integrate this cleanly with the CMC. My naive approach would be to just apply GEs in the predicted ability to modify a move speed attribute and use that as my move speed in the CMC. I think this would lead to corrections but they might be manageable if the change in speed isn't too great. Is there a better way to do this? I know typically you want to integrate with the CMC more tightly, extending FSavedMove and not modifying things externally.
Hello I am making a game for 4 players local co-op and am trying to test the game with multiple controllers. However no matter what I do it seems like all controllers try to become player 1, why is this? I have multiple player ID's created and I even have the game spawn in based on the player ID
I am at my wits end with it
this is the blueprints that spawns the player Inputrecievers that detect and spawn in the player's when the start button is pressed
this is the blueprints that spawn the character
this allows me to spawn in player 1 with any controller but it does not allow me to spawn in any more than that
It must be something I am just missing
with some further testing I can guarantee all 4 input recievers spawn in
but it has not fixed the issue
in multiplayer when a player is in spectator mode, how is relevancy handled? the client has a spectator pawn they use to traverse around ,but the server has no such pawn, where does it think the controller is and how?
the client specating around correctly has distance based relevancy applied and gets actors loaded ect, but how does that work?
i have a weird issue with inputs for GAS because of this, someone going from spectator -> spawned character while not being nearby to that spawned location is causing all inputs bound to abilities not to work, inputs just in the event graph works normally (yes there is another channel for gas and enhanced input but its not my direct question)
maybe its view target? but i still dont rlly get how it knows where that is when there is no spectator pawn on the server that i can tell
k nvm found it
Thx for not sharing ๐
lmao just bunch of stuff in APlayerController (server uses a vector that acts as the spectator location instead of just having the spectator pawn exist on the server why lmfao) so before spawning i just made sure to call SetSpawnLocation which updates this vector which when spawning and possessing my character the player is receiving the rpc for input assignment, more or less, maybe some other stuff was breaking like multicasts i didnt notice either but whatever
still stuck on my issue
it is not working and I don't know why
the only thing I can gleam is that perhaps my controller and keyboard are both controlling the same player 1 slot
but I ticked this box
so why
I have been at this for hours does anyone have any ideas
okay new discovery
I ran a print string to check the length of this unique array
this is all attached to a for each loop that runs 4 times
oh wait
I may be dumb hold up
Whatโs the best way to sync world when new player is joining? Like, all those pickups that were spawned, foliage that was gathered, structures that were built. Should I use save/load approach or repnonify?
okay I fixed a potential issue by actually making that array work, however it does not fix the player spawning issue
i have the client send an rpc to the server to request the information and then the server uses rpcs to send all that information down over the course of an amount of time, atleast for bigger lists of stuff like thousands of harvested foliage instances/inventory arrays, for individual actors i use repnotify if its something more insignificant because repnotify has added overhead then fire and forget rpc
oh wait but for some reason it now counts the array as 3, 3, 2, 1
the array should be going up
RPCs and multicasts fire only when they are called. Are you calling them again when the new player joins?
the client sends an rpc to their server player state and that player state on the server gets whatever i want to send and puts it in a job system of sorts working through to send rpcs back to that client with whatever info
although i could do it elsewhere on an owned actor, but that method basically
I see, thanks, what Iโm trying to understand isโฆ letโs say Iโm the host (listen server) and Iโve been playing all night. My friend joins in the morning. Should I rather save all the stuff that Iโve done using the save system so that the player can load it when joining? Or I should stick with repnotifies that can fire when a new player joins
well if you have every actor you want to be synced set to replicate, and you make all of the vars that have to also sync replicate, and use rep notify to set whatever is needed to happen from those vars that would work pretty much fine
if its not a game with many connections i dont see any issues
I see, thanks
So, itโs okay when a player joins and gets hundreds of repnotifies?
ideally you might manage replicated info with more scrutiny if you have more network constraints (large player count, shittons of replicated stuff but yeh
repnotify gets filtered through 'safely'
they WILL get it
eventually
unreliable rpc will get dropped and never received
reliable rpc will get received but hault everything else to do so
more or less
Are they async by any way? Or he will get those notifies all in one frame
Cool, thank you
you can also force an update to push it to the front of the list
so technically you could still just send a client to server rpc requesting the mosti mportant stuff and force it to update and in theory that should replicate what you really want first, without having to give it a super high priority / update rate
dunno never tried that, seems logical tho
your still always limited by bandwith ect, theres ini stuff that should let u adjust those things
oh okay now I am getting an error though
this makes sense to be causing the issue not entirely sure what to change to fix it though
it's this possess node that is coming back negative
so how it is currently set up the index is set to whichever number of the array it is currently on in the loop sequence and that number is based on an array of all the player spawns so this number will go from 0 to 3
this number then get's plugged in as the player index both to spawn the playerspawners and to possess the player spawners
also before this it creates a player for each of the loops
it says it's accessing none when trying to read the return value
Does the OSS Steam/SteamSockets support NAT punch through for P2P?
It seems I finally have everything setup correctly but when trying to connect to the listen server, I get
Failed to respond IP: [MyPublicIP]
omg
I fixed that error with an insane fix but it does not fix the core issue
putting this .2 second delay fixed it
but players outside of player 1 are not spawning
Would RPC be relevant to coop games? can everything just be multicast?
Yes. RPC is very releveant to coop games
do commands like p.NetShowCorrections work in shipping? and if so, do they have to be applied on the server or client?
Cheats console gets removed from the shipped games
console commands can be run from code though
I just dont know if they take effect while in shipping
Oh, nvm, this one is related to the console
Everything using that seems to have the UE_BUILD_SHIPPING macro
So I guess the answer is no
ok yea you're right
was just looking into this code myself
hmmm
need to think of how I can debug an issue that only happens in shipping
Yeah, that sucks ๐
as an update I am still ripping out my hair trying to fix my problem
Seems like you're going against Unreal. What exactly are you trying to do?
I am making a spawner to spawn in each player character upon the player pressing the start button, essentially like a player joining lobby
Are you doing that server-side only hopefully?
it is entirely local co-op. The strange thing is all my bluprints seem to work however when I test it by trying to press the start button on my controllers to spawn a player I find that each controller spawns only player 1 and no additional players are spawned
so I have these input receivers that are made at the start of the level and spawn at the player start locations
theoretically they are meant to make players for the game based on the number of spawns and have players possess them in order to have the control to press + to join the game
each player is supposedly tied to a different input recievers
however when I spawn the first player with any controller the system does not let me spawn in more...
regardless of the additional controller I use
the possession of the player changes when player is spawned so that the player spawned is possessed
but this also opporates based on the current player index so it should not move all of the players there
If I take away this possesion I can spawn infinite of player 1 but only player 1 regardless of the controller I use
on paper it should all work...
that is why I am confused
is this maybe a better question for #blueprints
since it's not actually an online problem
just local multiplayer
Local multiplayer is indeed not true multiplayer and you would design the game simmiliar to how you would do it in singleplayer.
Not many ppl doing local multiplayer afaik, you prob get more help trying to scour the internet and research
sadly I've been doing that for the past few hours...
the game is mostly done actually so this multiplayer frame work is standing directly in my way
Some time it takes days or weeks. Surely there is something in regards to setting up input for local multiplayer
Page that is intended to catalog common local multiplayer game issues and the methods to solve them.
thanks for the link, sadly I am following all these steps
I did notice an error however that slipped my sight
this is definately the issue just need to figure out how to fix it
I mean, iirc for Input you need the Controller to begin with
So you'd need to pre-spawn the PlayerControllers with CreateLocalPlayer I guess?
I do that, the player spawners are all pawns that are possessed by pre made player controllers
just only one of them work for some reason
Hello guys. I have a problem which is bugging me from some time.
I have a Main Menu level, which is the first level the game loads.
Each time the level loads, at first it spawns (I think) a camera in a random location in the map and it shows the environment and only after that my widget is loading (The widget, it's a black overlay with a loading icon). I want to have this widget, before possessing my camera.
I've tried to create the loading widget in the game instance init event, in the game mode on postlogin event (which as I know, these are first loaded) but still it shows the environment and only after that it possesses the camera/creates the loading widget. The thing is that in standalone play it's working. Also, the same thing it happens when I play the game on the dedicated server (A camera is somewhere in the worlds and only after 1 second it possesses the character's camera). Do someone knows any workarounds?
Thank you!
Hey guys!! I am having an issue setting up the owner for an equipped weapon... am getting this warning when I try to fire a weapon:
Error: LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor BP_KA74_C_1. Function Server_Fire will not be processed.
I do understand that the server is unaware of the owning actor... but its still being an issue when I am setting the owner in the server... this is what I am having atm:
The design: Player Spawns the Weapon and owns it... The weapon can be pickup up from the map as well
The code:
Player Class:
// When the player buys a weapon
UFUNCTION(Server, Reliable, BlueprintCallable)
void Server_SpawnWeapon(FWeaponDetails WeaponDetails);
UFUNCTION(NetMulticast, Unreliable, BlueprintCallable)
void Multicast_SpawnWeapon(ABaseWeapon* NewWeapon);
void APlayerCharacter::Server_SpawnWeapon_Implementation(FWeaponDetails WeaponDetails)
{
if(mPrimaryWeapon) mPrimaryWeapon->Destroy();
FActorSpawnParameters SpawnsParams;
SpawnsParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::Undefined;
ABaseWeapon* WeaponToSpawn = Cast<ABaseWeapon>(GetWorld()->SpawnActor(WeaponDetails.WeaponAsset, &GetActorTransform(), SpawnsParams));
WeaponToSpawn->Server_AttachWeaponToPlayer(this);
}
void APlayerCharacter::Multicast_SpawnWeapon_Implementation(ABaseWeapon* NewWeapon)
{
}
BaseWeapon Class:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "References")
class AActor* mOwnerRef;
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void AttachWeaponToPlayer(AActor* OwnerPlayer);
UFUNCTION(Server, Reliable)
void Server_AttachWeaponToPlayer(AActor* OwnerPlayer);
UFUNCTION(NetMulticast, Reliable)
void Multicast_AttachWeaponToPlayer(AActor* OwnerPlayer);
void ABaseWeapon::AttachWeaponToPlayer_Implementation(AActor* OwnerPlayer)
{
Server_AttachWeaponToPlayer(OwnerPlayer);
}
void ABaseWeapon::Server_AttachWeaponToPlayer_Implementation(AActor* OwnerPlayer)
{
if(OwnerPlayer == nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("Server Couldnt Set the Owner player Since its passing a null value!!"));
return;
}
SetOwner(OwnerPlayer);
Multicast_AttachWeaponToPlayer(OwnerPlayer);
}
void ABaseWeapon::Multicast_AttachWeaponToPlayer_Implementation(AActor* OwnerPlayer)
{
mOwnerRef = OwnerPlayer;
UMeshComponent* OwnerMesh = IPlayerInterface::Execute_GetMeshComponent(mOwnerRef);
const FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::KeepRelative, true);
AttachToComponent(OwnerMesh, AttachmentRules, WeaponSocket);
IPlayerInterface::Execute_SetWeapon(mOwnerRef, this);
mCollisionComponent->SetVisibility(false);
mCollisionComponent->SetGenerateOverlapEvents(false);
mCollisionComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
}
You should be setting the ownership when you spawn the actor, but you shouldn't have the function marked as an RPC like you do.
so, should this action not be a part of the server
It should be executed on the server, but it shouldn't be marked as a Server RPC.
UFUNCTION(Server, Reliable)
void Server_AttachWeaponToPlayer(AActor* OwnerPlayer);
Should be:
UFUNCTION()
void AttachWeaponToPlayer(AActor* OwnerPlayer);
Change the definition as well so it's not marked with Server_ and _Implementation
it didn't work on begin play :p
That's probably not a great place to determine a seeker then. Begin Play doesn't all happen everywhere at the same time.
in the game mode
lemme give it a go and see if that works
Exactly. Not a great place as all players may not have joined.
well it didnt even chose the host
Of course not. Begin Play of the game mode on the server happens before anyone has joined.
so where do i exec that function then?
At the point in which you would be ready to determine who the seeker is.
You have to determine when things are ready, like how many players have joined the game or maybe on a timer. It's up to your design.
could i have like a lobby on another map? and then wait until all players from that lobby join?
Yep, but that's getting into something I'm not well versed in myself. I'm not entirely sure there would necessarily be a signal of some kind to indicate everyone in the lobby map has joined on the new map.
maybe through gi
firstly store the amount of players in the lobby map, then check every x seconds in the game map if the amount of players is the same as (or close to) what it was in the lobby
@sinful tree could something like that work?
i'd also probably want to restrict that part of the GI to run only on the server/host
I'm curious how binding events works with the server/client model and whether these are replicated. If I bind an event in one of my blueprints, but only the server executes the binding, does that mean the clients have not bound that event? Sorry if this is a basic question, I'm new to multiplayer.
you are a LEGEND bruh!!! thanks alot!!!
but can you explain a bit what was the reason behind this
coz from what I could make out from the warning, the server did have knowledge about the weapon... but still it decided to throw this message... why is that
Because it's marked as an RPC it's trying to send it as an RPC, even if the execution is happening on the server already. It detects that there's no owner, and so it fails to properly call the execution of that function.
At least that's how I understand what is happening.
so is it like... I was trying to link the different rpc chains
Possibly, give it a go. The main take away is that you have to determine when things are ready yourself - you use other events to help determine if you're ready like a timer, or using PostLogin events to know that someone has entered the map and look over the number of players in the game.
alright, thanks i'll see what i can come up with
but i still dont know how to go about that
when the players will first join the game mode will already assign a pawn to them
idk how to later reassign the pawns. Or maybe the approach is wrong and I should have some kind of entry map instead that then redirects the players to the true game map...?
https://wizardcell.com/unreal/persistent-data/ --- This may or may not help you to figure out a way to retrieve data from players in one map and reuse it in the next map.
seems very cpp-ish to me
(im trying to do it in BPs)
does epic have some BP only mp examples, related to what im trying to do?
there's Multiplayer Shootout, but idk if thats what im looking for
all the more complex mp games are done with cpp
That's up to you. WHEN do you want to determine the seeker? I'd guess when the match starts but that's up to you
I thought it's impossible out of the box to have multiple level "open"?
As in the server and the clients must be in the same map
And travel to new map together thru server travel
Not exactly, but what I was getting at is finding out some way of storing some data about specific players during the lobby map and then retrieving that data in the new map, like using game instance and associating data about a player to their unique net ID and on entering the new map, read their net ID to retrieve the appropriate data or something along those lines.
I'm trying to create floating damage numbers when players shoot enemies, and I have it all set up. The only thing is I want the numbers themselves to be client-side, so only the player dealing the damage can see them. As of now, on Event PointDamage in my enemy BP, I take the damage causer and cast to my ThirdPersonCharacter, then call an event that spawns in the damage numbers (img 1)
The way I have it set up now, that event runs on Owning Client and calls a function that spawns in the actual floating number actor (image 2, 3)
The actor itself is set to replicates and replicate movement because it has a trajectory when it spawns. It's also set to only relevant to owner.
The problem I'm having is when the listen server host shoots enemies, the client cannot see the numbers, but when the client shoots enemies, both the client and the host can see the numbers. I can't seem to figure out how to get the replication so the server can't see client's floating damage numbers. I thought it might have to do with Event PointDamage running on server, but I thought running the floating damage event as runs on owning client would address that.
Give the engine a restart if you haven't already. The listen server should definitely not be seeing the damage numbers of the client with your current set up.
that's the greatest compliment you could ever give me lmao
that did the trick, it's a beautiful day when it's the engine's fault and not mine
what would be the best way going about modifying a pawn's speed based on states such as crouching or aiming or wading through water etc? just a good old multicast every time a state is entered or exited or is there a more clever way to do it?
Are you using the character movement component? You can set the character's walk speed using the CMC based on different states
for replication I'm pretty sure you just need to set it on both the server and the client, no multicasts needed
epics basic movement component yeah
what do you mean by different states though? you mean the 'walking' 'flying' or whatever or is there something else
The appropriate way of modifying speed when using the CMC is to insert a flag into the saved move list that triggers the change of speed. This then appropriately synchronizes the speed change across the network without requiring any additional RPCs and minimizes the chances of having any corrections due to rapidly toggling sprint or poor network conditions.
so you can add members to the enum somewhere similarly to how you can add enum members to the collision detection channels?
hhmm wait wouldnt lyra have a decent solution for this
But who usually modifies this List? Client or server?
Ideally the client if it's something they can control, otherwise you're breaking the client prediction built into the CMC as you'll have corrections occurring if you end up having the server changing the speed before the client knows about it. If you need to have the server apply it, you'll need to have either a brief grace period where you trust the client's movement regardless, or figure out some other way of allowing whatever client movement to go through before the speed change takes effect on the client.
I see, so basically for a "sprint" feature it would be like:
- Client pressed sprint key
- Client adds this change in speed to the CMC list
- Client calls server rpc "ServerPressedSprintButton" and server does Cmc->MaxWalkSpeed = new speed
is that the correct order of events?
Nope. No RPC is needed if you implement the flag in the saved move list and indicate what that flag is doing. The server will receive the flag and proceed with knowing the increase of speed as the move list is already sent to the server from the client.
so on the server side, when I receive that flag, I would do the check there, "if Sprint flag then Cmc->MaxWalkSpeed = new speed"
Sort of. It's more that you'd end up setting a bool in the CMC and overriding GetMaxSpeed() and changing the value based on that bool.
That bool however is being set by a compressed flag sent through the move list.
I see, so basically I would never call Cmc->MaxWalkSpeed = directly
just overriding is enough and doing the checks there
You technically can, but under real network conditions, you will end up with corrections.
yea it makes sense
Throwing it into the move list basically completely prevents it.
Of course, bad network conditions = you're likely to rubberband at some point ๐
but one thing I dont get is, where do I override GetMaxSpeed() and do those calculations? client or server? it would have to be both, right? I mean, logically thinking, the client would apply the change in speed first and add it to saved moved list to prevent corrections
If you're overriding GetMaxSpeed() that's where you'd do the calculations. Both the server and client read from that function.
I can't fully explain it all here as it's much larger than what I'd be willing to type in Discord, but you need to be modifying the CMC, setting a flag, and changing GetMaxSpeed() based on the flag. There are tutorials out there that do explain this, but you shouldn't be needing to do any RPCs at all.
https://www.youtube.com/watch?v=ixNGvOYkbno here this guy does it the right way ๐
And even explains it better than I could.
right, I was just wondering if there would need to be any checks I would need to do in there (GetMaxSpeed() ) for client vs server to do different things, but I understand what you mean, the logic there would be the same for both client and server, basically just check for the flag and change speed
Yea
its okay I understand exactly what you mean, I have already subclassed CMC and already have some custom logic there for other stuff, just haven't done sprinting yet
currently my sprint works like:
- Client pressed sprint key
- Client does
Cmc->MaxWalkSpeed = new speed - Client calls server rpc (ServerPressedSprintKey), and server rpc does
Cmc->MaxWalkSpeed = new speed
I was aware when I wrote it, that this breaks the prediction system and wanted to rewrite it at some point to do it properly through the CMC, "some point" has arrived now ๐
and since I saw your reply above talking about it, looked like a good chance to make my questions ๐
but I'm clarified at this point, thanks!
not sure whats going on here - class is the base weapon class (melee attack). it hits a building (idea is to damage the building).
the print string out of OtherActor prints the building name, but when i check what is hit on authority, it prints the weapon display name as : [2023.11.19-03.13.19:115][193]BlueprintLog: Error: "BP_Giant" BP_Hammer_C_0 (agent / weapon)
has anyone in here built a quest system of their own? im attempting to peice together differnt things from tutorials and it's not really doing me great
I'm building my own right now <_<
oh realllyyyyyyy?? lol well i would not mind some tips
are you doing the majority of logic in a component and attaching that character
Yep. Attaching to PlayerState.
Using a separate component to attach to objective targets as I want some additional functionality on targets beyond just tagging them.
i like that idea, yea curious why you putting on player state vs character? seems like a good play but i want to make sure players can do quests both by themselvves but also with someone else
I need the other players to see the name change
Anyone know how to fix this?
In case you're respawning the player, you don't have to reinitialize the component. In case the player ever disconnects, the playerstate is put into an inactive state that also allows you to copy data from it to the new one if the player reconnects.
that's dope, i like that. ihave no components on the player state as of now
Only thing is that you may want to use replication settings on the variables - like you probably don't want all the quest data being shared with all players, so you may want to do most of them as Owner Only.
But i already tried that, only the server can see it
It already set to it replicates
Theres a two dots on the variable
Input > Run On Server > Set Variable (Should be a Rep W/ Notify variable)
Rep w/ Notify will trigger the generated OnRep function when the value is changed and for anyone who joins later, and from there you can use the logic to do what you want with the new replicated variable.
Yes, i am using a widget
anyone ever have an issue with slot animations not replicating the socket location ?
npc has weapon, socket location is in sync from SERVER and REMOTE until npc arrives at building to attack.
starts attacing building using slot animations, socket location updates on client but not server despite slot animations being triggered by
PLAYMONTAGE_SERVER -> PLAYMONTAGE_MULTICAST
PLAYMONTAGE_MULTICAST -> standard ue play montage node.
is there any tutorial for this?
it seems that a cant find one
alright, whats next (Sorry idk on rep notify on widgets stats i just assume that they will automatically refreshed all the time)
Like this?
well that works thanks
Input > RPC > Set Name
OnRep > Call into Widget > Set Text (No RPC on the event, it's not required)
Right.
I'm trying to start a listen server, and it isn't working.
If I call
World->ServerTravel(PathToLobby, true);
Then this code, inside that method:
{
GameMode->ProcessServerTravel(FURL, bAbsolute);
}```
removes the "listen" option from the load URL, which means while I travel on what I intend to be the host, it does not open listen ports.
If I set the last flag in the ServerTravel call (`bShouldSkipGameNotify`) to true, it then skips that preserving the "listen" flag, but then I get a TravelFailure error, and again the server doesn't open.
If I manually catch the server in the debugger at the line where this all culminates in a server, and skip the check for the listen flag, everything works as I want...
this is probably a really dumb question but if i have cpp UFUNCTION(Server, Reliable) void DropItem(...) if i call this from the server does it just act like a normal function call and from the client it will do an rpc?
Yep
There's a ue page that explains what happens in all cases for server/client/multicast rpcs
On my phone so I don't have the link, but you could search it, it's quite handy
But you're correct, server treats it as a function call, client (if owning client) will send an RPC to server
I think non-owning clients will ignore calls to it
And if the actor or component isn't set to replicate, ofc it won't go anywhere
Keep in mind that if your client doesn't own that object (like a treasure chest in the world), you can't directly send server RPCs on that object
You need to route through something player owned like pawn/controller/player state, or make that player the owner
yep cheers
just making sure i dont need another layer or set of functions to route server calls
I want interaction traces to be processed by the server for each client. Now they sort of get, but it's always happening on the host's actor component, and not on the one passed in in the client to run the event on.
so it doesn't matter what that reference here is essentially, it will still just do it on the host's player actor comp
which doesn't make sense to me at all
neither did this work
As far as the trace goes u are only running it on server
What do u actually want to happend?
๐
I want to have the client call an even on its server representation
i realized im doing something completely wrong elsewhere
What's the proper way of obtaining a reference to the player camera manager of the controller that posses this actor?
Blueprint Runtime Error: "Accessed None trying to read property K2Node_DynamicCast_AsPlayer_Controller". Blueprint: C_Player Function: Execute Ubergraph C Player Graph: EventGraph Node: Set View Component
this is what i got after trying to do it through GetController
this didn't work either
if u want to call a function on the server u need to do it through rpc's
i sugest u take a look at the documentation or look at some tutorials
i did here
but this turned out to be the problem
i was always using the local camera
idk how to fix that though
What's the end goal? The naive way would be to trace on server, validate then do something
where are u calling that? do u have an owning connection?
As for the player manager, each client would have their own camera manager. I don't think it's replicated so if u are calling it on client, each machine will get their respective camera manager
after u do ur stuff in the server u probably need that value wither through a client RPC or a replicated var
i have no idea what ur doing tho
- If a player presses the input action, forward the interaction request to the server.
- Receive the req on the server and then do a line trace from the client's character viewpoint (on the server).
Sounds redundant to me. Let's say u are on client machine. U press input. U send request to server for line trace, then server comes back to u with, ok do the line trace?
I think you should either do it on the server or the client machine
where is the rpc being called?
only this is the problem
Don't do it on begin play, it's too early in multiplayer context for the client
There is a period of time before the pawn is possessed by the client, hence the error
no, the client shouldn't know about the line trace at all.
Instead begin play u can move your function to event on possesed
i'll try that thanks
Then I don't see the problem with what u already have
U already tell the server to do the line trace
You still get accesses none?
It should be valid I think. Try to print string the location
Or the value of transform comp
it gets it only for the server
(the upper window is the client and the lower one is the dedicated server)
Can you make a dedicated server without source builds?
You sure? someone said you could but not sure
Could you make a hosting and joining system without dedicated?
You're required to use a source build yes: https://docs.unrealengine.com/5.3/en-US/setting-up-dedicated-servers-in-unreal-engine/
To follow the steps in this tutorial, your project needs to satisfy the following requirements:
You must use a source build of Unreal Engine. See our Download Unreal Engine Source Code page for more information.
You can host and join w.o dedicated server
The only reason I use source build was to make dedicated server
Btw if I just hosted a server on a dedicated pc wouldent it be a dedicated server? ๐
does this mean that the property will only be synced between the client that owns it and the server or only the client that owns it?
you can host and join like far away with out dedicated server? ๐
If region is your concern. Can you pay for dedicated server?
The server will only sync whatever it is towards the client that owns that actor yes. Replication only works from Server -> Client. The same principle doesn't work from Client -> Server as you would then be using RPCs ๐
Or "events" or whatever BP calls them.
I was thinking I would just use on of my old pcs this game is just mostly for me and my friends so me with 2 other people would be playing it
@arctic minnow I would suggest looking around the internet a bit and searching for some common used techniques, you don't need a dedicated server for people to play with each other. If anything that's rarely every used in most games as dedicated servers are incredibly expensive to host. Often something like Steam matchmaking or EOS is used to connect clients to each other with one player being the 'host' (the listen server model).
I used epic games hosting service before to host a server and that seamed to work in my old game but theres no way I could remember how to do it now ๐
Use steam
Yes I would love to use steam matchmaking just have no clue how are there videos on it? ๐
I really want to do that wonder how complicated it would be?
You need 100 bucks for steam servers?
There is no steam servers
oh
U pay 100 bucks to become steam dev and get your own app id
oh
U can then host your game using steam api. Steam will broadcast the info
But it's not steam server, u will still be the bost
Host
There definitely are though ๐
If you integrate with their lobby system there's a good chance people are using their relay servers.
For initial connection they are 100% using their servers though.
I see so there would be no need for a source build? also couldent I use EOS for free instead idk how I feel about using a 100 bucks I mean I guess but ykyky
No if u don't need dedicated server
Would recommend giving this a read: https://docs.unrealengine.com/5.3/en-US/networking-overview-for-unreal-engine/
I will use dedicated server because server anim tick not behaving the way I want it
Also is there not a way just to make a host and join without any of that? https://youtube.com/shorts/Lhz4qmSff0w?si=xT7RPcG7bLtUmExw
#shorts #unrealengine #multiplayer #co-op
This video will show you how to create a multiplayer game using Unreal Engine.
- Links -
Website: https://elias-wick.com
Patreon: https://www.patreon.com/EliasWick
Twitter: https://twitter.com/EliasWick
Instagram: https://www.instagram.com/EliasWick
Ty I for sure will sometime! ๐
Anyone worked with "party" module?
Part of OnlineFramework
Super few info about that one but looks like some cool tech for making parties similar to CS:GO\2 or Dota2
One more question do I need to port forward my ip to host a server?
If you use steam then no they do the network thingy
If you are using the default network subsystem then you do have to portforward afaik
Wonder if I could find a steam id thing for free or just use someones to test it? ๐
Hmm ill probable just do eos its just such a pain
Steam have test app Id. 480 space war
U can use that just to test your game
When your game is ready u can pay for your own app id
Oh really so if I used that Id I would be able to test if the host and joining works?
Sure
Oh wow wait then whats stopping people from always using the test id? lol
Ppl want to release their game?
Oh lol well I dont want to release my game on steam just need something to host and join I can just send them my game file
There is term and condition
You will need to do some reading , I have no knowledge of that part
I see okay thank you! ๐
For a start Ur steam keys is limited
U have to request for keys and they are limited in number
After all it's for test purposes
If u never want to distribute with steam maybe use other platform
I am so sorry 1 more thing its right click to add c++ support right? how come there is no add c++
Tool , new cpp class if u haven't got any cpp file
Hello,
How does one call a Client RPC on a specific client's version? If you see what I mean
if we have 3 clients, and I need one client to request something specific from the server like an array of transforms, how do I make sure to send that data back to that specific client that requested the info
Guys what am I missing, I made a simple RPC from PlayerCOntroller to Gamemode, this gamemode function, send back a Client RPC to the PlayerController that issued the request (via param), but when I print string inside the Client RPC method it stills print "Server: blablabla".
Why this does not get only for the player who made the request ? Thanks
hey guys!! I need help with something... so the thing is that I am trying to update the Player HUD values when the player buys something from the shop... the system is set up something like this:
Player State: Contains the player details struct that includes: Current Bank balance, Team they are in and all those stuffs
the struct is replicated and is expected to trigger the OnRep method when it updates.
Inside the OnRep method, its calling the Controller to get the HUD class (since all the widgets are being managed from there) and calling the UpdatePlayerHUD method
I am updating the struct details from the Player Character when the player buys something on the server... but the problem is that the Rep method wont even trigger...
This is my code:
Player Character:
// When the player buys a weapon
UFUNCTION(Server, Reliable, BlueprintCallable)
void Server_SpawnWeapon(FWeaponDetails WeaponDetails);
void APlayerCharacter::Server_SpawnWeapon_Implementation(FWeaponDetails WeaponDetails)
{
if(mPrimaryWeapon) mPrimaryWeapon->Destroy();
FActorSpawnParameters SpawnsParams;
SpawnsParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::Undefined;
ABaseWeapon* WeaponToSpawn = Cast<ABaseWeapon>(GetWorld()->SpawnActor(WeaponDetails.WeaponAsset, &GetActorTransform(), SpawnsParams));
WeaponToSpawn->SetOwner(this);
WeaponToSpawn->SetInstigator(this);
WeaponToSpawn->AttachWeaponToPlayer(this);
Execute_SetWeapon(this, WeaponToSpawn);
AMP_PlayerState* pState = GetController()->GetPlayerState<AMP_PlayerState>();
if(UKismetSystemLibrary::DoesImplementInterface(pState, UPlayerStateInterface::StaticClass()))
{
FPlayerDetails PlayerDetails= IPlayerStateInterface::Execute_GetPlayerDetails(pState);
PlayerDetails.CurrentMoney -= WeaponDetails.WeaponCost;
IPlayerStateInterface::Execute_SetPlayerDetails(pState, PlayerDetails);
}
}
Game State:
UPROPERTY(ReplicatedUsing= OnRep_PlayerDetails, BlueprintReadWrite, EditAnywhere, Category = "Player Properties")
FPlayerDetails mPlayerDetails;
UFUNCTION()
void OnRep_PlayerDetails();
virtual FPlayerDetails GetPlayerDetails_Implementation() override;
virtual void SetPlayerDetails_Implementation(FPlayerDetails PlayerDetails) override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
void AMP_PlayerState::SetPlayerDetails_Implementation(FPlayerDetails PlayerDetails)
{
mPlayerDetails = PlayerDetails;
}
void AMP_PlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMP_PlayerState, mPlayerDetails);
}
void AMP_PlayerState::OnRep_PlayerDetails()
{
APlayerController* PC = Cast<APlayerController>(GetOwner());
AMP_HUD* Hud = Cast<AMP_HUD>(PC->GetHUD());
if(PC && Hud)
{
Hud->UpdatePlayerHUD(mPlayerDetails);
}
}
HUD Class:
void AMP_HUD::UpdatePlayerHUD_Implementation(FPlayerDetails PlayerDetails)
{
UPlayerHUD* PlayerHUD = Cast<UPlayerHUD>(Execute_GetWidget(this, PLAYER_HUD));
PlayerHUD->UpdateWidget(PlayerDetails);
}
oh thanks for the video lol i had gone to sleep and noticed the conversation about CMC continued. I checked out Lyra and it seems like they edited MAX WALK SPEED directly in a GAS ability called ADS(aim down sight basically or whatever) that makes you aim and walk slower, would that actually work too
For an actor that was spawned by the server, if I want to call a server RPC from one of the replicated clients, shouldn't that RPC work?
you mean if this spawned actor is AI or some object not directly controlled by a player?
Yes
MP is one of those things where you think you got the hang of it, then you work on something that makes you doubt yourself and you get confused ๐
Not if it's not owned by the client
Is it possible call on post login on dedicated server?
I need register players to session after they join
and I dont know how
to use a PRC the outer has to return the client iirc, only player owned actors can call PRCs basically yeah
Yeah because the actor is owned by the server
so if the actor component is on a non player pawn then youd have to keep switching the owner(i did this for a 'chest container at some point lol) but its probably better to use an actor component each player owns
or in my case for looting chests i just put the PRC stuff in my playercontroller
Yes that's how I've done it actually
hmm really
Yes I've made my actors have a unique replicated ID and the RPCs are called from the Controller
which means I can identify which actor I want while communicating to specific players
Would it be more reasonable to store inventory data for a multiplayer game within the player state rather than just storing it in an actor component? Im asking this because if storing it in the ac would be as good as storing it elsewhere, then i could reuse the same actor comp for all inventory related actors (such as containers)
Do you want it to persist across character deaths? If so, PS, if not, AC.
(Assuming you are following the built in way of respawning)
what's the built in way of respawning?
Anyone know how to register player in session in dedicated server?
Pretty much that
You'll end up hitting this block of code
You'll hit the "else if" condition, so you'll be spawning a fresh pawn
Register in what way? There are various login methods you can use.
ig ill use the ac as i prob dont want to keep the inv either way
Could sb explain how variable replication works in BPs? What are the replication conditions and how to use the RepNotify replication method?
when I see session in dev portal its always empty ๐
i need register them to session
but its not working
Condition describes who and when the variable should replicate. When you switch the variable to repnotify, a function should be automatically created, e.g. OnRep_ItemList. That is the onrep function, its signature shall not be changed however
how to use that autogen function?
do i just call it when i want the var to be replicated?
When the variable is set, it will be called automatically, based on your replicate condition, None means always replicate
So you just add stuff you want to happen after the variable set, to that function
What should I set the replication condition to if I want to replicate it only from the server side?
Oh, you're talking about EOS. There is a #epic-online-services channel
noone talking there ๐ญ
hey guys!! I need some help with Replication... actually this is what I am trying to do:
Basically, when the pawn is possessed it calls a delegate on the controller which than updates all the player UIs in the session... the binded method calls a server method which calls the game mode method to update the UIs for every client... the problem is that the method in the game mode is only called for the host player and not for the others
It does work from the Game State since I could easily get all the player states and update the UIs ... but I thought since the Game State is not for that purpose, I would refrain from doing this thing over there
(never gets set)
had a super brutal bug but i've narrowed it down to something very specifc:
Have an NPC that attacks a building with a BP_Hammer.
Hammer collision settings are:
ObjectType: Weapon
Overlaps: Building (nothing else).
Building collision settings are:
ObjectType: Building
Overlaps: Weapon (nothing else).
This works perfectly in editor but with client/server setup, no overlap is registered.
Anyone have problems with custom collision settings in multiplayer?
if i set building to world static and weapon to worldstatic/overlapall, it registers the overlap event in multiplayer
Player Controllers only exist on the owning client and the server, so multicasts on them will only fire on the server and the owning client.
Game Mode only exists on the server, so no RPCs will function on it as only the server can actually run anything on it.
Because replication is only from server->clients. You're setting the value on the client when pressing B
Additionally, are you certain you have your Inventory Component set to be replicated?
Are you spawning the BP_Hammer on the client only and trying to detect the overlap on authority or something similar?
just wanted to test if it would work for the client
but it didnt.
neither did it work for the server (N key)
so is Game State the only thing that is able to handle things like this
idk if Owner Only means what I think it means (I want the var to be replicated from Server to Client only. The Client shouldn't be able to modify it, so for it it would be sort of like a GET request thing)
No. You can RPC in many actors, but Game Mode and Player Controllers are special in that the game mode only exists on the server and Player Controllers only exist on the server and the owning client. The other basic classes that are somewhat special are HUD & Widgets, AI Controllers & Game Instance. HUD & Widgets can only exist on the owning client. AI Controllers only exist on the server. Game Instance exists only on whatever instance of the game is running. Any other actors that are marked as replicated can replicate to everyone, but you can change their network relevancy in C++, and also can use the network cull distance which can remove them from clients that are far away but will always exist on the server.
i'm testing overlapping only on authority, yea.
however, as mentioned i've narrowed the issue down significantly- because everything works great if i either :
- set weapon to overlap all - this will work w/ dedicated server.
- keep the weapon with custom collision - this will work on client, but not server.
i'm pretty sure its something to do with corrupted collision response channels somehow.
Unlikely. How are you spawning the BP_Hammer?
If it doesn't exist on the server, the server wouldn't detect the collision for example.
right, but as i've said a few times now, if i set the weapon to collision type overlap all and get the expected behavior, doesn't this make it almost impossible that it is not related to the collision channels?
Ahh right ok
i agree with what you're saying, i tried 100 dif versions of that same thing
been stuck on this for like 15 hours now
but i'm pretty sure i have narrowed it down to the point that it must be related to the collision channel settings
Can you provide screenshots of the collision profiles for both? Want to see all of this data.
i am using the average network conditions for network emulation, and getPingMs is returning 200
sec
is that normal?
@sinful tree even this didn't work when i set the variable to be not replicated
oh i think u need to add the element before u can set it ๐
it works now
ok so:
2 object types, WEAPON and FORGEDAGENT (building / ai).
test:
image 1, weapon profile, broken.
image 2: just weapon object type- broken.
image 3: building collision settings.
image 4: debugweapon profile- overlap all - works.
image 5: debugweaponprofile - overlap only forged agent - broken.
think there might be soemthing else going on ghm
Hmmmm...
Forged Agent (Cube attached to an actor)
Weapon (Cube attached to player pawn)
Can set both to query only as well and no change, still works.
yea
that would be my expectation for sure too
maybe you are right about the spawn i will check it
this is an npc though so isn't it already owned by the server?
like if i tick to get reference of weapon from hand, and print string on authority, its detected.
If you're getting responses on different profiles then it shouldn't have anything to do with the spawning.
Unless its detecting a different part of the actor.
nah i'm not sure thats it now, i had an additional mesh obfuscating things that i've now removed.
one second
so 99.9% weapon exists fine on server.
if you set a meshes collsiion settings in a blueprint, do you also need to set it in the static mesh ?
i had assumed no and that the mesh just gives you an easy default, but just a sanity check.
Authority doesn't really check if it's on the server. If it's spawned by a client the client is the authority of it.
yea i'm sapwning it through game mode so i think it should be fine there, also a lot of more complex behavior works in multiplayer.
plus as i mentioned i can print out the display name of the weapon
i think some other things must be happening, getting weird behavior.
Might be a silly question, but have you restarted the editor to try and resolve?
well its crashed about 100 times since i started this journey, but maybe i should before each important test.
if i wanna do a "round won" message RPC from the player state, whats the standard way to handle this? do i do a for loop to get all PlayerControllers to send the message or do i use a Multicast some how? whats the best method here?
You would likely want to send an RPC via the GameState that describes how the round was completed
Thats kind of what the GameState is for
Not the PlayerState.
ye but i want to reach the player controllers so that i can get the hud widget
So in the GameState on the Client get the local player?
and yes u are correct i wrote the wrong class, i meant gameState
ok so that is what i am missing
the game state has a function to get the local player?
or is that a kismet thing?
BP or C++?
c++
Guys I know this channel isn't for EOS just want ask isn't there outside some good guide or anything for it? been working with eos a long time and still solving many issues and found many solution only thank discord and reading history not in documentations like today I found in one chat that I can't have session set as started before registering player to session on dedicated server etc so many things.. :/
if anyone have some tips for me where to look or what read I will be grateful
im trying to find a way to call that function in BP so that i can then do it in c++ but google is telling me that GetLocalPlayer is in "APlayerController::GetLocalPlayer", and UWorld only has "GetFirstLocalPlayerFromController()"
are u sure there is a way?
GetFirstLocalPlayerFromController() is fine
Oh sorry
Hold on
Ill find it for you
UWorld::GetFirstPlayerController()
looking into it
How would you guys handle fast paced melee combat parry in a networked environment?
Since the attack command is authorated by the server, the server will always be ahead of the client. In this case the window to parry will be different both in client and server.
Should the client have the authorative say if it parried an attack and let the server validarion take over if the player is too leggy?
Should also mention that Cheating is not an issue for this context
Let client think it can do anything, client would run the anims with no latency, the actual damage application is only done on the server side however.
Thats why GAS is good, it handles alot of prediction part that one would need.
I was more worried about the visual aspect since clients will have different latency to server. It would be weird to see another player does parry animation one second after they get clawed
But yeah, thx I will see what can be done with gas. Still learning it atm
Yet to do any implementation
Only owning client does the prediction, everything else would come from server
So in that sense you would see them get clawed and parry the same "1 sec" late of latency
Thats like asking how long a piece of string is.
Only you know what the requirements of your game are.
Only you can profile that information.
You need to benchmark your game in order to understand how far you can push the hardware requirements.
How intensive your server and network related code is defines how much CPU is required.
It's not even really based on how many players, but how many network actors there are in general.
You could be hard pressed with even 1 player if you had thousands of actors replicating data every frame.
Actors have an update frequency. It tries to use that frequency to prioritise which actors to update. Unreal doesn't have a "tick rate".
That's true of every server.
Every server is running game logic and, in the case of 3d worlds, managing a 3d environment for collision and such.
Unreal is not minimalist
The dedicated server is a vastly cut-down version of the engine which removes a lot of client stuff, like rendering.
Pretty much, it holds the authoratitative versions of every actor and replicates those states to the clients.
As well as running game logic, etc.
Unreal doesn't do #2.
I will probably update the animation locally every tick, though.
You can see the valorant dev vlogs on how they handled that.
Pretty sure there's a setting about whether to update skeletal meshes on dedi servers.
Can't remember the exact details.
Yes. There are big areas for improvement for sure, but it depends on the type of game you make.
Maybe you need the server to be updating skeletal meshes every tick for your game to work?
UE can't assume that you don't.
Keep in mind that Unreal was never designed for large Player Counts.
Its the main reason why it does things the way it does
And why there has been so much effort recently to become more efficient
It was designed for Arena Shooters.
Thats it.
The lengths that Epic likely went to in order to support just 100 Players in Fortnite is a consequence of the Engines design and purpose.
Doubtful, you need to choose the right tool for the job.
If you want to build an MMO, there are likely better choices out there than Unreal.
As an example.
Since it was never designed for that.
And they'll all be hitting the same problems.
It can be made to be efficient
But that depends on what you mean and in what context, specifically.
If you're using the CMC, all hope is lost and you should just never try.
Which is what makes it hard to answer your question.
Because there are to many variables to consider.
Baldur's gate is anything but small scale. It may have low #s of players, but it has a high level of detail and moving parts.
It may be a lot lighter on the network stuff because it's only replicating to 4 people instead of 4000 (imagining all teh npcs were players), but still.
It really isn't.
That maybe a choice by the developers
As a tradeoff
Again, it depends on the game.
You have to do a lot of work to get physics to be even close to deterministic.
Unreal is open source, you can choose to do what you like.
Expecting everything out of the box, is unreasonable.
For any Engine.
Again, that depends on you and your game.
I wouldnt write UE off as "intense".
Because its as intense as you make it as the developer.
It's not really replication that's the issue, it's the processing power it takes to run the damn thing.
Yes, because it is designed to be a highly accurate movement solution for arena shooters.
Its your choice to use it or not
It can be made more efficient
But you have to trade away features
To get back that overhead.
Or accept less accurate results.
It's basically also a general implementation that's meant to work in a lot of different situations, half of which probalby don't apply to your game.
A custom (well designed) replacement is always going to better.
For example if you were making an RTS (which you probably shouldnt in UE), you would not use the CMC at all.
RTS you wouldn't even use actors, let alone characters or cmcs.
An RPG is a reasonable excuse to use the CMC, but you would likely want a custom version or an entirely separate movement mode for AI.
Again, depends on your game.
What do you mean?
The Detour AI Controller?
The Controller just tells the Pawn what inputs it needs to process.
Its likely that it has the best support with the CMC, but it probably doesnt require it.
However, Ive never used it so Im unsure.
You really should do some research on the different game framework features of UE
A lot of your questions might be answered just by doing that.
In order to find the right answers, you need to be able to formulate the right questions.
Your questions indicate you are very new to UE
If you look into UEs history, you will find that its design was driven by Multiplayer Arena Shooters.
Singleplayer is not even part of that equation, as you can classify any engine in that way.
u can set the tick rate in a .ini file somewhere
not sure where
ue networking is pretty sturdy
i once tested my game with a dude that played from india
and he had 60 ping
im from europe
well, its hard to get in and the deeper u go the more complex it gets
but out of the box is a very nice tool
@fossil spoke thanks for the tip earlier, got it working
so for unreal engine games on steam does steam convert controllers to Xinput?
just wondering since my procontroller can control unreal games on steam but not in the editor
Aah I see!! So I tried following these rules and it does work... just out of curiosity that I tried to update the UI from the game mode this time and the player class was the instigator for the rpc call... and it indeed works... is it because the instigator was the player which is a replicated actor
Yes
because the game mode is only present in the server
Have a look at Cedric's MP compendium in the pinned messages, it's a great resource
Trying to do this tutorial but the problem is it wants me to go to config.ini I dont have that in my game its just config and its dif https://youtu.be/xnMMVAzf9zg
Support me on Patreon: https://www.patreon.com/KibibyteCompany
Make sure to join my Discord: https://discord.gg/UfYfuFAVae
Don't forget to check out my Unreal Engine marketplace products: https://www.unrealengine.com/marketplace/en-US/profile/BrokenArm+Studios
#unrealengine5 #ue5 #ue5tutorial
There is an improved version available: UE5 - Imp...
Oh wait I do have ini I just had exstened names off then why does it not work hmm?
What I'm trying to say could someone help me sit up hosting a joining with steam servers? Online so like let's say somebody can join my server without Lan ๐
I've seen a server time sync over clients solution by ping-ponging server and adding half the time difference to the server RPC send timestamp on the client. But it also claims that it might not be perfectly good since sending and receiving are not exactly taking the same time. Would it solve this problem to keep ping-pong'ing and saving the previous results and getting an overall difference?
The term is RTT, round trip time
I think sending and receiving should be the same time
Would it be an overkill to do it every now and then to make sure that the first one doesn't reflect an incorrect time difference due to bad connection?
I think normally its always checked frequently
Like every 5 seconds maybe? I dunnoe. You can decide
Is doing standalone game the same as just 2 clients or a server? ๐
The file they are referring to is default engine. I actually just got this down on my game
Quick question as I cannot find much online. I have an actor based on the Pawn class. The root is a Skeletal Mesh component (helicopter). The SkM is set to replicate and is also animated via few variables which are also replicated (set from the user's input). Spawning and movements work fine, as well as the animation on the server side. But the animation for the chopper doesn't work properly on the client(s) and the chopper stays in the base pose. What did I overlook?
Animations don't replicate directly, just driven locally from info to the Pawn.
How does the ABP look? What does the Pawn BP look like? I can't think of anything off the top of my head that is obvious.
Is this a listen server setup?
The AnimBP uses the replicated vars pulled from the Pawn to set the animation, I was expecting this to be enough, but I obviously missed something.
It animates properly on the listen server, but not on the client. If I debug the AnimBP for the client the Animation Update is not called, so I am missing something I guess.
About to get my hair cut - bad timing. When I'm back home, if you don't have an answer, I'll resume.
Check that the client even has the ABP. And there is some setting as well, can't remember where, where client poses don't tick for listen servers.
Sure no worries!
@sinful tree so how should I go with the flow when updating the UIs if not the controller and Game mode... coz I will be updating the health bars as well which would be replicated to the other players as well... so I am looking for a consistent aproach
and the UIs are managed by the HUD class
Why do you need game mode to update your U.I?
U I should just read data. Like player hp or w.e you can store the hp in player state for example.
U.I job is just to display the current value of hp in player state. I dont think you need some bp to tell U.I to update
You update player hp via damage event or w.e then widget simply read the replicated hp in player state
Can also use on rep. When health value is changed, check if widget is valid. If it is , call update on widget.
Or ez mode is just to set health value on tick
Alright, I'm back. Figure it out?
its an overhead widget which shows the health bar and the team name
Then just read the hp bar and team name
Do your replication stuff, widget will just read the current value and dont care about how the data is handled
I want to do the exact same thing but those values are coming from a struct called PlayerDetails inside the Player state
I did that... so the player is calling the methods from its own class
and the problem is that the UI doesnt update when the new player joins
Afaik player states are replicated on all machines
Yup
I suppose you can broadcast to clients then when new player join
so if I wanted to update the UIs for all the players, will the player state update it for everyone... else atm its showing the default value
coz I thought the player state was specific to the client
I havent done much multiplayer stuff tbh. Mostly just quick test and lots of reading.
Yeah but u can read other ppl players state
I am setting an On Rep notify variable inside a run on server event right now in which I attach an actor to a different actor. Both actors (Interacting Player and Self) are valid for both the client and the server but still this attachment is not visible on the client. What could be the issue?
thats new... coz I thought the game state could do that