Object reference not set to an instance of an object

I recently downloaded a proyect from the asset store and when I tested it, Unity threw this exception. Well, i didnt notice where the problem is. I have let the part of the code where i think the problem is.
Someone could help me? Thanks in advance.

NullReferenceException: Object reference not set to an instance of an object
Meteor.MagneticEffect () (at Assets/Game/Scripts/Controller/Meteor.cs:159)
Meteor.Update () (at Assets/Game/Scripts/Controller/Meteor.cs:71)

void Update ()
    {
        ModeSelect();

        if (GameController.instance.isGameOver == false && sceneMode == SceneMode.gamePlay)
        {
            MagneticEffect();
        }
    }
void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("PlayerAttract"))
        {
            shipTransform = other.transform;
            magnetZone = true;
        }
    }

    void OnTriggerExit2D(Collider2D other)
    {
        if (other.CompareTag("PlayerAttract") & looseMagnet)
            magnetZone = false;
    }

    void MagneticEffect()
    {
        if (magnetZone)
        {     
            Vector3 directionToShip = shipTransform.position - trans.position;
            rigidBD.AddForce(directionToShip * magnetDirection * Time.deltaTime, ForceMode2D.Force);         
        }
    }

Does your rigidBD actually have a reference to the RigidBody? It would either be set in Start or in the Inspector.

I reference it now from the inspector changing it to public but it doesnt work :frowning: thanks for you reply)

Your error includes a line number where it is happening, but you didn’t bother to mention what line that is of the code you posted. Add debugging before whatever line it is to determine what reference is null. Then figure out why it is null when it shouldn’t be and fix.

Mmm, i reasigned the transform component and the error disappear but it doesnt work yet, i will think a diferent way. The lines in the code are 8 and 30. Thanks for reply.

Yeah, so line 30 means either shipTransform or trans are what is null.