Sorry if this seems like a dumb question to ask. I am fairly new to unity.
Anyways, I would like my player to pick up an object. I would like to use the same key (E) to pick the object up and also place it down if the player is holding it. I haven’t really been able to get it to work.
Code:
Something like?
var canHold = item.tag == "Grabable";
if((canHold || isHolding) && Input.GetKeyDown(KeyCode.E))
{
if(isHolding)
{
PutdownItem();
}
else
{
PickupItem();
}
}
@sacredgeometry
It kind of works, yet the thing I am trying to pick up freaks out for some reason.
Sometimes if I press E it doesn’t pick up or put down fully. It will just appear to be placed or picked up for a split second then go back to its normal position.
I wasn’t having an issue like this when I used separate keys to pick up and place the object.
I also changed a bit of your code to fit mine.
New Code (Including some more):