Item pick up problem.

Code is partly copied.
#pragma strict
var SpawnTo : Transform;
var WD : Transform;
var dist = 1;
private var isHolding = false;

function Update() 
{
if(Input.GetKeyDown("e"))
	{
	if(Vector3.Distance(transform.position, WD.position) < dist)
	{
		isHolding = !isHolding;
	}
	if(isHolding == true){
	WD.parent = SpawnTo;
	WD.transform.position = SpawnTo.transform.position;
	}
	else{
		SpawnTo.transform.DetachChildren();
		}
	}
}

So theres is two problems with it.
1.Distance thingy does not seems to work.
2.Everytime object is picked its getting stretched and bigger, so for example after 20 times pickin up it gets 20 times bigger. hah.

Also is it possible for example to spawn it to the same location where hand is but plus +2 to the x lets say for example. Its hard to explain. What I mean is:
Spawnto = right_hand
When its spawns it gets a bit more to the left than I would like it to be.
So lets say arms x position is 200.
Is it possible to transform WD position to 202?

Ermmh… I think thats it.
Hope you understood me.
ANY help is appreciated very much.

THANK YOU :stuck_out_tongue:

For vector3.distance, flip those 2 (ie. WS.position, transform.position); if that doesn’t work please elaborate

WD.transform.position.x = WD.transform.position.x+2

Edit: changed to answer