is my code bad?

hello
so im trying to make a inventory in c++, and i have referenced userwidget in the details panel and, just as i though i was gonna get this to work, when i run my code. it gives me a lot of error


this is what i have coded, idk if the toggleInventory is bad coded. how can i improve or solve this


these are the error im getting.

make sure INVENTORYCPPCharacter.cpp has #include that contain UTest and WidgetClass is not null

if u did, the crashes could be somewhere in UTest

the error is telling you that what you are trying to AddToViewport() is a null/invalid reference which is causing your crash.

ok so i have choosen an UI for the widgetclass, it kind of works but the UI doesnt show up, only the debug log

just by interest also might be blind but how do you know that? does it say it in the error?

EXCEPTION ACCESS VIOLATION is the first giveaway, this is usually an invalid reference. Next giveaway is memory address is 0x000000000 etc

ahha i see, makes pretty much sense with the 0’s, thank you for explaining

1 Like