adding Copy Location and Copy Rotation constraints with Python during runtime

Hi all,

I have a character and miscellaneous tools for it. I have created bones on the character armature in the left and right hand which would be in charge of tools.

I can do this in the default view:

  • select the tool
  • go to the Constraints tab in Properties
  • Add Object Constraint -> Copy Location and bind it to the bone on the armature
  • Add Object Constraint -> Copy Rotation and bind it to the bone on the armature

When I run the game, the tool is in place and moves accordingly with the bone in the armature

What I don’t know how to do during runtime with python:
After I have added the character and the tool to the scene using KX_Scene.addObject(), I want to add these constraint with the script.

Can anyone help with this, or are there ideas how to achieve that a KX_GameObject object follows a BL_ArmatureChannel object?

P.S. I have seen one idea of adding these constraints before runtime and hiding a tool and later on showing it later when it’s necessary. I don’t like this idea, and I’m trying to avoid it by any chance. :slight_smile:

Thanks in advance