I have an open level sequence with a MetaHuman and its control rig added as tracks. I want to animate the MetaHuman using the control rig, using python. The online instructions do not seem to work (cannot access the open control rig) and the documentation is opaque to say the least. Can someone offer me some sample code? UE5.
I’ve made some progress, but am getting the error message “Error: Control Rig Wrong Type”
rigProxies = unreal.ControlRigSequencerLibrary.get_control_rigs(levelSequence)
// rigProxy = rigProxies[0] or equivalent…
rig = rigProxy.control_rig
print(rig)
// returns:
// <Object ‘/Game/LookAtAroundTable/LookAtSequence.LookAtSequence:MovieScene_0.MovieSceneControlRigParameterTrack_0.MetaHuman_ControlRig’ (0x000006B67728E800)
frameNum = unreal.FrameNumber(0)
transform = unreal.ControlRigSequencerLibrary.get_local_control_rig_transform(levelSequence, rig, “head_ctrl”, frameNum)
// Returns: “Error: Control Rig Wrong Type”
Hi, have you solved this question @Reojo22 , thanks
Nope, not yet.
And, yet more information: it seems that what unreal was complaining about has something to do with the control rig being set to use a world transform, not local, and also apparently quaternions. If I have a desired local rotation (60 degrees Yaw), how do I implement that?
Got it! (Not sure the right way to tell the forum that this is solved…) This code presumes you have an open level with an open level sequence. The level sequence has a metahuman (or probably equivalent) with its control rig as the first control rig.
import unreal
import numpy as np
levelSequence = unreal.levelSequenceEditorBlueprintLibrary.get_current_level_sequence()
rigProxies = unreal.ControlRigSequencerLibrary.get_control_rigs(levelSequence)
rigProxy = rigProxies[0] # It's the first one, in this case
rig = rigProxy.control_rig
# Set the yaw to turn the head to the right and left
yawDegrees = 60.
# Create the quaternion for this rotation
desiredRotator = unreal.Rotator(0, 0, yawDegrees)
desiredRotatorQuat = desiredRotator.quaternion()
# Get the base transform -- where things are now for the head_ctrl
baseTransform = unreal.ControlRigSequencerLibrary.get_control_rig_world_transform(
levelSequence, rig, "head_ctrl", unreal.FrameNumber(0))
transform = baseTransform.copy()
transform.rotation = desiredRotatorQuat
# Rotate to the right (at start and end of the repeating sequence
unreal.ControlRigSequencerLibrary.set_control_rig_world_transform(
levelSequence, rig, "head_ctrl", unreal.FrameNumber(0), transform)
unreal.ControlRigSequencerLibrary.set_control_rig_world_transform(
levelSequence, rig, "head_ctrl", unreal.FrameNumber(30), transform)
# Rotate to the left (middle of sequence)
transform = baseTransform.copy()
desiredRotator = unreal.Rotator(0, 0, -yawDegrees)
desiredRotatorQuat = desiredRotator.quaternion()
transform.rotation = desiredRotatorQuat
unreal.ControlRigSequencerLibrary.set_control_rig_world_transform(
levelSequence, rig, "head_ctrl", unreal.FrameNumber(15), transform)
Got it, see my response
thanks so much, i’ll try
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.