Nodes/Avatar Graph/Object Set Track Axis
ComfyUI Node

Object Set Track Axis

Which way an object points when it's tracking a target

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Set Track Axis
  • BPY_OBJ
  • BPY_OBJ
valuePOS_Y

track_axis is the Blender property that tells a Track To constraint which local axis of the object points at its target. Object Set Track Axis is the auto-generated setter for it, with a default of "POS_Y". If an object in your avatar graph is set to track something and it's pointing sideways instead of at the target, this is the value you fix.

How it works

Standard auto-generated setter: setattr(object, "track_axis", value) against the embedded bpy instance, returning the same BPY_OBJ. The value input is a STRING defaulting to "POS_Y". Valid values are Blender's own track axes: POS_X, POS_Y, POS_Z, NEG_X, NEG_Y, NEG_Z.

The setup that uses this: an object (often an empty or a camera-like element) gets a Track To constraint targeting another object, and the constraint looks up track_axis to decide how the object orients itself. Pick POS_Y and the object's +Y arrow aims at the target; pick NEG_Z and its -Z arrow does. The classic gotcha is that Blender's default orientation for many things doesn't have its "forward" on +Y - so a tracked part ends up looking sideways or backwards until you try a different axis. When that happens, pair this with Object Set Show Axis to actually see the local axes, then set the track axis until the arrows point the way you want.

The inputs

  • BPY_OBJ - the object that tracks a target (empty, camera, or similar).
  • value - track axis string, default "POS_Y".

Output: the same BPY_OBJ.

Install & gotchas

Ships with the Avatar Graph pack:

cd ComfyUI/custom_nodes
git clone https://github.com/avatechai/avatar-graph-comfyui
cd avatar-graph-comfyui && python -m pip install -r requirements.txt

Or ComfyUI Manager → "Avatar Graph". The pack pins bpy==3.6.0, which requires Python 3.10 - no wheel for 3.11+, so the pack won't load on newer runtimes (conda python=3.10 per the README). First launch auto-downloads a ~2.5 GB SAM model and mediapipe landmarker files.

The realistic trap: track_axis is meaningless without a Track To constraint actually attached to the object. If you set it and nothing changes, check whether the object has a track constraint at all - this node only configures an existing one. And it's the constraint, not the axis flag, that has to be created downstream before this setter runs (scene resets each queue run). Keep it after the constraint-adding node in the chain. And as always, the live editor preview needs --enable-cors-header; without it you still get exports via Save File on Avatar Main Output.

Categoryblender

Inputs (2)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
valueoptSTRINGPOS_Y

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ