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 Hr Mller · Apr 02, 2011 at 05:15 PM · boundsdrag-and-drop

Object within bounds of another object

How do I check if an object is within bounds of another object?

I am doing a 2D game and doing some drag'n drop and have check if the object getting dragged is within the bounds of another object. If false the dragged object have to be destroyed.

There might be an easier way than using bounds and since I'm new to Unity I'm open for every kind of solution. I do prefer UnityScript though.

Thanks in advance:)

Comment
Add comment · Show 5
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 Jesse Anders · Apr 02, 2011 at 05:19 PM 0
Share

What are the shapes of the objects involved? Are they convex? Non-convex? (Etc.)

avatar image Hr Mller · Apr 02, 2011 at 05:36 PM 0
Share

Not convex. Simply just a plane above another plane.

avatar image Hr Mller · Apr 02, 2011 at 05:48 PM 0
Share

...and completely square. I'm co$$anonymous$$g form flash where I simply would check my rectangles or coordinates.

avatar image Jesse Anders · Apr 02, 2011 at 08:59 PM 0
Share

Squares are convex :) Anyway, if you're using the built-in physics system, you might be able to use colliders, as harmless suggested. Otherwise, you could just perform the test manually (containment tests involving rectangles and other convex polygons are pretty straightforward).

avatar image Hr Mller · Apr 02, 2011 at 09:50 PM 0
Share

Well alright - maybe I should do some reading in geometry:) Thanks for your inputs. As you can see in my below comment I've got it working but now have some other problems.

2 Replies

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

Answer by loopyllama · Apr 02, 2011 at 05:53 PM

use built-in mesh colliders like a box collider and set isKinematic to true then do an OnCollisionEnter as referenced in the docs

http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html?from=Collision

you could also roll your own system but perhaps the above is easier...

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 Hr Mller · Apr 02, 2011 at 09:53 PM 0
Share

Thanks it worked but another problem occurred: When I duplicate my GameObject that hace the collider and Rigidbody attached the collision detection disappears from the cloned object.

avatar image loopyllama · Apr 03, 2011 at 07:53 AM -1
Share

simply post a new question:) this system wasn't intended for an evolving discussion. that is what the forums are for!

avatar image Hr Mller · Apr 05, 2011 at 02:41 PM 0
Share

Right:) I might post another question but I think I've found a better solution

avatar image
0

Answer by heaversm · Jul 11, 2011 at 04:00 PM

Hey - HR - I'd love to know how you did this. I come from Flash too and I don't really get the collider thing. Did you find a way to do it with bounds? Would much rather do it that way.

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

1 Person is following this question.

avatar image

Related Questions

How to Place and arrange 3D cards using Grid and Bounds 0 Answers

CalculateFrustunPlanes / TestPlanesAABB returns unexpected results 0 Answers

How can i make sound when the gameobject exit the camera? 1 Answer

LodGroup manually set Bounds 0 Answers

SpriteRenderer Bounds is Returning the Wrong Extents (Sometimes) 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