Where are the Inputs?

Where is the input reference?

There are TWO input reference in this package and it is located below:

  • GeneratorItem script has an input for interacting with objects with the raycast

  • GeneratorInventory script has an input for opening and closing the inventory

  • Edit the input keys int he GenInputManager script

Changing the Input:

GenInputManager:

public class GenInputManager : MonoBehaviour
    {
        [Header("Raycast Pickup Input")]
        public KeyCode interactKey;

        [Header("Inventory Inputs")]
        public KeyCode openInventoryKey;
    }

GeneratorInventory:

void Update()
{
    if (Input.GetKeyDown(genInputManager.openInventoryKey) && hasJerrycan)
    {
         isInventoryOpen = !isInventoryOpen;
         genUIManager.ShowInventory(isInventoryOpen);
    }
}

GeneratorItem:

private void Update()
{
    RumbleGenerator();
    GeneratorFuelBurnLogic();

    if(isLooking) 
    {
         if (Input.GetKeyDown(GenInputManager.instance.interactKey))
         {
             keyHoldTime = Time.time;
             StartCoroutine(CheckForLongPress());
         }

         if (Input.GetKeyUp(GenInputManager.instance.interactKey))
         {
             if (isFilling)
             {
                 StopWaterPour();  // Stop the sound when you stop pouring fuel
             }

             if (!isFilling)
             {
                 // If the key was released before the delay, perform the normal interaction
                 ObjectInteraction();
              }
              isFilling = false; // reset the flag when the key is released
            }
       }
}

IEnumerator CheckForLongPress()
{
    // Wait for the delay
    yield return new WaitForSeconds(keyHoldDelay);

    //If the key is still being held down after the delay, start filling the generator
    while (Input.GetKey(GenInputManager.instance.interactKey))
    {
        isFilling = true;
        GeneratorFillingLogic();
         yield return null;  // This makes the coroutine wait for the next frame before continuing
     }
}

Last updated