Finally i am done with my Itemsystem and can now pickup items. the problem is, that i dont know, how i can “use” the picked items.
i was thinking, about making a door with key system, and i have no idea, where in my code i have to store the KeyID and where i have to check if the ID is the same as from the door.
i have a struct with Item and Amount. an BPC for the inventory, where i can add items
i followed the udemy cource for horror games.
Ok seems straight forward enough. The item which is the key needs to have a variable that cobtains the code for the door.
In the door blueprint when you interact theres 2 ways you can do this. Either you pass the actors inventory to the door for it to search for a matching key(passive use) or more direct use , make the player equip the key or use it and pass the code to the door. An interface would be a good way for this. But just passing the actor to the door is also possible , chrck he has a key equipped , if so check the code
What you need to do, on the top code where you have your player ref and inventory. Add a for loop (with break) to the inventory, check each item , if the item is a key, check the code. If the code matches set a local bool called bValidKey then break out the loop. On the completed section branch the bValidKey true unlock door, false do nothing (or whatever you want raise an alarm , fire a laser anything)
Or
If your players has an equipped slot, compare that to key item and check its code if matches the open door etc