Forum begins after the advertisement:


[Part 11] Map Generation Error

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #13640
    Nathan
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    Hello, I’m having issues with a couple thing regarding the map generation. I’ve noticed the some others have had some map issues also but I haven’t really been able to find a fix. My first issue is getting a null reference regarding the CheckAndSpawnChunk() function. I think this is causing chunks to inconsistently spawn. I am new to using Unity but I believe the null reference is referring to me not having access to currentChunk because the inspector is empty. If I recall correctly though, the chunk trigger script will fill in the chunk game object in the inspector so it needs to be left empty in the map controller. I also found after running in the same direction for some time, the chunks stop spawning in general unless different key inputs are used. Any help or ideas would be much appreciated. Thank you.

    View post on imgur.com
    View post on imgur.com
    View post on imgur.com
    #13645
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Nathan,

    I haven’t looked at the spawning system yet since taking over the project, so I’m not very clear on how the spawn system works at the moment. Once I’m done with the enemy spawning system, I will be taking a closer look at the spawn system.

    That being said, let’s see if fixing the null reference exception in your code fixes all your issues. I think the issue might be to do with your chunk prefabs. Can you check to see if all your chunks have a trigger with the ChunkTrigger script attached, and a collider on the Chunk Trigger that is sized like this?

    View post on imgur.com

    The issue you are having is that CheckAndSpawnChunk() is calling when you are outside the ChunkTrigger, and when that is happening, it means that currentChunk will be null.

    #13647
    Nathan
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    I see. The trigger script was assigned to all the terrain prefabs but I did notice that the box collider was at 19.5×19.5. I also did notice that in one of the prefabs, the static points that hold where a chunk goes was spelt incorrectly. After fixing all that, I no longer get a null reference exception. Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: