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 s_guy · Apr 20, 2013 at 06:18 AM · 2dpixelsnapalignmentcoordinate

Can I get perfect 2d tile alignment using grid snap AND vertex snap on 1x1x1 unit cubes??

How do I get a nice approach to creating and aligning tiles? I presumably have a perfect 1x1 prefab, since that is what my mesh claims to be.

I'm looking for perfect tile origin coordinate offsets, e.g. (1.0, 1.0), (2.0, 1.0)? I would like to be able to use both grid snap and vertex snap interchangably, though I'll resign to one or the other if I must. The tiles are box colliders, so they can't have a gap that will cause problems with typical CharacterConroller and rigidbody solutions, though overlap may be permissible.

In my experiments, I always end up with an apparent drifting floating point precision error. So, a long row of grid snapped tiles diverge from vertex snapped tiles, which diverges from perfect coordinates. If I mix and match use of grid snap and vertex snap, I'll get blocks that don't align. Is there a way to keep blocks on the grid by using vertex snap?

Thanks!

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

2 Replies

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

Answer by s_guy · May 03, 2013 at 05:55 AM

So, I played with an editor script for object drag and drop that forced a grid snap posted here.

But, ultimately, I concluded that this was unnecessary for my purposes. I abandoned the vertex snap approach, which introduced an accumulating floating-point precision issue with my cubes. Instead, I'm using both Ctrl + axis drag on selections and Ctrl + plane drag (when I only want to restrict it two two axes). Now, all of my cubes stay on intended transform position multiples, but I can layout and manipulate fast with duplicate and drag.

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
avatar image
2

Answer by MountDoomTeam · Apr 20, 2013 at 06:40 AM

Hello, it is done with general maths, if you want each tile to be one unit, you make a loop on X and Y so that every tile is in between on position 0.5, 1.5, 2.5... that is perfect precision it is as easy as that.

     var size= 20;
     
     for (var z = 0; z < size ; z++)
 
     for (var x = 0; x < size ; x++)
     {
 
 instantiate(tile object, Vector3(x+.5,0,z+.5), Quaternion.identity);
 }
Comment
Add comment · Show 3 · 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 MountDoomTeam · Apr 20, 2013 at 06:41 AM 0
Share

if you are doing blocks/bricks walls using bouncing physics, you may find you need to space them by a tiny amount otherwise it will think they corners are in the same place and will bounce them.

avatar image s_guy · Apr 20, 2013 at 07:23 AM 0
Share

Thanks for the idea. I think this would work for programmatic tile placement.

$$anonymous$$y challenge is to have a pipeline in the Unity editor where I can use the grid snap (Ctrl + drag a translate axis) and vertex snap (V, select a vertex + drag to another vertex), and it still remains coordinate perfect.

$$anonymous$$uch of my content will be hand-edited. That's why I'm caught up on this tricky pipeline.

Thank you again for the good idea.

avatar image MountDoomTeam · Apr 20, 2013 at 07:47 AM 0
Share

you may find for the moment that clicking on the position of the tile and pressing 1.5 tab 1.5 tab 1.5 etc can be faster than using the cursor.

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

12 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

Related Questions

Clear, Crisp pixel textures for a 2D RPG 2 Answers

How to create 2D pixel water shader ? 0 Answers

2D Animation does not start 1 Answer

How to make shadows in Top Down 2D game 1 Answer

Is it possible to zoom in or out with the pixel perfect camera? 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