Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by fr0nt1er · May 28, 2016 at 01:15 PM · 2dmapconnecting

How to connect a set number of nodes on a map into a grid?

Hello!

I'm trying to learn using Unity and C#.

In my 2 player game the map is visually represented with a sprite on which in a pre-determined set of coordinates script spawns "Node" objects. I have successfully managed to implement node creation, drawing their graphics, stashing them neatly in the hierarchy and a few other things.

Each node knows its number, its coordinates, its Allegiance (player, opponent, none or contested basically), its Region and the amount of influence of each player.

Even though in the world they are spread apart coordinates-wise on various distances, I would like these nodes to be connected in a "grid", and influence "flows" along the "tubes" connecting the grid. Really it would probably suffice if my nodes knew which nodes are adjacent to them, but it would also be great if I could adjust the "thickness" of these tubes based on variables (distance to node, its region, blah blah...) of the "adjacent" nodes.

There are not very many nodes at the moment (~100), however it would be nice of course if I could include more nodes in the future without too too much trouble.

I could probably go about it the long and hard way (I have the map of nodes, so I can make list of connections for each node by number, for example, node 1 is adjacent to nodes 43, 7 and 14 etc., manually then import it into Unity using JSON ...), but I was wondering if more experienced community members have some advice for me?

Comment
Add comment · Show 3
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 Mmmpies · May 29, 2016 at 06:50 AM 0
Share

That's a pretty complex list of needs. I can't really answer as the script would take quite a chunk of my time to put together however this is the approach I'd take...

Tag each Node (e.g. create a Node tag and make sure they're all tagged as Node).

Then look up findgameobjectswithtag.

You'll need to do a foreach loop on that list of objects and get the distance of each one.

Record however many you want as being close enough to have a linking line, Record the gameobject for each one you want to draw a line from and to and then use line renderer to draw the line.

That's the rest of your weekend gone :D

avatar image fr0nt1er Mmmpies · May 29, 2016 at 01:38 PM 0
Share

Sweet, thanks for your input! I think implementing this will take more than one weekend ;)

avatar image Mmmpies fr0nt1er · May 29, 2016 at 02:08 PM 0
Share

Actually I linked to the singular version of find game objects with tag.

[THIS][1] is the right link - and good luck

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.

Follow this Question

Answers Answers and Comments

84 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

Related Questions

Help with dynamic loading or occlusion culling in scenes on 2D metroidvania? 1 Answer

A good 2D tile map editor that works with Unity? 1 Answer

[SOLVED] Converting a Generic List to JSON in Unity 3 Answers

Movement and zoom of camera on the map 0 Answers

How to create own 2d map with roads and moving cars. 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