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 FusionSausage · Oct 22, 2013 at 03:07 PM · terraingriddrawsquare

Create squares and draw them on terrain

Some of you've might played Clash of Clans or Simpsons tapped out? I'm not trying to make a game like them, but they have one feature I like. They're grid system. I'm familiar with the math around squares and grids, a * a = b(square). So that's no problem for me. My real problem is how I would transfer this into unity. Say I'd like the squares to be 3 units times 3 units, which makes 9 units in area. How do I create this in Unity and loop it over the terrain? This would be good to know, because I need to create a grid system for my game, but as I said, the game is not going to be as any of those examples, it's just an idea how the grid would be. Any examples, tutorials or just logic is appreciated, I just want to get moving with this. Also, I prefer code.

Thanks!

Comment
Add comment · Show 6
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 VesuvianPrime · Oct 22, 2013 at 03:40 PM 0
Share

How complicated is your terrain? If it's flat, then you could start experimenting by writing a 2d loop that creates a bunch of tiled planes.

avatar image AlucardJay · Oct 22, 2013 at 05:06 PM 1
Share

Screenshots, images or links are helpful to describe what you are attempting.

It all depends on if you want a cursor that moves around the terrain while snapping its position to a grid, or if you want to texture the whole terrain as a grid.

Basic snapping formula : http://answers.unity3d.com/questions/325293/script-place-blockprefab-align-to-grid-like-$$anonymous$$ecr.html

This link is more advanced, and only some parts may be relevant. Try video 5 : http://www.youtube.com/playlist?list=PLbghT7$$anonymous$$mckI4qGA0Wm_TZS8LVrqS47I9R

Even more advanced would be editing the splatmap of the terrain to texture it as a grid.

avatar image FusionSausage · Oct 23, 2013 at 06:56 AM 0
Share

Hi, and thank you for your answers. $$anonymous$$y terrain is flat, but I'd rather use code to be honest. I made an image as suggested by @alucardj

Grid system

Basically, the grid will be used to instantiate objects and will also be used for combat and AI systems. As I said, I prefer code guidance :)

grid.png (67.1 kB)
avatar image AlucardJay · Oct 23, 2013 at 03:12 PM 2
Share

This tutorial may be useful, specifically the video on placement (3b) : http://cgcookie.com/unity/cgc-courses/unity-tower-defense-course/

avatar image FusionSausage · Oct 23, 2013 at 03:35 PM 0
Share

Looks awesome! Thank you :)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by flaviusxvii · Oct 22, 2013 at 04:57 PM

Make a camera. Position it at -10, -10, -10. Have it look at 0, 0, 0.

Now make some Planes. Texture them with grass and stuff. Duplicate and place as many as you need for your game map.

Now make a script called TerrainTile, or something like that. Give it an OnMouseDown() function. Now you can handle mouse clicks and stuff. Put that script on all of your planes.

Good start?

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 FusionSausage · Oct 23, 2013 at 06:58 AM 0
Share

That's a good start, but I'd prefer code. But thanks anyways, but this is totally a solution if I don't make it with code :)

avatar image flaviusxvii · Oct 23, 2013 at 03:00 PM 0
Share

Not that different in code. $$anonymous$$ake a tile prefab. Use Instantiate to make a bunch of them in a loop.

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 would I replicate Gizmos.DrawLine in-game? 1 Answer

Terrain Brush Problem 2 Answers

How to draw an outline over a shape composed of many squares in a square grid? 1 Answer

Transparent grid shows odd irregularities when displayed. 1 Answer

Creating a terrain of tiles from an dimensional array 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