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
1
Question by Caps · Nov 26, 2010 at 05:23 PM · collidercharactercrouch

when crouch, falling through floors

Hey guys,

Ive been creating a character using the character controller. So I have written my own script to make it move, run, jump and crouch.

Now, everything seems to be working properly, except when the character uncrouches, that means, whe it stands up, it falls through the floor.

The issue is that, when using crouch, the controller.height is being altered from 2 to 1. So, when standing up, its 1 to 2. Thats exaclty the problem, when going back to the height of 2, that height goes through the floor so the character is now insered in the floor, thus falls.

I have already seen a solution where the gravity is "zeroed" or "stopped" for standing/uncrouching, but that really is not a solution for me because the player should be able to jump and crouch and also stand while in a jump.

Also I have tried smoothing this transition in controller.height, so it gradualy goes from 1 to 2 and 2 to 1, still not working, player falls through.

I have also tried giving a "little impulse" somewhat similar to stopping gravity, wich in this case it works, but again, not a good solution.

I have also tried setting the controller.center.y, wich would be an alternative way of changing the colliders position while standing so it doesnt go through floor but Ive had no success yet.

Would someone please give me any suggestions? I bet me and a lot of people would appreciate it!

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

2 Replies

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

Answer by Loius · Nov 26, 2010 at 05:34 PM

You have to move the character controller (that is, transform.position.z += 1) so it's not clipping the ground. If it clips through something when its size is changed, it'll fall right through.

Comment
Add comment · Show 7 · 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 Caps · Nov 26, 2010 at 06:05 PM 0
Share

Ok, Ill try that now...

avatar image Caps · Nov 26, 2010 at 06:09 PM 0
Share

Just to add here, is this intentional, not to use the actual $$anonymous$$ove or Simple$$anonymous$$ove funcions of Character Controller?

avatar image Caps · Nov 26, 2010 at 07:19 PM 0
Share

Ok, still needs some adjustments, still very jerky movement but, lets see how it goes under testing with other movements like jumping etc... Thank you Vicenti for your help. :D

avatar image Loius · Nov 27, 2010 at 07:41 AM 0
Share

You could use .$$anonymous$$ove; that would let you check to make sure the character actually can un-crouch (if they're in a narrow pass, you could undo the uncrouch). Getting the animation to sync with the sudden movement is the tricky part; I haven't gotten around to implementing this yet in my game, unfortunately, so I don't have any concrete examples.

avatar image Caps · Nov 28, 2010 at 04:35 AM 0
Share

Yes, the .$$anonymous$$ove, because this is whats recommended for moving the character collider (at least from what Ive read so far), thats why I asked about it... Now, the thing that I think worked is because there is no interference with gravity, because gravity is being applied as a $$anonymous$$ove function... So by using translate, maybe this gave an extra moving possibility without altering gravity.

Show more comments
avatar image
0

Answer by Snipe76 · Jan 02, 2019 at 03:34 PM

@Caps Move the crouching part to FixedUpdate instead of Update

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

character bounces on a box 0 Answers

How to prevent rigidbody with capsule collider from walking off the edge of cube mesh if button held down? 1 Answer

what the heck why is this happening 1 Answer

Player falls through floor after 10-20 seconds and above certain resolution consistantly(Bug?) 5 Answers

Raycast problem trough the terrain 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