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

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #11528
    Xavier Lee
    Level 16
    Keymaster
    Helpful?
    Up
    1
    ::

    Introduction

    Following the release of Part 2 in which we first touched upon Map Generation, a lot of you have pointed out several notable issues with the system. So, I’ve put together this running list to help us keep track of them. I’ll mark each problem as [SOLVED] or [UNSOLVED], and keep this updated. Feel free to comment or make a new topic if you have any new errors!

    Chunks do not spawn when player is pushed

    [SOLVED]

    Some of may you have noticed that when the player gets pushed by the enemies, the chunks fail to spawn.

    This issue has been solved in Part 11.

    Chunks spawn inconsistently when player moves diagonally

    [SOLVED]

    A number of you reported that when the player moves diagonally, the chunks adjacent to the diagonal one fail to generate, interrupting the map’s consistent generation.

    This issue has been solved in Part 11.

    has upvoted this post.
    #13635
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Just to add on to the information from Xavier above, below are some topics related to Part 2 that may be helpful to you as well:

    #14781
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Here’s a map generation error that one of our viewers ran into (which was solved): https://blog.terresquall.com/community/topic/part-11-map-generation-error/

    #15046
    Panda Angy
    Level 2
    Participant
    Helpful?
    Up
    0
    ::

    one problem that i am running into is that the chunk gets turned into a collider and boost my character out of the chunk.

    nvm figured it out.

    #15047
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::
    one problem that i am running into is that the chunk gets turned into a collider and boost my character out of the chunk.

    For anyone else reading this, he probably forgot to check the Is Trigger property on his chunk collider.

    #15139
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Just nothing something that @krzysztofpuchalski4224 pointed out about the Part 2 video.

    At 25:12 you should assign Terrain Chunk in Chank Trigger script for each copied Trigger. This isn’t shown in the video
    #16137
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Chunks still not loading properly after Part 11?

    After Part 11, if your chunks still don’t load sometimes when moving diagonally like this:

    View post on imgur.com

    Please check out this topic: https://blog.terresquall.com/community/topic/part-11-chunk-not-loading-correctly-and-enemies-are-multiplied-when-spawning/

    #17186
    Sangui
    Level 3
    Participant
    Helpful?
    Up
    1
    ::

    Hi,

    I have an issue, when I spawn the chunks load correctly but I can’t move outside the starting chunk, and it seems that the chunks that spawn have a collider that prevents me to enter them, what could be the issue? Thanks!

    has upvoted this post.
    #17187
    Sangui
    Level 3
    Participant
    Helpful?
    Up
    1
    ::

    Nvm I didn’t put trigger on the single prefabs, only on the TerrainChunk Asset

    has upvoted this post.
    #17188
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    @emanuelesanquirico glad you managed to fix it :)

    #17224
    anon (Æternus Lux)
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    I have an issue where my map controller never gets updated and the current chunk stays set to the starting chunk

    here is my chunk trigger code

    void Start()
    {
        mc = FindObjectOfType<MapController>();
        if (mc == null )
        {
            Debug.Log("map controller not found!");
        }
    }
    
    private void OnTriggerStay2D(Collider2D col) // Use OnTriggerEnter2D
    {
        if (col.CompareTag("Player"))
        {
            Debug.Log("player entered trigger for:"+ targetMap.name);
            mc.currentChunk = targetMap; // Set currentChunk
        }
    }
    
    private void OnTriggerExit2D(Collider2D col)
    {
        if (col.CompareTag("Player"))
        {
            if( mc.currentChunk == targetMap )
            {
                mc.currentChunk = null;
            }
        }
    }

    }

    here is my map controller code

    void Start()
    {
        pm = FindObjectOfType<Player>();
    }
    
    // Update is called once per frame
    void Update()
    {
        ChunkChecker();
        if(!currentChunk)
        {
            return;
        }
    }
    public void ChunkChecker()
    {
    
        if (!currentChunk)
        {
            return;
        }
        if (pm.MoveInput.x > 0 && pm.MoveInput.y == 0) //right
        {
            //player.transform.position + new Vector3(24, 0, 0)
            //currentChunk.transform.Find("Right").position
            if (!Physics2D.OverlapCircle(currentChunk.transform.Find("Right").position, checkerRadius, terrainMask))
            {
                noTerrainPosition = currentChunk.transform.Find("Right").position;
                SpawnChunk();
            }
        }
        else if (pm.MoveInput.x < 0 && pm.MoveInput.y == 0) //left
        {
            if (!Physics2D.OverlapCircle(currentChunk.transform.Find("Left").position, checkerRadius, terrainMask))
            {
                noTerrainPosition = currentChunk.transform.Find("Left").position;
                SpawnChunk();
            }
        }
        else if (pm.MoveInput.x == 0 && pm.MoveInput.y > 0) //up
        {
            if (!Physics2D.OverlapCircle(currentChunk.transform.Find("Up").position, checkerRadius, terrainMask))
            {
                noTerrainPosition = currentChunk.transform.Find("Up").position;
                SpawnChunk();
            }
        }
        else if (pm.MoveInput.x == 0 && pm.MoveInput.y < 0) //down
        {
            if (!Physics2D.OverlapCircle(currentChunk.transform.Find("Down").position, checkerRadius, terrainMask))
            {
                noTerrainPosition = currentChunk.transform.Find("Down").position;
                SpawnChunk();
            }
        }
        else if (pm.MoveInput.x > 0 && pm.MoveInput.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.MoveInput.x > 0 && pm.MoveInput.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.MoveInput.x < 0 && pm.MoveInput.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.MoveInput.x < 0 && pm.MoveInput.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);
    
    }

    }

    I have triple check all the fields are set correctly in unity so idk what’s wrong

    #17225
    Lukas Kazda
    Level 14
    Gold Supporter (Patron)
    Helpful?
    Up
    0
    ::

    hi, your previous post has been moved to :)

    #17226
    Lukas Kazda
    Level 14
    Gold Supporter (Patron)
    #17233
    anon (Æternus Lux)
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    So I checked to see if I could check that the ontriggerStay2d was even communicating with my map controller at all and it does not seem to be triggering at all when I enter the the collider it won’t even trigger a debug.log it looks like istrigger is set to ture for all instances of my trigger and player etc etc so ii don’t have a clue whats going on maybe I just need to restart the whole process and see if the problem goes away in a fresh project

    #17234
    anon (Æternus Lux)
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    OMG I fixed it lol I didnt have rigigbody 2d facepalm lol thanks for your help the tip about the boxcollider 2d sent me on the right track to notice that I was missing a rigidbody2d

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

Go to Login Page →


Advertisement below: