merge joonasp joonasty

This commit is contained in:
HelarJ
2022-04-11 18:56:51 +03:00
parent cd1633af54
commit ec2dd764d4
11 changed files with 36526 additions and 348 deletions

View File

@@ -92,7 +92,7 @@ public class InventoryItem : MonoBehaviour
if (Count == 0)
{
//Destroys this gameobject if the count is 0 or lower
Destroy(this);
Destroy(gameObject);
return true;
}
UpdateText();
@@ -101,6 +101,30 @@ public class InventoryItem : MonoBehaviour
return true;
}
public void PopItem()
{
GameObject item = Instantiate(_itemData.prefab, transform.position + transform.forward, Quaternion.identity);
item.transform.localScale = Vector3.one;
item.transform.name = _itemData.name;
var colliderComponent = item.GetComponent<Collider>();
if (colliderComponent != null) colliderComponent.enabled = true;
var rigidbodyComponent = item.GetComponent<Rigidbody>();
if (rigidbodyComponent != null)
{
rigidbodyComponent.isKinematic = false;
rigidbodyComponent.useGravity = true;
}
var xrGrabInteractableComponent = item.GetComponent<XRGrabInteractable>();
if (xrGrabInteractableComponent != null) xrGrabInteractableComponent.enabled = true;
ChangeCount(-1);
}
public int GetItemid()
{
return _itemId;

View File

@@ -10,6 +10,7 @@ public class ItemData : MonoBehaviour
public bool canStack;
public string itemName;
public string itemDescription;
public GameObject prefab;
public override string ToString()
{