Alright, so I'm having a delay problem with a pickup script. Well rather, I can't get a delay working. I've looked through a bunch of delay answers on here, but I can't get any of them to work. Here is a snippet of what I'm working with:
function Update () {
if( timer > seconds.getSecondsFloat() +3)
if (Input.GetKeyDown("f") && itemHeld == true) {
object.transform.parent = null;
object = null;
held = false;
}
}
function OnTriggerStay(collider : Collider){
if (Input.GetKeyDown("f") && collider.tag == "hands")
if (itemHeld == false){
Debug.Log("i see you keep hitting me, there");
aquireObject();
}
}
function OnTriggerEnter(collider : Collider){
if (Input.GetKeyDown("f") && collider.tag == "hands")
if (itemHeld == false){
Debug.Log("i see you hit me, there");
aquireObject();
}
}
It works, to pick up the object. But the command executes so fast that when I go to set the object down it will pick it back up. I've tried setting a counter that increments on every frame and I put in an if condition for if (counter > 60), but then I can't even pick up the object. I've tried a coroutine, but to be honest I can't find too much information on them. I could have done it wrong. I had startcoroutine(functionthatyields) and yielded 3 seconds. I called it inside the if condition an everything. But I'm not sure how to get this working. :|