I animate my character, addObject to add a gun and set gun parent to hand object, but gun doesnt follow the hand movement.
hi you need set parent for add pistol and need arm collider for parenting, if you use python use this -
arm_r = scene.objects[‘Player_Arm_Right’]
pistol = scene.addObject(“Pistol”, arm_r, 0)
pistol.setParent(arm_r, True)
pistol.worldPosition = arm_r.worldPosition
pistol.worldOrientation = arm_r.worldOrientation
this script add in scene object Pistol, set parent arm collider, and set arm collider position and orientation
Hi i did like you said, the pistol doesnt follow my character rig.
How you add pistol? way is pistol object name? maybe you pistol very big or small? say wats happening
I added in the scene the same way you did in your script…the gun is added in correct position but doesnt follow the animation of my character, doesn atach to the hand object…
from the screenshot, it is not clear the problems of the script-take a screenshot of the python console - at the top of the “window-show the console” without this, I can only guess where you had an error
the gun should not be a descendant of the hand collider, it should be on another layer, otherwise it will not be added, and the names of objects should be in square brackets as in the script - or they should be replaced in the script with the names of objects that you have on the active layer, and it is also not recommended to change the scale of the colliders otherwise the added object will decrease or increase in size
Yes the gun is on another layer. Console show no error.
parent an empty to hand bone, now simply add gun on empty spot and orientation and parent it to the empty.
Solved…thanks