Hi guys,
I was wondering what I should do to make a map which shows an X spot (of a pirate chest for example) and if a player goes there and dig, something comes out of the ground.
What I mean is I know how to make a map with program like Photoshop, but I’m missing two things:
-
how to generate random X everytime a player gets a new map
-
how to match that X shown on the map to the terrain of the level
Thanks for your help
The same stuff that lets you show items on a minimap will let you correlate a map “X” with a real-in-game X, so check out some minimap tutorials to get an idea of what’s involved.
It’s pretty straightforward, basically a linear transformation from the 2D coordinates of your minimap to the world. To simplify setup, you can put invisible GameObjects in the world that constitute the extent limits of your hand map, but definitely start from tutorials because there’s many ways to approach the problem.
As for generating a random spot, usually you pick a range of acceptable values and use Random.Range() to pick X and Y (or X and Z) coordinates in that range.
If your ground has elevation (altitude) then you could raycast to the ground to find out how high that spot is, like if it’s on a mountain or in a ditch.
You can also pre-generate a bunch of possible “interesting” spots and put them in your level as invisible GameObjects, then randomly pick one each game to put your treasure on. This lets you make the game always select “interesting” spots for the treasure, rather than just completely random spots.
1 Like
Awesome answer man, thanks a lot!
Know I really know what I have to study, thanks!! 
Marked this thread as resolved and thumbs up from me!
1 Like