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 oscarlundberg · Jun 09, 2017 at 05:27 PM · collisioncharactercontroller

Character Controller collision

I've been looking for an answer to this for a while now but I can't find it anywhere.

It's a very simple question: Where do I control what happens when my character controller collides with something?

My game object contains nothing more than a character controller and a script. Simply declaring onCollisionEnter in my script obviously doesn't do anything, since the method is never called.

So I need to know where I can add code that executes whenever my character controller collides with something.

Thanks in advance

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
0
Best Answer

Answer by Habitablaba · Jun 09, 2017 at 05:38 PM

The simplest answer is to add an appropriate Collider component to your player object, and one to anything that you want to collide with.

The less simple, and potentially much more awful solution is to do distance checks between your object and whatever you may collide with. If you have only one or two things you're checking collision with, this might be fine, but I'm sure you can see how this would get out of hand pretty quickly. In this case, you could do these calculations in the Update method.

Comment
Add comment · Show 4 · 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 oscarlundberg · Jun 09, 2017 at 06:09 PM 0
Share

Yeah, I came up with this solution a while after asking (took a few days to moderate)

But i find it odd that we can't access the collider included on the character controller...

avatar image Habitablaba oscarlundberg · Jun 09, 2017 at 06:48 PM 0
Share

There is no collider included in the character controller. If you have a character controller which references a collider, then you need to add it as a component on the player. Once you've done that then yes, you can absolutely access that collider.

avatar image oscarlundberg Habitablaba · Jun 09, 2017 at 06:56 PM 0
Share

Well, If you add the character controller component to an object you can see that it seems to be using sort of a capsule collider. But indeed, it's not an actual collider component that you can access, which i find odd.

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

OnControllerColliderHit won't trigger if not moving 2 Answers

Rigidbody: how to get collisions for the current frame ? 0 Answers

CharacterController and end of collision 2 Answers

Collision issues with character collider 1 Answer

CharacterController & Particles 1 Answer


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