Search Unity

2D Maze Game

Discussion in '2D' started by richasachdeva, Sep 18, 2014.

  1. richasachdeva

    richasachdeva

    Joined:
    Feb 14, 2014
    Posts:
    3
    Hi,

    I'm making a 2d maze game in unity, where maze is a a png (got it from http://www.mazegenerator.net/Default.aspx). So, maze is transparent except for walls, and I want player to be stopped by them. I can't use box collider 2d as it would be for entire maze, and I want only for some part. So, next step was to be able to find the color on the maze sprite, and based on it let the player move. But in that I am having problem with picking the right maze color.

    I am using sprite, then extracting texture from it, and using GetPixel, but it's giving me incorrect value, probably as GetPixel needs pixel coordinate and I'm missing something there.

    Any help would be appreciated.

    Thanks in advance. Have attached maze png that I am using.
     

    Attached Files:

  2. Suraj.

    Suraj.

    Joined:
    Jan 27, 2015
    Posts:
    4
    did u figure it out? i am facing same problem :(
     
  3. richasachdeva

    richasachdeva

    Joined:
    Feb 14, 2014
    Posts:
    3
    Hi,

    As I essentially needed a 2d maze, and I was going by the above approach as I thought working with sprites will be easy, but it turns out to be wrong. So, I switched to 3d objects viz cubes, and for your reference, check the below link -

    http://forum.unity3d.com/threads/pac-man-clone-in-60-lines-of-code.56054/

    as it really helped me and was the basis for my 2d maze.

    Hope it helps.
     
  4. Suraj.

    Suraj.

    Joined:
    Jan 27, 2015
    Posts:
    4
    Hey thanks....But I made my game by creating a maze generator script...Just giving final touch ups now :D
     
  5. Myckwilde

    Myckwilde

    Joined:
    Mar 21, 2015
    Posts:
    3
    Hi !
    Might be tedious to do so but I think you could also create empty game objects with edge colliders and adjust them to the size of your maze lanes where you want your player to be blocked. But it might not be the best option if you have a complex maze as it would mean you'd need a lot of game objects...