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 Lucasr07 · Aug 13, 2020 at 01:34 AM · collider2dnormalsraycasthit2d

HOW TO ONLY DETECT ANGLES BY COLLIDERS2D FACES

Explaining my question: I have an object that has 6 raycasts to detect angulations, they all start from the edges of that object as illustrated in the image.

they return to me the angle of the surface that they are colliding for me to detect what is soil and what is wall.

But it can happen that the boxcollider of this object of mine enters the ground a little and then the raycast is completely inside the collider without passing through any surface, in this case it returns me 90 angle, and vector 2 (1.0, 0.0) of normal.

there is some form for me to say that when inside a collider this angle is zero, or else just detect angulations on the faces of collider2d.

I really appreciate if anyone has any suggestions, it will help me a lot! thanks in advance!

alt text

sem-titulo.png (17.2 kB)
Comment
Add comment · Show 7
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 Spip5 · Aug 13, 2020 at 01:41 AM 0
Share

Do you have a RigiBody attached to it ? Try setting the Collision Detection to Continuous first of all if it is not already. Also, when do you call the raycasts ? In the Update or FixedUpdate ?

avatar image Lucasr07 Spip5 · Aug 13, 2020 at 01:47 AM 0
Share

Yes, I have a rigidbody attached with continuous detection, I also did the raycast call tests by FixedUpdate, and by Update, I also tried to change the physics update in the settings to Update but it didn't seem to have any effect. I think I just need to find a way to filter this condition.

avatar image Spip5 · Aug 13, 2020 at 10:36 AM 0
Share

What about checking the angle from the upper raycasts ? I guess they all return the same angle anyway ?

avatar image Lucasr07 Spip5 · Aug 13, 2020 at 11:47 AM 0
Share

I’m checking all of them to detect collisions with walls, in case if the angle of any surface is greater than 60, that surface is recognized by the groundcheck as a wall and not soil, so I need verification on all raycasts, because if it happens to terrain is not high enough to reach the upper raycasts, so the lower ones detect it.

avatar image Spip5 Lucasr07 · Aug 13, 2020 at 11:40 PM 0
Share

OK I understand where you're going with that. Would't it be more accurate and error proof to use something like this ? Then you calculate the angle between each hit points of the raycasts, and you're sure you never have false positive alt text

raycasts.png (14.3 kB)
Show more comments

0 Replies

· Add your reply
  • Sort: 

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

135 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 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

How can i compare Text string from multiple child Text objects? 1 Answer

Is there a convenient way to check if two gameobjects are touching BUT NOT overlapping? 2 Answers

How can i shoot 2D ball/bounce of wall using Raycast? 1 Answer

Is there a way to only acces one collider when there are many colliders with the same tag? 1 Answer

Is my 2D Raycast set up correctly? because it does not seem to hit anything when i use a layer mask. 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