I am still fairly new to C# but,
I cannot figure out what my error is here. I am trying to add the GameObject that entered the collider to a list of GameObjects. initial thought would have been that maybe the ‘other’ is a collider or transform of sorts but I still don’t think that makes sense but to be honest I am not sure. Any help much appreciated!
(heres the whole code I have at the moment)
public class craftingScript : MonoBehaviour
{
[SerializeField] private string pickuppableTag = "pickuppable";
public GameObject leaf, stick, stone;
public GameObject[] items;
public GameObject[] r_string = leaf;
void Update()
{
}
void OnCollisionEnter(Collider other)
{
if(other.transform.CompareTag(pickuppableTag))
{
items[] = new GameObject(other);
}
}
}
Maybe im completely blind today, but i don’t see a List anywhere. Just some arrays.
Additionally, depending on your approach, OnCollision and OnTrigger are considerably different, and may require you to look at your use of rigidbody, or lack of.
I thought GameObject[ ] was a list… It isn’t an array because throughout the code the length will change depending on how many items are inside the collider