Databinding Scoreboard, Bind Viewmodel Property to another
I’m making a scoreboard type project, where I want to have multiple “players” (called “packs” in my project). Each player has multiple values, that can be stored as an instance per player.
I figured the simplest way would be to have all the data come from a single view model with several instances. Each instance would be the values for a different player. Down the line, I will have each “player” instance be updated with new values from web js, but for now the native Rive instances will work for testing.
I Created a view model to hold all the player data, called “packData”. I made two instances “p1_Data” and “p2_Data”.
Heres the most basic question:
I have an artboard called PackCard, which will display the values for a player. It has its own view model called “packCard”. The artboard and viewmodel have text for the player name , called “foldName”.
Because all the data is stored in the packData view model, I need to pull the string value from “folderName” from there, so that my “PackCard” can display it.
I have tried bringing in the packData viewmodel as a new property in packCard. I have also tried directly binding the text player name to the packData “folderName” directly. Neither of these worked.
I cant figure out how to get my “PackCard” (player score artboard) to update with values from the initial “packData” sets of values.
(Later, I want to incoroporate the numeric values from the player data instances, and have them update various bar graphs that I made as nested components. But I am not to this step yet).
I have attached a .rev file if interested, and also made a mockup of what the score card might look like if it got the data populated.
The .rev file has another artboard and some properties that arent shown here, that can be ignored.
The screenshot shows the VMs. I’m trying to get the packData VM properties into the packCard VM and display on my artboard.
You can ignore the purple nested components for now.
Below is a mockup example of how an instance of packData could show up.
In the future I want to use the nested components to display values like numKick and pctKick etc, but connecting the folderName string is the simplest first goal.