The object doesn't register the other arrow that it's touching.
public class CheckArrow : MonoBehaviour
{
public int Arrow;
KeyCode CorrectKey;
public bool IsAvailable;
public GameObject OtherArrow;
public float Score;
void Start()
{
if (Arrow == 1)
CorrectKey = KeyCode.UpArrow;
if (Arrow == 2)
CorrectKey = KeyCode.LeftArrow;
if (Arrow == 3)
CorrectKey = KeyCode.RightArrow;
if (Arrow == 4)
CorrectKey = KeyCode.DownArrow;
}
public void OnCollisionEnter2D(Collision2D collision)
{
IsAvailable = true;
OtherArrow = collision.otherCollider.gameObject;
}
void Update()
{
if (Input.GetKey(CorrectKey) && IsAvailable)
{
Destroy(OtherArrow);
Score += 1;
}
}
}
```Why does this happen and how can I solve it?