Skip to main content

Animation Curves

Overview

When curve data is attached to the animation, and the curves can blend with each other, the logic layer can use the curve data to drive different effects (e.g. drive IK intensity, material values, etc.). The animation data can be customized using the Animation Curve, which is the semantic description of the animation data.

The following image shows the effect of the Animation Curve feature, which allows the character's feet size to change continuously.

Preview

Animation Curve Panel

Animation Curves can be created and edited in the Animation Curve panel,which is displayed in Animation Sequences and Montages.

image-20230428101446969

Creating Animation Curves

Open an Animation Sequence asset, and in the Animation Curve panel of the Animation Sequence Editor, click the image-20221130094224166 button, then enter the curve name in the pop-up window, and click the OK button to finish the creation.

image-20220829181140572

image-20230215153512691

Editing Animation Curves

After creating an Animation Curve, check the checkbox to expand the curve edit panel and uncheck it to fold it. The editing of the curve can be done in the curve edit panel after it is expanded.

EditArea

The curve name can be modified in the text box.

image-20221130103006644

Click the image-20221130105852579 button to delete the curve.

image-20221130151642363

To reedit the previously created animation curve, click the image-20221201094203971 button to select a previously created curve and open its curve editing panel.

image-20221201094825883

Editing Keyframes

Double-click a blank space to add a keyframe. Click a keyframe and move it to change its Time and Value, or select a keyframe and change the values in the pop-up Time and Value input boxes at the top left.

AddKeys

Select a keyframe and right-click it, then you can select to delete it in the pop-up shortcut menu. Hold down the Ctrl key to multi-select keyframes, or directly left-click to box-select multiple keyframes.

image-20221201133743222

Adjusting the Viewport

Click the two buttons at the top left corner to adjust the Viewport to the appropriate interval according to the curve's value range.

Change

The Viewport can be adjusted manually by scrolling the wheel; Hold down the Ctrl key at the same time to only zoom horizontally; Hold down the Shift key at the same time to only zoom vertically.

AdjustTheCurve

Associating with Bones

In the Animation Editor, click Window (Menu Bar) -> Anim Curve Viewer to open the Anim Curve Viewer panel, where you can view the real-time changes of the curve data.

image-20230517170354920

Select a curve in the Anim Curve Viewer panel and the relevant information on the curve will be displayed in the above Details Panel.

image-20221205100109617

You can also associate bone data with the curve in the Details Panel. Click the Add button under Bones, then click the Root button and select the bones to be associated with in the pop-up window. Close the window after selection.

image-20221205100912160

To delete a specific associated bone, click the Del button next to the associated bone in the Details Panel to disassociate the bone with the curve. Click the Clear button to disassociate all bones from the curve at once.

image-20221205101532666

Example

The following is an example displaying the Animation Curve feature.

Creating Actors

Refer to Assembling Actors to create an Actor (.actor) containing tpose animations and fi_bow_run animations.

image-20230427172431834

In the Asset Browser of the Animation Editor, select fi_bow_run, right-click and select Convert Skeleton To AnimSeq, then enter the name of the converted Animation Sequence in the pop-up window, and click the OK button to complete the conversion.

image-20230426113423143

After conversion:

image-20230426113542996

In the Actor Editor, click Resource Detail and set Default Action to Animation Sequence fi_bow_run_sq.

image-20230427172910255

Editing Animation Assets

Creating Animation Curves

Double-click Animation Sequence fi_bow_run_sq in the Action List.

image-20230427173013936

Click the image-20230426131044229 button in Animation Curve, select Create Curve, then enter the name in the pop-up window and click the OK button to finish the creation.

image-20230427173246564

Editing Animation Curves

Add keyframes in the curve editing area. The curve is shown below:

image-20230427173858254

In the Animation Editor, click Window (in the Menu Bar) -> Anim Curve Viewer to open the Anim Curve Viewer.

image-20230517170457439

Select the created curve in the Anim Curve Viewer, then bind bones Bip01 L Foot and Bip01 R Foot in the Details Panel. Refer to section Associating with Bones to finish binding the bones.

image-20230427174033102

After editing, click File (Menu Bar) -> Save All to save.

image-20230427174114333

Creating Characters

In the Component Editor, click Create Game Object (in the Tool Bar) -> Character.

image-20230426150411509

In the Inspector panel, select CharacterMesh0(Inherited) and drag the created Actor (.actor) from the Resource Preview window into the Skeletal Mesh Config File slot.

image-20230427174404857

After dragging:

image-20230427174457871

Select ColliderCylinder(Inherited) and CharacterMesh0(Inherited) in the Inspector panel, then adjust the position of the character's capsule and mesh respectively, so that the feet of the character skin are on the ground and the capsule is above the ground in the premise that the capsule wraps the character as much as possible.

image-20230426151642299

Setting Characters

Select LCharacter(Instance) in the Inspector panel, then click the Add Component button and select Script Component to add a Script Component to the character.

image-20230426163111404

image-20230426163204580

Drag the written Script file from the Resource Preview window into the Script File slot of this Script Component.

image-20230427175143480

After binding:

image-20230427175219592

Script

function on_begin_play(component)
local owner = component.GameObjectOwner

if not nx_is_valid(owner) then
return
end

local mesh_com = owner.MeshComponent

if not nx_is_valid(mesh_com) then
return
end

local vis = mesh_com.VisBase

if not nx_is_valid(mesh_com) then
return
end

nx_callback(component, "on_tick", "tick")
end

function tick(component, delta_time)
if not nx_is_valid(component) then
return
end

local owner = component.GameObjectOwner

if not nx_is_valid(owner) then
return
end

local mesh_com = owner.MeshComponent

if not nx_is_valid(mesh_com) then
return
end

local vis = mesh_com.VisBase

if not nx_is_valid(vis) then
return
end

local curve_count = vis:GetCurveCountInSkeleton()

if curve_count < 1 then
return
end

local curve_name = "curve_test"
local bone_count = vis:GetConnectedBoneCountFromSkeletonCurve(curve_name)
if bone_count ~= 2 then
return
end

vis.Speed = 0.5

local bone_name1 = vis:GetConnectedBoneNameFromSkeletonCurve(curve_name, 0)
local bone_name2 = vis:GetConnectedBoneNameFromSkeletonCurve(curve_name, 1)

if not nx_find_custom(vis, "curve_index") then
vis.curve_index = vis:GetCurveIDByNameInSkeleton(curve_name)
end

if vis.curve_index < 0 then
return
end

local value = vis:GetCurveValue(vis.curve_index)

if value > 1.0 then
local v = 1.0 + (value - 1.0) * 2.0
vis:SetBoneScale(bone_name1, 1.0, 1.0, 1.0)
vis:SetBoneScale(bone_name2, v, v, v)
elseif value < 1.0 then
local v = 1.0 + (1.0 - value) * 2.0
vis:SetBoneScale(bone_name1, v, v, v)
vis:SetBoneScale(bone_name2, 1.0, 1.0, 1.0)
else
vis:SetBoneScale(bone_name1, 1.0, 1.0, 1.0)
vis:SetBoneScale(bone_name2, 1.0, 1.0, 1.0)
end
end

PIE

Click Create Game Object (in the Tool Bar) -> Default Pawn to create a Default Pawn, and then adjust its Angle and Position.

image-20230427175903014

In the Inspector panel, set the Auto Possess Player property of the Default Pawn to Player 0.

image-20230427180116769

Click the PIE button to see the effect.

image-20230428094633974