Jump to content
  • Advertisement
Sylon87

MiniMap With FOG

Recommended Posts

Hello!

i hope that somebody can help me to figure out "hot build a MiniMap"

actually i'm using Unity Engine and what i need to do is the following.

Get a Minimap by a Sprite and put it on the corner of the screen (here it's ok)

figure exactly where Player and NPC are in the map. (need help to understand how exactly translate from world position to the sprite one(minimap))

and how to create a fog for the undiscovered area, then remove it when will be uncovered (here i thought to make a grid on my and set every area with a bool, then read that data from a shader pixel to turn visible or not that area....)    <-- i wasn't able to find any tutorial about this online so i'm totally confused... any help?

 

thank's you in advance for any help

 

Share this post


Link to post
Share on other sites
Advertisement
3 hours ago, Sylon87 said:

figure exactly where Player and NPC are in the map. (need help to understand how exactly translate from world position to the sprite one(minimap))

If the world has definite bounds, and the minimap shows the entire world, this should be a (fairly) simple matter of mapping values from one range to another.

Presumably the main map scrolls, so you first need to figure out the position in absolute world space. Then you could, for example, do a little math to yield normalized world coordinates (that is, in the range [0 1]). Then you can use these normalized coordinates to compute a corresponding coordinate in the space of the minimap.

Quote

and how to create a fog for the undiscovered area, then remove it when will be uncovered (here i thought to make a grid on my and set every area with a bool, then read that data from a shader pixel to turn visible or not that area....)    <-- i wasn't able to find any tutorial about this online so i'm totally confused... any help?

I'd be surprised if there weren't some good resources available on this. I Googled 'unity fog of war' (it's even a suggested search) and got some hits. It looks like there are even some solutions available in the asset store.

There are probably shader-based solutions, but one possible solution that comes to mind is to maintain a dynamic grid mesh and change colors and/or texture coordinates to create the dynamic fog effect. A crude implementation that doesn't handle edges in a sophisticated way might be fairly straightforward to implement. For a more polished effect, you might want different images for different 'edge configurations', and then set the texture coordinates in the dynamic mesh as appropriate to show the correct edge images where needed. (This might require some thought due to the different ways edges can interact with each other, e.g. you'd need edge images, corner images, etc., and would need to select the right ones as appropriate and get them oriented correctly.)

Again though, it looks like there are some existing resources available on this, so I'd probably start there.

Share this post


Link to post
Share on other sites
5 hours ago, Sylon87 said:

i hope that somebody can help me to figure out "hot build a MiniMap"

actually i'm using Unity Engine and what i need to do is the following.

Get a Minimap by a Sprite and put it on the corner of the screen (here it's ok)

figure exactly where Player and NPC are in the map. (need help to understand how exactly translate from world position to the sprite one(minimap))

Is this a school class assignment?

Share this post


Link to post
Share on other sites
9 hours ago, Zakwayda said:

If the world has definite bounds, and the minimap shows the entire world, this should be a (fairly) simple matter of mapping values from one range to another.

Presumably the main map scrolls, so you first need to figure out the position in absolute world space. Then you could, for example, do a little math to yield normalized world coordinates (that is, in the range [0 1]). Then you can use these normalized coordinates to compute a corresponding coordinate in the space of the minimap.

I'd be surprised if there weren't some good resources available on this. I Googled 'unity fog of war' (it's even a suggested search) and got some hits. It looks like there are even some solutions available in the asset store.

There are probably shader-based solutions, but one possible solution that comes to mind is to maintain a dynamic grid mesh and change colors and/or texture coordinates to create the dynamic fog effect. A crude implementation that doesn't handle edges in a sophisticated way might be fairly straightforward to implement. For a more polished effect, you might want different images for different 'edge configurations', and then set the texture coordinates in the dynamic mesh as appropriate to show the correct edge images where needed. (This might require some thought due to the different ways edges can interact with each other, e.g. you'd need edge images, corner images, etc., and would need to select the right ones as appropriate and get them oriented correctly.)

Again though, it looks like there are some existing resources available on this, so I'd probably start there.

thank's you!! actually yes, i founded something about fog of war but is all about raycast and vertices alpha changing, what i'm looking for is a pixel alpha changing way.

7 hours ago, Tom Sloper said:

Is this a school class assignment?

no, it is for a my project :)

Share this post


Link to post
Share on other sites
13 hours ago, Zakwayda said:

If the world has definite bounds, and the minimap shows the entire world, this should be a (fairly) simple matter of mapping values from one range to another.

Presumably the main map scrolls, so you first need to figure out the position in absolute world space. Then you could, for example, do a little math to yield normalized world coordinates (that is, in the range [0 1]). Then you can use these normalized coordinates to compute a corresponding coordinate in the space of the minimap.

I'd be surprised if there weren't some good resources available on this. I Googled 'unity fog of war' (it's even a suggested search) and got some hits. It looks like there are even some solutions available in the asset store.

There are probably shader-based solutions, but one possible solution that comes to mind is to maintain a dynamic grid mesh and change colors and/or texture coordinates to create the dynamic fog effect. A crude implementation that doesn't handle edges in a sophisticated way might be fairly straightforward to implement. For a more polished effect, you might want different images for different 'edge configurations', and then set the texture coordinates in the dynamic mesh as appropriate to show the correct edge images where needed. (This might require some thought due to the different ways edges can interact with each other, e.g. you'd need edge images, corner images, etc., and would need to select the right ones as appropriate and get them oriented correctly.)

Again though, it looks like there are some existing resources available on this, so I'd probably start there.

well for Performance, i'll do it by have just a scrollable image with mask where it will with player movements, but i'm not good with math, and i can't find out any tutorial that should me help out this way..

everything that i found is by using render texture tool in unity

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!