Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

create game map (not minimap)

Discussion in 'Getting Started' started by saifmn, Jan 19, 2017.

  1. saifmn

    saifmn

    Joined:
    Jan 14, 2017
    Posts:
    4
    Hello, I'm beginner in unity and i whant to create a map for my game that indicate the player location (not minimap) and open it when click on M key ?
    I hope that you give me the steps, step by step and thank you
     

    Attached Files:

    CYCLE-6 likes this.
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Well, I'd probably use a UI.Image for the map, and another UI.Image for the player marker. Set the anchor of the player marker so that it corresponds to the point on the map that corresponds to the world origin (i.e. 0,0,0 in world coordinates). Then, in code, you can just set the marker's .anchoredPosition to the position of the player (times some scaling factor).
     
    saifmn and theANMATOR2b like this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    @JoeStrout's method is good.

    Another way to do a map is to use a second camera.
    • Attach an appropriate set of symbols to every object in the world, orientate them looking upwards.
    • Put them on a layer that is not visible to the main camera.
    • Make a separate camera that looks only at the symbols layer.
    • Turn the camera on and off as appropriate.
     
  4. saifmn

    saifmn

    Joined:
    Jan 14, 2017
    Posts:
    4
    can anyone give me a video tutorial or some codes to try
    im a beginner and this is my first project
     
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Then you shouldn't be worrying about stuff like this yet. It's definitely "intermediate" level stuff. Keep it simple — do some of the official tutorials. Then, go make a Flappy Bird or Doodle Jump clone. Then make another. Then do something else. Come back to this when the stuff we've written above doesn't sound like Greek to you!
     
  6. saifmn

    saifmn

    Joined:
    Jan 14, 2017
    Posts:
    4
    thank you @JoeStrout i finished 80% of the game following some tutorials .then i created a minimap and a GUI that appear when the M key is pressed but i don't know how to indicate the player location in this GUI Map.
     
  7. TheCandy

    TheCandy

    Joined:
    Dec 5, 2016
    Posts:
    22
    I am total begginer myself, but maybe I could help.....

    It really doesnt matter if you use the UI method, or second camera... But I prefer the second camera watching some plane with map texture, it is probably more dirty method, but easier for me to comprehend.... I did this by creating some icon - sprite, or something like that. Then you add a script to it, that moves the icon...

    Lets say, that you have a map, that is 10x10 units, and you world is 1000x1000 units , so the map is 100x smaller(those units are just for the example). Then the script for the movement of the icon would have the target (object the icon is representing) and then in the Update, you use something like:
    transform.postion = target.transform.position / 100 ;
    transform.postion.y = 0.1f; (simply some value, so the icon would be floating just above the map plane, if you use ortographic camera watching exactly from above, you wont even notice anything)

    ... division by 100 is because the map is actually 100 smaller than the world itself, so the icon move just like the real object on the x,z plane, only 100x less.

    It is somewhat primitive, but works actually pretty well.
     
    saifmn likes this.
  8. thisisadhi

    thisisadhi

    Joined:
    Oct 7, 2017
    Posts:
    4
    I tried this and I had an Image for the map, but the Player Icon on the map always for some unknown reason, always went to the edge of the screen. I don't know why. Bu the code I has was scaling the actual Player position to the map image version, then finding the difference in the x axis and other axis then making it move the necessary steps but it went to the far left instead of moving correctly, do you know why????
     
  9. BOrellana23

    BOrellana23

    Joined:
    Feb 7, 2020
    Posts:
    1
    You should add a collider to your icon and add walls on the edge of the map.
     
  10. jbnlwilliams1

    jbnlwilliams1

    Joined:
    May 21, 2019
    Posts:
    267
    Kiwasi, Excellent idea. Your 2 camera method will work for me for an entirely different reason.
     
  11. sn30814867

    sn30814867

    Joined:
    Apr 11, 2020
    Posts:
    1
    Can you give the video URL? Beacuse I can't find related video. thx
     
  12. AnshG_xD

    AnshG_xD

    Joined:
    Jul 21, 2020
    Posts:
    1
    This code may help you

    using UnityEngine.UI;
    using UnityEngine;
    public class EnableMap : MonoBehaviour
    {
    public RawImage map;
    private bool isMapEnabled;

    private void Awake()
    {
    isMapEnabled = false;
    map.enabled = false;
    }
    private void Update()
    {
    if (Input.GetKeyDown(KeyCode.M))
    {
    isMapEnabled = !isMapEnabled;
    MapEnabling();
    }
    }
    private void MapEnabling()
    {
    map.enabled = isMapEnabled;
    }
    }
     
  13. kbrooker

    kbrooker

    Joined:
    Aug 23, 2012
    Posts:
    21
    How about what is the best way to Make the Image itself without all the gizmos and crap in the editor by just screenshotting the scene top down anyone got any suggestions for that???
     
    CYCLE-6 likes this.