This method can be used to manually rotate a bone. You can control skinned models enirely in code or apply your own movements on top of animation.
Parameter | Description |
---|---|
rotation, (pitch, yaw, roll) | rotation to set |
global | if set to true rotation is relative to the skeleton, otherwise it is relative to the bone's parent |
To combine programmatic movement with animation, this method should be called after World::Update and before World::Render.
This example will load and display an animated model, but we will add code to turn the character's head back and forth as they walk.
local world = CreateWorld()
local camera = CreateCamera(world)
local light = CreateBoxLight(world)
local model = LoadModel(world, "https://github.com/UltraEngine/Documentation/raw/master/Assets/Models/Characters/Fox.glb")
local neck = model.skeleton:FindBone("b_Neck_04")
local rotation = Vec3()
-- Main loop
while window:Closed() == false do
world:Update()
rotation.y = Cos(Millisecs() / 10.0) * 65.0
neck:SetRotation(rotation)
world:Render(framebuffer)
end