Calculate Direction. (Physical Item Picking)

Hi
Sorry 4 my bad english.
I write a script to Pick-Up and move items with the
cursor (Oblivion or Amnesia like).

I have a rigidbody component attached to the items.
And when I click to an item, I add an AddFroce()
to the rigidbody of the item.

var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast(ray, hit, 3)){
   myRigi.AddForce([color=red]hit.point[/color]);
}

The red part is not correct. I must have there the direction from the item to the hit.point.
But I dont know how I can calculate this.
I tested it with Lerp and Slerp but the Item goes
everything to the same edge in the room.

pls help

Force is a vector, not a point. What you’re looking for is probably something like this (untested):

Vector3 direction = hit.point - itemPosition;
direction.normalize();
myRigi.AddForce(direction * forceMagnitude);

Thx it works.
But I’m not sure that this is the right way.
I looking for a better way to “hang an object
to the mouse cursor”. Do you know, what I mean?
Have someone an idea, please?

One possibility is to confine the object to a single plane using a configurable joint. You could, for example, set the joint’s Z motion parameter to Locked and leave the other two axes free to confine the object to the XY plane. Once the drag is finished, you can remove the joint using the Destroy function:-

var cj = GetComponent(ConfigurableJoint);
Destroy(cj);

@vampir26 - The DragRigidbody.js script that comes with the Standard Assets package will do exactly what you are talking about. Just attach it to a camera and you will be able to drag any rigidbody in the scene.