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 Designosaurus · Feb 01, 2016 at 06:35 PM · syntaxphysics.raycastupdates

Physics.RaycastAll -- No more RaycastHit?

So I've been working in Unity for about a year now, and I just went back to do some raycasting the way I usually do, and then I see this:

alt text

I've never seen this QueryTriggerInteraction stuff before, and I no longer see a spot to put any kind of RaycastHit. I've tried this with Linecast, Raycast, and RaycastAll. It all does the same thing.

What's going on? Is Unity trying to get rid of (or has gotten rid of) RaycastHits? How do I do this guys?

unity-what-are-you-doing.png (8.8 kB)
Comment
Add comment · Show 1
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 Bunny83 · Feb 02, 2016 at 03:37 AM 0
Share

Just look at your own screenshot. As you can see at the front the Raycast method has 16 overloads and you're curently viewing the 9th. Just press up / down to cycle through them in the intellisense popup. Intellisense automatically picks the first overload that matches your given parameter count. You currently have 4 parameters (at least 3 commas which means you want to pass 4 parameters at the moment).

RaycastAll never had a parameter for a RaycastHit structure since the method returns an array of RaycastHit.

So in the end nothing has actually changed. They just added a few overloads that take an additional QueryTriggerInteraction enum value.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Teravisor · Feb 01, 2016 at 09:06 PM

Just use something like

 public static bool Raycast(Vector3 origin, Vector3 direction, out RaycastHit hitInfo, float maxDistance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);

or

 public static bool Raycast(Ray ray, out RaycastHit hitInfo, float maxDistance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);

In manual Physics.Raycast there are overloads that have out RaycastHit hitInfo like I've listed above, it's just they're not on top so you have to scroll page down. Your MonoDevelop/VS codehint should have them as well as those that don't have RaycastHit.

Example:

 Ray ray = new Ray();//Replace this with proper ray obviously
 RaycastHit hitInfo;
 if(Physics.Raycast(ray, out hitInfo))
 {
      //We hit something, so do something. What we hit is in hitInfo.
 }

Specifically in your case call is as Physics.Raycast(ray, out hitInfo, 100.0f, lm_GravityZoneMask);

Linecast has overload like that too: Physics.Linecast(start,end,out hitInfo);

I don't know what's problem with RaycastAll as manual states it still returns RaycastHit[] and my VS sais same.

QueryTriggerInteraction defines whether this raycast should hit isTrigger colliders or not. By default it uses global setting (Physics.queriesHitTriggers).

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Syntax for a game object component variable on a transform in an FBX hierarchy? 1 Answer

Developing for iOs (is there a certain syntax?) 1 Answer

Quick GetComponent syntax problem! 2 Answers

Problem syntax C# => JS 1 Answer

How Do I deActivate One Sphere ? 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