- Home /
How to bind two gameobjects together?
Hey,
want to parent an Armature to a bone of another armature but if i change the hirachy of the Model they are in the animation doesn't play properly anymore.
Here is a bit more explanation:
The selected object is the "child" armature. The red dot is roughly were the "parent" bone is. In the bottom picture one of the animation is playing. You can see the armature object didn't move it's position only the the bones. This makes it a bit difficult for me to just make a script that can handle the "childs" position. The reason why i want to parent it is. The parent bones of the red marked one can rotate around there y-axis which makes the Model lean.
Here is the current Hirarchy a bit more zoomed in:
I would be happy to get a solution wether it's in Unity or in Blender.
PS: I read both of the answers but i still didn't manage to get a working script and the suggestion to apply the animation to an empty gameobject i just don't understand how that works? So íf anyone would explain me those suggestion a bit more that would me too.
here is the dropbox link containing my current setup. If you want to help me just delete the PlayerScript after you imported it to Unity.
https://www.dropbox.com/sh/n2v0nqrv6ocy85u/rD-huVjURK/Unity%20Parent%20Issue.unitypackage
I don't quite get your question. On the one hand, you don't want the two parented together, on the other hand you want them 'as if' parented together?
I basically want them to be parented but the problem is that when i just drag the one armature to the bone of the other armature in Unity the child doesn't get affected by any animation ... because the hirarchy changed. If i would be able to parent/link the armature to the bone in Blender beforehand everything would be fine but until this point i couldn't figure out how. Now i thought i may be able to achieve a similar behaviour with a unity component or script without changing the hirarchy (like a joint but without rigidbodies).
So my question is: Is there a way to do it in Blender or in Unity? (Preferrable in Blender)
Do you have an idea?
Does no one have an idea how to parent an armature to a bone of another armature in Blender?
Answer by Hamzah Khan · Dec 31, 2012 at 09:57 AM
Perhaps use empty gameobjects as mediums of transformation? Sorry that's the best I can do but I still don't understand exactly what you want
Well the perfect solution would be if someone can tell me how to link/parent an armature-object to the bone of another armature in Blender but if that's not possible for some reason i need a way of parenting the armature to the bone in Unity without actually dragging it on the bone. I can't do that because if i just drag it the animation can't root to the armature anymore because it isn't in the "right place". I really need to know this because i can't really continue otherwise.
If you have more question just let me know.
Hope to hear from you.
Can you not apply the animation to the empty game object that Hamzah is suggesting - therefore having the right structure for the animation system to find the rig?
What do mean by applying the animation to the gameobject? Both armatures are part of a model and as a result the animations are stored in the $$anonymous$$odel Object.
I added the Player's hirarchy how i have it right now to the question.
Hamzah or whydoidoit can you please explain what you meant with your suggestions. I added more information to the question.
Answer by benk0913 · Dec 29, 2012 at 03:52 PM
Maybe you should try setting ones transform.position to the others transform.position. Having the first transform position constantly set the others transform position as his.
Thanks for the reply. That's a good idea. The only problem i have still is that I have animations which affect both armatures. One of them I play right at the beginning. I just tried your apporach and just set the position of the "child" gameobject to the position of the "parent" gameobject but that makes it so that the "child" doesn't get affected by the animation anymore and the position is way of where it should be. Is there a way around this? $$anonymous$$aybe with relative positions/rotations?
benk sry for not replying to your comment but for some reason i can't see it here on Unity answers. I just noticed that you replied because i checked my mail inbox. The problem that i have with the script method is that the Armature root object is to get the positioning and the rotation right. The Animation was still affecting the Armature but the script did set the position of it to something else. I would need a script which works with relative positions and relative rotations but i couldn't figure out how to make such a script until this point although i'm pretty good with maths and scripting :) . I would also prefer a method which doesn't involve permanently executing the same code if possible as i think it could cause problems (performance-wise) in a multiplayer-game.