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 adriandevera · Jul 01, 2015 at 03:48 PM · colliderthroughpassunits

Allow Units with Colliders to Go Through Each Other

Im trying to allow units not collide with one another with the tag "unit". Plain and simple, so far i have this but its not working:

 charcontroller = GetComponent<CharacterController> ();
 
 //if collides with another unit such as itself
 //pass through
 void OnCollissionEnter(Collision col){
     if (col.transform.tag == "unit") {
         Physics.IgnoreCollision (charcontroller, col);
     }
 }

Comment
Add comment · Show 3
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 meat5000 ♦ · Jul 01, 2015 at 05:23 PM 0
Share

http://answers.unity3d.com/questions/997193/how-to-stop-my-sword-from-hitting-myself.html

avatar image adriandevera · Jul 01, 2015 at 08:01 PM 0
Share

That doesnt work for an event of two character controllers

avatar image meat5000 ♦ · Jul 01, 2015 at 08:18 PM 0
Share

Dont you have a hard time making two character controllers colliding in the first place?

Especially without using this

http://docs.unity3d.com/ScriptReference/CharacterController.OnControllerColliderHit.html

Oh yes, the other answer on that page was deleted. It was about the Collision $$anonymous$$atrix.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by maccabbe · Jul 01, 2015 at 05:07 PM

An easy alternative would be to make the units on the same layer and disable collisions between objects in that layer

http://docs.unity3d.com/Manual/class-PhysicsManager.html

http://docs.unity3d.com/Manual/class-Physics2DManager.html

http://docs.unity3d.com/ScriptReference/Physics.IgnoreLayerCollision.html

http://docs.unity3d.com/ScriptReference/Physics2D.IgnoreLayerCollision.html

If you want to use Physics.IgnoreCollision (or Physics.IgnoreLayerCollision) then you should use it before a collision happens. Once OnCollisionEnter is called after a collision is computed and it uses this data. If you want to turn off collisions after the initial one you should make sure you objects are setup correctly so OnCollisionEnter is called.

http://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html

http://docs.unity3d.com/ScriptReference/Physics2D.IgnoreCollision.html

Comment
Add comment · Show 2 · 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 tanoshimi · Jul 01, 2015 at 05:17 PM 0
Share

Also, OnCollisionEnter, not OnCollissionEnter ;)

avatar image adriandevera · Jul 01, 2015 at 08:14 PM 0
Share

oh right! and since im using a character controller that means I use OnControllerColliderHit? http://docs.unity3d.com/ScriptReference/CharacterController.OnControllerColliderHit.html

As for layers, I have never used them. Is there a recommended tutorial?

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

My Character Controller passes through walls of my imported assets from Google Sketchup,how do I resolve it? 2 Answers

sphere gets into cube 1 Answer

Adding a spring or joint makes object fall through object 0 Answers

Some objects falls through Plane with mesh collider(grenade) 2 Answers

ball sometimes goes through the bat when hit... collider problem... How to do a Raycast? 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