• 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 Obsdark · Jan 21, 2018 at 06:25 PM · meshrenderingproceduralworldfloor

how to make an horizontal mesh? c#

I'm working in a world than generate some tiles, this tiles have over themselfs some mesh to be rendered, right now i don't have any trouble rendering the grid VERTICALLY

is there any way to render the tiles horizontaly without the need to actualy rotate the world?

Here is the mesh renderer code:

   private bool InstanceTileMesh()
     {
         try
         {
             //Create 4 Vertices
             Vector3[] vert = new Vector3[4];
             //2D
             vert[0] = new Vector3(-1, 1, 0);//0
             vert[1] = new Vector3(1, 1, 0);//1
             vert[2] = new Vector3(1, -1, 0);//2
             vert[3] = new Vector3(-1, -1, 0);//3
 
             //3D
             //vert[0] = new Vector3(-1, 1, -1);//0
             //vert[1] = new Vector3(1, 1, -1);//1
             //vert[2] = new Vector3(-1, 1, 1);//2
             //vert[3] = new Vector3(1, 1, 1);//3
 
             //Create the triangles using the vertices
             int[] tris = new int[6];
             tris[0] = 0;
             tris[1] = 1;
             tris[2] = 2;
             tris[3] = 0;
             tris[4] = 2;
             tris[5] = 3;
 
             //int[] tris = new int[]
             //{
             //    0,1,2,
             //    2,3,0
             //    //0,2,3,
             //    //3,1,0
                 
             //};
 
             //Create a new mesh and pass down the vertices and triangles
             Mesh mesh = new Mesh();
             mesh.vertices = vert;
             mesh.triangles = tris;
 
             mesh.RecalculateNormals();
 
 
             //<--------------------------------------------->
             //Make sure than can interact with MouseController
             if (!this.tile_GO.GetComponent<BoxCollider>())
                 this.tile_GO.AddComponent<BoxCollider>();
 
             this.tile_GO.GetComponent<BoxCollider>().size = new Vector3(this.tile_GO.GetComponent<BoxCollider>().size.x * 2, this.tile_GO.GetComponent<BoxCollider>().size.y * 2, this.tile_GO.GetComponent<BoxCollider>().size.z / 90);
             //<--------------------------------------------->
 
             //Make sure mesh filter and mesh renderer componenets are attached
             if (!this.tile_GO.GetComponent<MeshRenderer>())
                 this.tile_GO.AddComponent<MeshRenderer>();
 
             if (!this.tile_GO.GetComponent<MeshFilter>())
                 this.tile_GO.AddComponent<MeshFilter>();
 
             /*if (!this.tile_GO.GetComponent<Tile>())
                 this.tile_GO.AddComponent<Tile>();*/
 
             this.tile_GO.GetComponent<Tile>().Instance = this.ToJson();
 
             //Pass down the mesh data to mesh filter
             this.tile_GO.GetComponent<MeshFilter>().mesh = mesh;
             //Send material data to mesh renderer
             this.tile_GO.GetComponent<MeshRenderer>().material = WorldController.Instance.MaterialForTiles;
 
             this.ChangeColor(this.colourName);
             //Debug.Log("Tile Renderer Bounds: "+this.tile_GO.GetComponent<MeshRenderer>().bounds.size);
             return true;
         }
         catch (Exception ex)
         {
             Debug.Log("InstanceTileMesh() Error: " + ex.ToString());
             return false;
         }
     }



image as of right now image as of right now

Have in consideration than, if i uncomment the 3D vertices and comment the 2D ones, the white thingy is not gonna render anymore and they are not gonna change the form or order of themselfs.


Before you ask, yes, i'm aware i can rotate the world, but i don't want to do it.

And yes, i'm aware than that is gonna request the world to generate horizontaly instead of vertically

Also yes, i also try to change "Y" for "Z" values to no avail, that's why this question is here

If you have any comment, request for clarification, or some other constructive comment to improve this question, please, feel free to do a coment about it and i see if it can be implemented


Thanks a lot

actualcode.png (161.6 kB)
Comment

People who like this

0 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 Cherno · Jan 21, 2018 at 06:47 PM 1
Share
 3D
             vert[0] = new Vector3(-1, 1, -1);//0
              vert[1] = new Vector3(-1, 1, 1);//1
              vert[2] = new Vector3(1, 1, 1);//2
              vert[3] = new Vector3(1, 1, -1);//3
avatar image UnityVeris · Jan 22, 2018 at 03:01 AM 0
Share

What do you mean by "to no avail"? What happens when you change them?

avatar image Bunny83 UnityVeris · Jan 22, 2018 at 05:22 AM 0
Share

This is not an answer. I've converted it into a comment. Cherno's comment actually would almost count as answer ^^.

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

92 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

Related Questions

Shadow artifects on mesh with Standard shader 1 Answer

Seam on Procedural Mesh 1 Answer

Generating unique vertices for a procedural mesh 2 Answers

How to create a grid with four 4 triangle squares? 1 Answer

Model looks ok on PC, horrid on Android, why??? 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