#look in the thread

1 messages · Page 1 of 1 (latest)

north acorn
#

so

#

before

#

in the hot bar manager i was calling UpdateSelectedSlot

#

and that was running before the slot even had an item

#

so now when i added the awake

#

it works because the item is first set and then the method in hotbar manager is called

north acorn
#

and now that i also put it in awake

#

the item in the slot is getting set first

latent meteor
#

CheckForItem

#

since it depends on another object being intiailized (the slot)

latent meteor
#

how what?

north acorn
#

why not awake

#

i need it in awake

latent meteor
#

wait sorry I'm getting confused between CheckForItem and UpdateSelectedItem

north acorn
#

CheckForItem() just checks if the slot has an item

#

HandleSlotSwitching() checks if you have an item in the current hotbar slot you are on and equips it

latent meteor
#

honestly rather than bothering with this I would just run CheckForItem lazily whenever the item is accessed

#

in a property getter

#

rather than putting it in Awake/Update/etc

north acorn
#

how?

#

also this is my inventory script

#

and when i pickup the item

#

it gets added to the inventory

#

and then i call the UpdateSelectedSlot() method from hotbar manager

#

but it doesnt do anything

#

because the method gets called before the slot even has a chance to set item to the item it currently has

#

what do i do?

#

@latent meteor

north acorn
#

how do i do that?

latent meteor
#

which part

#

write a property?