Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 CommitteeWind · Nov 18, 2013 at 05:53 AM · isometric

How do I properly draw complex 2D isometric tiles?

How do I properly draw complex 2D isometric tiles? I am having trouble with my current attempt which can draw flat isometric tiles perfectly, but renders weirdness when those tiles are given a 3D-ish look to them.

The code I am using to do the drawing is:

 using UnityEngine;
 
 public class TileMap : MonoBehaviour
 {
     [SerializeField]
     private GameObject m_tile;
     [SerializeField]
     private int m_width = 10;
     [SerializeField]
     private int m_height = 10;
 
     private float m_tileWidthPx = 128;
     private float m_tileHeightPx { get { return m_tileWidthPx * 0.5f; } }
     private float m_unitsPerPixel = 100;
     
     private float m_unitsOffsetX { get { return (m_tileWidthPx / m_unitsPerPixel); } }
     private float m_unitsOffsetY { get { return m_unitsOffsetX * 0.5f; } }
 
     void Start()
     {
         for (int i = 0; i < m_width; i++)
         {
             for (int j = m_height - 1; j >= 0; j--)
             {
                 var tile = Instantiate(
                     m_tile,
                     new Vector3(
                         (j * m_unitsOffsetX / 2) + (i * m_unitsOffsetX / 2),
                         (i * m_unitsOffsetY / 2) - (j * m_unitsOffsetY / 2),
                         0),
                         Quaternion.identity);
 
                 tile.name = string.Format("({0}, {1})", Mathf.Abs(i), Mathf.Abs(j));
             }
         }
     }
 }

I am getting these results:

alt text

The red lines are used to indicate the problem areas.

isometric-art-problem.png (343.8 kB)
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
1
Best Answer

Answer by s_guy · Nov 18, 2013 at 07:54 AM

You need a camera set to orthographic projection mode. This will remove all foreshortening and all grid lines on the same plane will be parallel or meet at the same one angle in the viewport space and screen space. Play with the orientation of that camera to get the exact angle you want.

Comment
Add comment · Show 2 · 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
avatar image CommitteeWind · Nov 18, 2013 at 02:15 PM 0
Share

I am already doing this, which can be seen on my rendering on the right. I don' think it is a rendering issue (camera related) as much as it is a algorithm/math issue.

avatar image s_guy · Nov 18, 2013 at 08:38 PM 0
Share

Ah. I didn't realize that the flat tiles example was in engine.

To help visualize the problem, I'd use a flat texture with a pattern on it and zoom way in. That way, you can see if your tiles are lining up and debug the instantiation positions more easily. For example, I can't tell if the black outline from your flat white tiles are being shown all the way around or if we're just seeing the northwest and southwest edge of each tile. Also, try drawing a red outline on the edges of the 3d texture so the optical illusions aren't confusing the situation. (If not for you, for people trying to help out.)

If you don't want the apparent stairstep effect, you'll need to offset each tile by the visual top of the 3d texture, rather than by the actual tile width and length. Then, to get the vertical edges to only draw where they're supposed to, you can either:

  • sort the draw order top to bottom and right to left OR

  • adjust your UVs to draw only the tile tops except for the edge tiles which have either a trim tile added or larger tiles on the southwest and southeast sides to account for the edge

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

17 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

Related Questions

How do I create a customizable isometric grid system? 0 Answers

How to do isometric camera 1 Answer

How Can I Make My Baked Lights Look Exactly like Still Dynamic Lights? 1 Answer

Isometric Prespective camera drag/drop 0 Answers

GameObject rendering behind the top half of my isometric map 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