How to correctly bind an object from a factory to a bone?

Why if I have a head model in the collection and I tie it to the neck bone of another model, it stands up properly, but if I create a head from the factory and tie it to the neck bone, it does not stand on the neck?

That’s my code for tying the head to the neck:

  local id=factory.create("heads#bear")
  local bone_head = model.get_go("#modl", "head")
  msg.post(id, "set_parent", { parent_id = bone_head, keep_world_transform = 1 })
1 Like

Hard to understand what’s wrong from the description. Are you able to share a minimal project?

just for the sake of experimentation, I create a gun from the factory and rotate it:

function on_input(self, action_id, action)
 if action_id==hash("one") and action.released then
  tx=tx+90
  if tx==450 then tx=-90 end
  go.set(self.gun_id, "euler", vmath.vector3(tx,ty,tz))
  print(tx,ty,tz)
 elseif action_id==hash("two") and action.released then
  ty=ty+90
  if ty==450 then ty=-90 end
  go.set(self.gun_id, "euler", vmath.vector3(tx,ty,tz))
  print(tx,ty,tz)
 elseif action_id==hash("three") and action.released then
  tz=tz+90
  if tz==450 then tz=-90 end
  go.set(self.gun_id, "euler", vmath.vector3(tx,ty,tz))
  print(tx,ty,tz)
 end
 print(">>>", go.get(self.gun_id, "euler"))
end

I see from the print that

vmath.vector3(-90.010704040527, 180, -2.105209419062e-14)

turn I need, I set this euler now after creating an object, and it shows a completely different direction, and in the input printed

>>> vmath.vector3(-107.74453735352, -21.475099563599, -85.142112731934)```
1 Like

What if you get the euler with a one frame delay (use a timer). Is it correct then?

I still don’t fully understand the problem/can’t visualize it. I suggest you share a small sample project.