OK, the title here may be misleading as I'm not TOTALLY sure it's the issue, but it's the only thing i can think of right now. I'm writing a script that allows you to pick up and drop objects, only i cannot get the object to drop at all. Here's the if statement I currently have:
-function Update() {
var fwd = transform.TransformDirection (Vector3.forward);
var hit : RaycastHit;
var LayerMask = 1 << 9;
var otherThing: Transform;
var hasObject = false;
Debug.DrawRay(transform.position, fwd, hit, 50, LayerMask);
if(Input.GetButton ("Fire2")){
if (hasObject){
otherThing.rigidbody.isKinematic = true;
transform.DetachChildren();
//otherThing.parent = null;
hasObject = false;
print("Dropped "+otherThing.gameObject.name+"
");
} else{
if (Physics.Raycast (transform.position, fwd, hit, 50, LayerMask)) {
otherThing = hit.transform;
otherThing.rigidbody.isKinematic = true;
otherThing.parent = transform;
hasObject = true;
} else{
print ("Nothing to pickup!
");
}
}
}
}
So my object gets picked up, but not put down again. The Object dropped message doesnt display either. I THINK the issue is that because i'm repeatedly defining hasObject as false due to it being in an Update function, but I don't know how to make it only define hasObject at false when the level loads whilst still being able to call it into my update function. Probably quite a rookie problem i admit :)
Thanks for the help!