the image set on the inspector is not displayed. I am a beginner

I read the book for beginners and constructed the following script.
When the main character (Uta) is hit, the hero disappears, an alternative sprite is displayed, and it is an action of being pulled upward.

Although it operates, the image specified by will not be displayed. The main character disappears and becomes inactive, and it is seen that the enemy is going away on top. However, the image set on the inspector is not displayed.

Advice please.

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

public class BruburuScript : MonoBehaviour {

    public Sprite BruSprite;
   
    bool isBru = false;

	// Use this for initialization
	void Start () {

        Vector3 pos = this.transform.position;
        pos.y = Random.value * 4 + 1;
        this.transform.position = pos;
		
	}

	
	// Update is called once per frame
	void Update () {
        if(isBru){
            Vector3 pos = this.transform.position;
            pos.y += Time.deltaTime * 6;
            this.transform.position = pos;
        }
		
	}
void OnTriggerEnter2D (Collider2D col)
	{
        if(!col .gameObject.name.Equals("Uta")){
            return;
        }

        col.gameObject.SetActive(false);

       this.GetComponent<SpriteRenderer>().sprite = BruSprite;

        isBru = true;
		
	}
}

Good day.

Is possible you have a Space here?

if(!col .gameObject.name.Equals(“Uta”)){

right after .gameobject?

General Tips: As you say you are a begginer, take note:

If want to ferear the object that contains this script, use “gameObject” (minusc “g”) , not “this” like here:

gameObject.transform.position = pos;

[is the object who have a transform, not the script]

[…]

or…

gameObject.GetComponent().sprite = BruSprite;

[is the gameObject who have components. The script is a Component of the gameObject also]

Bye!

tormentoarmagedoom

Thank you!
But…
No picture appears like the picture.!


[I changed “BruSprite” to the same name “hookOnSprite” as book. Copy & pasete]

I changed the code as follows.
Thanking you in advance.

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

public class BruburuScript : MonoBehaviour
{


    public Sprite hookOnSprite;

    bool isHook = false;


    void Start()
    {

        Vector3 pos = this.transform.position;
        pos.y = Random.value * 4 + 1;
        this.transform.position = pos;
    }


    void Update()
    {
        

        if (isHook)
        {
            Vector3 pos = this.transform.position;
            pos.y += Time.deltaTime * 6;
            this.transform.position = pos;
        }
    }


    void OnTriggerEnter2D(Collider2D col)
    {

        if (!col.gameObject.name.Equals("Uta"))
        {
            return;
        }


        col.gameObject.SetActive(false);

        GetComponent<SpriteRenderer>().sprite=hookOnSprite;

        isHook = true;
    }




}