Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by grayfox · Jun 20, 2011 at 02:48 PM · 2dgridcoordinatesorthographic

2D coordinate grid over a 3D scene?

Fairly new to Unity, having a hard time figuring this out. I have a 3D scene where users can drag objects from a menu onto that scene. I'd like to implement a grid (either invisible or visible) where these objects would stick on to, but I'm not sure how I would go about adding a 2D grid to a 3D scene.

I was thinking about using a separate orthographic camera but only making this gird "layer" visible to it, but I'm not sure how to best tackle this. I've only been working with Unity for about two weeks so I'm still in noob territory.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by e-bonneville · Jun 20, 2011 at 03:17 PM

Just constantly round the coordinates of the objects you're dragging. That'll snap them to a 1x1x1 grid. If you'd like to overlay a visible grid on the screen you can either use a GUI texture or a separate orthographic camera.

Comment
Add comment · Show 1 · 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 grayfox · Jun 21, 2011 at 02:25 PM 0
Share

Thanks, but how I actually move an object with 2D coordinates in a 3D scene?

Ok, so I have this 3D backdrop with a perspective camera, but I want the user to be able to click and drag an object in a 2D space (x and y, no z). When the user is done setting that object's position, I'll then get the 3D coordinates using ScreenToWorldPoint, but it's the first part I'm stuck at.

avatar image
1

Answer by GTaveira · Jun 20, 2011 at 07:57 PM

My first thought was to create a plane collider and place it wherever you want it to be. Then, you could cast a ray from you mouse screen position and get the point where the ray hit the collider. You would assign your object Y-axis based on that point. That way you could freely move in 2D and your object would be snapped to the grid.

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
1

Answer by dentedpixel · Feb 13, 2012 at 12:40 PM

To find the 2d coordinates of an object on the current camera you can use this function Camera.WorldToScreenPoint

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Arrange objects in a box formation? 1 Answer

How to make 2d distortion? 2 Answers

Get position from Isometric TileMap 1 Answer

parallax scrolling using orthographic camera 1 Answer

play sound while at certain coordinates of map (javascript) 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