pub struct AnimationGraph {
pub asset_id: AssetId,
pub target: Option<SkinnedMeshHandle>,
pub parameters: Vec<AnimationParam>,
pub initial: String,
pub states: Vec<AnimationState>,
pub transitions: Vec<AnimationTransition>,
pub ik_chains: Vec<AnimationIkChain>,
}Expand description
An animation state machine for one SkinnedMesh.
While a plain set of Animation clips blends every clip all
the time, a graph plays exactly one state at a time and moves between
states along declared transitions, crossfading poses over each
transition’s duration_secs. Transitions fire when their conditions –
comparisons against the graph’s named float parameters – pass. Gameplay
systems write parameter values each frame (the anim-param debug command
does the same from a cn debug session).
A graph owns its target: every Animation targeting the
graph’s mesh must be referenced by exactly one state, and at most one
graph may target a given mesh (both are build errors otherwise). Clip
weight and fade_in_secs have no effect under a graph.
Transitions are checked in declaration order and the first match wins. A state with no outgoing transitions (or none passing) keeps playing; looping states wrap, non-looping states hold their final pose.
AnimationGraph {
initial: "idle".into(),
..Default::default()
};Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
target: Option<SkinnedMeshHandle>The SkinnedMesh asset this graph animates.
parameters: Vec<AnimationParam>Named float parameters transitions compare against.
initial: StringName of the state the graph starts in. Defaults to the first state.
states: Vec<AnimationState>The graph’s states. At least one is required.
transitions: Vec<AnimationTransition>Directed transitions between states.
ik_chains: Vec<AnimationIkChain>Two-bone IK chains applied on top of every state’s pose; see AnimationIkChain.
Implementations§
Source§impl AnimationGraph
impl AnimationGraph
Sourcepub fn compile(
&self,
resolve_clip: impl Fn(AssetId) -> Option<(usize, f32, bool)>,
) -> Result<CompiledGraph, String>
pub fn compile( &self, resolve_clip: impl Fn(AssetId) -> Option<(usize, f32, bool)>, ) -> Result<CompiledGraph, String>
Compile the authored graph into the runtime representation, resolving
state and parameter names to indices and clip references through
resolve_clip, which maps an Animation asset id to its
index, duration, and looping flag in the target’s clip list. Structural
problems (unknown names, missing clips, non-positive rates) are
reported as errors; the build validates the same rules earlier, so a
runtime failure here means the world blob and the clip list disagree.
Trait Implementations§
Source§impl Clone for AnimationGraph
impl Clone for AnimationGraph
Source§fn clone(&self) -> AnimationGraph
fn clone(&self) -> AnimationGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for AnimationGraph
impl Component for AnimationGraph
Source§const NAME: &'static str = "AnimationGraph"
const NAME: &'static str = "AnimationGraph"
Source§fn inject_name(&mut self, id: AssetId)
fn inject_name(&mut self, id: AssetId)
Source§fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§impl ComponentSlot for AnimationGraph
impl ComponentSlot for AnimationGraph
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.