⛽
Generator System - Doc
  • Generator System - Introduction
  • ⭐Getting Started
    • Quick Start
    • Detailed Setup
  • ❓Support
    • FAQ
    • Power Event
    • System Namespace
    • Missing UI Text?
    • Adding Audio Clips
    • Where are the Inputs?
    • Adding New Sprites
  • 🌀Development
    • Patch Notes - V1.5
    • Roadmap
  • 📧Contacts
    • Contact Me
    • My Other Assets
Powered by GitBook
On this page
  • Where is the input reference?
  • Changing the Input:

Was this helpful?

  1. Support

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
     }
}
PreviousAdding Audio ClipsNextAdding New Sprites

Last updated 1 year ago

Was this helpful?

❓