#TheWillowFox issue
1 messages · Page 1 of 1 (latest)
sorry forgot about the thread bit
The video is still unclear to me.
I see you
- standing next to a box with some shining effects on top
- Open the UI and circle an empty slot. Not sure what you're trying to show by that?
- You close the UI, go to the door and open the UI again. Now there is an item in the slot.
- You go out the door(change scene I assume?), go back in.
- 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?
when i re-enter the room there is a test cube at the edge of the bed
i pick it up logs dont fire off doesnt show up in ventory
if i pick it up before leaving it shows up
What exactly is "picking up" how does it work in your game? What code is responsible for it?
https://hastebin.com/share/qoxeliqili.csharp
picking up items work via an onstaytrigger box collider
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
that fires off an Event.Bus method
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
the eventbus
So do you see the debug log in the OnTriggerStay when the issue happens?
no the pickup works as when i pick up the item the log tells me what ive picked up _item.Name being the name of the item
so as far as ik it works
So it doesn't print when you expect it to print, do I get it right?
Or does it print even when the issue happens?
the pickup works just fine
the inventorycontroller and slots are the ones that dont fire off under specific conditions
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
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);
}
ok
the debug in event bus did something
an error accured as soon as i came back into the room and collected the item
Great, so now we know that nothing is subscribed to that event. You should investigate and debug the place where you expect to subscribe to it.
could it be dontdestroyonload messing with the data stucture
I'm not sure what you mean by that
or the event being unable to communicate wit DDOL
Instead of just making assumptions, investigate and debug.
And confirm the assumptions
https://hastebin.com/share/fovavelata.csharp
ok after debugging a bit a finding nothing else im gonna have to speculate
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
How/what did you debug and what's the speculation?
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
Did you try investigating what I suggested here:
#1239421400981442641 message
?
the item doesnt subscribe to it upon reloading the scene
idk if that would be an issue with the pickup script or iventory controller
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.
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
the whole thing is doen through 3 diferent scripts
Okay, so where do you actually subscribe to the PickUpItem..? I feel like I've been pointing to/asking about it 5 times already
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
No it's not. It's not subscription
It's invocation
Do you understand what it means to subscribe to an event?
i thought i did
i thought the top pickupitem was the event itself
and the onPickupitem?.Invoke was the invocation
What does it mean to subscribe to an event? What does it do? And how would it look like in code?
Ok, simpler question: what's the point of an event? What does it do?
Okay, so what do the other scripts need to do to receive the signal?
What? How does that answer the "what do they need to do" question?