Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by 4illeen · Feb 18, 2012 at 10:42 PM · 2dtilemaptiletiles

2D Tiles and sprites

I plan to create a 2D (2,5D) isometric game similar to old fallouts. I've got most of the code figured out, the only thing I don't know is how to visualize everything for the player. Levels/maps are supposed to be hex tiles, although rectangle/square tiles aren't bad either. As far as I know there are two ways to display content to the player - via game objects and GUI. I tried both ways and neither is sufficient for my needs.

Gameobjects: I made hex models in 3ds max and made my sript instantiate them for each field of my array

 using UnityEngine;
 using System.Collections;
 
 public class HexGrid : MonoBehaviour {
     private const int MAP_H = 50;
     private const int MAP_W = 50;
     public static int[,] map;
     
     private GameObject hex;
 
     
     void Start () {
         map = new int[MAP_H, MAP_W];
         hex = Resources.Load("Prefabs/hex") as GameObject;
         
         for(int i = 0; i < MAP_H; i++)
         {
             for(int j = 0; j < MAP_W; j++)
             {
                 Vector3 coords;
                 if(i % 2 == 0)    coords = new Vector3(j * 3, 0, (i / 2) * -1);    
                 else             coords = new Vector3(1.5f + j * 3, 0, 1 + (i / 2) * -1);
                 GameObject go = new GameObject();
                 go = Instantiate(hex, coords, hex.transform.rotation) as GameObject;
                 go.name = i.ToString() + " " + j.ToString();
             }
         }
     }
 }

I also have a camera control script which allows me to move it around to see all the map. Sadly this is merely 50x50 field map and it already loads very long and I'm going to need something bigger, not to mention everything that's going to appear over the map (houses etc).

GUI: I tried the same thing using GUI.Buttons, sadly I can only have square buttons, can't rotate them.

What I need is an alternative way to display tiles, and way to check if mouse is over them (and I mean exactly over the pixels, not the empty area of the rectangle). Alternatively I need an advice on how to handle this problem

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sammual12 · Feb 23, 2012 at 05:46 PM

A large number of 3D Hex tiles is slow. (At least the ways I have tried it) If your hex tile can be flat you are better off creating a procedural (hexagon) mesh and using texture atlas with all your Hex Tertures in it.

http://answers.unity3d.com/questions/25067/setting-custom-uv-mapping.html

Other options are;

Tasarran's HexTech - http://forum.unity3d.com/threads/102511-HexTech-Hexagon-Tile-Based-Map-Framework-available-on-Asset-Store

ForceX's FX Hex Grid - http://forum.unity3d.com/threads/107656-FX-Hex-Grid-(Hex-Grid-Generator)

Comment
Add comment · 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

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

6 People are following this question.

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

Related Questions

Need tiles to contain data or a reference 0 Answers

Streaming in 2D tiled maps for seamless world, does this conflict with Unity's editor? Do I need to use an external editor? 1 Answer

Object Squeezing Between Tiles 0 Answers

Tilemap color will only change to white, black, cyan, yellow or magenta. 0 Answers

Remove a single tile from a tilemap 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