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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by ciroby · Jun 21, 2012 at 02:26 PM · dragsnapdropedges

Drag and Drop and snap between the edges!

Hi

i'm new in unity i follow your forum often but now i have a question for you. I looked in the forum and there isn't a reply to my question. If there is one, please can you post me the link.

So the question is: i have two cubes and i need to drag and drop one of the cubes on the other cube and when the cube is really near i need to snap it to the other like a magnet but not in the center they need to match the edge of the face!

let me know if all is clear

Thanks,

Roberto

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 tomekkie2 · Jun 21, 2012 at 02:43 PM 0
Share

You can set the six possible positions of the dragged cube corresponding to the planes of the static cube. So if it is a unitary cube, these positions would be unitary vectors drawn from its centre in six directions. Then set the "snap range "and then check the transform position of the dragged cube if within the range, if yes then set its position and stop dragging.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ciroby · Jun 21, 2012 at 02:51 PM

can you post me an example...or something.

And if the other cube is not static so what i mean is i can drag&drop and snap both cubes. How i can check the coordinates?

Thanks,

Roberto

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 tomekkie2 · Jun 21, 2012 at 02:56 PM 0
Share

Static - I mean you can drag one cube at a time with mouse. So I named the other one as static. And the question is how do you intend to drag it? I mean If you want to drag it in 3d space you need a gizmo, if you drag it on a plane you just pick, cast the mouse position to the plane, and drag.

You can modify and use the drawRigidBody.js script from the Shadow Demo example project.

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

Coding Advice Needed: Building a 2D ship editor 1 Answer

When is the OnDrop method called? IDragHandler 1 Answer

Drag n Drop in a 3D orthographic environment 1 Answer

[NGUI] - Drag and drop 2 Answers

Grab and throw object immediately 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