#then how would it know what to put in

1 messages · Page 1 of 1 (latest)

bitter dock
#

here

#

to avoid spam

#

This is in the pickup script

digital heath
#

Are u calling that function?

bitter dock
#

yes

#

the issue is with line 90

#

Object reference not on an instance

digital heath
#

everything else works?

bitter dock
#

yes

#

this is the most recent edition

#

i feel like its something small and dumb im missing

digital heath
#

Would u mind posting the whole code?

bitter dock
#

just cant find it

digital heath
#

It normally is

#

U look like u know what ur doing ur prolly missing one small thing

#

U just need someone else to look at it

bitter dock
#

I have a few holes in my C# education

#

i know more about unity than actual coding rules

digital heath
#

hold on

#

Sorry just reading it

bitter dock
#

no worries thank you

digital heath
#

it looks like ur missing a reference to ItemSO

bitter dock
#

okay let me see

#

itemInSlot is a ItemSO

digital heath
#

ok its nested so lemme so

bitter dock
#

wait a second

digital heath
#

ur assigning it in that class

bitter dock
digital heath
#

not the class thats calling for it

bitter dock
#

can you explain

#

waitttt

#

i seeeee

#

thats referencing the class variable

#

i need to make an instance variable

digital heath
#

yeah

bitter dock
#

oh my gosh

#

thanks

#

its small things like these i need to iron out

#

still learning

digital heath
#

yeah its very nested

bitter dock
#

what does that mean

digital heath
#

Like classes depending on classes u should try implementing interfaces

bitter dock
#

for me it makes things more readable

#

and easy to understand (usually)

#

but what are interfaces?

digital heath
#

yeah but u run into small things like this that catch u off guard

#

interfaces are contracts that say a class must have this and they are easy to work with its prolly to late to implement them now but basically it says "ANYTHING THAT HAS THIS INTERFACE HAS THIS IN IT" so if something is a item it can have a class with a ITEMINTERFACE that way it can say like its touchable or can put in ur inventory and u can just check for that

#

its better explained else where lol

bitter dock
#

ill check it out

digital heath
#

also i believe line 35 and 37 can be put into on if statement

bitter dock
#

however i still dont know how to fix this

digital heath
#

is it still giving u a error?

bitter dock
#

i dont know how to fix it

#

im not sure what to code

digital heath
#

i gotchu bro no worries

bitter dock
#

thanks

digital heath
#

lemme read it over again

bitter dock
#

line 90

digital heath
#

U should prolly have an Array have ItemSO[] for each slot

bitter dock
#

that would be better

digital heath
#

ItemSO = hotbar.right.itemslot

bitter dock
#

like this

digital heath
#

yeah?

bitter dock
#

same error

digital heath
#

nonono

#

haha no my friend

bitter dock
#

):

digital heath
#

assign in the if statement on line 90

#

it looks like u did it backwards on line 102

bitter dock
#

ohhhhhh

#

so 102 was the correct way

#

?

digital heath
#

i may be wrong hold on

#

i think it because

#

is itemInSlot assigned in the hotbar class?

#

im sorry if im repeating myself its alot of jumping around

bitter dock
#

yeah theres so many scripts to keep track of

digital heath
#

its not

#

U should make a function that assigns it in some way in that class

bitter dock
#

this is confusing

digital heath
#

interfaces will make ur life easier lol

#

or a abstract class

#

ur a good programmer its spaghetti rn tho

#

ur actually really good its just how u decided to make classes my friend

bitter dock
#

thanks!

#

so i need to learn a different structure

digital heath
#

yeah learn about inherentice or however u spell it

bitter dock
#

okay

bitter dock
#

@digital heath okay i know that its bad to use Chat.GBT

#

but this was too cool

#

it perfectly described what my script does and found the error

#

before you hang me i know the dangers of chat GBT and im not using it to learn

#

this however did not help

#

but i have a new idea

bitter dock
#

I WAS TRYING TO ASSSIGN THE ITEM IN THE ITEM SLOT

#

BUT THERE WAS NO ITEM SLOIT!!!

#

AHHHHHHHHHHHHH

#

i fixed with SO's

#

spent WAYYY too long on that

digital heath
#

It happens man lol

#

Sorry 4 the late response was with my gf and hey you made a slot array nice !!!!

#

If you need help with anything please lmk bro

#

Is this ur first game or?

bitter dock
#

Yes it is! And I'm a big idiot and I'm going for my dream game first

#

But I've spent the last year and a half learning to work my way up to this project.

digital heath
#

Thats good to hear!!

#

U mind if i ask what type of game it is?