#multiplayer
1 messages Β· Page 88 of 1
hi i need help i have two charactes and each one have a life but when one attacks the life is change just for one in the his screen and the life that changes is both no just one
Show your code
the first screen attacks but just the another changes
i already replify the var life but nothing works
ok that looks fine, show how your health bar is getting the health to display
that's the problem
you aren't showing the health of the pawn it's on, you're showing the health of the 1st character on the server, in both health bars
i dont know how take your own character
without mention anothers
yes
exactly
You're halfway there, you have a HEro ref
but i dont know how to take your own character and show it
I'm assuming that's meant to be a ref to the character this hp bar is for
What creates this widget? Is it in a WidgetComponent?
yeah
At begin play in the pawn, set HEro ref to self
yes attach to the character
component on the character
yes so the character can tell the widget which character it cares about
get widget component -> get widget -> cast to YourWidgetClass -> set HEro ref
hmm ok
You might need to expose it, it looks like it's private
the variable?
i think that i know
its works thanks
but not in the begin play
because
this do it and set that the my character will be my own character
and this do the inverse and set that my object or pawn in the index 0 will be the character
but whatever thanks
help me a lot
more one question its for best practice, do my status character have to be in the pawn or in the playercontroller?
hmm ok, I was in doubt because of this text on the unreal site
Also, in some cases, putting input handling or other functionality into the PlayerController is necessary. The PlayerController persists throughout the game, while the Pawn can be transient. For example, in deathmatch style gameplay, you may die and respawn, so you would get a new Pawn but your PlayerController would be the same. In this example, if you kept your score on your Pawn, the score would reset, but if you kept your score on your PlayerController, it would not.
but i undestande know
hey guys, im trying to join a friends session but never, they can join my sessions fine
gives the following errors
[2023.05.29-22.49.58:892][634]LogOnlineSession: Warning: STEAM: Session (GameSession) already exists, can't join twice
[2023.05.29-22.49.58:892][634]LogBlueprintUserMessages: [BrowserCell_C_2147479137] failed to join session
the last error is a print i added
it means that you are already in a session and therefore need to destroy your current session before joining
yes interface, which makes it more complicated
thats what i assumed but it makes no sense since, it happens when the game is opened for the first time and i just try to join a session that my friend made
Hey, can someone tell me if an replicated UObject can have an replicated array of UObject? I have an weapon(UObject) and in this weapon I have an replicated array of attachments(UObjects). The client can call the function to add attachments on server but when trying to get this array it has the correct length, but all the items are null. On the server it's all fine. I've done the steps to be able to replicate an UObject and it's working, the Item array on the inventory component can be accessed by the client, I'm only having trouble with the attachments.
You would have to add them to be replicated in the ReplicateSubObjects function as you did for the Weapon itself.
In the same place as the weapon or in the weapon itself?
Same place.
Does anyone know if there is an event on the server for when the level becomes initialized on the client? I see in UNetConnection there is ```C++
bool UNetConnection::ClientHasInitializedLevelFor(const AActor* TestActor) const
but I need an event, not necessarily a bool.
onPostLogin?
/**
* Called to notify the server when the client has loaded a new world via seamless traveling
* @param WorldPackageName the name of the world package that was loaded
*/
UFUNCTION(reliable, server, WithValidation, SealedEvent)
void ServerNotifyLoadedWorld(FName WorldPackageName);
This function in APlayerController
However it is only fired for Seamless Travels
I just noticed that its marked as a SealedEvent
Probably cant override it π¦
I think this is a bug in the collab viewer template from epic games. Notice the outline around the car. Its black for one player and white for the other player. Its supposed to be red from the red player and blue from the blue player.
Was there a way to have a Client decide if they want to "receive" replicated data?
E.g. I have Struct with some Data that the Client predicts and in this scenario, I want to have a way to decide if the Client receives the Data based on the incoming Data.
I know I could decide this inside NetSerialize of the Struct, but is there a different way?
How would I go about getting the players current session info
for some reason I cant figure it out and I need it to keep working on my game
Depends on what Data from it you need.
I need the current player count and the max player count
I don't know how up to date it is
But you should be able to get the Session from the Session Interface
When the Player joins a Session, it adds a NamedSession locally too. So you should be able to do "GetNamedSession" on the SessionInterface with e.g. NAME_Game to grab that Session info
I just don't know if the Client constantly keeps that up to date when new players join and leave
@gray orchid
How do I handle procedural items(for my item/inventory system) with DataAssets? Do they replicate?
DataAssets are like their name suggests just Assets
Since you usually don't modify those runtime (as they aren't instanced) you can also handle them as such
So if you set that in a Replicated Property or an RPC Parameter, they should replicate just fine.
Would it be better to go with an object library instead then? π
Well, if you need to runtime modify them, then you either use Structs or UObjects.
Where UObjects need C++ (and an Actor) to be replicated
I made it with UObjects, and replicated them by doing what epic does with AttributeSets, but I'm trying to figure out the best way to store the items, and create new instances of them. π
I want to be able to create them at runtime, using the stored versions as a "template" or base version of the item, where the items' stats will be rolled(generated) when instantiated
If I turn off replication on a component on the client, will it stop listening to RPCs from the server?
Couldn't you do skip owner in the rep settings?
Otherwise - I don't recall any other method π€ (short of what you're saying)
Nope, the Data is actually inside a simulated proxy
I fixed the two cases I could repro by now
Via NetSerialize that is
Serialized the data into a local struct and compared
Works fine I guess
Hi guys, i wanted to make every player look their own way, but they look at the same spot on each client. This is really confusing me, could somebody help me?
Not necessarily. A component doesn't actually need to be replicated to send/receive RPCs. It just needs to be name stable on it's actor and the actor replicated.
Also you don't turn off replication client-side but server-side
The other option involves overriding PreReplication and conditionally replicating your thing?
Poll time - is there a server reliable way of verifying QTEs?
I keep thinking about it and just keep coming to the conclusion, "screw it - trust the client. It's easier"
QTEs?
Quick Time Events
Any examples?
So, think about repairing a generator in Dead By Daylight. A radial pops up on the clients screen. A hand (think like clock hand) goes in a circle and the client has to hit a button at the right time in order to pass the check.
How can I ignore a specific character for AI Perception?
I want to create a dying system, the most suitable method for my mechanism is the AI Perception method. When the character dies, I want to disable AI Perception for this player.
How can I do that?
How could the server verify that they really did do it correctly? π
Maybe have some tolerance level?
I'm sure I could come up with some fancy rollback or w/e. But that is just too much work π
Are these player controlled pawns?
yes
You need to only do this line trace if the pawn is locally owned. You need a SkipOwner, replicated vector. You need to set this locally on the locally controlled pawn. And send it through the ServerRPC for it to be set on server so that it can actually be replicated.
This is painful π₯²
Make an array of actors to ignore, and anytime your perception is updated, check if the stimulated actor is in your ignored actors, if it is then do nothing
Indeed it is π . That's why I just say, "screw it. Trust the client"
I do imagine a tolerance would be an ez mode solution
A tolerance that is ping driven 
Should be able to just unregister the component when your monster dies. Get a reference to the component and then pull off from it and check for anything in the perception system.
I'm thinkin' about stuff like this because there are some situations where I want to test the player, like say if they get grabbed and need to hit a key at the right moment. Ya' know?
Or maybe have a mechanic where they can parry an attack at the right moment.
These fall under the same "style" of a QTE to me.
@spiral rain To cover on this a little more and explain better. The local player who owns this pawn knows where it is looking. The other machines, server included, do not know exactly where that player is looking.
So for the locally controlled pawn you locally do their movement and location set and rotation so that it looks and feels nice to the player using it.
Then you have that player send the location they're looking at through to the server. The server can then replicate this state to all other clients. All non locally controlled pawns can interpolate their updates on a non locally controlled branch of tick so that it looks mostly okay.
So how do i exactly send the location to the server so others can see it?
Unreliable server RPC on tick
The Data is changed locally. So the Server (who calls PreReplication iirc) doesn't have the info to check if the data should be replicated to that client or not.
I've got a mechanic similar to BotW's Magnesis where I can pick up objects and move them around. The left stick controls the character movement and the right stick controls the object's movement. How would I replicate that from client to server? Is RPC the only way? It seems like a lot of information to send over the network.
Shouldn't be too much for that affect. It's largely nothing but a vector and rotation. Few bytes.
Alright, I'll give that a go. Thanks!
Ah ok. Then you have no way around replicating the data, right?
RPC is the ONLY way to send data to server
I was wondering how the character movement component was doing it and whether they had a more efficient way than just calling an RPC every frame
It's doing RPCs internally
Specifically, it's making move structs and sending them over. It gets complicated but that's the gist of it
What I want is not Monster, but when my base character dies Monster should ignore the base (specific) character for Multiplayer. I added the Unregister from Perception System into my base Character_BP, didn't work. (rpc + multicast)
cast to your base character and check to make sure it's not dead
Thanks
Make array and each loop method also didn't work but Unregister from sense worked!
why are you rpcing and multicasting that, it should be serverside only
You mean just RunOnServer? I'm doing multicast so that the process I've done on other players can be seen.
No i mean the server should be calling the shots on important things.
Why is the client involved with AI stuff?
When the AI's target character dies (on the server), the AI should no longer care about them (on the server)
Oh, I didn't quite understand, what is the part I need to change as a result for this?
Just set it up as if it wasn't networked at all, just have it all happen on the server (gate by HasAuthority)
So I should add HasAuthority to Unregister from Perception System so that only the server can run it, right?
But what I don't understand is if I do this it will only work on Server. So the Client can also die.
I hope I understood you correctly. But let me test it.
Dying should be a thing the server decides, which is replicated down to clients
Server calls the shots
I had GameLift working fine a few months ago, but I tried deploying again with the new interface and now I can't submit a fleet deployment because I get the following error:
GameLift is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::691907551351:role/service-role/GameLift-StartGameSession-role-8xjd5bid
Anyone know what that's about?
Ok, I'm gonna try, thanks.
@thin stratus is that c++ cause I need blueprint
Yeah 100%. If you don't have a plugin that can do that for you (not sure what Advanced Sessions offers) then you need c++
Blueprint-only Multiplayer has a lot of limits
You won't get session info in native blueprints
Only thing you can get there is info about connected players in the server (cause server and session are two different things)
Something like a match/lobby timer - how would you guys go about making this so its synced across remote clients - without having to do an RPC every second?
I of course am using GameState to replicate the variable - but I just did a timer (non-repeating) for N# of seconds to start it - and an event when its finished..... if I DONT do an OnRep function - it wont send an RPC out every time it updates (every second) if i switch it to that funcitonality - will it?
vori had a sync network clock that I'd probably use for such a situation
cannot give you the details
theoretically it makes sense that it DOES NOT send an RPC event every time it ticks the timer - because its not ONRep functioned
Okay so, in case anyone has to deal with
GameLift is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::691907551351:role/service-role/GameLift-StartGameSession-role-8xjd5bid
You need to go into the policy (GameLift-StartGameSessionin this case) and edit the trust relationship policy document (not the policy document itself, but the one in the "trust" tab) so that it contains
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "gamelift.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
I hate AWS so much.
everybody uses AWS and everybody hates AWS
I had once a coworker who had the theory that they made AWS horrible on purpose so that people need to certificate in order to be able to use it
π€£
Lol, now that's a conspiracy theory I can buy into.
man fk that certification program
i dont have the time/patience to try to remember 84 different services & depth that it goes into each service - to pass the tier1 exam
plus - i'm old
"Oh hey, we introduced a new IAM system but we also kept the old one around, and half the instructions out there use the old system's authentification system and half use the new, have fun"
Gun->ToHead()
also tbbh unless you are a cloud infrastructure guy you don't need it
tell that to the hasbeen managers in my company
its a sales promotion thing
"We have N# of certified AWS programmers.... GOLD TIER BABY"
AWS error:
Cannot run program "/local/game/install.sh" (in directory "/local/game"): error=2, No such file or directory
What it ACTUALLY means: there is aninstall.shthere but it uses Windows line returns instead of Unix line returns. π
If you don't need anything fancy, do an RPC of the value when the client connects and when the match starts. Then just let it tick down on the client.
This is the naive approach though. Should work in plenty of scenarios though. Unless you absolutely need to the millisecond guaranteed accuracy.
Hello ! i was wondering how can i show individual steam name for my lobby ? right now, its showing my name for each players in the lobby instead of their name
(here is my code)
Do you know why that's your problem?
Not really, i'm sorry ^^
What does that node do?
It's searching for the player controller, but i guess locally only
It's getting the FIRST player controller
which is the local player on clients
and the host on the host
Oooh, this is why it's my name, because i'm the game host
You need to iterate over all players, GameState has an array of PlayerStates, start there
does this code run per list item?
as in, per player?
Yes
the outer widget should do the iterating
an individual widget doesn't know what player it cares about
the outer widget needs to tell them which player they care about
Okay i see
unless you just use widget index inside parent as the index of the player they care about
but you should deal with PlayerStates, not PlayerControllers. Only the clients PlayerController exists on their machine
thanks i have learned a lot 
Playing montage in a highping (or even low ping) will result in rubber banding due to CMC correcting the location of the character when it play the montage. How can I do it in predictive way? π¦ I know we can do sprint with Prediction which utilize SaveMove but how about gameplay action like playing an attack animation? How can I make a multiplayer that isn;t rubber banding with root motion?
Does anyone know how a Multiplayer Save-Game would work?
Like, player skins, player currency, etc. Storing player data on a server and retrieving it.
How would that work, potentially
I guess that depends on your model. You could store the data locally like skin currency, etc. And when the player join server just allocate the player skin based on the player skin from local save file
ofc doing it that way makes it easy for anyone to alter the local data.
if you want security you need to store the save file on the server side
If you intend to have servers that are distributed (ie. Players can host them or some other third party hosts can) then you cannot use a database system for saving details like that as any malicious person could fudge your database with junk data as you'd have to allow access for those servers to request writes to the database. Once someone has access to your database, they are essentially free to write almost anything they want to it.
eg. Say you have a database where you are storing PlayerID 55535 and they have 500 currency. The player gains an additonal 5000 currency during their play time and quits the game. The server sends an update to the database indicating PlayerID 55535 now has 5500 currency, and or/ to add 5000 currency to whatever is currently present. The thing is, if the player themselves control the server, they can then do something like... Update PlayerID 55535 to have 99999999 currency and you'd have no real way of validating if that was an actual valid request, so your database accepts it. At worst, they could then be real jerks and do stuff like Update PlayerID 22455 to have 0 currency, wiping someone's currency they've earned, even if they never even played on this particular server making the request.
If you want to avoid that scenario, then you must host all the servers yourself and not distribute the server executables. Then you'd maintain control.
One alternative is to not store the data online and instead just use save games on the server the player is connected to, allowing players and other 3rd parties to host servers . Then only the data that is on that particular server could potentially be compromised. The downside here is that player data is not retained between servers.
A dedicated server in relation to Unreal is akin to an instance of the game that is only being used to host the game and allowing players to connect.
One can still distribute a dedicated server build and allow others to host it.
The issue is who is hosting it. Are you saying you intend to host all potential servers that the game would be running on and not allowing anyone else to host a game themselves? (By me asking if you are intending to host the servers, you can use whatever hosting provider like AWS or Azure, just that you'd be setting up a system to launch servers and remain in control of them)
I guess, yeah. Like Overwatch, they join the servers. I would be the one hosting
And the player data such as player owned skins or stats or playtime would be on the server for the client to retreive, correct?
I want to know how that would work, because i was going to create a character selector, but since the Save Game thing seems to not replicate or whatever is it.
You would likely end up using a database system of your choosing that your servers would read and write data from/to. Player data would likely be stored in a way that you'd use a unique ID to identify the player like SteamID or Epic ID. I know Steam has a session ticket that the player can pass to a server, and then the server can validate the ticket with Steam and retrieve their Steam ID from the ticket. Alternatively, you could roll your own authentication system and have them sign up with their email and then you'd store their password (SECURELY).
Unreal Engine doesn't have anything built in to handle authentication of players (save for using Steam or Epic sessions) or database connections if I recall correctly. This is more something that you'd have to develop yourself and have the right workflow worked out for what it is you intend to do and how you want it to be handled.
It boils down to you'd likely need external systems to handle purchases and matchmaking. Once a player joins into a dedicated server, the server can authenticate the player again and retrieve the data about that player directly through Unreal if it's set up to connect to the database. Anything data related before actually joining a game can happen if you have some other system that isn't Unreal handle the requests for you as long as you authenticate the client/request.
Ok, but how would that work in terms of blueprints or c++ or anything for making it happen.
This is not something that can easily be conveyed in terms of code or using blueprints as it would be an extremely large system and even requires applications running external to Unreal itself.
What you're asking is something that large scale game companies would likely be working on for months.
Unreal doesn't have exactly what you'll need from the get go. You'd have to code in systems (or use plugins) to make REST requests and handle database connections.
You'd have to code the external applications to handle REST requests, and make your own API, using whatever you're able to use for handling such systems (I've done it myself using something like AWS Lambda and Javascript of all things)
You'd have to code in how you want your database queries and writes to work, again likely through some external API you can call from anywhere, and authenticate it.
Once you have those parts done, then you have to worry about trying to work with those bits of code to make the requests and responses you want, then code in how you want Unreal to handle any data returned and sending it from Unreal.
This was what I meant, so thanks. I understand now
so the data handling is on the API and stuff
Just a plain old savegame will work fine if persistance within a single server is ok (like Minecraft or Terraria)
what do you mean
if the saved stuff being only for that one server, like Minecraft or Terraria, then just a normal savegame will work.
The same way Minecraft saves a file per player
can someone clarify if anyone uses root motion at all in their mp game?
Iβd like to have a series of boulders randomly spawning and rolling down a plane that will kill a player if hit. Simplest way to do this is have physics enabled and let them rollβ¦ but Iβm assuming the server will not be able to keep them in sync between all players if I use physics, is that right? Alternatives Iβve considered are using a series of randomly assigned splines or using AI and plotting a path. Any better options? Synchronization is somewhat important but not essential unless players are getting killed by boulders they canβt actually see
You could try the PMC if you want a simple implementation.
Hi, When you create a Local Player. The Split screen is supposed to work directly or not?
I'm in a Menu, and select to play 2P. Then i create a local player.
But it looks like a new screen is added behind the main screen. So it's not splitted.
I was expecting to have the same screen for everyone (menu) but splitted
Can you screenshot it? Initially it sounds like a widget being added to viewport vs being added to player screen.
Is there a udemy course or course in general that covers the basics of making an online game in ue from.a to z thats good? I vaguely recall tom looman, think, had some shooter game course for example but i heard it might be a little outdated
so it's the selection screen
it's open my start screen
and with the controller 0
if i press back
i have the main menu, and behind the screen open from when i create the new local player
and i try that
i try without the last Client Set Hud
and when i press a button of the new controller i have an error message
all those action are well defined for player 0
it's like if the controller 1 create a new game mode
and like if the new player controller , create a new game mode, the new game mode create a new HUD, and the hud create the new start screen
but i was not expecting it to act like that
IMO, this menu should never have two players. Main menu is meant for the first local player. A second player shouldn't even be considered or allowed to do anything until something like a lobby.
but if i want to let them select their car (before the game).. that's mean i should create a new game mode to allow them to select their car?
because its true i start with a solo menu
then i select multiplayer mode
that's mean i show change game mode there? and create a new one for multiplayer menu?
That's usually like a lobby screen or something. Which I'd consider making into it's own map, or the same map as the race so that you can support online sessions if you want as well. But local coop should largely work the same as far as coding except that it's a second local player on the machine.
Yes, it's a lobby screen, that has it's own map.
when i click on solo mode, i open a new level with all instance parameters.
i have the possibility to select my car and the race
when i click on the lobby screen multiplayer, i open a new widget.
In that widget i select the number of local player. then create new local player. Should i expect new game mode to be create?
when you say : "But local coop should largely work the same as far as coding except that it's a second local player on the machine."
Do you mean, local player should have their own main menu lobby level?
What I mean is to separate the main menu and the lobby entirely. Main menu is just a place to select where to go. Should be one player, never two. Specialized simplified game mode, HUD, PlayerController, everything. It's meant to handle specific tasks that aren't really like the rest of your game.
When you choose to start a race. Open a whole new level. This level has a different gamemode, hud, playercontroller, etc meant for the race.
IMO for simplicity and initial setup I would even make your lobby a third level with it's own set of core actors just to make joining easier to handle. You generally don't want players hotdropping into the middle of a race. And handling lobby vs race code in the same set of actors is annoying. Alternatively you could probably put a lot of that state on a component in the game state and destroy it when the race starts.
I wouldn't create players that aren't being used either. There is an event in GameInstance that runs when gamepad stuff changes. You could probably detect local user intentions from or around code related to this.
so for you the car selection it's a part of the Race? because we can have multiple player there?
So what you advise me to do is :
- Level Menu : 1 controller
- Multiplayer : New Level with multiple controller
- Run de race : New Level (1 or multiple controller)
it's will only a local game (no online functionality)
but the create local player shouldn't split the screen automatically ?
It should split automatically I think. Depends on your project settings for it though.
Hi I have a question, about replication. So we are creating VR game, and we have setup that in the GameInstance We have our variable (custom struct) that's replicated that stores parts for the avatar (array of some custom struct for avatar parts, path of the head,torso meshes...) and in the single player it's working fine, but when we joined MP match or creates one, that variable in the game instance, has 0 items in the array. I trying in the editor it's working fine, but in the build it's empty. Does anyone has some ideas how this might be fixed? Thanks in advance π
When NetSeriliazing, when does it make sense to use SerializeOptionalValue?
I'm looking at existing code where someone previous to me used that to serialize an actor pointer
And so I did the same when I added a second pointer and it totally wrecked the serialization. Are there rules to this?
Does it have to be placed at the start or so?
GameInstance is not replicated and can't replicate data. It's not meant to be used for replicated data, let alone gameplay logic and data.
Every client has their own and no one should have access to another player's GameInstance.
Thanks for the answer, but that's good then, we wanna load from the game instance variable in the Character::BeginPlay (IsLocallyControlled->True) and read those values, but every time when client reads his game instance it's empty. Is there any way to get those values in the session?
BeginPlay -> IsLocallyControlled is wrong for Characters
Characters aren't possessed instantly
They call BeginPlay before that
You need to either use the PlayerController's BeginPlay or move the code to a ControllerChanged Callback in the Character
Oh, didn't know that. Thank you for the answer. I'm gonna try doing that now, and get back to you with the response/answer. Thanks again:)
Heyo, I tried that and it still get's me with an empty array from the game instance. I tried using it on ReceiveControllerChanged & PlayerController's BeginPlay, but still nothing. Whenever I print out the array from the Game instance it's empty on host as well
Any idea on how to implement Waypoints visual in an RTS game that handles the movements over the server only? So I don't really know when unit arrived to destination..etc
I am working on a multiplayer game and would like to do a real world test with several players around 20. Is there a way to do this test virtually somehow without having to find volunteers? I can run a bunch of game instances through the editor but obviously this lags my whole computer down and is super unrealistic.
Then you have an underlying issues with that data being reset somewhere
If oyu just call GetGameInstance locally it should give you the local GameInstance with the Data it has
If the data on it is erased, then something is doing that
You should be able to also use the NavMesh locally and just get the Path for visualization
can you give me more intel about this ?
Not to my knowledge. You usually also want to test real world ping so having players is somewhat necessary
Only minimal. You gotta have this on iirc:
And then you could use stuff like this locally to get the Path Points to draw a spline or so
Thanks so much, will look into this
I looked into implementation and that variable is not changed at all, it's set whey you login and that's it just reading from it
Login? You mean with some backend while being in the Main Menu?
Yea, when you start game, it will make a backend call to login, in the response I get the whole struct (it's valid in the SP) but when I Join/Create session it's empty
You must be doing something for that to happen
I can't help you here sadly
You can share parts of your code here if you want
Maybe someone can spot a mistake
Thanks anyway. I'd like to share but it's not C++ it's blueprint code only and it has a lot of nodes for loading specific path of the mesh. But I can send this part. That's being called in the BeginPlay from the PC if it's locally controlled
ive gotten the 2 players to join a game session. However its always the client thats movement is all messed up. For instance when jumping he sometimes flies up to like 3 times the jump height and overall is jittery and messed up.
So i guess some main questions are
did i need to check some box for anything replicated related when creating the character?
I think the problem is my jump and dash and slide have timelines and something is getting thrown off because of that?
Does anyone know of how to handle this or maybe what needs to be replicated?
other info--- the jump has a timeline to increase gravity, basically to give a mario jump
the dash timeline just sets his velocity for a period during the dash
when doing a semless server travel nothing saves from a scene to another
ruight
its like starting a brand new level
Make sure you don't mark any variables or events replicated in the GameInstance
Not that it will fix the problem but they shouldn't be replicated
What does GetViewGameInstance do?
You won't get around trying to follow where and why the GameInstance resets that value
Level-wise, nothing saves, that's correct.
hm and thers no fucntion like in unity " (Dont Destroy on load) " ?
fyi, replicated movement in Blueprints is a nogo
C++ is full on required because you need to tie that stuff into the CharacterMovementComponent
Otherwise you get corrections like you see
damn, was the only way i could really get the timline working for that
mostly everything is c++ minus a few things that were easier on bp lol
i.e. the timelines
If you need something like a timeline I can suggest you to define a Float Curve asset pointer in your CMC
And using Timestamps based on Server and Client Data in the CMC to check where along the curve server and client are
You can persist additional actors via the SeamlessTravel list in C++
But not sure how well that works with stuff that is supposed to be in specific places in the level
π€ im fairly new to doing multiplayer but have done like half a course on an online shooter
but hadnt done any kinda timeline stuff
well its basicly stats that needds saving but
with replication
Where are those located?
Place them on the PlayerState instead
And use "CopyProperties" to move them from old to new PlayerState
That's how it's supposed to be done at least
sorry whats CMC? and do i just research timestamps? or is timestamps something to replicate
There is a CMC example pinned to this channel
CharacterMovementComponent is CMC
Timestamp is just a record of the current time
E.g. if you start jumping, you save the time you started
i had thought perhaps i should be doing some kinda delta time thing
And while jumping you can do "CurrentTimestamp - StartJumpTimestamp" to get the time elapsed
this is good because my jump also has a timline on it to increase gravity haha
I removed replication from it, just wanna test on RepNorify will it fire, anytime after it's set. It's not replicated anymore. The ViewGameInstance is just returning CustomGameInstance that will do just: Cast<UCustomGameInstnace>(GetGameInstance)
unfort
CMC is no joke. I'm doing this sh*t for a couple years now and I still run into problems with it
There is a lot to be aware of
seems harder than replicating the amount of ammo i have ina gun haha
You should study the git repo that is pinned
Replicated Movement is somewhat of a master class
Or at least predicting it
Yeah not sure then. You should know where you set the variable. Breakpointing or printing there should be enough
The funny thing is, that variable is set only once in the OnLoginCompleted event π
Hi, I'm not sure if this is the correct section to ask this but. I use the Unreal's replay system on my project. Like when I move the NPC's on BehaviorTree using AIMoveTo, it rotates to movement direction on server and client as i use Orient Rotation to Movement. On the replay, NPC always walks backwards but to a corrent location, so it doesnt rotate even if it does so on client and server. Also when I scrub on the timeline, replay always forgets like AnimationLayers which are choosen in OnRep -functions. I just dont get it, why is the moving working different in replay and why scrubbing the replay fucks up the RPC's
so the gist of this is im gonna have to implement client prediction and rollback in regards to anything using a timeline or such?
The gist of this is that you have to implement your custom movement into the CharacterMovementComponent as there is more to it than just calling the Timeline.
The CMC has prediction and rollback, as well as reconciliation
ah ok im reading up about it
But you need to add your stuff to the correct places and structures in the CMC to make use of it
so its like i gotta have a custom movement for dash slide etc?
sorry for all the newb questions
It very much depends on what you want to make and how much custom logic it needs
Sometimes you can just override a handful of functions and you are good
Othertimes it's a lot more involved.
i mean maybe itd be easier to just have a timer and set the velocity then end it at the timer
im more on the still trying to learn like what actually needs to be repped more than anything
for sure have no idea usually if i run into a problem what to search for. thats really what i wish i was better at. being able to understand the docs half the time haah
how do i connect an EOS login to the owning player
In multiplayer, I want to set location some ball actor in the level in other client's computer without using replicate for some reason. by using run on server - multicast, is it possible even though the ball's owner is not my computer's pawn? Difficult to explain..
are you the vaei guy
No. They're Cedric
~~Hello, I'm going through some Lyra interaction, and I noticed that it gives this warning LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: AbilityTask_GrantNearbyInteraction /Engine/Transient.AbilityTask_GrantNearbyInteraction_0 NOT Supported. the first time per play a client approaches some interctable object. ~~
By searching for some information I only got that the warning is saying that the ability task is not supported in networking, but why should it be saying that if this task is only triggered on the server? That's the only place this task is triggered in:
void ULyraGameplayAbility_Interact::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData)
{
Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);
UAbilitySystemComponent* AbilitySystem = GetAbilitySystemComponentFromActorInfo();
if (AbilitySystem && AbilitySystem->GetOwnerRole() == ROLE_Authority)
{
UAbilityTask_GrantNearbyInteraction* Task = UAbilityTask_GrantNearbyInteraction::GrantAbilitiesForNearbyInteractors(this, InteractionScanRange, InteractionScanRate);
Task->ReadyForActivation();
}
}
Does anyone know how to fix it?
Edit: it doesn't have anything to do with the activation, but with the task itself. It grants abilities, but when it creates AbilitySpecs it inserts this as the source object, which makes the networking try to replicate it.
my plugin allows for that
I can send LineTrace by RPC + Multicast.
What I want is this Line, when it hits a Player, to print a PrintString on the screen of the person who was hit.
(Characters are the same)
How can I do this?
Is it possible at all to play Animation with root montages when using CMC? CMC always try to correct the player resulting in snap back π¦
Montages yes.
Not sure about anim BP tree
why are you multicasting this
Do it more like this
Owning Client:
WHatever event -> trace -> hit somethign? -> tell server
Server:
Something was hit -> optionally verify the hit -> ok tell them
if you care about not cheaing on the trace you could move the trace to after the RPC from owning client to server but that's up to you and what you're actually doing
anyway, no multicasts
But when playing montages with root motion the character alwyas snap back because root motion is fighting with cmc correction π¦ im starting to give up working on rpg action game like dark soul.
If you're new to this you are not going to make anything even close to the core mechanics of dark souls
just flat out aren't
root motion and the CMC can play nice but you'll have to dig into it.
You gotta call it on Server and Client
I made a climbing system where I used RootMotion for the "Climb up onto obstacle" and it worked quite fine
Hmmm even calling it on server and client, the problem is, the cient uses prediction
saved move right, it still pending
You can try to call FlushServerMoves before
So it;s still correcting the position of the character
That's at least needed for RMS
I will dig into FlushServerMoves
trying to find a way to incorporate playing montage with the prediction π¦
Paragon coded this by hand
I read thru internet and a lot of people said to just give up on using root motion in network game
But one time RootMotion Montages should work
The CMC should be catching up on them
we are using RMS at least extensively
And that's just faking RootMotion from a code source after all
And again, I used this before for climbing animations
from what i gather CMC use prediction system which mean the client will be authoritive? The problem is the moment we play anim montage, the anim montage will use the server location of the player. Is there a way to incorporate playing montage in prediction? There is the FSavedMove for movement, are we able to use a simmiliar class where we can inject our own code? my understanding is without using time and prediction, CMC and root anim montage will not be compatible?
I didn't quite understand. Is it true what you said about the initial stage of the process?
What I want is when this Line Trace hits a Player, to print a PrintString on the screen of the person who was hit.
RootMotion is already integrated into this
But you are right that the location must be the same
The Start Location in this case
π₯Ή
The RootMotion data is checked upon based on a lot of values
So they must be they same for this to work iirc
But the CMC 100% has logic in it to handle RootMotion, including the Reconciliation aka SavedMoves
For movement I suppose I can use GetCompressedFlags and UpdateFromCompressedFlags but how can I do it for something else?
My client (work) is using GAS for their project. So we use RootMotionSources to fake dashes and jumps. We have to ensure all parameters are matching. Start, End, Duration, etc.
We are using AbilityTasks to send TargetData over from client to server to ensure they are both using the same data when starting.
I see, but that wil cause delay on the action part in high ping scenario?
Well, those were used for sending flags like "I want to jump"
but this is also somewhat outdated
We have proper Struct Containers now that can just be extended
We as in UE community/users/whatever
The jump is also another example why it can be fluid because the server will perform the act after it gets the compressed flag from the client
but in the case of playing montage, the engine just went, hey play this anim montage, ignore the incoming prediction
Jumps work just fine
Yeah jump works perfectly fine
As long as you use the Jump function from the CMC
The Client actually tells the server that it's playing the montage
Or rather the rootmotion
Again you have to call it predicted on teh client and then RPC to the Server
To have it sync
The server will figure out based on ping and timestamp where along the RootMotion it is when it gets the same call
The CMC 100% handles this
It might just be enough to call FlushServerMoves before playmontage
We do that for the RMS
Thank you I will look into FlushServerMoves
i tried FlushServerMoves but it;s still snapping. This simple setup seems to remove the rubberband, maybe it was snapping becuase I played the animation twice?
Is this setup correct or will there be a problem?
I'm half sure you don't need to call this on everyone
Only local and server
And yes, you would be calling it twice with the multicast if you don't filter
@dark parcel
@thin stratus Tysm
hi everybody again
i have trying to set my rotation character its works normally but in the mode online this doesnt work
the logic is when i click with my mouse de rotation changes but in the online mode this happen only in the server and in the client its like no rotation changes always the same
how do it works on form online?
I use FConstPlayerControllerIterator to count players in the level, it works on PostLogin in Game Mode but after 10 to 15 seconds it returns an invalid iterator, why is that?
do you think spell invocations are using TCP connection in dota2 / LoL?
Right now you are never telling the server WHAT you hit
you're just telling it that you hit something, and giving no other information
i don know
Great idea! Is it easier for the server to keep projectiles synced since itβs not using the physics engine? Some of the objects will be colliding with blocks or players. Main concern is I donβt want players getting hit by βinvisibleβ boulders. But would also like for them to be able to see where thereβs a boulder being blocked by a cube so that they can destroy the cube and cause the boulder to roll over someone
As far as I know PMC is synced, and supports bouncing effects.
Ok, I know but, this is only for printing string on Server when LineTrace hit the opposite character.
This doesn't provide a solution to the problem I'm having, This is just the baseline to get me to the process needed to solve the problem.
What I do next is more important to me, so what can I do and just project a PrintString on the hit person?
Tag method? Or Hit Actor and Cast to character, I really couldn't find it.
expand that hit result
it includes the actor you hit
Oh, I didn't know that, so the problem was because of the baseline. Thanks a lot!
It worked.
The system is working, but I am very curious about one thing. Why didn't we Multicast?
So when RunOnServer is used, doesn't it mean that it will only work on the server and not on other clients?
Why do I use Multicast if it will already appear on other Clients when I do RunOnServer. So I couldn't really tell the difference.
you don't need to do the trace everywhere
You want to trace and tell the thing you hit that you hit them
you need to go through the server so you at least need a run on server event somewhere
yeah, I understood that step but So why not use Multicast?
multicast runs everywhere
if you trace and hit Bob, what's that got to do with me? Why would I care
When I run on server, it shows everywhere already, what was the main difference
that's because whatever you're doing is implicitly showing everyone. Just running something on a server doesn't do anything for anyone but the server
If you specifically want to do a trace and show some notification on the hit persons screen, it'd go something like
Input -> trace -> run on server event (passing over hit actor)
Run on server event -> get hit actor -> run on owning client event on that hit actor
Run on owning client event -> show the thing
You can also do it like:
Input -> run on server event
Run on server event -> trace -> get hit actor -> run on owning client event on that hit actor
Run on owning client event -> show the thing
2nd approach is more secure but you'd have no instant feedback on the initiating client
oh
So if I'm going to shoot (with a gun) and emit sound, if this sound will be visible to everyone, is it Multicast or the method you say?
I took note of what you wrote, these will be very useful for me.
You'd multicast the FX yes
or spawn an FX actor, depends
Gun having a multicast event ShotFX is the general way to do things
ShotFX -> play sound -> spawn particle -> etc
but nothing gameplay related
My last question (promise, no more questions) π
Input -> trace -> run on server event
Run on server event -> get hit actor -> RunOnOwning..
Here we can get hit actor and cast to Character _BP and change the Variable in it just for him.
What I'm wondering is, what should we do if there is no "hit actor"? So we get the HitActor through LineTrace, what if we don't have the origin that indicates that it is that character?
For example, if we are going to change a variable for a random character in the game without a specific reason, what should we connect to the "Object" part of Cast to?
cast the hit actor to Character_BP
if it fails it wasn't a Character_BP
Thanks, now thanks to you I can shoot more fat Bobs in game.
Need help! for VR multiplayer replication, should i put MotionControllers in a PlayerController or Pawn? and what about HMD?
Would this be correct when changing a mesh for a client to server type thing or is there an easier way? I know i still have some tweaking but it was a general idea
If you want an Action/Event from one player to be transmitted to other players then yes, an RPC to the Server then RPCs down to all other Clients is correct.
Hello, I was dissecting Lyras inventory system with their item fragments and FastArraySerializer, and I was wondering if the fragments are supposed to replicate (from what I tested they do).
I looked through the code and remade some of it myself and I didn't find anywhere where they explicitly told the fragments array to replicate. Does this have to do with the FastArraySerializer or am I completely mistaken on some other part?
fragments don't replicate, they're static data placed on item definitions. Everyone already has all the fragments and the data set on them.
There was a bug I saw, and i fixed it, the game was still trying to call for the Mesh i destroyed
Out of curiosity I tried just putting a variable (int) on one and if I increment the int on the servers all the clients see the change.
that's only because you're in single-process PIE
you're not modifying that client's version of the asset. All clients in PIE share assets, so you're modifying it for everyone (and the editor itself)
Fragments aren't meant to contain any data that changes at runtime - that's what item instances are for.
anyone have confirmation on whether structs replicate atomically?
as in is there ever a case if i do
struct S {int A = 0; int B = 0};
server sets A = 1 and B = 2
is it ever possible that a client gets {A = 1 , B= 0} or {A = 0, B = 2}?
Is that even really a problem though? Is replication done on the game thread or is it a separate thread that can just come on in the middle of an update and just replicate stuff as it sits?
packet loss
Like if I set a, and then in the next line, set b, is there any way that replication could have happened between a and B being set?
no, but that's not what atomicity in replication means
Oh are you saying setting a and B would imply two packets?
no
if property A gets set, then property B gets set some time later but the packet containing property A was dropped then you can potentially have a (possibly temporary) state where property A isn't set but property B is
the only way to guarantee that property B can only have a certain value when property A does is to not use delta serialization.
The some time later being key, right?
...yes
Yeah that's what I was getting at.
but that's still a problem
if you have properties that depend on other property values then you have to write your code with the possibility that they can be out of sync, or you have to guarantee they stay in sync by throwing out delta serialization
how to transfer the actor variable by multicast to all clients?
Hi! Is any easy way to identify a player like with GetDeviceId in UE5.1? I found only that but it was deprecated
hi guys, im trying to track down a fatal error my clients get when testing my game over the internet, but i cant seem to get anything to print in the log(running the packaged build via powershell -game -log) the fatal error is just a generic windows box pop up with 'fatal' error on it and thats it.
making it hard to track down whats causing the error, anything I can do to make debugging easier?
don't
why is this not just a replicated variable?
You mean that the actor object variable can't be delievered to all clients by multicast?
I'm doing for AR..Replicate can be only used when all clients's origin is same.
but AR is not and remote rendering I'm using is not support for set the world origin location and rotation.
so I'm creating multiplay withough using replicate of actor, only doing by RPC
and only with blueprint! πΆ
It can but multicasting state is a bad idea
What are you actually trying to do? WHat game mechanic.
Use the crash reporter and the PBX files and upload to something like BugSnag
Any body knows how can I make a pawn movements like character movement?
Just do it.
Tick -> ????? -> set actor transform.
hi good morning
please someone help to do it
i trying all nothing works
i create a interface
so i put in the character
on click i send a message to interface and pass a vector 3
with that vector 3 i change my rotation
it works
but not update on the server when i do it on the client
You need to pass the vector over inside the run on server event
that's probably not the only problem you have but it's the first one I saw
ok i dint know that the custom event can put a input value
and why your nick name have ask me about 1d physics?
I have an issue with split-screen local multiplayer on UE5, it does not work, it makes the screen divided into 2 parts but when I press the keyboard button and gamepad button it only moves player 0, and player 1 will not move , any solution?
Think in the default setup the first controller and keyboard are input devices for the first player. If you plug in a second wired controller, you should be able to control the second one.
it only work on UE4 , not work in UE5
it does not work in Unreal engine 5.1
both keyboard and gamepad controls the player 0
How about two xbox controllers plugged into your PC - the second controller is still assigned to player 0 ? I doubt this behaviour is different in UE5
Hey all - when looking to hire a freelancer who can design a multiplayer setup for a VR app - what keywords, roles, etc. should I be adding to my job posting? Trying to determine the best way to seek out the task I want completed, after which I'll post in the hiring threads.
yes , I tested it with UE5.1 third person default project with 2 gamepad controller and both still assigned to player 0
guys any help ? it work in 5.0 but not working in 5.1
I have 2 players, one server and one client. When the client is possessed, i try to acces its controller using the "GetController" node but it returns null. I know that there is a controller on the client side and server side but why i can't I access it on the server ?
Where are you trying to access the controller from?
In the OnPossessed Event
If i getcontroller in the beginplay for example, the client return a value for himself but the server returns null for the client
I don't know if i am clear enough
No, all i do is in character blueprint
But i know that there is a controller, as there is an output for the OnPossessed event and if I print it, it print the good controller
https://wizardcell.com/unreal/multiplayer-tips-and-tricks/ has some info about GetController and some common issues people run into with it.
I'll read that, thanks
BP or C++?
And you're overriding "Possessed" in the Pawn?
Yes
In the c++
I call the Parent function and do some stuff
void AMainPlayerCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
PawnExtComponent->HandleControllerChanged();
}
I copied some stuf that are in Lyra
And you're 100% that controller is null, and not the Controller's Pawn?
Well i call GetController in the pawn so it can't be null right ?
As it is effectively called
Definitely doesn't make sense. That super should be setting your controller in the Pawn.
And the only thing that calls that normally is a controller, so it's usually not invalid.
Ohhh
I know why
I'm so stupid
In the blueprint i wasn't calling the parent function
That shouldn't stop the controller setting though?
Yes actually
Those are two different functions. One is a BlueprintImplementableEvent that the other one calls.
π€·ββοΈ I dunno. But not calling that Parent function in BP should only break parent BP classes, not this class.
The only way that should come through null is if this class has a BP child that overrides Possessed, calls the Parent function, and doesn't pass in the controller.
Actually scratch that. It wouldn't even then because you're using GetController.
Yeah it is weird π€
I just tracked down the spawn logic of a player - and had some questions of you guys... how deep down the rabit hole do you guys override for your own projects for custom player spawn logic?
I started in the function ChoosePlayerStart() but it goes much deeper than that - and theres ALOT of functionality in the engine base implementation of these functions...
It seems appropriate that you'd override AGameModeBase::Login() - but that takes out 3 underlying functions in chain - and several other lines of implementation... seems dangerous :/
Question, should character death be handled on the character asset or within the gamemode? Is there any downside to handling it in the character?
Both more or less
The Death of the Character itself, so the visuals, the health, any abilities it might have, whatever, should be done in the Character.
Any outer gameplay, like scoring points, queueing a respawn, etc. should/could be handled in the GameMode
Thanks, I figured there wasn't too big of a difference.
Is there an easier way of incrementing a variable thats set to RepNotify than this?
Increment node doesnt work with repNotify π¦
I go as deep as I need to go and no further π
is there a way to spawn an actor on the server, have the player position it somewhere in the world with input, and then replicate that placed object to all the clients?
No
Server RPC through a player owned actor its new position, set it to a replicated property, and set the actor position to the newly set position in the repnotify function
Well.... thanks π
Make yourself a blueprint function library (note the integer input needs to be passed in by reference)
That's readable, what's wrong with it?
I'm almost sure this has the same problem
if you don't call the Set node directly, it won't trigger the RepNotify
RepNotify in BP s*cks
Same with array modifying functions
I always set the array with itself at the end
.>
Of course its readable. Still takes more nodes than the increment node^^ Was just wondering if there was something else. I just made a macro to have it look a bit cleaner in there. There is a lot of stuff around that so I wanted to keep it smaller i guess π
Where should I store a list of player controllers that I want all players to be able to reference? I thought gamemode, but that is server side only.
you don't
player controllers only exist on the server, except for the player who it belongs to
no client can see any player controller other than their own
PlayerState is what you're wanting
and you already have an array of all PlayerStates
hey, I have a question about OnRep functions. The server is setting ActivePlayer and the OnRep is being called. The listen server receives OnRep and a valid object, but the Client OnRep function is null?
im having a bit of an issue trying to spawn a widget only on the local player, i have a basic pawn that spawns at the beggining of the game, this pawn is only for spawning logic, it spawns a a widget where u select ur character and then gets destroyed and u get ur proper character, but im having dificulties getting the proper "IF" check so that it only spawns on user that it relates to
where are you spawning it from? you need to get a reference to the controller that owns the hud/pawn. you can is Is Locally Controlled on a branch to get the controller
it spawns from the game mode class, its the default pawn
im trying is locally controled but i need to call that on the owner and the owner doesnt have that function
only "get player pawn" has it
and player pawn 0 is lawys localy controlled
pawn0 isnt always locally controlled, if there is a dedicated server it wont control any pawn but have a reference to all of them
*controller 0
if you are spawning a tempoary pawn for the player until they make their choice, you can spawn the UI in there. when a player connects to the server they are assigned a controller, and if there is a default pawn in the game mode set, the game mode will spawn a new pawn for them, and the controller will posses it. you can either spawn a HUD on the Controller Beginplay, or when the pawn is posessed
you are adding the child actor component only on the server
It looks like your "Active Player" is probably a player controller, which are not replicated to all clients.
References to them will never be valid on other clients other than on the client that is using that player controller.
its replicated in the blueprint for that one
neither are showing on other clients or the server
I see. I guess I need to save the active player state on the server so it can be repped to clients?
No. Use the playerstate as the active player.
When you change ActivePlayer, the OnRep would be called and can read the name from it as you want.
the turn manager is setting the active player which is the vent I need to trigger. So do I run that only on the server, which sets ActivePlayerState and that OnRep can be passed to clients?
Yes (Sorry, after re-reading what you wrote I realized that was what you were asking)
ah i mixed up the node order on something, it was spawning but in the sky 
Hello everyone!
I am spawning actors and positioning them in the server and I want to know if there is an event on client that let me know when all the spawning and positioning is ready on the client side.
you need to set them to replicated variables. If the object you spawn has an OnRep replication type, it will trigger an event when the pointer has been updated onc onnected clients
so when the client can access to the actor pointer I can assume it is completely replicated?
what about the location changes?
assuming that the client has no authority on this actor
if you spawn an actor on the server and it has replicate set to true, it will spawn on clients, and the BeginPlay event will be the first time the client is aware of it
location changes, you can check Replicate Movement on the actor properties
its important to realise that unreal asks you to specify EACH variable inside the object and if clients should know about it. setting replicate to true will just mean that the client knows of an empty shell of an object, but not much about the data inside
to get the variable data on clients, you have to set each variable to replicate in its properties. this does not guarantee you will have the data when you look for it, beecause when the data is changed on the server, it takes time for it to propogate to clients. there is another replication mode OnRep this will replicate the data and generate an event for when the data is updated on the client
its done this way to save bandwidth so you need to be aware of that. setting the actor to replicate and replicate movement will spawn objects on connected clients, but if you need clients to know about data inside them you need to replicate that manually
Awesome! Thank you so much!
i have a pawn that return true on "locally controlled" when it first spawns, but after respawning that pawn in the server and possessing it, it returns false is this normal?
Hello everyone, I got a multiplayer game that I make, I use Layers with WP. I tried to change the light for the dongeon and the worldmap. here my code.
I have created two seperate layers, but does'nt seem to change the state here. any Idea ?
I run this from PlayerController
I changes the PlayerController replicates checkbox
The "Set Data Layer Runtime State" nodes appear to be marked to only be able to run on the Authority as indicated by those icons. Your player controller would not be something that the client would have authority over so it won't execute on the client.
The variables "World Map" and "Dungeon" would also likely play a big role in what you are doing. If your intention was to have the client execute based on values that the server has, the client needs the values of those variables to do the exact same. Those variables would either need to be replicated or passed through an RPC so the nodes have the values to execute.
First thank you for your help very appreciated.
I change the WorldMap variable to replicated but does'nt seem to work
and here the custom event
First bit I said...
The "Set Data Layer Runtime State" nodes appear to be marked to only be able to run on the Authority as indicated by those icons. Your player controller would not be something that the client would have authority over so it won't execute on the client.
ok understand, but how to make the player execute something on the server then.
if I enter in a dongeon, I need to turnoff the world light on client side then.
my goal here is to use Layers on multiplayer... and change light when entering to a Dungeon.
Actually nix what i said.. Just realized that the target is the subsystem - that means it would run on the client as the subsystem is likely tied to game instance which your client would have authority over.
It's likely running those nodes correctly, but the values being fed in may not be correct. If you just set those variables and then call the RPC the RPC could be arriving before those variables are actually replicated. You may need to figure out a better way to handle the logic like if these variables are meant to be stateful, then set them as Rep w/ Notify and use the OnRep function to perform these actions instead. Then whenever these variables change, the client will receive the new value and call the OnRep function, which can call these nodes to apply the changes.
ok well , those variables will not change, it's why I have both variable for each realm. if I make a print screen at the end of the custom event it's pass. but not executed.
I will try with OnRep if it help
You likely do not want to use a multicast in that case either... Every time you're multicasting then you're asking the server to do the same thing which you probably don't want it to do every single time. Perhaps only use a "Run On Client" event marked as reliable and pass through the variables as inputs so they'll pass whatever the server value has along and then use it on the client.
does'nt work either... gee.. it's hard lol
this is a difficule exemple but what append in a multiplayer game and a player decide to turn off the light switch for a light in a room, since it's the server that control everything, player don't have any power to change anythings ? or maybe using interface ?
Run On Server means only the server will run it.
Based on your current logic line, you're checking authority, which means the true branch would be running on the server. From there, you'd have to call a Run On Client event if you want the client to run it..
The thing is, you're using something that doesn't replicate - your subsystem is likely tied directly into the game instance. Any changes you make to that subsystem will not replicate automatically.
That means you have to pass something to the clients.
but "Set Data Layer Runtime State" is Autority only, only executable on server
The target is something that the client would have authority over - namely the subsystem which is tied to game instance which clients have authority over.
The thing is, this subsystem exists separately on the server and the client. They cannot talk to eachother directly.
ok I need to send it as parameter to my custom event
from client/server
for the subsystem
question for you folks. I've got a TArray of an FInventoryItem structs where the TArray is replicated. I'm updating the UI in my OnRep, but the thing is once I simulate network lag, it gets kinda slow (taking like a second to update even at only a latency of 30). I tried doing some client prediction but if you started moving things too quickly, the UI would get confused. What can I do to fix this? Would switching to a FastArray help? The inventory lives on an actor component on the character which has the default netupdatefrequency
UPROPERTY(ReplicatedUsing=OnRep_InventoryItems, BlueprintReadOnly, BlueprintGetter=GetInventoryItems, Category=Inventory)
TArray<FInventoryItem> InventoryItems;
I think the typical approach is for the subsystem to spawn an actor to replicated through
Hm it shouldn't take a second with 30 Ms ping. But fast array could help either way. Predicting the item move is something where your whole setup has to fit. You most likely can't use the OnRep then anymore
DOES anyone know how to make character animations play on the server even on a dedicated server where it is not being viewed?
I have a sword attached to my Mesh and it is not detecting overlap events on the server unless a listen-client is nearby
Driving me crazy
Yeah it probably wasnβt a full second but definitely not all that responsive. Yeah idk if I wanna do client prediction for that reason but Iβm not so sure. Iβll try to implement it as a fastarray and see how it goes I guess?
do folks usually try to do it with client prediction? if that's the case then maybe i should refactor and go that route
Well in theory a lot of stuff should be client predicted that isn't. UI imo should probably be if possible
You'd mainly need to keep track of the Inventory interactions in some local history when and moving an item tell the server the result and some id to know which interaction this is about.
If the server has the same result you can send an RPC to acknowledge the interaction.
If the server has different result you can send a correction.
Theoretically you don't even need the local history if the correction should simply reset the whole history anyway
E.g. when dealing with movement you usually replay newer moves locally after a correction based on the new starting point.
For moving items back and forth you might not want that
Then it would simplify itself to just the correction RPC fwiw
Ah that makes a lot of sense actually
Thanks for the explanation!
I might still try to do fastarray first and if that doesnβt work Iβll go the client predicted route
I appreciate the advice!
Hi guys i'm a little confused on what's going on but right now, in the editor when i change the number of players from 1 to 2 or 3, player 0 ends up not having a pawn to possess but players 1 and 2 do have pawns that they can possess and move on with. if i comment out my handlenewplayer implemetnation function, player 0 will have a pawn to possess but player 1 will be frozen. I also noticed that within my handlestartingnewplayer implemetnationfunction, when i check to return if the new player has a pawn, it always returns true and so returns from the function but i am confused as to how my player has a pawn once they login because i never implemented any function to spawn a pawn for the player to possess once they connect to the server unless post-login or pre-login or init-game already does this?
Why does PreLogin not call its Super implementation?
You absolutely want to be doing that.
Could someone please help me out? I am pretty new at UE but learning as I go! I have created a sailing system in a multiplayer game I am working on. I have the possession of the ships sorted & replicated. but the ship movement is not. On the server side I can use the sails and drive the ship but on client side it doesnt work. Would someone please assist? Ill send all screenshots in DM -
If you're new, why in the hell is the first thing you do a multiplayer physics-driven game?
Are you using physics or doing the actual movement on tick yourself? Show your code
whoops i just changed that. my issue is still there thou. it kinda looks like this for a visual representation
like i see character 1 on the client side for player 1 but for player0, there's just nothing and i can't move
Replicated
Can I test a mulitplayer game using world partition in Editors of 2 PCs in local network? I remember I used to do this on UE 5.0 and the editor crash.
The CMC is several thousand lines of code, very tightly integrated with the character class. Any particular reason you're trying to basically just remake it?
Hi, I currently have BT-Task Aim. That takes the target location and saves the Yaw as a float on tick on the server. The float is RepNotify, so when the float changes on BT-task, it also sets worldrotaion yaw for the character on server and client. The thing it, it seems to be really heavy for the network. Thats why I'am now wondering if its a completely wrong way to do it. Thank you
Iirc the AI stuff already has a "Focus" logic, where you can supply an AI with a current Focus and the Character Class or whatever drives this should already handle rotating towards it
In case that's your reason for this
Guys I am making a mechanic where in my gamemode the general pawns are charged as the users are connected with the postLogin the doubt in the spawn actor of my pawn how should I mark the collisions to avoid that sometimes the character stays locked with map
Yes
Or I need something like general movement component fo free
Hi there. Is it possible to have unreliable replicated variables?
Not really
You think it's a good idea to have variables that are meant to convey state, be unreliably dropped?
In some cases yeah
Yeah no :D
A location variable for example
There are already a lot of ways to control how often they should replicate
And how they should be serialized to keep the footprint small
How do you control how often they should replicate? Haven't seen that in the documentation.
As well as only replicating them to some net roles that need to know about them and not replicating the actor at all if unrelevant
Not per variable, cause that makes no sense
You can toy around with the NetUpdateFrequency and the Net Priority of the Actor
Or change them to be Push Based (C++ only)
I didn't see anything about push based in the doc either
No idea about the docs
Well thanks
PushModel is basically just a way for you to mark them dirty when they are changed so the engine doesn't have to compare them every time even if they are unchanged
If you need to keep the footprint low you netserialize them as small as possible and usable.
I'm very familiar with replication in general. That's what I did professionally. Just trying to figure out how to do it in Unreal.
I want to replicate actor locations, but not their rotations. Doesn't seem like Unreal allows that. So I was looking at doing it myself with an unreliable location variable.
Is there a good guide for how to setup a 1 vs 1 win/loss system from 5 rounds? I feel like i've been banging my head against a brick wall watching all the tutorials on youtube as they don't provide enough help with the networking side
I just need it so in the gamestatebase I can reference all the players and their slots
You already can
gamestatebase already has all playerstates
doing this always failed when I run the game as client.
void AARMACharacterBase::BeginPlay()
{
Super::BeginPlay();
APlayerController* ControllerRef = UGameplayStatics::GetPlayerController(GetWorld(), 0);
AARMAPlayerStateBase* MyPlayerStateRef = ControllerRef->GetPlayerState<AARMAPlayerStateBase>();
if(!isvalid(MyPlayerStateRef))
{
//log Player State failed
}
}
how to fix this issue?
Controller has a pointer already - try using this:
instead of GetPlayerState<T>()
i do the following in my own project:
CastChecked<AVI_PlayerState>(PlayerState, ECastCheckedType::NullAllowed);
@nocturne quail
I can try this will update in a moment about result
this is still not valid in client mode with 1 player on index zero
what timeframe are you accessing this variable? maybe playerstate isnt available yet?
ALSO - i've got in the habit of this - way back when i started Multiplayer....
AVI_PlayerState* NewPlayerPState = nullptr;
do
{
UE_LOG(LogVIGame, Log, TEXT("NEW PLAYER JOINED - LOOPING PLAYERSTATE."));
if(AVI_PlayerState* TempPS = Cast<AVI_PlayerState>(NewPlayer->PlayerState) )
{
UE_LOG(LogVIGame, Log, TEXT("NEW PLAYER STATE CAST SUCCESS"));
...
NewPlayerPState = TempPS;
}
}
while(NewPlayerPState == nullptr);```
you may think this is unsafe....
on begin play I casted, and later I have an event running on server which is called by pressing the num1
be understanding that PState isnt 100% available at time of PController instantiation... takes a few frames to set in
in ALL of my logging - thi shas only done the UE_LOG 1x
which i would imagine = 1 frame
unless you have a bad game mode setup - this will never crash engine.
i picked this up SEVERAL years ago
this not crash the engine, I am returning when it fails so it not crash
trying this now, hope it will work
i dont think you're understanding me - you have to loop as I did above to get the playerstate.
but if you do 1 player, still need loop?
its a latent setting - and unfortunately to my knowledge - not a lifecycle event on its setting
its safe.... i would just say YES safely
Ok, I am now implementing the loop, I hope it will work, will update for results
let me know how it goes for you - we can hop in a VC if you want & screenshare/work through it
so ... i've granted my abilities as server - and when I execute my abilities i'm getting a print strin gof both Server/Client... which tells me that its at least running as both.... but when I attempt to just simply do a SetActorLocation() - its not setting the location on remote clients. Should I have some other functionality here - perhaps using the CMC so its replicated? This obviously isnt a problem on ListenServer client
the loop has freezed my PC , and for 10 minutes my keyboard and mourse stops woking
i guess that begs to question then - are you setting your playerstate class in your game mode?
restarted the PC by direct power buttom pressing for few seconds
OFC
then somehow you have circumvented setting the playerstate in the playercontroller - do you have any overrides you've done in playercontroller class?
maybe any custom spawn logic in GameMode that does perhaps htis?
its going to be deep-seeded at this point :/
yeah in game mode I am spawning items in level
for a safety sake - you could just do a iteration - instead of a endless loop... that way you iterate 10x persay - and stop if it doesnt reach it... of course your funcitonality would be the same - playerstate would be nullptr :/
but atleast you have loop-safety
sorry it crashed ur PC
when I play the game, I got print string on screen the PlayerState success, logically the loop should stop, but it doesn't
past eyour code so we can figure it out
If you're doing htis in BeginPlay - remember that htis runs on both SERVER/CLIENT... you're inevitably running this loop 2x
if it is faililng - its failing in one of those netmodes
do
{
print("New Player Joined, looping");
if (AARMAPlayerStateBase* TempPS = Cast<AARMAPlayerStateBase>(NewPlayer->PlayerState))
{
print("NEW PLAYER STATE CAST SUCCESS");
MyPlayerStateRef = TempPS;
}
} while (MyPlayerStateRef == nullptr);
NewPlayer is of type PlayerController
APlayerController* NewPlayer = UGameplayStatics::GetPlayerController(GetWorld(), 0);
and yes I am running on beginplay
I would authgaurd this then on server only.
i'm uncertain where your failpoint is - what class::BEginPlay() are you running this in?
Mycharacter
if you're all the way in MyCharacter - you're playerstate is most certianly valid.... and ALSO has a TObjectPtr named Playerstate..... you dont even need to reach ou tto the controller to get it.
i'm almost sorry we went through all of htis - i went back to read your original post and saw that the class was indeed your CharacterBase .... this was alot of unecessary troubleshooting :/
yeah it was a confusion π
I need to do something like this, right?
MyCharacter.h
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
AARMAPlayerStateBase* MyPlayerStateRef;
MyCharacter.cpp
if(HasAuthority())
{
do
{
print("New Player Joined, looping");
if (AARMAPlayerStateBase* TempPS = Cast<AARMAPlayerStateBase>(GetPlayerState()))
{
print("NEW PLAYER STATE CAST SUCCESS");
MyPlayerStateRef = TempPS;
}
} while (MyPlayerStateRef == nullptr);
}
if (AARMAPlayerStateBase* TempPS = Cast<AARMAPlayerStateBase>(Playerstate))
take out the do/while ...
you shouldnt need it
not in ACharacter tiemframe
Has a getter
Also what in the world are you doing there haha
If you need a valid PlayerState use PossessedBy for the server and OnRep_PlayerState for the clients.
The do while is never ever needed for this
And will also not work cause you just get stuck in the current frame
Ok so I will use with get method standalone for server and for clients onrep
How can I do this properly with code?
Like could you show the events I should make for the round system for a 1 vs 1
Array of all PlayerStates, maintained on both server and clients (PlayerStates are always relevant)
I mean it's just there
just get it
Give your Playerstate an int NumGamesWon variable or whatever
give gamestate a NumGames variable
ok
whenever someone wins a game, increment NumGamesWon for them and check if it's > NumGames/2
I think maybe i'm overcomplicating it.. I am still not sure about networking
You can do all this on the serverside of GameState and PlayerState etc. If you find yourself reaching for a RPC of any sort, probably not (maybe something like CongratulationsYouWon but nothing gameplay related should need any RPC for this)
Detect win condition -> add to players score -> check if they won the set -> ??? -> profit
all of that can be done serverside just setting replicated variables (so clients can see their score update etc)
Do you have to set an actor as replicated in the constructor or can you do that later?
Can do that later via SetReplicates
And that will create an instance on clients too?
Can also make it dormant and wake it from dormancy once it wants to replicate
It will
Awesome, thanks
how does one detect the shutdown of a dedicated server?
the GameInstance::Shutdown and GameInstance::ShutdownAfterError dont get called for dedicated servers, is there any other way?
I tried to add SetReplicates(true); on character, and attached a mesh to character, got a breakpoint in here
// Due to replication order the ensure below is only valid on server OR if not both parent and child are replicated
if ((Owner && Owner->GetLocalRole() == ROLE_Authority) || !(GetIsReplicated() && GetAttachParent()->GetIsReplicated()))
{
// Make sure parent points to us if we're registered
ensureMsgf(!bRegistered || GetAttachParent()->GetAttachChildren().Contains(this), TEXT("Attempt to detach SceneComponent '%s' owned by '%s' from AttachParent '%s' while not attached."), *GetName(), (Owner ? *Owner->GetName() : TEXT("Unowned")), *GetAttachParent()->GetName());
}
solved, it was due to a 1 sec delay somewhere in the ch class, deleting the delay fixed this issue.
can Replicated functions call a return type function?
What do you mean?
RPCs are Events, Events dont have return types.
means like:
const FName UserName;
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
FName ServerUserNamesDatabase(FName NewUserName);
FName UserNamesDatabase()const {return Username};
ServerCalculateHoldGunSocket(FName NewUserName)
{
UserNamesDatabase(NewUserName);
}
Ok, thank You very much for correcting me
UserNamesDatabase in that example would just be a regular function?
There is nothing wrong with the code you posted above.
yep
it doesn't compiles, complaining error : Replicated functions can't have return values
.h
const FName UserName;
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
FName ServerUserNamesDatabase(FName NewUserName);
FName UserNamesDatabase()const;
.cpp
void AARMAPlayerControllerBase::ServerUserNamesDatabase_Implementation(FName NewUserName)
{
UserNamesDatabase(NewUserName);
}
bool AARMAPlayerControllerBase::ServerUserNamesDatabase_Validate(FName NewUserName)
{
return true;
}
FName AARMAPlayerControllerBase::UserNamesDatabase() const
{
if (!HasAuthority)
{
UserName = ServerUserNamesDatabase(UserName); return UserName;
}
//Somemore logic...
return UserName;
}
Ohh sorry
I must have missed it in the original code
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
FName ServerUserNamesDatabase(FName NewUserName);
This is wrong
You cannot have a return type on a RPC
As I said earlier, they are Events
Events dont have return types
hmm sadly
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
void ServerUserNamesDatabase(FName NewUserName);
Im not quite sure what you expect to happen here?
What are you trying to do?
I am trying to connect the sql db to my project to save user data,
names, scores, kills etc
Ok thats sort of a separate issue though.
Why do you think you need a return type on the RPC is the question.
It was not planned, I created a server version from a normal return type function by duplicating it and it got fname automatically
later compiled, and got error
Do you understand what an RPC is?
OFC, remote procedure call
Ok, so you know they are only 1 way calls.
Thats why they dont have return types.
So converting an existing function to an RPC with a return type makes no sense.
Ok, but I didn't convert...
I just tried to call this function FName UserNamesDatabase()const; on server , just duplicated it and added those return types and the function type remained FName as well
Now its working changing it to void
Thank you very much for correcting me
π
ive run into a bit of an odd problem. so im simulating two players trying to interact with the same 'chest' that has an array of game items they can manipulate
now the problem is ive made it so the last player to interact with the chest takes 'ownership' of the container actor for the purposes of being able to use PRCs but then that stops the first player who interacted with the chest from making use of those RPCs, is there some more universal solution to this
I fixed that by splitting the Inventory into 2 systems or rather components.
I have inventory components and an inventory manager component.
The Inventory Component sits on the Chest and other Actors and mainly deals with the actual item part of Inventory as well as with modifying itself. It doesn't have any logic to move items between inventories (or itself) but rather had the logic one needs to perform that action. Such as figuring out where an empty place is or if it can stack something. And then actually adding and removing entries. However all of that without the knowledge of a second inventory.
The Inventory Manager Component sits on the PlayerController and can receive RPCs. It exists once per player and handles the communication between two inventory components. Such as move item from I InvComp 1 to InvComp 2 .
anyone know why my server isnt found?
oh not bad, this makes total sense, thank you
anybody here knows how to make a whitelist system for beta testers (IP based) so that if a beta tester sends a build to someone who isn't a beta tester the game crashes at startup
Is this on top of an account-based system?
Curiosity
Hey everyone i wanted to ask about making multiplayer games using blueprints, ive been working on my fps over a year now and ive made it completely in blueprints and ive implemented most of the core systems but i am slowly finding out that blueprints are not really suitable for making a big multiplayer project, does anyone have any ideas of what can be done in such situations?
It's not an either/or choice between "blueprints" and "no blueprints"
you can always migrate just the bits you've run into problems with into C++ and keep the rest in blueprints
the systems are designed to work together
How would i migrate bits of my character bp into cpp when most of it is already done?
Generally speaking that decision is made at the actor level, and in most cases involves a rewrite
typically you'd have the basic code functionality of the actor (so, in this case, movement, input binding, etc) in a C++ class and then make your Blueprint derive from that class and add stuff like models, animations, etc in the blueprint
Right , id have to basically rewrite the whole thing from scratch
this is why it's good to design scalably early! whether it be with just a simple division of labor between components (you can mix and match C++ and blueprint ActorComponents too) or with the gameplay ability and gameplay feature systems
Indeed but i didn't know that only bps would not be the right way
Depends on the scale and complexity of the project, for alot of things the "bp only" approach is definitely enough. Especially if you dont need any cpp-only functionalities, performance isnt an issue, or you work individually/as a small team and fast iterations on game features are preferred.
im quite confused as to what to really do, most of my character bp is done, almost all of it tbh. and suddenly figuring out that bps are not optimized- is there a way to optimize things without having to rewrite the entire thing cause its quite alot
and i do wish to someday publish this project on steam so i do wish for it to be optimized and for people to not jitter around-
there's no such thing as an objective "not optimised"
profile first
there are far too many moving parts in modern games for performance to be a game of pure reason
measurements are king
Guess it depends on specifically what aspects are unoptimized. If it's deeply tied to your core class functionality, then I guess only a full rewrite can really improve things. If it's a specific functionality tho that you can turn into a component lets say and only move that part over to cpp, that's an option then. It all comes down to your bottlenecks and the hardware youre targeting. Do you ACTUALLY have a perf issue atm?
(Also gotta point out that not even cpp can save bad coding, so it really depends on what youre actually doing.)
and yeah you can move just the bits that you need to optimize into c++, you know? whether that be via actor components, blueprint function libraries, loose uobjects, subsystems...
The only issue ive faced is when play testing till yet theres a bit of a movement jitter or rubberbanding but thats all really
Are your player pawns Characters?
Yeah
huh, usually that kind of network jitter should be handled by Characters then
in any case I don't think it's a performance problem then unless the game is stuttering or the profiler shows a high time for the blueprint
Listen server or dedicated? Whats the architecture? Network lag/jitter can show for multiple reasons.
Listen server
I realise it can be a bit contributer to this but i was more concerned just about the use of bps
Ive been watching more videos regarding how they are not really the way anyone would go about making a multiplayer game and it tensed me up since ive been working on my project since quite a long time
And tbh i did test my game in conditions where there was a network issue from the host
Blueprints, by themselves, are not unoptimised by default
Code performance is more about the code you write rather than what you write it in
Blueprints are slower than C++ but that's often an entirely acceptable tradeoff in the vast majority of situations
no longer exists
ah, it's still a thing in 4
still, it got removed from 5 for a reason
(unreliability and complexity)
Oh i see
So you say i do not need to rewrite or worry much unless i do face an issue that strikes out
In any case
Don't worry, honestly
The engine has profiling tools, you shouldn't overoptimize too early
Some thought is good to put into it early but you don't need to squeeze every cycle out before you even have a game
Thats relaxing to hear. I shall profile before i take any decision i guess. Sorry for the weird doubt ig as i said i just got tensed over having to work all over again on something ive been working for so long for. I appreciate your help and input : )
I think worrying abt BPs without an exact performance issue is pointless. If you see high game time (bp execution time), thats where you should spot the code thats causing the issue and try to optomize it. If you cant, (cz it absolutely needs i.e lots of nested loops or w/e, things that are inherently slower in BPs than in cpp), thats where you could look into turning that functionality into a cpp component or function library.
i see i see, as ive said i have no such issues quite at the moment- nothing that stands out as an issue either- my game works fine and has worked quite well the last time i tested it aswell - so as you all have pointed out i have not much to worry for at the moment
is it bad practice make iteminfo modular like lyra? many tutorial make item info into one big struct
Is it because this way is more performent in a multiplay environment?
lyra's modular way was seemed better, but everyone don't using it, so I'm afraid it would be the wrong way
hello, i have an actor that loses net relevancy (as intended) but it takes around 3 seconds to remove it from the client, how can i speed that up? i tired increasing the net update frequency and the net priority but it seems the same duration to disappear
Hey guys I'm developing a multiplayer game for Android bt I am unable to use unreal engine deafult gamepad joystick for example let's say we have 3 players then only player is getting controlled like if 1st player uses controller 2nd player moves and if 3rd player controls 2nd player moves
How can I fix this add your inputs guys. Anything will be appreciated
People don't use it because it's newish. People have a hard enough time following Lyra let alone implementing it's data structure.
Whether it's good or bad depends. As far as static data goes, it's probably the best way. Pointers are cheap to replicate and all you really need is the top level asset holding all of the other assets for a thing. If you have statically specified modules for stuff that you want to swap out, it's probably still a good idea to use data assets.
But for anything that needs to be dynamic. Like the item stack on a simpler item, you still need some form of pod replication, which is usually best in a struct of some kind.
Thank you for the explanation, then it's not bad except dynamic. Is it possibly good way to use Item Structure and mix Fragment Class and Stack Count Int as properties for dynamic? i'm confusing if i use struct form then when i change something in struct like int stack count, i should re-replicate whole item struct like one big struct way?
Hey iβm working on a multiplayer game and setting up a server for the first time so i decided to follow Ryan Laleys online sessions tutorial but now Iβm stuck with only the host session being able to spawn in with their chosen character and everyone else spawning as a blank character class. in his tutorial heβs able to fix it because he handles respawning in blueprints but thatβs handled in c++ for my project and iβm not really a good enough programmer to sort this out myself tbh can anyone help?
Basically the way I have it set up is that you join a session into a character select lobby and once you choose a character it gets saved to a game instance and once you load into the map after start it looks at the game instance and replaces the default pawn with your chosen character
however only the host will actually spawn as the character they selected
@jaunty marsh I can already tell you that there are better ways to do the "Save what Character got selected" when you are already connected to the Server
Moving data from MainMenu to Lobby might be a sh*tshow, but Lobby to Gameplay Level is a lot easier
You can save the Data in the PlayerController of the Player (Server-side)
And in the GameMode you have a function called "OnSwapPlayerController"
Where you can move the Data from the Lobby to the Gameplay PlayerController.
The cool thing about this is that you can then override the "GetDefaultPawnForPlayer" (or whatever it is called) and simply get the data from the Player function param.
Also saves you from the whole sh*t of RPCs you need for the GameInstance solution
Does require you to use SeamlessTravel ,which you should anyway
@thin stratus I got it mostly working thank you
How shuold I identify the player which has won?
Idk what your project looks like or plays like cz I wasnt following, but normally you'd have a bDead bool var somewhere, you can have it in the player state in this case and you'd set it to true when someone dies ingame (based on your custom rules and gameplay). If it's 1v1 then it automatically makes the other player win, if more players, then you'd check for an overall wincondition everytime anyone dies.
guys i have a problem i am using the gamelift plugin in blueprint and now with the aws interface change. When I have to change the map with the open level, it doesn't do it and before in the previous version, yes. Has this happened to anyone?
The part I don't understand is what would it look like in code to setup a system where when a player dies the other wins?
Like how do I put it into code
Where the player takes damage, youd check if they died from that damage. If yes, you call all your other functions for checking win conditions, setting your variables etc
Have you coded your damage system already? Dealing/taking dmg
How can I properly set a variable in the gamestatebase from the player?
What are you setting in there?
I guess the number of wins the players have
Also which player won the overall game
Because I need to call an end screen widget
Yeah you set it on the server only. Server handles damage, server handles player death, and server handles gamestate. Not sure what else I should add here, youre literally just setting an integer var for every player.
Would you be able to show me because I spoke to a few other people and they just said what I said basically lol
Im on phone so I dont have UE available atm, but if you have concrete questions I'll help you through.
Would you be able to send a screenshot of it later?
Pls
Since idk how your damage system etc is made, idk what to send you a screenshot of
I just need to know how to determine the player who won via the gamestatebase
Incrementing an integer for every win is clear, right?
Yeah for the player
But i'm not sure how to keep track of the winning player
Like how to reference it in the gamestatebase
Where do you keep the integer for the number of wins for every player?
Player state
And you made sure it's the server thats incrementing the value right?
Yeah
This is the gamestatebase
Getting the player state in the last pic is pointless, just cast the array element to your custom class
And you pretty much have it btw
The only thing missin is you calling your gamestate check when incrementing the value for the win
I see
Getgamestate->cast to your gamestatebase class -> call the win check
Call this DecideGameWinner function on increment
First increase the int in your playerstate, then call the gamestate winner check to see if with this last win anyone has won the game overall.
Youre doing it the other way around
You can't increase the player variable from the gamestatebase?
I would prefer this if possible
You can, but it still needs to come first
It doesn't work