Hello everybody, i modified a piece of code that i found for an inventory system, and after i changed it it doesn't work anymore. The only piece of code that was modified was the following:
function OnCollisionStay(col : Collision){
if(!collider.isTrigger){
if (Input.GetButtonDown("TakeItem")){
var playersinv=FindObjectOfType(Inventory);
playersinv.AddItem(this.transform);
MoveMeToThePlayer(playersinv.transform);
}
}
}
It should make it so that whenever i press E it picks up the item and puts it in my inventory but it does absolutely nothing. Does anybody know how to fix this? PS: i know that this is some very shoddy coding, still learning.
↧