private void HandleLongShortPress(ref ShortLongPressStruct pressStruct) { Transform socket = SelectSocket(pressStruct.socketType); PickupInteract attachedObj = GetAttachedObject(socket); if (Input.GetButton(pressStruct.buttonName)) { if (!pressStruct.isHolding) { pressStruct.pressTime = Time.time; pressStruct.isHolding = true; } if (!pressStruct.hasLongPressed && (Time.time - pressStruct.pressTime) >= longPressDuration) { // When longpressed, either interact with holding object // Or closest object if not holding any if (attachedObj) { attachedObj.Interact(socket); } else if (closestInteract) { closestInteract.Interact(socket); closestInteract = null; } pressStruct.hasLongPressed = true; } } else if (Input.GetButtonUp(pressStruct.buttonName)) { // When shortpressed, try attached object's secondary use // Interact with closest object if that fails if (!pressStruct.hasLongPressed && (!attachedObj || !attachedObj.SecondaryUseDown()) && closestInteract) { closestInteract.Interact(socket); closestInteract = null; } pressStruct.hasLongPressed = false; pressStruct.isHolding = false; } }