Open alialacan opened 5 years ago
just remove the SpawnPoint tag for destroyer object and it is good to go.
The project is throwing null pointer exception for RoomSpawner, Row:53 because of template reference is being null, when it detects collision. Normally, physics functions are called after the initialization functions (and it does find the reference of templates in start when I debug) but I still got that error in Unity3D 2019.1.3f1 Simply, adding null check for templates does the trick if anyone having this issue.
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("SpawnPoint")) { if (other.GetComponent<RoomSpawner>().spawned == false && spawned == false && templates != null) { Instantiate(templates.closedRoom, transform.position, Quaternion.identity); Destroy(gameObject); } spawned = true; } }
Yes it will remove the error but in return there's a chance that the boss room will spawn with no entrance any chance to fix it in other way i will wait for response thank you
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("SpawnPoint")) { if (other.GetComponent
().spawned == false && spawned == false && templates != null) { Instantiate(templates.closedRoom, transform.position, Quaternion.identity); Destroy(gameObject); } spawned = true; } }
my instantiate line gives this error :
NullReferenceException: Object reference not set to an instance of an object RoomSpawner.OnTriggerEnter2D (UnityEngine.Collider2D collision) (at Assets/RoomSpawner.cs:63)
@carvrodrigo also I did what you said but it just solved another bug in if(collision.GetComponent).
Is easy to fix it only increase a number in Invoke methode
Simply add this statement:
private void Awake() { templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent<RoomTemplates>(); }
and remove it from Start function
PLS Help!!!How i can repeat process of generation
The project is throwing null pointer exception for RoomSpawner, Row:53 because of template reference is being null, when it detects collision. Normally, physics functions are called after the initialization functions (and it does find the reference of templates in start when I debug) but I still got that error in Unity3D 2019.1.3f1 Simply, adding null check for templates does the trick if anyone having this issue.