So, not to overwhelm with detail; I’m trying to have an item appear on a tree once an object from the inventory is place on it.
I thought the easiest way to do this would be to activate a gameobject (the decoration) once a collider has been triggered from dragging a decoration item from the inventory. Unfortunatly the item doesn’t seem to be triggering the collider and I think it has something to do with the inventory dropper script.
protected virtual Vector3 GetDropLocation()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitData;
Vector3 offset = new Vector3(0, .5f, 0);
if (Physics.Raycast(ray, out hitData, 1000))
{
return worldPosition = hitData.point + offset;
}
return transform.position;
}
This is the code for dropping an item into the world from the inventory.
private void OnTriggerEnter(Collider other)
{
//getting all items in array
//running through each object in array
if(other.CompareTag("Pickup"))
{
foreach (var item in _gameObject)
{
for (int i = 0; i < _gameObject.Length; i++)
{
if (isActive == false)
{
item.SetActive(true);
isActive = true;
Destroy(other);
}
}
}
}
}
And this is for activating the game object.
Any help would be greatly appreciated. Although I’m sure i’ll figure it out as soon as I post this; as is often the case.