- Home /
Hinge joint is not moving
Im making a game which you can swing. So for that im using the hinge joints and for connect the next point which is on my way, i have a that function.
public void FindRelativePosForHingeJoint(Vector3 blockPosition)
{
//Update the block position on this line in a proper way to Find Relative position for our blockPosition
hJoint.anchor = blockPosition-transform.position;
hJoint.autoConfigureConnectedAnchor = true;
hJoint.useMotor = true;
lRenderer.SetPosition(1, hJoint.anchor);
lRenderer.enabled = true;
}
But my function can't set the anchor position when i do this. But if i change it with
public void FindRelativePosForHingeJoint(Vector3 blockPosition)
{
//Update the block position on this line in a proper way to Find Relative position for our blockPosition
hJoint.axis = Vector3.forward;
hJoint.anchor = blockPosition-transform.position;
hJoint.autoConfigureConnectedAnchor = true;
hJoint.useMotor = true;
lRenderer.SetPosition(1, hJoint.anchor);
lRenderer.enabled = true;
}
the function can change the anchor point correctly. But for that time i can't move at all. I tried with hJoint.axis = Vector3.right(cause my object is moving in z) but for that time i couldn't change the anchor correctly too. How can i move my object with joint axis = Vector3.forward?
Your answer
Follow this Question
Related Questions
How to find the point of contact with the function OnTriggerEnter??? 4 Answers
Snake Head should be Followed by body and tail like classic snake game 1 Answer
Store Joint Motor as temporary variable? 1 Answer
Attaching rigidbody to a HingeJoint via C# 1 Answer
Bounce back after spinning an object once it hits the angle limit. 1 Answer