I need someone here for some Important Questions
first: I’m working on a multiplayer shooter game
1-I’m using (Game Instance) to (Create, Join, Find & Destroy) Sessions, so is it the right place to fire some functions like that?
2-I’m using the (player state) to store some player data such as (player money, Inventory(Skins & other Items), player score, other player data (like Player Name & other stuff), etc), so is it the right place for it & how can I use (Epic Online services) to store Important data like (Player Money & Inventory)?
-because it’s something that needs to be online
3-when I cast to (Game Mode, player state, Game state, player controller) from (player character, actors & widgets) the cast fails on the clients & works on the server, so could that happens when I release the game & player start playing the game?
-because there are important (events, Functions, Variables) that I need in gameplay.
First of all, PlayerState is exactly the place to store this kind of data. It is replicated from the server to all clients. And each player gets their own instance, so each player can store their corresponding Money, scores etc. When you say the cast fails, i assume you created a custom PlayerState based of on PlayerState, with your custom properties for score, money etc. in it, right? Have you assigned this new type to the GameMode?
You can find these in your Project Settings. If you also overwritten your GameMode you can set this in the Blueprint Editor or in C++ accordingly.
thank you, yes I’ve assigned the player state to game mode
but the cast fails on the clients only not the server
that happens when I cast to the (Game Mode, player state & player controller) from the (player character)
So my question is: when I release the game & players start playing it in multiplayer will the cast fails again or it’s going to work?
because there are some (game events, functions & data) that I need to cast to (Game Mode, player state & player controller) from the (player character, other widgets & actors) to get it to work or to get any data from it, for the gameplay & stuff like that.
Yes, that’s normal. GameMode is a server-only (not replicated) actor, so clients can’t access it. That’s why you got the GameState which is an actor replicated to all clients. The thing you MUST do now is read this a few times, as you lack basic networking knowledge.
Thank you very much, I’m using [Run On server] to cast to [Game Mode] then I use [Run on multicast] to send the [Game Mode] Referance to all the players, my problem that I don’t have multible Hardwears to test it, & I think that should work when the Game Release, is that Right ?
It is pointless to send a reference from an object that isn’t replicated. The GameMode is not replicated so the clients can’t use the GameMode reference.
You can’t use any type of RPC on an actor that isn’t replicated. GameMode isn’t replicated.
For the other point, that’s not right. Imagine, you have to work on a game from the ground up and you can’t/don’t test the stuff you are doing until you think you have a “working” game. 99.9% the game won’t compile, and you are going to have a million bugs to solve. What you should do instead is test it bit by bit. Every time you work on something, and you get to a milestone, you test it. You don’t need to package your game to test it. You can either test in editor (PIE) or launch standalone (right click your .uproject). At the early stages of your game using PIE is enough, but you should know that it doesn’t always reflect how your game is going to function in realtime! That’s why a standalone/packaged game is a better option.
Thank you, but I didn’t meant that I’m not testing the game
1-I do what you said everytime [test every function and event if it’s working or not] & I also used stanalone game to test [Epic Online services] and it’s woking 100%
and I didn’t package my game before because It’s like 14 GB
and I have some problems packaging the game
2- I’m using RPC function from my [player character] to get [game mode] referance for only this client when I run it [on server] I don’t think it’s working but right now I don’t need game mode because I’m using [game state] & it’s working the problem was only when I play as a [client] with more [clients] or with a [server] from the same hardwear because it’s working when I play only with one [client] or one [server]
thank you for repling my question this is amazing to me
I think you need to show us what you have done rather than explain it. Also when debugging it is important that you know exactly where (on which client / server) and when things are being called by print string and breakpoints.