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 Rosmarus · Jun 06, 2016 at 07:07 AM · javascriptcollisionraycasttransformobject

Move object to raycast point.

OK, so essentially, I have script that emits a raycast forward from the camera, and moves grabbed objects to the hit-point. However, this presents the problem of the objects colliding into walls and into the floor when i release them.

I've tried displacing the position the grabbed object's position based on their extents, which works for cubic objects oriented towards the camera, pointed at flat walls, but not for any other situation.

alt text alt text

As you can see, the picked up object is rendered on a layer above the standard camera layer.

My question is, how can i prevent the objects from being projected into positions where they would not fit, such as in corners, or through small gaps, or generally just walls and floors?

65944-64372-screenshot-2.jpg (45.7 kB)
65943-64371-screenshot-1.jpg (29.0 kB)
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
1

Answer by Brijs · Jun 09, 2016 at 02:05 PM

If i understood question correctly then cube shouldn't penetrate wall

So for that.......

Add rigidbody component to cube

Use rigidbody.Addforce()(In FixedUpdate() method) in direction(from gameObject to hit point) of hit point instead translating.

In rigidbody component set Collision Detection parameter to "Continuous" and Interpolate parameter to "Interpolate"

now cube will not penetrate wall corners, small gaps.

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 BrayanKrad03 · Jul 08, 2018 at 01:44 AM

Hi, this is an old post, but how you made that script? could you share it with me?

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 araz01 · Sep 27, 2018 at 05:19 PM

share the dam code alrdy... and if you wanna fix that, use vector3 lerp, so it happens overtime... come on... coding isnt about hiding, but showing... unless ur ea lol...

@Rosmarus

or what ever ur name is! Much Dove!

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycast object as far as possible? 1 Answer

Layered Collisions 1 Answer

Child instantiated object to RayCastHit's parent. 1 Answer

How To Detect MouseClick Using Raycast Java Script 0 Answers

Send Raycast to ground, place player at Raycast hit? 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