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
-1
Question by awplays49 · Feb 22, 2015 at 04:31 PM · ignore collisions

Physics.ignorecollision is not working

Hi I have an issue with physics.ignorecollision. I want the player to not collide with the gun but I have to delete the rigidboyy when the player picks up the gun but it causes collision to register again upon rigidbody rebuild. So I put the ignore collision on update and now it's still not working...

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 awplays49 · Feb 22, 2015 at 06:50 PM 0
Share

Halp please ;(

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer Wiki

Answer by LaireonGames · Feb 22, 2015 at 08:24 PM

Does the player ever need to collider with the gun? I suspect not and if so then you can just edit the layers to ignore the collisions. To do that:

(On Windows go to the menu options at the top) Edit/Project Settings/Physics

Then you can see all the layers that can collide with each other. Make one for your gun, or a generic layer for the player to ignore, and make sure its checkbox is unchecked against the player and they will never collide.

As an FYI deleting and rebuilding a rigidbody will be pretty slow.

BTW if my method doesnt encompass what you need then I suggest making a layer for pickups, have your gun on that layer when it needs picked up then change its layer to one that the player ignores once it is picked up and it should work without you having to hack with deleting and creating rigidbodies

Comment
Add comment · Show 7 · 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 awplays49 · Feb 22, 2015 at 08:53 PM 1
Share

It does not ever have to collide no.

avatar image awplays49 · Feb 22, 2015 at 08:55 PM 0
Share

And what if I need my guns to be ignore ray cast? I can't assign them another layer...

avatar image awplays49 · Feb 22, 2015 at 09:45 PM 0
Share

@$$anonymous$$2 Games :)

avatar image LaireonGames · Feb 22, 2015 at 10:07 PM 0
Share

I'm not really sure what to say.. you haven't said anything I can reply to!

And what if I need my guns to be ignore ray cast? I can't assign them another layer...

You can switch the layer of your gun as needed, since as you say it can't be more than one layer at once but it also should never need to be.

I also don't see why it would have to be ignore raycast since what I explained above is a way of making any layer ignore collisions from any other layer.

If you are doing raycasting yourself again you can ignore your custom layer by telling the RayCast function which layers to check

avatar image awplays49 · Feb 22, 2015 at 11:20 PM 0
Share

But I'm using onmousedown so it's built in. What do I do so that the cursor ignores a user layer?

Show more comments
avatar image
0

Answer by Sungold · Aug 03, 2017 at 04:32 PM

Hate to revive such an old question; but I'm actually having this issue right now. When my character holsters his gun, it moves his whole body because there is a part of the animation where part of the collider of the gun moves outside his body.

The gun has a collider set to isTrigger (originally it was box collider, I tried mesh collider too)

I was using Physics.IgnoreCollision on my inventory script, I even tried putting it before and after the crouching function on my movement script because that changes the character height.

I tried putting the ground on a separate layer and turning off collision between the player layer and everything else but the ground layer.

Nothing works, it actually is extremely frustrating :(

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

22 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

Related Questions

Raycast 2D hits sprite with collider, but returns error when not hitting any collider 2 Answers

Layer Collision issue 1 Answer

How to use Physics.IgnoreCollision for multiple objects / toggling collisions for multiple, specific objects? 0 Answers

On Collision sound clip change 1 Answer

Make object stay on the Terrain, while the isTrigger is checked 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