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 NoUJoe · Mar 11, 2014 at 05:42 PM · bugcharactercontrollerspherecastcapsulecast

Spherecast/Capsulecast bug/glitch

I am trying to make my own Character Controller. I don't mean using the Unity Character Controller component, I'm attempting to make my own from scratch as the Unity one just isn't that great. I researched for a couple of days to see if anyone else has attempted to create their own character controller (which not many people have apparently). I was sure that using raycasts was not the right approach as they are just a line. Eventually I discovered Spherecast/Capsulecasts which (seemed) like it was the solution. All was going well, I managed to get my test capsule to stick to the ground and go up/down slopes. Then I discovered the bug with both types of casts. If a collider is near the origin/start point for either type of cast, then it will not register a hit, at all. So I set out looking for answers and saw that people had been complaining about this as long as 3 years ago. I couldn't find a solution or an explanation as to why it does this, so I presume it must be a bug. There is 1 issue reported in the issue tracker which had 0 votes until I just voted for it. If anyone could help me out in any way, I would appreciate it!!

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

Answer by whydoidoit · Mar 11, 2014 at 05:46 PM

So if you start a raycast from within a collider it will not register - this is desirable behaviour.

You can check a particular area with Physics.OverlapSphere, you can start your spherecast "back a bit" if there's a danger that you are colliding with something immediately (normally ignoring the player's collider layer so that this is possible). You can also reverse cast back towards the player, which is very useful for camera controllers.

Finally you could also consider Rigidbody.SweepTest

Comment
Add comment · Show 5 · 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 NoUJoe · Mar 11, 2014 at 05:58 PM 0
Share

Hi thanks for the quick reply! I understand that you would not want a cast to register the collider that is attached to the game object it is being fired from, but I have no collider attached to my capsule. I am effectively trying to make my own collider, which I know is 100% possible without this bug/glitch/whatever it may be. I am going to throw an image together to demonstrate what I mean more clearly.

avatar image whydoidoit · Mar 11, 2014 at 06:09 PM 0
Share

But your raycast is probably starting inside the thing that you are hitting right? I'm not talking about the player's collider. So as I say. Start the whole cast from further back in the opposite direction.

avatar image NoUJoe · Mar 11, 2014 at 06:25 PM 0
Share

I understand what you are suggesting to do. But unfortunately the problem would still persist.

Here is the image to hopefully make things clearer.

http://oi62.tinypic.com/qs8cx1.jpg

avatar image whydoidoit · Mar 11, 2014 at 06:32 PM 0
Share

So you would always need to cast outwards to find that wall, and I would suggest an above cast to find the floor to avoid already starting inside the collider.

alt text

screenshot-2014-03-11-18.28.11.jpg (33.5 kB)
avatar image NoUJoe · Mar 11, 2014 at 06:51 PM 0
Share

Hmmm... I did have something in $$anonymous$$d quite like that. I will give it a try combining it with overlap shpere and see if I can get the desired results.

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

21 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

Related Questions

I get launched when I walk off a surface with CharacterController 0 Answers

How can I edit this script, that it will check if the character is standing on a specific layer? 0 Answers

How to get the center of a CapsuleCast or SphereCast on collision 1 Answer

RayCast ignoring mesh colliders? 2 Answers

Inconsistent results when doing line/sphere casts? 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