simvx.core.animation.state_machine

Animation state machine with parameter-based transitions.

Module Contents

Classes

AnimationState

Single state in animation state machine.

Transition

Transition between animation states.

AnimationTree

Animation state machine with parameter-based transitions.

Data

log

API

simvx.core.animation.state_machine.log[source]

‘getLogger(…)’

class simvx.core.animation.state_machine.AnimationState[source]

Single state in animation state machine.

name: str

None

clip: simvx.core.animation.track.AnimationClip

None

speed_scale: float

1.0

loop: bool

True

class simvx.core.animation.state_machine.Transition[source]

Transition between animation states.

from_state: str

None

to_state: str

None

condition: collections.abc.Callable[[], bool]

None

blend_time: float

0.2

class simvx.core.animation.state_machine.AnimationTree(target=None, **kwargs)[source]

Bases: simvx.core.node.Node

Animation state machine with parameter-based transitions.

As a Node subclass, it participates in the scene tree and gets process(dt) called automatically. By default it animates its parent.

Example: tree = AnimationTree(target=player) tree.add_state(“idle”, idle_clip, loop=True) tree.add_state(“run”, run_clip, loop=True) tree.add_state(“jump”, jump_clip, loop=False)

tree.add_transition("idle", "run", lambda: tree.parameters["speed"] > 0.1)
tree.add_transition("run", "idle", lambda: tree.parameters["speed"] < 0.1)
tree.add_transition("idle", "jump", lambda: tree.parameters["jump_pressed"])

tree.set_parameter("speed", 0.0)
tree.start("idle")

Initialization

add_state(name: str, clip: simvx.core.animation.track.AnimationClip, speed_scale: float = 1.0, loop: bool = True)[source]

Add animation state.

add_transition(from_state: str, to_state: str, condition: collections.abc.Callable[[], bool], blend_time: float = 0.2)[source]

Add transition with condition function.

set_parameter(name: str, value: Any)[source]

Update animation parameter.

get_parameter(name: str, default: Any = None) Any[source]

Get animation parameter.

start(state_name: str)[source]

Start animation tree with initial state.

stop()[source]

Stop animation tree.

process(dt: float)[source]

Advance animation state machine each frame (called by SceneTree).

to_dict() dict[source]

Serialize tree state.

classmethod from_dict(data: dict, target=None)[source]

Deserialize tree.

strict_errors: ClassVar[bool]

True

script_error_raised

‘Signal(…)’

classmethod __init_subclass__(**kwargs)
property name: str
property process_mode: simvx.core.descriptors.ProcessMode
reset_error() None
add_child(node: simvx.core.node.Node) simvx.core.node.Node
remove_child(node: simvx.core.node.Node)
reparent(new_parent: simvx.core.node.Node)
get_node(path: str) simvx.core.node.Node
find_child(name: str, recursive: bool = False) simvx.core.node.Node | None
find(node_type: type, recursive: bool = True) simvx.core.node.Node | None
find_all(node_type: type, recursive: bool = True) list
property path: str
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) bool
ready() None
enter_tree() None
exit_tree() None
physics_process(dt: float) None
draw(renderer) None
input_event(event: simvx.core.events.InputEvent) None
input(event: simvx.core.events.TreeInputEvent) None
unhandled_input(event: simvx.core.events.TreeInputEvent) None
start_coroutine(gen: simvx.core.descriptors.Coroutine) simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
clear_children()
destroy()
property app
property tree: simvx.core.scene_tree.SceneTree
get_tree() simvx.core.scene_tree.SceneTree
__getitem__(key: str)
classmethod get_properties() dict[str, simvx.core.descriptors.Property]
__repr__()