I can’t figure out how to access properties of nested models in one artboard.
I have a RIV file that contains multiple artboards.
I know how to access the properties. I create different RiveModels and set their properties.
Example:
local HP_BAR = "/hud#hp_bar"
local LVL_BAR = "/hud#level_bar"
local GOLD = "/hud#gold"
local TIMER = "/hud#timer"
function init(self)
self.vm_hp_bar = rive.databind.create_view_model_instance_runtime(HP_BAR, "hp_bar")
rive.databind.set_view_model_instance_runtime(HP_BAR, self.vm_hp_bar, "hp_bar")
rive.databind.set_properties(HP_BAR, self.vm_hp_bar, {
corrent_hp_num = 500,
max_hp_num = 500
})
self.vm_lvl_bar = rive.databind.create_view_model_instance_runtime(LVL_BAR, "level_bar")
rive.databind.set_view_model_instance_runtime(LVL_BAR, self.vm_lvl_bar, "level_bar")
rive.databind.set_properties(LVL_BAR, self.vm_lvl_bar, {
level_num = 30,
procent_level_progress = 50,
})
self.vm_score = rive.databind.create_view_model_instance_runtime(GOLD, "Score")
rive.databind.set_view_model_instance_runtime(GOLD, self.vm_score, "Score")
rive.databind.set_properties(GOLD, self.vm_score, {
gold_value = 50,
})
self.vm_timer = rive.databind.create_view_model_instance_runtime(TIMER, "timer")
rive.databind.set_view_model_instance_runtime(TIMER, self.vm_timer, "timer")
rive.databind.set_properties(TIMER, self.vm_timer, {
secunds = 50,
})
end
Is there any way to change the value for nested models in one artboard?
The neural network offers this option, but it doesn’t work:
local MODEL = "/hud#rivemodel"
function init(self)
self.vm = rive.databind.create_view_model_instance_runtime(MODEL, "Main")
self.vm_main = rive.databind.create_view_model_instance_runtime(MODEL, "Main")
rive.databind.set_view_model_instance_runtime(MODEL, self.vm_main, "Main")
rive.databind.set_properties(MODEL, self.vm_main, {
["level_bar.level_num"] = 30,
["level_bar.procent_level_progress"] = 50,
["timer.secunds"] = 60,
["hp_bar.corrent_hp_num"] = 500,
["hp_bar.max_hp_num"] = 500,
["Score.gold_value"] = 100,
})
end
Thank’s!