Using OnTriggerEnter2D my integer is only increasing once? Why?,My integer isn't every time increasing using OnTriggerEnter2D. It only increases once?

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Bullet : MonoBehaviour
{
public Rigidbody2D rb;
public int coins;
void Start()
{
}
// Update is called once per frame
void Update()
{
rb.velocity = new Vector2(0f, 8f);
}

private void OnTriggerEnter2D(Collider2D other)
{
    if (other.gameObject.CompareTag("Plane"))
    {
        coins += 5;
    }
}

}
I have assigned all the tags and it is only increasing once.
,using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Bullet : MonoBehaviour
{
public Rigidbody2D rb;
public int coins;
void Start()
{
}
// Update is called once per frame
void Update()
{
rb.velocity = new Vector2(0f, 8f);
}

private void OnTriggerEnter2D(Collider2D other)
{
    if (other.gameObject.CompareTag("Plane"))
    {
        coins += 5;
    }
}

}
This is the code but it only increases by 5 once not a second or third time. Also, yes I have assigned the tags.

@VolditeDev - It seems that the bullet continues to move with a constant velocity after the first collision. When the bullet enters the trigger of the “Plane” object, the OnTriggerEnter2D function is called, and the coins variable is increased by 5. However, after this point, the bullet remains inside the trigger, and the OnTriggerEnter2D function is not called again.

To resolve this issue, you can either destroy the bullet or deactivate it when it collides with the “Plane” object. Here’s an example of how to destroy the bullet:

private void OnTriggerEnter2D(Collider2D other)
{
    if (other.gameObject.CompareTag("Plane"))
    {
        coins += 5;
        Destroy(gameObject);
    }
}

If you prefer to reuse the bullet instead of destroying it, you can set the bullet to be inactive after the collision:

private void OnTriggerEnter2D(Collider2D other)
{
    if (other.gameObject.CompareTag("Plane"))
    {
        coins += 5;
        gameObject.SetActive(false);
    }
}

By destroying or deactivating the bullet after a collision, you ensure that the bullet is no longer inside the trigger, and the OnTriggerEnter2D function will be called again for subsequent collisions.

I will however leave a friendly reminder here to looking “object pooling” to ensure you´re not creating more gameobjects than you need and simply reusing them as it is a lot more performant.