Hello, I have been wondering if you can give individual players a variable in verse… Like giving them a class of their own. Like, when a player presses a specific button that player will be given a variable exclusive for that player alone in verse.
Hi @LyssaSugarNya , do you have a specific example in mind? You can create a map where the player is the key and you specify what value you want associated with the player.
For example:
player_info := class:
# Data to associate with player goes here
var MyData:float = 0.0
my_device := class(creative_device):
# Map between player type and player_info class created above.
var PlayerInfoMap:[player]player_info = map{}
You can learn more about map at Map
I read somewhere that classes needed the specifier to be used in maps. Does this code work for you regardless?
You don’t need a specifier to use classes in a map but if you’re using a class as the key to a map it must be comparable as stated in the documentation for map Map. Do you remember where you read that?
I’m sorry I left out which specifier. It was the *unique specifier i was referring to. This was explained on a Youtube tutorial I watched.
I do this all the time, and generally end up initializing the map on the player spawned event which entails having an @editable array of player spawners in your device. And since UEFN/Verse is new and still in the not-totally-predictable stage, it’s worth saying that maps work as advertised.
I do custom classes and attach them to the players and this turns out to be useful for many functions.