- Home /
Question by
CupOfMayo · Aug 13, 2013 at 11:16 AM ·
hingejointaddcomponentbasic
Creating Hinge Joint at runtime?
So I have got this piece of script:
var sc : HingeJoint;
function Update ()
{
if(Input.GetButtonUp("Jump"))
{
sc = gameObject.AddComponent("hingeJoint");
//I also tried sc = gameObject.AddComponent("HingeJoint");
}
}
Don't work :/ Can someone correct my script or maybe tell me what am I doing wrong?
Comment
Did you try without the "s? sc = gameObject.AddComponent(HingeJoint);
Yes I tried, won't work. Edit: Sorry It acctually works, I just made typo and wrote hingeJoint ins$$anonymous$$d of HingeJoint, ;) Thanks.
Best Answer
Answer by Linus · Aug 13, 2013 at 11:20 AM
try:
gameObject.AddComponent(HingeJoint);
sc = GetComponent(HingeJoint);
Not sure if you need them on seperate lines, try both.