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 You! · Jun 15, 2012 at 06:04 AM · enemygravityfloorfalling-through-floor

Enemy falls through floor when both have collider

I have a floor (complete with box collider not set to trigger) and an enemy (with a collider not set to trigger and a character controller). The rigidbody applies gravity to the enemy. The enemy, instead of falling and stopping at the floor like everything else in the room, falls straight through the floor into infinity. The floor's box collider is extremely thick (extends 100 meters below the 1 meter floor). The gravity of the enemy is minuscule (much less than one). I tried the "DontGoThroughThings.js" from the Unify community, with the floor set to a different layer. I have made sure that the enemies are well above the floor collider. I've been thinking through this and have searched through this site (my search yielded the Unify community "solution"), with the solutions that I found either something that I have already found or something that I have already tried. Does anyone have any idea of how to fix this?

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

Answer by Bunny83 · Jun 15, 2012 at 09:13 AM

Don't use a CharacterController AND a Rigidbody on the same object unless it's a kinematic Rigidbody. This doesn't work. Both components are responsible for moving the object. The Rigidbody is a physics object and the character controller is ment as a controlling component without being affected by physics, so you have full control over the character. You can't combine them. The CharacterController usually get it's own gravity applied in a script. Just take a look at the CharacterController-package that comes with Unity.

You have to decide which way of movement you want / need.

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 You! · Jun 15, 2012 at 04:34 PM 0
Share

...This creates an odd problem. I need the character controller for the movement of the enemy - its the way its programmed, but I need the rigidbody for the collision events that it has... Should I use OnTriggerEnter ins$$anonymous$$d?

avatar image Bunny83 · Jun 15, 2012 at 05:00 PM 1
Share

No, the CharacterController has it's own collision detection. See OnControllerColliderHit. If you need other moving things to collide with your player, they should have a rigidbody + collider. This way you get OnCollisionEnter if the other object moves into your character and if you move your character into the other object, you get OnControllerColliderHit and maybe OnCollisionEnter when the rigidbody is still awake.

avatar image You! · Jun 15, 2012 at 05:17 PM 0
Share

I removed the rigidbody component and changed some of the collision events. It works better... The enemy still falls through the floor, but actually stops at some point. I think this would have to deal with the skin width... Am I right?

avatar image fafase · Jun 15, 2012 at 05:55 PM 1
Share

It could have to do with the position of your CC. Does it wrap the whole model?

avatar image You! · Jun 15, 2012 at 06:01 PM 0
Share

Yes it does...and it isn't off-center from the model, either...

Since the parts of the model are off-center (including the collider), I re-positioned the model to where the center of the object parts was the "center" of the entire object. The model remains the same - except that the scale of the object jumps from 1 to 10! Any ideas?

...which should be in a different question. Removing the rigidbody did fix the problem addressed in this question.

avatar image
1

Answer by zerox911 · Jun 15, 2012 at 09:00 AM

this is just a guess..

try positioning the object slightly higher(like y = + 0.5 / + 1.0) than the platform..

and when it fell.. note the position..

i had this problem before..

and..

its a wild shot to answer your question...

and i apologize if this doesn't work..

Comment
Add comment · Show 1 · 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 You! · Jun 15, 2012 at 04:43 PM 0
Share

The enemy is already well above the floor... It ends up falling to about -.9 before dropping like a rock.

It usually is a good wild shot, @zerox911, so you don't have anything to apologize for. (I've had this problem before too.)

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Object falls through floor 1 Answer

How to check if a enemy is moving up or down? 1 Answer

THIN objects can fall through the ground? (AMAZING SOLUTION) 2 Answers

Enemy Ai Problem with the collider and gravity 1 Answer

Use enemy as trigger just for the char ( not the ground ) 2 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