• 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
Question by u11303418 · Mar 23, 2021 at 02:48 PM · 2d gamemapvectorsmap-generationmap making

,Identifying direction of GameObject in Range

My Question is much more complex than the heading suggests.

I am very new to programming and unity but I learn quickly, I have a few gaps that is leading me to inefficient paths, and I feel very lost at the moment, please help!

I have a random map generator, that generates a 'genesis' map on each 8 sides (corners included) of the center map. To add complexity, the bottom center and left generates 'snowLands", the left center and top generates 'grassLands', top center and right generates "groundLands", and finally, right center and bottom generates "rockLands". Each different type of land is generated by it's associated 'type'-MapGenerater GameObject that has their choice of prefabs to generate the map to favor the type of land, and spawn appropriate trees and so forth, all connected to the same map generator script.

When a map type is generated, it creates an associated GameObject trigger type in the middle of the map, that has a child gameobject "MapOverlay" covering the map with a collider. Each Trigger located in the center of each map has the same LandTriggerScript

 public bool isLandOpen = false;

 public bool hasNorthLand = false;
 public bool hasEastLand = false;
 public bool hasSouthhLand = false;
 public bool hasWestLand = false;
 public bool hasNorthEastLand = false;
 public bool hasSoutEastLand = false;
 public bool hasSouthWestLand = false;
 public bool hasNorthWest = false;

My center map has 4 triggers, one for each side, and their Booleans are set accordingly.

This is where I need help...

When isLandOpen goes to true (when an adjacent land's trigger is triggered), The Overlay will be turned off and access will be granted to the map.

The newly open map must then also Check (in range) the surrounding area for adjacent maps to see if it has to generated a map on the sides that are "false" (based on probability of type) and turn those Booleans true

When the newly founded map's center trigger is triggered, it will open all adjacent lands (accept corners, and lands that have already been opened), and generate new locked land on the border of those open lands, where lands have not yet been generated.

What is the smart way to do this?

alt text

I believe I have everything covered, I just need the syntax;

 public class LandTriggerScript : MonoBehaviour
 {
 public bool isLandOpen = false;
 public bool hasNorthLand = false;
 public bool hasEastLand = false;
 public bool hasSouthhLand = false;
 public bool hasWestLand = false;
 public bool hasNorthEastLand = false;
 public bool hasSoutEastLand = false;
 public bool hasSouthWestLand = false;
 public bool hasNorthWest = false;

 public GameObject[] adjacentTriggers;    

 public void PrepareTriggers()
 {   
    Collider[] triggers = Physics.OverlapSphere(transform.position, 30);
    foreach (Collider col in triggers) 
    {
         if (col.gameObject.tag == "MapTrigger")
         {
             //add game object to the array of gameobjects named adjacentTriggers
         }
    }

    for(a = 0 ; a < adjacentTriggers.length; a++)
    {
        //if the gameobject's x axes is smaller than transform's x value, set the transform's hasWestLand boolean true,
             //as well as the opposite side for the target game object...and so on for all 8 sides.
         //check if adjacent land is open, open only if it is either north/east/south/west and set their isLandOpenValue to true.
             //create closed adjacent lands to the newly open land where there is no land on all 8 sides.

    }

 }

   

}

genesismaps.jpg (63.3 kB)
Comment

People who like this

0 Show 0
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

149 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 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 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 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 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 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 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 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

Easy way to build a 3d map based on real world? 2 Answers

Errors with the Google Maps SDK Demo 0 Answers

How do I make an interactive map on Unity? 0 Answers

Building Unity map best practises 0 Answers

Random Map generation like Temple run,Random Map generation like Temple Run. 0 Answers


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