So the problem I am running into is I am trying to make a game where you switch from tool to weapon if Q is pressed but if held down which ever one your using at that time is dropped but every time I hold it down it still switches to a different item and drops that one instead of the one that I tried to drop since I can’t explain to good like this let me show you the main things. NOTE some of the things in this code doesn’t matter because I am not done yet so yeah.
public PTool Tool;
public PWeapon Weapon;
private Camera cam;
public bool UsingWeap;
public bool UsingTool;
void Update() {
//When somethings in your inventory
if (Weapon != null)
{
}
if (Input.GetKeyDown(KeyCode.Q))
{
if (UsingWeap == true)
{
UsingTool = true;
UsingWeap = false;
}
else {
if (UsingTool == true) {
UsingWeap = true;
UsingTool = false;
}
}
}
else {
if (Input.GetKey(KeyCode.Q)) {
Drop();
}
}
if (Input.GetKeyDown(KeyCode.E))
{
PickUp();
}
else { }