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 RealFighter64 · May 28, 2015 at 08:59 AM · collidercharactercontrollerboxcollider

Character Controller collision box too large?

Hi there, I am making a Tetris-style game, and for some reason when I place the blocks they are hanging just above the platform that I place them on. Is this the box collider or the character controller? I don't know.alt text

capture.png (48.7 kB)
Comment
Add comment · Show 4
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 virgiliu · May 28, 2015 at 09:28 AM 0
Share

A screenshot of the scene with the colliders visible would help, but indeed it seems that the colliders are too big, what happens if you make them smaller?

avatar image RealFighter64 · May 29, 2015 at 08:26 AM 0
Share

Here's a picture, and how much do you recommend I shrink it by?alt text

capture.png (21.5 kB)
avatar image virgiliu · May 29, 2015 at 08:38 AM 0
Share

That's weird, the collider looks O$$anonymous$$.! If you shrink it by half what happens? I suggest shrinking by 1% over and over until you get the right kind of contact. But it's unusual that they have that gap around them, maybe something else is going on. I made a test project with just 2 cubes and added a Rigidbody and BoxCollider and they overlap just right (the offset is there so you can see where each cube ends).

screen-shot-2015-05-29-at-113526.jpg (177.9 kB)
avatar image RealFighter64 · May 29, 2015 at 09:09 AM 0
Share

Hmm... First, I'm using a character controller, not a rigidbody, and second, shrinking is by half is the same.alt text

capture.png (116.1 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by florianveltman · May 29, 2015 at 02:35 PM

Though I would generally disagree with the use of a character controller in this situation (I don't know the whys and wherefores of your project but a character controller seems way overkill for a tetris-style game), an easy, temporary fix might perhaps be to check the character controller's height and radius. Maybe try to reduce its size to be a magnitude smaller than the collider to see how it behaves.

In any case, both the character controller and the collider prevent the object from going through the other, so one of them is probably redundant.

Comment
Add comment · Show 3 · 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 RealFighter64 · May 29, 2015 at 03:11 PM 0
Share

Does the collision with BoxCollider still work if I use transform.Translate()? I'm kind of a noob at Unity, so I don't know. The only reason I was using a CharacterController was because I knew that definitely checked for collisions. I didn't want to use a Rigidbody because I thought it would be a bit too unstable. So, would this still work with OnControllerColliderHit?

avatar image florianveltman · May 29, 2015 at 05:32 PM 0
Share

Collisions actually only ever occur with physics, with the character controller being the exception. It's indeed a good idea to use the character controller for collisions if there are no physics involved in the game, but since your project seems to actually be about collisions between the boxes, it'll be better to use Rigidbodies, which will be better optimised for multiple moving parts that need to collide.

The correct way to move a Rigidbody is to use AddForce(), ins$$anonymous$$d of transform.translate. It pretty much works the same way, but it informs the engine that you are effectively moving a Rigidbody around. If you want to use transform.translate, you should make the Rigidbodies kinematic — but this will disable the possibility of detecting collisions. OnControllerColliderHit() is indeed for the character controller, ins$$anonymous$$d you can use OnCollisionEnter(). Note that you can also constrain a Rigidbody's position and rotation on various axes, this might come in handy when using Rigidbodies without gravity.

If you however really want to avoid using physics for some reason, you might want to have your blocks move on a grid of valid positions. This will enable you to use OnTriggerEnter(); you could make the box colliders a little bigger than the actual boxes, and when the trigger fires, have the manipulated box snap to a certain position.

Hope that helps!

avatar image RealFighter64 · May 29, 2015 at 06:08 PM 0
Share

Alright, I'll try that out in a bit. Thanks!

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

Box collider with character controller? 0 Answers

how to disable the character controller and box collider for after hitting the character controller 1 Answer

Charcter won't go through Box Collider!! Need Help asap! 1 Answer

OnColliderStay does not work 1 Answer

Character's trigger collides with itself 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