Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by Lukamyte · Nov 11, 2013 at 04:00 PM · raycastplane

Raycast not detecting planes

I have some randomly generated planes, but, I added a script to make them send a raycast upwards to see if there are any more planes above them. The planes are rotated at Vector3(90, 180, 0).

 function Start(){
     yield WaitForSeconds(1);
 
     if(Physics.Raycast(transform.position, Vector3.back, 2)){
         
     }else{
         Instantiate(so on...)
     }
 }

I can't find out what's wrong...

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

4 Replies

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

Answer by HuskyPanda213 · Nov 11, 2013 at 05:03 PM

Add a cube collider to the plane, this would work better than a mesh collider or whatever you are using.

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
5

Answer by Huacanacha · Nov 11, 2013 at 05:24 PM

Planes are single sided non-convex objects. You can only see them on one side (the side the normals are facing) and if you use the default Mesh Collider you can only collide with them on the visible side. To check a collision from 'behind' the plane you need to work around this. Here's a few ways you could do it:

  • Use a Box Collider with nominal height (0.01 or something depending on the scale of your scene) - this is probably the easiest solution

  • Use two planes, one facing in each direction

  • Model a two sided plane yourself and use this instead of the Unity primitive

Note that you may want to use a Quad instead of a Plane primitive for performance reasons. A Quad only has 2 triangles so will be better for rendering, and also physics performance if using a mesh collider.

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 DFledermaus · Nov 11, 2013 at 05:06 PM

Do they have colliders? And if so, are they mesh colliders? Unless they are double sided planes if they are facing away from the raycast it may go straight through them.

If the planes are box shaped you may want to give them box colliders instead, that could be faster than mesh colliders anyway.

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 DSivtsov · Dec 23, 2021 at 02:42 AM

As a Variant, because a Planes is a single sided, You can change Ray to opposite direction (sent not from start to start + direction, but sent from start + direction , to start)

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

20 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

Related Questions

Math - calculate position in world space from ray on infinite plane 2 Answers

how to check if 1 sided plane is facing the camera 1 Answer

Plane.Raycast layerMask? Using both Physics and Plane raycast 0 Answers

Raycasting plane mesh from the side 0 Answers

Raycast visual and moving text possition. 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