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
1
Question by JoeD86 · Oct 06, 2015 at 02:06 AM · collisionraycastfirst-person

How to make Raycast ignore object NOT on the Ignore Raycast layer?

I have a raycast that is cast from the camera attached to the player in a first person game I'm making that is used to interact with the environment. The problem I'm having, however, is that when you look down enough, the Raycast hits the player object. I am aware you can put the player on the Ignore raycast layer, however the thing is there are key mechanics that are completely dependent on raycasts hitting the player. So my question is, how do I tell this raycast to ignore the player? I am away of the Physics.IgnoreCollisions function but I can't seem to get it to work properly.

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

1 Reply

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

Answer by Bunny83 · Oct 06, 2015 at 02:22 AM

You can only ignore things that are on a specific layer. It doesn't have to be the IgnoreRaycast layer but it has to be "some" layer. You can only ignore the whole layer, not just one or some objects on that layer. You can ignore as many layers as you want.

Likewise you can raycast only against object that are on a specific layer. This is usually the more common approach. If for example you want to find enemies you could put all your enemies on a seperate enemy layer. When you do the raycast you can pass a layermask as parameter which specifies against which layers you want to raycast.

The easiest way to define a layer mask is to create a public variable of type LayerMask. That way you can choose which layers you want inside the inspector.

Comment
Add comment · Show 1 · 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 impurekind · Jan 10, 2019 at 07:07 PM 0
Share

I can't use a different layer because as soon as I put the object on another layer it just falls through the level (presumably because it's not on the same as the floors and stuff that makes up the level).

So how do I make the raycast ignore the actual object in such a case?

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

How to check if a raycasthit detects an angle less than 45 degrees and touches the ground 2 Answers

Subframe Collision Detection 0 Answers

making ray ignor certain collider 1 Answer

Obstacle avoidance 1 Answer

Destroy Turret with machine Gun 0 Answers


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