Deleted gameObject before Getcomponent

i have deleted the game object word in the line of the Code that before GetComponent and the method work fine.

private void OnTriggerEnter2D(Collider2D other)
{
DamageDealer damageDealer = other.GetComponent();
damageDealer.Hit();
HitsProcess(damageDealer);
}

and the same thing was done before in the Enemyspawner.cs the gameObject wasn`t there

var newEnemy=Instantiate(waveconfig.GetEnemyPrefabs(),
waveconfig.GetWayPoints()[0].transform.position,
Quaternion.identity);
**newEnemy.GetComponent<**EnemyPathing>().SetWaveConfig(waveconfig);
yield return new WaitForSeconds(waveconfig.GetTimeBetweenSpawns());

the Question is , as it dosnt matter in both cases may i ignore writting it in any upcoming script ?

Privacy & Terms