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 thereal_mpellegr · Oct 31, 2013 at 04:10 PM · physicsraycastcollidercharactercontroller

Can't raycast on Character Controller?

I have a Game Object with a Character Controller component and I am not able to collide with it using Physics.Raycast(). I am able to collide with other objects that are using box colliders, etc. I've read in other questions that Character Controller's automatically created collider doesn't allow ray casting, and that particular questioner switched components. In my case I can't do this, so what do I need to do to allow ray casting? I've tried adding another collider, but I get a message that "Replacing existing component. A Character Controller is already added, do you want to replace it with a COLLIDER_I_CHOSE?".

Comment
Add comment · Show 7
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 Tomer-Barkan · Oct 31, 2013 at 04:20 PM 0
Share

I have no idea why it doesn't work with the character controller's collider, but have you considered manually running the collision methods when you raycast? The Raycast will return the hit info, which includes the object, so you can try manually running the OnCollisionEnter etc.

avatar image instruct9r · Oct 31, 2013 at 04:25 PM 1
Share

Do you have other colliders, attached to your character or it's children? If so the raycast might be hitting them. Use Debug.Log, to see what the hit is, when the ray shoud be hitting the character... Have you added your character to specific layer?

avatar image thereal_mpellegr · Oct 31, 2013 at 04:27 PM 0
Share

I noticed something interesting. The capsule collider I couldn't see from the Character Controller, but when I change the radius and height values to be those of the characters BEFORE I scaled them, then I can see the capsule surrounding the character. Is that what you are supposed to do with a Character Collider?

avatar image Owen-Reynolds · Oct 31, 2013 at 05:27 PM 0
Share

tr_mp (OP): Colliders try to size themselves around the object, and resize with you. But as you rescale x,y,z, the collider can get confused and be too small or large. So, YES, you are supposed to always check/adjust collider values so they look good.

Collider "auto-sizing" is merely helpful, and is in no way official or special.

avatar image thereal_mpellegr · Oct 31, 2013 at 06:02 PM 0
Share

I went to the mesh of my character, and looked under "Skinned $$anonymous$$esh Renderer" and found something about bounds, so I plugged the height and radius from their into the controller, but the capsule collider still isn't aligned correctly with the character. Am I supposed to just put in random values until looks about right? Or is there a way I can be more exact about this?

Show more comments

1 Reply

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

Answer by thereal_mpellegr · Nov 06, 2013 at 03:13 PM

I've confirmed that resizing the Character Controller component of my human entities allows a raycast to correctly collide with them. As for the vehicle, I think it just shouldn't be using a Character Controller at all because when I change the width to be large than the height, the collider turns into a sphere collider. I'm not sure what the values mean though because I'm modelling in meters and the radius and height were in the triple digits.

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

17 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

Related Questions

Returning list of Triangles, Vertices or Points by raycasting through a mesh (iPhone) 1 Answer

Physics.Raycast not checking layermask properly? 1 Answer

How to prevent a sphere from jumping? 0 Answers

Raycasts hit triggers disabled - force collision for specific raycast 1 Answer

How to make Ray collide with Character controller ? 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