How to one variable is same in all players? (UE BluePrint Basics)

How to one variable is same in all players?

i mean i have one variable and if i changed that variable then all other players can know about that variables change.
it means if change ZVariable=1 to 2 then all other players ZVariable is =2
i mean all players can access to one variable’s pool.

you can store the variable in a common place like a gamemode blueprint

create your gamemode Blueprint and put as level gamemode

image

create a variable in it

in any other blueprint just get your default gamemode, cast to your gamemode class and store in a local variable so each time you want to access from that blueprint no need to cast again

and then you can access the variable (get or set)

1 Like

@eldany.uy do i need to cast GameMode in BP?
if Cast Failed so what should i do?

yes…if you want to access gamemode variables and functions you must cast (if you do just once and store in a local variable the same class of your gamemode blueprint is better because you can reuse then without casting all the time.

If you know what are you casting then should not fail. You can also use gameinstance instead of gamemode too…Gameinstance persists when you change level (gamemode resets everything and restarts when you load a new level). Gameinstance is defined in the settings of the project in maps & modes

I reeded your original post again and I am not sure If what I suggest is the right solution.

Now I think your question is more aimed to multiplayer and replication and not having a lot of blueprints reading the same value.

This guy has a great YouTube playlist explaining in details everything about replication and multiplayer. I highly recommend!

1 Like

@eldany.uy
i did your way and tested on Client
image

But Game Mode Cast failed:

That is why in my last reply I said I misunderstood your question and what you want is actually related with multiplayer and replication.

1 Like