- Home /
Question by
The Roman One · Oct 24, 2012 at 12:42 AM ·
jointanchorconfigurable
Configurable Joint in Script!
Hey guys.
How do I access a GameObject's configurable Join?! I looked around the forum for answers(couldn't find anything that helps me) but I did notice that it's different in script than any other joint. that's a piece of my code:
var CJ : ConfigurableJoint;
CJ.GetComponent(ConfigurableJoint);
function Update()
{
CJ.anchor=hit.point; //"hit.point" is a Vector3 type variable.
}
but it keeps showing me the following error: The variable CJ of 'Script' has not been assigned.
Comment
Answer by Aberrator · Oct 29, 2012 at 10:50 AM
Hi. here is solution in C#: (inside your behaviour script)
var CJ = this.gameObject.GetComponent(typeof(ConfigurableJoint)) as ConfigurableJoint;
CJ.anchor = hit.point; //"hit.point" is a Vector3 type variable.
You are trying to get component ConfigurableJoint from ConfigurableJoint. You need to get that component from your gameObject where configurableJoint is attached.