@piinthesky Here’s another parent/child example. The robot is the parent to the shield. The shield is the parent to the blue and white flags. You can turn the shield and flags on/off with the boolean sliders. The state of the flags are remembered when the state of the shield is turned on or off. You can rotate the robot or shield with the sliders.
displayMode(STANDARD)
function setup()
parameter.number("Rotate", 0, 360, 208)
parameter.number("shy",-180,180,-30)
parameter.number("shz",-180,180,30)
scene = craft.scene()
ground = scene:entity()
ground.model = craft.model.cube(vec3(10,.2,10))
ground.material = craft.material("Materials:Specular")
ground.material.map = readImage("Blocks:Dirt")
ground.material.specular = color(0, 0, 0, 255)
ground.material.offsetRepeat = vec4(0,0,1,1)
ground.y = -1
robot = scene:entity()
robot.model = craft.model("Blocky Characters:Robot")
robot.y = -1
robot.z = 0
robot.scale = vec3(1,1,1) / 8
shield = scene:entity()
shield.model = craft.model("CastleKit:shieldRed")
shield.x = -3
shield.y = 7
shield.z = 4
shield.scale = vec3(2.5,2.5,.1)
flag1 = scene:entity()
flag1.model = craft.model("CastleKit:flagBlueWide")
flag1.x = 0
flag1.y = 0
flag1.z = 0
flag1.scale = vec3(.5,.5,.5)
flag2 = scene:entity()
flag2.model = craft.model("CastleKit:flagWhiteWide")
flag2.x = 0
flag2.y = 0
flag2.z = 0
flag2.scale = vec3(.5,.5,.5)
sword = scene:entity()
sword.model = craft.model("CastleKit:sword")
sword.x = 3.2
sword.y = 6
sword.z = 1
sword.scale = vec3(1,1,1)*1.6
scene.camera.z = -6
shield.parent=robot
flag1.parent=shield
flag2.parent=shield
sword.parent=robot
parameter.boolean("sh",true, function() robot.children[1].active=sh end)
parameter.boolean("blue",true, function() shield.children[1].active=blue end)
parameter.boolean("white",true,function() shield.children[2].active=white end)
end
function update(dt)
robot.eulerAngles=vec3(0,Rotate,0)
sword.eulerAngles=vec3(45,0,0)
shield.eulerAngles=vec3(180,shy,shz)
flag1.eulerAngles=vec3(180,-90,45)
flag2.eulerAngles=vec3(120,-90,45)
scene:update(dt)
end
function draw()
update(DeltaTime)
scene:draw()
end