#TheWillowFox issue

1 messages · Page 1 of 1 (latest)

nimble yew
#

Better keep it in thread

hard ivy
nimble yew
#

The video is still unclear to me.
I see you

  1. standing next to a box with some shining effects on top
  2. Open the UI and circle an empty slot. Not sure what you're trying to show by that?
  3. You close the UI, go to the door and open the UI again. Now there is an item in the slot.
  4. You go out the door(change scene I assume?), go back in.
  5. You open the UI again and we see the item in the slot.

Assuming you're taking the item in step one, I don't understand what the issue is. Is it not supposed to be in your inventory?

hard ivy
#

i pick it up logs dont fire off doesnt show up in ventory

#

if i pick it up before leaving it shows up

nimble yew
hard ivy
#

that fires off an Event.Bus method

#

the eventbus

nimble yew
hard ivy
#

so as far as ik it works

nimble yew
#

Or does it print even when the issue happens?

hard ivy
#

if i leave the room and come back and pick an item up the pickup will still fire but the inventory and slots script wont

#

but if i pick them up before leaving the iventory and slot logs fire off

nimble yew
#

Okay, then debug the event in your EventBus script. See if anything is subscribed to it.

#
    public void PickUpItem(ItemData itemData)
    {
       if(onPickUpItem == null)
           Debug.LogError("nothing subscribed to onPickUpItem");
onPickUpItem?.Invoke(itemData);  
    }
hard ivy
#

ok

#

the debug in event bus did something

#

an error accured as soon as i came back into the room and collected the item

nimble yew
hard ivy
#

could it be dontdestroyonload messing with the data stucture

nimble yew
#

I'm not sure what you mean by that

hard ivy
#

or the event being unable to communicate wit DDOL

nimble yew
#

Instead of just making assumptions, investigate and debug.

#

And confirm the assumptions

hard ivy
nimble yew
hard ivy
#

tried debugging the dont destroy to see if it was causing problems

#

nothing

#

investigate whether if i need to outwardly have the eventbus try to find and sub to ddol stuff

#

nothing

#

quite literally the thing works fine until i leave the room and come back in

nimble yew
hard ivy
#

the item doesnt subscribe to it upon reloading the scene

#

idk if that would be an issue with the pickup script or iventory controller

nimble yew
#

Well, where do you subscribe to it?

#

Share the relevant code

#

If you know that it doesn't subscribe, the next thing to investigate is why.

#

90% of debugging code is just checking whether a code line runs or not and at what timing.

hard ivy
#

wait had to think about the event bus tree

#

ok
pickup script ==> eventbus ===> onpickupitem() in ventory contoller

#

and if im readying the error log you gave me

#
       Debug.LogError("nothing subscribed to onPickUpItem");
     EventBus.Instance.PickUpItem(_itemData);
     Debug.Log(_itemData.Name);
     Destroy(gameObject);
    }```
#

if pickupitem is nonexistent then fire off error

nimble yew
#

That's not what I suggested.

#

Wait, is it 2 scripts in one snippet?

hard ivy
#

the whole thing is doen through 3 diferent scripts

nimble yew
#

Okay, so where do you actually subscribe to the PickUpItem..? I feel like I've been pointing to/asking about it 5 times already

hard ivy
#

in the pickup script thats were it starts

#
using System.Collections.Generic;
using UnityEngine;

public class ItemPickUp : MonoBehaviour
{
    [SerializeField] private ItemData _itemData;

private void OnTriggerStay(Collider other)
{
    if (!other.CompareTag("Player")) return;

    if (Input.GetKey(KeyCode.E))
    {
     
     EventBus.Instance.PickUpItem(_itemData);
     Debug.Log(_itemData.Name);
     Destroy(gameObject);
    }
}

}``` the pickupscript
nimble yew
#

No it's not. It's not subscription

#

It's invocation

#

Do you understand what it means to subscribe to an event?

hard ivy
#

i thought i did
i thought the top pickupitem was the event itself

and the onPickupitem?.Invoke was the invocation

nimble yew
#

Ok, simpler question: what's the point of an event? What does it do?

hard ivy
#

to allow callbacks and signaling

#

to other scripts

nimble yew
hard ivy
#

the inventory contoller

#

because thats the event

nimble yew
#

What? How does that answer the "what do they need to do" question?