Nodes/Avatar Graph/Object Hook Recenter
ComfyUI Node

Object Hook Recenter

The 'why is my hook dragging the mesh sideways' fix

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Hook Recenter
  • BPY_OBJ
  • modifier
  • BPY_OBJ

Every Blender user has been here: you add a hook to some verts, and the moment the hook empty moves, the mesh doesn't just follow - it lurches sideways first. That's because the hook's offset was baked relative to where the empty sat when you created it, and if that spot was off-center, "move the empty" starts from a skewed reference. Object_HookRecenter is the reset for that offset. It tells Blender "recompute the hook's center based on the currently hooked vertices," so the mesh sits where it belongs.

In the Avatar Graph pack - which embeds a real Blender scene inside ComfyUI so you can rig 2.5D avatars - this is the cleanup node you reach for after hooking a ponytail or fringe and discovering it drifts when you test the bone.

How it works

It calls bpy.ops.object.hook_recenter(). In Blender's UI, the Hook modifier has a "Recenter" button for exactly this: it moves the hook point to the average location of the vertices the hook affects, without changing the modifier's effect on them. Net result: the mesh doesn't jump when you first drive the hook.

The BPY_OBJ input sets the active object in the embedded scene and passes back out unchanged, per this pack's pass-through convention.

The one field beyond the object is modifier, typed B_ENUM - which here means a string naming the Hook modifier, fed via the pack's ENUM (Blender) helper node. Type the exact modifier name (Hook, Hook.001, whatever was generated); wrong name and the operator won't find anything to recenter.

When to use it in a rig

Anytime you create a hook and the result doesn't look "neutral" at rest. Common Avatar Graph pattern: hook the fringe to the head bone, and at rest the fringe is floating an inch off the scalp because the hook center was computed wrong during creation. Run Object_HookRecenter (with the right modifier name) and the offset normalizes. You can also run it after reassigning verts with Object_HookAssign, so the center matches the new vertex set.

Inputs and outputs

  • BPY_OBJ - the mesh with the hook you want to fix.
  • modifier - the hook modifier name (ENUM helper node).
  • BPY_OBJ output - the same object, pass-through.

Installing it

Ships in Avatar Graph (avatechai/avatar-graph-comfyui). ComfyUI Manager: search "Avatar Graph". Manual:

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

The pack pins bpy==3.6.0, so ComfyUI must run on Python 3.10.x - newer versions fail to build bpy and the whole pack stops loading. First launch also pulls the SAM ViT-H checkpoint (~2.5 GB) and MediaPipe landmarkers automatically.

Common issues

The usual suspect is the modifier string: this field isn't a dropdown, it's a name you must type through the ENUM node, and it has to match the modifier that actually exists on the object. If recentering does nothing, that's the first thing to check. And since the pack's README openly says nodes and templates are still changing, treat odd behavior as possibly-a-bug rather than a mystery of your graph.

Categoryblender

Inputs (2)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
modifieroptB_ENUM

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ