Picking up rigid bodies with two fingers
Ok lets say I had two fingers floating in space and a cube on a table that I wanted to pick up and hold onto. What friction coefficients would I need to use on the these rigid bodies? Right now I have it so I can grab the object but it keeps sliding out of my grasp.
Right now I'm just doing:
void FixedUpdate () { input = new Vector3(Input.GetAxisRaw ("Horizontal"), 0, Input.GetAxisRaw ("Vertical")); if (rigidbody.velocity.magnitude < maxSpeed) { rigidbody.AddForce (input * moveSpeed); } }
Then the arrow keys allow me to open and close the fingers. But what I want it to do is for the fingers to stay closed with out me having to hold the arrow key once it grabs an object.
Posted Dec 12, 2014, 4:27 PM UTC · edited
Like jonhykrazy said, joints might be a good idea. If you want infinite friction, you could just place a fixed joint at the point you touch connecting the finger and the object. I use that method for my grappling hook in my game and it seems to work quite well.
That's my code for attaching the "hook" if you will, of the gravity gun on the object I want to grab, I then apply a force on that hook to move towards a "zero point" in the air in front of my player.
What you could do is give both of the fingers a fixed joint and when a finger touches an object, it attaches the joint to the point on the rigidbody it touches.
Let me know if you get anywhere with that.
Also, if you plan on moving those attached fingers with addForce, high drag values are your friend. Was able to stabilize my gravity gun really well like that, to the extent that you can throw stuff with it by flicking, but it still moves really smoothly.