#Collision is broken

1 messages · Page 1 of 1 (latest)

pine crystal
#

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?
twilit relic
#

Have you had a look at the FAQ?

pine crystal
#

yes

#

oh, just realized, it needs to be a non-kinematic rigidbody

#

sorry, not fixed, something else is going on