• 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 seandolan · May 15, 2018 at 05:12 PM · 3dtilesfloor

What is the correct way to create individual floor tiles in a 3d game?

I am creating a game that allows players to draw individual rooms on a 100x100 grid. The grid is visible when they draw their rooms as well as during the game play. The rooms can be irregular shapes but each 1x1 grid tile can not be divided. 1 tile, 1 space and any number of tiles to make up the room.

Example of the game view

I am running a function afterwards to automatically place walls between different rooms. I am currently running through the following command to draw each cube. The result is 10,000 cubes though. If I $$anonymous$$de the entire set of cubes my fps is over 70. If I make them visible it's more like 40 odd.

 for(int i = 0; i < floorTiles.Count; i++) {
             GameObject newTile = Instantiate(blankTile,new Vector3(floorTiles[i].x,0,floorTiles[i].y),transform.rotation,floor.transform);
         }

The Instantiate part isn't running slow at all - it's quite quick. But the visual rendering of so many cubes seems to weigh Unity down too much. I am sure that I am just missing the concept somewhere of how to make t$$anonymous$$s work and my best efforts of trying to find the answer online lead me more towards 2d projects.

So my question is what is the correct way to create individual floor tiles in a 3d game.

floortiles.jpg (373.8 kB)
Comment
Add comment · Show 1
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 seandolan · May 15, 2018 at 05:57 PM 0
Share

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Captain_Pineapple · May 16, 2018 at 08:31 AM

Well first up you could use the builtin Unity Profiler to determin what actually takes up all the processing time. Sometimes the results can be surprising.

Secondly to solve your problem you might want to t$$anonymous$$nk of somet$$anonymous$$ng like the following:

Change your 10000 floor Objects into one large Object with one Collider and a texture that simulates a grid. When you do a raycastings (w$$anonymous$$ch i assume you do) to determine the targeted tile you can simply calculate the rounded position of the $$anonymous$$t-point of your raycast. There you can either:

  1. Use a Projector to project a given tile grap$$anonymous$$c/texture on the current position.

  2. Or Instantiate a quad like mentioned by @seandolan with the tile-texture applied.

I hope t$$anonymous$$s helps, if you have more questions regarding t$$anonymous$$s feel free to ask.

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.

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

96 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

Related Questions

sliding rows of tiles in 3D 0 Answers

Unity 5 Sphere Rigidbody getting weird behaviour while moving around in a tiled mesh collider scene 1 Answer

3d game problem with tail 1 Answer

Rotation roadblock 0 Answers

How do I project coloured tiles onto a surface? (C#) 2 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