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 CarbonNanoRob · Aug 20, 2015 at 12:19 PM · c#collisioncharactercontrollerignore

Collider not continuing to Ignore CharacterController after center changes.

So basically I have an Item(GameObject with rigidbody and boxcollider) which ignores collisions with my CharacterController, currently it works as intended, however if my CharacterControllers' center changes during runtime,(which it does when I crouch) the Item no longer ignores collisions with the Controller. I would like the collision to be ignored all the time. Maybe I'm just having a brain fart day, so I'm hoping one of you wonderful members of the Unity Community could help me, or point me in the right direction.

Here is the Crouch part of my CharacterMotor.

 if(crouching.enabled)
         {
             mainCamera.transform.localPosition = crouching.cameraPos;
             if(inputCrouch == true)
             {
                 crouching.holdingCrouchButton = true;
                 if(crouching.holdingCrouchButton)
                 {
                     controller.height = Mathf.Lerp(controller.height,crouching.crouchHeight,crouching.crouchSpeed);
                     controller.center = Vector3.Lerp(controller.center,crouching.crouchCenter,crouching.crouchSpeed);
                     jumping.enabled = false;
                     crouching.cameraPos.y = Mathf.Lerp(crouching.cameraPos.y,crouching.cameraHeight-1,crouching.crouchSpeed);
                     sprinting.sprinting = false;
                     crouching.crouching = true;
                 }
             }
             else
             {
                 if(controller.center != defaultControllerCenter)
                 {
                     controller.center = defaultControllerCenter;
                 }
                 if(controller.height != defaultControllerHeight)
                 {
                     controller.height = defaultControllerHeight;
                 }
                 jumping.enabled = true;
                 crouching.crouching = false;
                 crouching.cameraPos.y = Mathf.Lerp(crouching.cameraPos.y,crouching.cameraHeight,crouching.crouchSpeed);
             }
         }

And here Is the part of my Item Script which Ignores the controller.

 void Start()
     {
         if(Player != null)
         {
             Debug.Log("PlayerFound");
         }
         Physics.IgnoreCollision(Player.GetComponent<CharacterController>(),collider);
     }

I am avoiding Using IgnoreCollisionLayer, because of future reasons. And I have tried to ignore the collision during an Update function, however it doesn't continue to ignore while the controller is crouched, only when it returns to its standing position. Any help would be greatly appreciated.

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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Cube with colliders ignores other colliders, why? 1 Answer

How to hold objects in third person? 1 Answer

How to change CC script to Rigidbody script 1 Answer

Why does my player object decide to ignore colliders whenever he feels like it? c# 1 Answer

OnControllerCollider hit called when moving away from a surface 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