Forum begins after the advertisement:
[Guide] Notable Map Generation Errors
Home › Forums › Video Game Tutorial Series › Creating a Rogue-like Shoot-em Up in Unity › [Guide] Notable Map Generation Errors
- This topic has 28 replies, 14 voices, and was last updated 2 weeks, 4 days ago by
Alp Apustaja.
-
AuthorPosts
-
April 22, 2025 at 5:46 am #17975::
Based on the reference information, there are a few potential issues:
- Ensure the player object’s tag is set to “Player”
- Make sure each Terrain Chunk has:
- A Trigger BoxCollider2D
- A Rigidbody2D component (can be kinematic)
- Child objects named “Right”, “Left”, “Up”, “Down”, “Right Up”, “Right Down”, “Left Up”, “Left Down”
- In the MapController, verify that:
- The
terrainChunkslist is populated - The
playerreference is set - The
checkerRadiusis set to a small value (like 0.2) - The
terrainMaskis set to the Terrain layer
- The
Could you confirm that you’ve set up all these components exactly as described in the reference information?
has upvoted this post. April 22, 2025 at 5:55 am #17976April 22, 2025 at 6:00 am #17977April 26, 2025 at 3:54 am #18029April 26, 2025 at 3:55 am #18030::It looks like you’re trying to share an image link for context, but I can’t view external links directly. If you could describe the issue or any error messages you’re encountering, that would be really helpful!
Additionally, please make sure to check the following:
- Are the
currentChunkandtargetMapreferences set correctly? - Is the Rigidbody2D on the player and the chunks configured properly?
- Are you seeing any debug logs in the console when you enter the trigger area?
Let me know, and I’ll do my best to assist you!
June 23, 2025 at 11:23 pm #18339::SerializedObjectNotCreatableException: Object at index 0 is null UnityEditor.Editor.CreateSerializedObject () (at <e1073c193ef84b1a9ad1995ac137921f>:0) UnityEditor.Editor.GetSerializedObjectInternal () (at <e1073c193ef84b1a9ad1995ac137921f>:0) UnityEditor.Editor.get_serializedObject () (at <e1073c193ef84b1a9ad1995ac137921f>:0) UnityEditor.GameObjectInspector.OnEnable () (at <e1073c193ef84b1a9ad1995ac137921f>:0)>< after i test Chunk trigger my unity crash then this erorr appear form nowhere lol, any1 have any idea what this error was?
June 23, 2025 at 11:26 pm #18340::The
SerializedObjectNotCreatableExceptionerror you’re encountering typically means that there’s an issue with one of the objects or components in your Unity project. Here are some steps you could take to troubleshoot and possibly resolve the issue:-
Check for Null References: Make sure that all references in your scripts (like
currentChunk,targetMap,player, etc.) are properly assigned in the Unity Inspector. If any of these references are null, it could cause the error. -
Inspect the GameObjects: Check the GameObjects in your scene. Sometimes, if an object is missing a required component or script, Unity may throw this error. Ensure that all required components (like
Collider2D,Rigidbody2D, etc.) are present. -
Clear the Console: Sometimes, clearing the console and restarting Unity can help reset any temporary states that might be causing the issue.
-
Reimport All Assets: Go to
Assets -> Reimport All. This can fix issues related to corrupted asset files. -
Check Custom Editor Scripts: If you have any custom editor scripts, make sure they are not causing the issue. Sometimes, errors in these scripts can lead to problems in the editor.
-
Review Recent Changes: If the issue began after a specific change, consider reverting that change to see if it resolves the issue.
-
Update Unity: Ensure that you are using a stable version of Unity. Sometimes, bugs in Unity itself can cause issues like this, so using the latest stable version may help.
-
Check Project Settings: If you recently changed any project settings or updated packages, consider resetting them to see if that resolves the issue.
-
Create a New Scene: If the problem persists, try creating a new scene and see if the error occurs there. This can help determine if it’s a problem with your current scene.
If you’ve tried these steps and are still encountering the error, providing more details about what you were doing when the crash occurred might help pinpoint the issue further.
January 13, 2026 at 6:48 am #19194::I’m having the issue where none of the chunks spawn at all. I was recently having the issue where chunks would only load on top of other chunks, when they should be spawning on the edges, but after the supposed bug fixing in part 2 it no longer spawns any chunks.
heres my code
using System.Collections; using System.Collections.Generic; using UnityEngine; public class MapController : MonoBehaviour { public List<GameObject> terrainChunks; public GameObject player; public float checkerRadius; Vector3 noTerrainPosition; public LayerMask terrainMask; public GameObject currentChunk; PlayerMovement pm; void Start() { pm = FindObjectOfType<PlayerMovement>(); } void Update() { ChunkChecker(); } void ChunkChecker() { if (!currentChunk) { return; } if(pm.moveDir.x > 0 && pm.moveDir.y == 0) //right { if(Physics2D.OverlapCircle(currentChunk.transform.Find("Right").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Right").position; SpawnChunk(); } } else if (pm.moveDir.x < 0 && pm.moveDir.y == 0) //left { if (Physics2D.OverlapCircle(currentChunk.transform.Find("Left").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Left").position; SpawnChunk(); } } else if (pm.moveDir.x == 0 && pm.moveDir.y > 0) //up { if (Physics2D.OverlapCircle(currentChunk.transform.Find("Up").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Up").position; SpawnChunk(); } } else if (pm.moveDir.x == 0 && pm.moveDir.y < 0) //down { if (Physics2D.OverlapCircle(currentChunk.transform.Find("Down").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Down").position; SpawnChunk(); } } else if (pm.moveDir.x > 0 && pm.moveDir.y > 0) //right up { if (Physics2D.OverlapCircle(currentChunk.transform.Find("Right Up").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Right Up").position; SpawnChunk(); } } else if (pm.moveDir.x > 0 && pm.moveDir.y < 0) //right down { if (Physics2D.OverlapCircle(currentChunk.transform.Find("Right Down").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Right Down").position; SpawnChunk(); } } else if (pm.moveDir.x < 0 && pm.moveDir.y > 0) //left up { if (Physics2D.OverlapCircle(currentChunk.transform.Find("Left Up").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Left Up").position; SpawnChunk(); } } else if (pm.moveDir.x < 0 && pm.moveDir.y < 0) //left down { if (Physics2D.OverlapCircle(currentChunk.transform.Find("Left Down").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Left Down").position; SpawnChunk(); } } } void SpawnChunk() { int rand = Random.Range(0, terrainChunks.Count); Instantiate(terrainChunks[rand], noTerrainPosition, Quaternion.identity); } }using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; public class ChunkTrigger : MonoBehaviour { MapController mc; public GameObject targetMap; void Start() { mc = FindObjectOfType<MapController>(); } private void OnTriggerStay2D(Collider2D col) { if (col.CompareTag("Player")) { mc.currentChunk = targetMap; } } private void OnTriggerExit2D(Collider2D col) { if(col.CompareTag("Player")) { if(mc.currentChunk == targetMap) { mc.currentChunk = null; } } } }using System.Collections; using System.Collections.Generic; using UnityEngine; public class PropRandomizer : MonoBehaviour { public List<GameObject> propSpawnPoints; public List<GameObject> propPrefabs; void Start() { SpawnProps(); } void Update() { } void SpawnProps() { foreach (GameObject sp in propSpawnPoints) { int rand = Random.Range(0, propPrefabs.Count); GameObject prop = Instantiate(propPrefabs[rand], sp.transform.position, Quaternion.identity); prop.transform.parent = sp.transform; } } }January 13, 2026 at 6:57 am #19195January 13, 2026 at 12:40 pm #19196::Sigh….nevermind. Just realized the issue. I forgot the “!” in front of all of the “Physics2D.OverlapCircle” if statements. No idea how hard I’m facepalming right now. Leave it to one singular exclamation point to ruin everything…
It happens to all of us :)On a separate note, you may want to check this one out — we recently made an improved MapController script: https://blog.terresquall.com/community/topic/part-2-5-map-generation-on-roids-greatly-improved/
Video for this is coming soon as well.
January 13, 2026 at 8:17 pm #19197::Based on the reference information and the code provided, there are a few potential issues:
-
The
if (!currentChunk)check inChunkChecker()will prevent chunk spawning if no current chunk is set. -
The
Physics2D.OverlapCircle()check is looking for an existing chunk, but you want to spawn a chunk where there isn’t one. -
The condition should be negated to check for the absence of a chunk.
Here’s a corrected version of the
ChunkChecker()method:void ChunkChecker() { if (!currentChunk) { return; } if(pm.moveDir.x > 0 && pm.moveDir.y == 0) //right { if(!Physics2D.OverlapCircle(currentChunk.transform.Find("Right").position, checkerRadius, terrainMask)) { noTerrainPosition = currentChunk.transform.Find("Right").position; SpawnChunk(); } } // Similar changes for other directions... }The key change is using
!Physics2D.OverlapCircle()to check for the absence of a chunk at the specified position.Would you like me to elaborate on any of these points?
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: