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
0
Question by BiffJenkins · Aug 14, 2017 at 02:28 AM · physicsvector3raycasthit

How do I find the closest point on a specific side of a bounding box?

I am trying to 'draw' an object between two points. This is working fine, but I would like the objects start/end positions to be the furthest right and left, respectively, of the objects that they are drawn between.

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
0

Answer by IvovdMarel · Aug 14, 2017 at 03:34 AM

You should look at

https://docs.unity3d.com/ScriptReference/Collider.ClosestPointOnBounds.html

or just

https://docs.unity3d.com/ScriptReference/Bounds.ClosestPoint.html

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
0

Answer by BiffJenkins · Aug 14, 2017 at 03:59 AM

Hi @IvovdMarel,

Thanks so much for your response. I was looking at this, but haven't been able to get it to work in my particular scenario.

I have a cube and I cast a ray hitting the front of it. I now need to know where the corresponding vector3 is it on the right side of the cube.

alt text


untitled-drawing.png (6.7 kB)
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 IvovdMarel · Aug 14, 2017 at 04:04 AM 0
Share

Hi BiffJenkins, so is this 'Desired Vector3' point always at the exact same position relative to the object? In that case you could create a child-transform or set a standard offset.

Or, is it relative to the position that was hit? And if so, how is it relative? Perhaps explaining your full intention would be easier.

avatar image BiffJenkins IvovdMarel · Aug 14, 2017 at 04:29 AM 0
Share

It is relative to the position that was hit. I am essentially trying to "draw" a bridge between two points by instantiating a GameObject. The player can click anywhere on valid game objects which I check with a Raycast hit and tag. A valid mouse click down instantiates the bridge object which scales towards their mouse while holding down click. When mouse click up on another valid game object, the bridge object is 'finalized'. If they let go of click on an object that isn't valid, the bridge they were 'drawing' is destroyed.

I am using 3d objects specifically for lighting, but it is a 2d game. I need the bridge to be as short as possible because I will be checking collisions for later gameplay.

http://imgur.com/P6uB69u

avatar image
0

Answer by Damiano96 · Jul 23, 2020 at 08:10 AM

Hello @BiffJenkins, im working on something similiar, did you ever find a way to solve your problem? Thankyou!

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

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

Related Questions

Raycasts in opposite directions only returning RaycastHits on right 1 Answer

Wall Running using Javascript 0 Answers

Rigidbody object intersection 0 Answers

Advice on keeping distance using AddForce 2 Answers

Using Lerp in a Constant Moving Object 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