Question by
averysmarttardigrade · Dec 05, 2019 at 09:56 AM ·
error messageaddcomponent
AddComponent isn't working
I have been looking over the forums and nobody has answered my question. My code is getting error messages. Here is the line that doesn't work. Head.addComponent(); Head.HingeJoint.ConnectedBody = Joint; I have assigned a rigidbody to head and joint too. Any fixes? Thanks.
Comment
Answer by Larry-Dietz · Dec 05, 2019 at 02:48 PM
First this that sticks out to me, is you are calling AddComponent without telling it what component to add.
For example, to add a Hinge Joint to the head (What I am assuming you are trying to do) try this...
Head.AddComponent<HingeJoint>();
Hope this helps, -Larry
Your answer
![](https://koobas.hobune.stream/wayback/20220612215535im_/https://answers.unity.com/themes/thub/images/avi.jpg)