- Home /
How can i change HingeJoint's axis from code?
I want to change HingeJoint's z axis when click on screen but i dont know how to do it. I tried to do it from "GetComponent.axis.z = -1;" or "GetComponent.axis = Vector3.left" but both of them didnt work and in Unity's scripting API says "Joint.axis" but i dont know how to use it.
Thanks for help.
Answer by Owen-Reynolds · Aug 19, 2015 at 01:11 AM
Unless the editor ate some of the code you wrote above, the problem is your code isn't using GetComponent correctly. Just look up any example of using GetComponent. May also need to look up any example of setting Vectors (you often have to set all parts at once, like your 2nd "left" example.)
Thanks I got this but I have one more problem. How can I change motors Target Velocity. I tried the code which is in the scripting API but not working and also tried some other things but do you have exact answer?