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
0
Question by MadCow · Nov 19, 2009 at 01:57 AM · collisionphysicscharacter

CharacterController:disable character-to-character collision

I was wondering if there was a way to disable character collision when using CharacterController.

I still want all other collision detection (terrain etc) but when colliding with other CharacterControllers, I'd like that collision ignored.

Any idea?

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 Loius · Oct 10, 2010 at 12:49 AM 6
Share

If using unity 3, you can put all CharacterController objects on their own layer and use Edit->Project Settings->Physics to have that layer ignore collisions with itself.

2 Replies

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

Answer by Sam Bauwens · Nov 19, 2009 at 07:23 AM

You can make a script that you attach to a single game object (for which there's just going to be one instance) and you put the following code in the Start function of the script :

void Start() {

         UnityEngine.Object[] characterControllers = GameObject.FindObjectsOfTypeAll(typeof(CharacterController));

         System.Collections.ArrayList existingCCColliders = new System.Collections.ArrayList();

         foreach (CharacterController charController in characterControllers)
         {
             Component[] colliders = charController.GetComponents(typeof(Collider));

             foreach (Collider collider in colliders)
             {
                 foreach (Collider existingCollider in existingCCColliders)
                 {
                     Physics.IgnoreCollision(collider, existingCollider);
                 }
             }
         }

}

Now there are probaly bugs in this code.It's just the logic, I haven't tested it. But the idea should work. and maybe you'll have to replace the arraylist by some other type of collection as I don't remember if arraylists are supported in Indie.

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 rpl oye · Oct 09, 2010 at 11:09 PM

function Start() { ignoreCollision("Player"); }

function ignoreCollision(tag: String) { var objects = GameObject.FindGameObjectsWithTag(tag); for (o in objects) { if (o.GetComponent("Collider") && o != gameObject) Physics.IgnoreCollision(collider, o.collider); } }

just editing the post above me.

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

1 Person is following this question.

avatar image

Related Questions

Voxel engine physics 3rd person character controller 1 Answer

How to stop first person player from walking through animated door 1 Answer

early collision above character controller 2 Answers

How can i make particles push back the player on collision? 1 Answer

gameobject destroyed on collision with character 3 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