Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Rokugan90 · Aug 20, 2013 at 03:40 PM · 2dmapinteractive

Interactive 2D world map?

Hi, I tried to look around about this topic but I couldn't find what I needed, so here I am .

I'll try to make it simple, I would like to know if there is a way to create an interactive 2D world map in Unity. I need to have a map with clickable regions that upon click would change the map with a zoomed section (probably a different image, not a zoom in of the original). Using this map I made as an example: http://imageshack.us/a/img838/1127/ov52.jpg .

I need to be able to click on the "Arien Plains" region, after that I will have a map that represent that region alone, and if I click on one of the cities I would like to have another change to the city map. I hope this makes sense, if not I'll be happy to add more details (forgive me if my english is not perfect, that's not my first language ^^)

EDIT: So I managed to work at something. At this point I have one majon Issue. I managed to create custom meshes with the shapes of the regions, assign mesh colliders in unity with a script that change the map. The big problem now is that being the same plane with different texture the colliders will still be there, so if i click in a zoomed section i'll be teleported to another section. One way to avoid this I think would be using different planes, each one with a section of the zoomed map.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Aug 20, 2013 at 03:58 PM 0
Share

Are you familiar with scripting? Because there are many ways to achieve what you want but you need some knowledge of scripting.

One method is like the below answer says, using GUI functions. But I would suggest something else, using raycast and colliders. You can put your map on a plane and add various colliders for each region, then on click fire a raycast from the mouse position. Then when the raycast hit one of the collider the maincamera can change position to another map in the same scene.

avatar image Rokugan90 · Aug 20, 2013 at 04:02 PM 0
Share

I'm not very familiar with scripting but in this project I have also involved a friend of $$anonymous$$e who is a programmer so he probably could manage that better than me. Thanks for you reply ^^

4 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by mattssonon · Aug 20, 2013 at 04:37 PM

This could be done in several ways, here's one suggestion.

Create a bunch of empty Game Objects with Box Colliders. Place these colliders on the parts of the map where you want interaction like this:

alt text

Create a script which listens for mouse clicks on the Game Object it is attached to:

 public Texture2D zoomedInTexture;
     
 void OnMouseDown() {
     GameObject.Find("Map").GetComponent<Renderer>().material.mainTexture = zoomedInTexture;
 }

Add this script to all colliders, and set the proper, zoomed in textures for each region on each script's zoomedInTexture variables in the Inspector. This also assumes you call the Game Object with the map on it "map".

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rokugan90 · Aug 20, 2013 at 04:50 PM 0
Share

This looks like a good method! The only thing I would like to change is the shape of the collider. $$anonymous$$aybe I could create custom meshes(lowest poly as possible) and then use a mesh collider and make the mesh invisible. Something like this Example Image

avatar image
1

Answer by Bunny83 · Aug 20, 2013 at 04:57 PM

Something like this?

http://answers.unity3d.com/questions/289506/view.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rokugan90 · Aug 20, 2013 at 05:15 PM 0
Share

$$anonymous$$inda, but without the color selection part cause as you can see the map is going to be quite detailed. As you stated in your other reply using buttons is not accurate enough so I was thinking about using custom meshes created in maya and assign a mesh collider. Something like this http://puu.sh/46vWH.jpg

avatar image Bunny83 · Aug 21, 2013 at 01:38 AM 0
Share

I don't get your complaint... the color map is for selection only! It won't be displayed anywhere. It's only used to deter$$anonymous$$e in which part your cursor is. You just sample the color of the "selection map" at your cursor position and you immediately know what section you're in. Again the selection map is a completely seperate texture.

I've edited my answer on the other question. Here's the sample selection texture for the map of the other question.

avatar image
0

Answer by ActionAbbas · Aug 20, 2013 at 03:53 PM

Hi, so from what your question say's you want to have an interactive map, which you can click on certain areas to move to a different map. Well the way I'd do this would be to have separate scenes for each new map area. So one world map scene, one town map scene etc. Then for example in the world map scene you can have a camera facing towards a plane with your map picture on it and then have a script which you can attach to the camera, this script would have GUI buttons which when pressed would transport you to the next requested scene. So if you clicked on the "Arien Plains" region from the world map you would be transported to a new scene which would have the new area's map on the plane and the same sort of thing can be done again but with one extra GUI button in the corner which would take you to the previous scene.

Hope this helps!

By the way you English is perfect!

Cheers Abbas

Edit: The Gui buttons would be placed on the scene wherever you would want them. So in this case on top of certain regions of the map.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mattssonon · Aug 20, 2013 at 03:56 PM 0
Share

It's a waste to use individual scenes for something as simple as showing a different image.

avatar image Yokimato · Aug 20, 2013 at 03:57 PM 0
Share

Each have it's own scene? yikes! that could get messy real quick in my opinion! I don't see a reason why he has to concern himself with retaining state of his game scene to show a different map. Neat idea though :)

avatar image Rokugan90 · Aug 20, 2013 at 03:58 PM 0
Share

Thanks for the answer! Is there a way to have the GUI buttons match certain areas? Or they are bound to be boxes?

avatar image ActionAbbas · Aug 20, 2013 at 04:03 PM 0
Share

Honestly i'm not sure, i think they are bound to boxes.

avatar image ActionAbbas · Aug 20, 2013 at 04:08 PM 0
Share

Oh actually you can re-size the buttons but then you would have to make them transparent.

avatar image
0

Answer by Yokimato · Aug 20, 2013 at 03:56 PM

One way you could do it is have a each click point be a gameobject that's overlaid on top of the map. Each of these would need a collider (to interact with the mouse click). Each of these would also need a simple script to keep track of which map to show. On the click, hide or fade the top level map and show the one referenced in the script.

Hope this helps.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rokugan90 · Aug 20, 2013 at 04:10 PM 0
Share

Thanks for the reply! So basically with what you and neurological said the best options would be to play around with colliders on a plane with the map attached as a texture, if I understood correctly.

avatar image mattssonon · Aug 20, 2013 at 04:26 PM 0
Share

Exactly, I just posted an answer with screenshots and a script sample, it needs moderator verification though, should be here in a sec.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Dynamic Interactive 2d World Map 0 Answers

Change position in my scene based on a click on a 2d topdown map texture? 1 Answer

How to make a 2d hand drawn map?,What should I use to make a 2d drawn map? 0 Answers

2D Dynamic map generation 1 Answer

How to make endless 2D map in every direction 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges