- Home /
Question by
kag359six · Dec 08, 2012 at 05:52 PM ·
rigidbodydragspring joint
Dragging rigidbody with SpringJoint?
I have seen the DragRigidBodyShadow script, and I simply can't follow it. Can someone explain this chunk of code if possible?
if (Mathf.Abs(mousePos.x - Input.mousePosition.x) <= 2 && Mathf.Abs(mousePos.y - Input.mousePosition.y) <= 2 && Time.time - startTime < .2 && springJoint.connectedBody)
{
dir.y = 0;
dir.Normalize();
springJoint.connectedBody.AddForceAtPosition(dir * pushForce, hitpoint, ForceMode.VelocityChange);
ToggleLight( springJoint.connectedBody.gameObject );
}
Otherwise I really just need some help on moving a rigidbody using the spring joint in a natural way like how that DragRigidBody script does. It has been extremely frustrating as I didn't think it would be so complicated. I'd be grateful for any information.
Comment
Your answer
Follow this Question
Related Questions
How can i set AddRelativeForce relative to how fast/slow im moving my mouse? 2 Answers
Limiting the top speed of a rigidbody in 3d space? 1 Answer
Drag around riggidbodies with a "pin" 0 Answers
How to move a group of objects with rigidbodies together? 2 Answers
how do you activate a sound effect when two objects with box colliders hit? 0 Answers