Jakub Cernicky
New member
- Joined
- Jun 7, 2022
- Messages
- 3
- Programming Experience
- Beginner
hello I'm doing a game and I'm stuck here, I have a collider box created and if I put a bucket in the collider box, it will be added to the List and when I put it away from the collider box it will be removed from List but I need it to fill with dirt in that collider box and I don't know how I have get the definition of this bucket from that sheet so that it only works for that one bucket in the collider box
I'll upload the script I have here
Thank you for your help
I'll upload the script I have here
Thank you for your help
My list code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SiveController : MonoBehaviour
{
public GameObject EmptyBucket;
public GameObject BucketOfWater;
public GameObject BucketOfDirt;
public GameObject Dirt;
List<GameObject> currentCollisions = new List<GameObject>();
void updateItems()
{
// I don't know how to get the definition of a bucket that is added in a list
// ↓
if (currentCollisions.Contains( ))
{
Debug.Log("EmptyBucket Enter");
}
if (currentCollisions.Contains(Dirt))
{
Debug.Log("Dirt Enter");
}
// I don't know how to get the definition of a bucket that is added in a list
// ↓
if ((currentCollisions.Contains(Hlina)) && (currentCollisions.Contains( )))
{
Debug.Log("Filling the Bucket");
EmptyBucket.gameObject.SetActive(false);
BucketOfWater.gameObject.SetActive(false);
BucketOfDirt.gameObject.SetActive(true);
currentCollisions.Clear();
}
}
void OnTriggerEnter(Collider Other)
{
currentCollisions.Add(Other.gameObject);
Debug.Log("Entering" + Other.gameObject.name);
updateItems();
}
void OnTriggerExit(Collider Other)
{
currentCollisions.Remove(Other.gameObject);
Debug.Log("Leaving" + Other.gameObject.name);
}
}