Brick script says brick does not contain definition for GetComponet

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

public class Brick : MonoBehaviour {

public int maxHits;
public Sprite[] hitSprites;
private int timesHit;
private LevelManager levelManager;

void Start () {
	timesHit = 0;
	levelManager = GameObject.FindObjectOfType<LevelManager>();
	
}

void Update () {
	
}

void OnCollisionEnter2D (Collision2D col)
{
	timesHit++;
	if (timesHit >= maxHits) {
		Destroy (gameObject);
	} else { 
		LoadSprites ();
	}
}

void LoadSprites () {
	int spriteIndex = timesHit - 1;
	this.GetComponet<SpriteRenderer>().sprite = hitSprites[spriteIndex];
}	

void SimulateWin () {
	levelManager.LoadNextLevel();
}

}

this.GetComponet().sprite = hitSprites[spriteIndex];
it says there is an error with getcomponet and sprite is highlighted in red also but it says “Brick” does not contain a definition for “GetComponet” and asks if I am missing a using directive or an aseembly reference? not entirely sure where the issue is coming from.

1 Like

Check your spelling again :wink:

1 Like

Thanks. I’m going to go step in front of a bus now.

1 Like

That’s quite extreme, for spelling…

…if it was grammar I would be inclined to push you :wink:

Privacy & Terms