I am trying to make an inventory system where items get added to a list when the E key is pressed while the character is within the item’s collider, and then the item’s model is removed from the game. I thought the way remove objects was with endObject(), but it doesn’t seem to be working. I have a Collision sensor on the character that looks for the “item” property, and it’s attached to a Controller with a python script loaded into it. The items have the “item” property, and here is my script so far:
import bge
keyboard = bge.logic.keyboard
item = bge.logic.getCurrentController().sensors["Collision"].hitObject
eKey = bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.EKEY]
itemList = []
if eKey:
itemList.append(item)
item.endObject()