it’s not as hard as you think, trust me - it’s just a fun way of introducing a new dimension to the game, xD
sounds simple. I could see how this can be used in countless ways for enemies. For idle states, random death animations, big boss fights where transitioning at specific times is essential, etc… Once the bank is off the charts (I’m reading the same article for the thousandth time as we speak, trying to figure out how in the world do you make this work for third person… my mind ain’t mind-ing though ), I’ll go give this a go. Hopefully it ain’t too hard though
Edit: I created a GameObject and stored the bank there on the banker himself. Next, so far I managed to get the player to enter the banking state machine, and I ended up calling the ‘OpenBank’ function I created for ‘OtherInventory.cs’… Now I’m looking for a safe way to get the bank and open it. For the most part, I think all the major functions are (ALMOST) fully taken care of for that one
and… I’m stuck with this weird error now:
NullReferenceException: Object reference not set to an instance of an object
GameDevTV.Inventories.OtherInventory.<OpenBank>b__3_0 () (at Assets/GameDev.tv Assets/Scripts/Inventories/OtherInventory.cs:49)
RPG.Bank.BankAction.Update () (at Assets/Project Backup/Scripts/Bank/BankAction.cs:44)
which leads to this function that I created, which comes from ‘PlayerBankingState.Enter()’:
[SerializeField] GameObject bankUIToOpen;
public void OpenBank(PlayerStateMachine player)
{
Debug.Log("OpenBank Function Called");
player.GetComponent<BankAction>().StartBankAction(transform, () =>
{showHideUI.ShowOtherInventory(bankUIToOpen);}); // <-- this is where the error is coming from
}
which leads to this:
public void StartBankAction(Transform bankTarget, System.Action callback) {
if (bankTarget == null) return;
this.callback = callback;
target = bankTarget;
GetComponent<ActionSchedular>().StartAction(this);
}
Which I’m a little clueless on because… well… I’m confused on what ‘System.Action callbacks’ are (usually when we enter this code, I know it’s advanced territory… so I’ll just quietly copy paste). Please… Help @Brian_Trotter - I tried just enabling the UI, but I can’t transfer anything in and out of the inventory if I do just that… I think something is missing
(I’m trying to copy-paste and tune whatever the point-and-click solution had, but damn this is quite hard tbh…)
And then it hit me that ‘System.Action Callback’ is literally nothing but giving a function a call to another function as a parameter. Please correct me if I’m wrong, but if true, then WOW… What a way to go around it
Edit 3: A few hours of debugging later, I realize that the Inventory Slots of the bank ALWAYS return the NRE error if we hover over them, with this function for ‘OpenBank’:
public void OpenBank(PlayerStateMachine player)
{
bankUIToOpen.SetActive(true);
// figure out why in the world wouldn't the Inventory Slot UI refresh for the bank, although it refreshes for the player's Inventory
bankUIToOpen.GetComponentInChildren<InventoryUI>().Setup(bankUIToOpen);
}
and why is that the case? Because this function in ‘InventoryUI.cs’ always returns a false:
public bool Setup(GameObject user) {
if (user.TryGetComponent(out selectedInventory)) {
// if the object has an inventory (our bank in this case), set the Selected Inventory Up,
// Subscribe to the Redraw() changes, and then redraw the inventory:
selectedInventory.inventoryUpdated += Redraw;
Title.text = selectedInventory.name;
Redraw();
return true;
}
return false;
}
How do we fix this? (I’m really sorry to drag you into another topic… I’m trying my best not to bother you by asking for anymore help, as you’ve helped me a lot (and I’m grateful for that!), but I’ve been trying for a few more hours after writing the previous code, and I still can’t figure it out. So… Please Help me get the bank to work again
)