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
2
Question by petediddy · Mar 15, 2015 at 11:25 AM · cube

Cube player not sliding smoothly on floor made from prefab cubes

I've got a cube with rigid body and box collider as my player. The floor is generated from a script which instantiates a handful of objects from a prefab 1x1x1 scale cube which also has both rigid body and box collider. I'm adding force to the player cube to slide it across the floor made of the prefab cubes. While the floor looks (visually) to be smooth, there must be a seam between the cubes... the edge of the player cube catches sometimes (not at each seam between floor cubes, only about 1/3 of the time from my estimation from testing in the Game view), causing the player cube to register OnCollisionExit and the cube rotates forward a bit, then almost immediately OnCollisionEnter when it rotates back to starting rotation as it continues to slide across the floor.

Any ideas what may be causing the floor to not be as smooth (in the physics world) as it appears to be on-screen? I need the floor to be smooth so there is no OnCollisionExit registering (or unwanted rotation) as the player cube moves from one floor cube to the next. I'm using a script to generate and recycle the floor cubes.

Comment
Add comment · Show 2
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 AlwaysSunny · Mar 15, 2015 at 04:54 AM 0
Share

This is a known phenomenon; just a quirk you'll learn to live with. When two colliders are mathematically adjacent, they overlap and can cause this issue. Easy fix is to try reducing the size of the colliders; try (0.99).

avatar image petediddy · Mar 16, 2015 at 08:19 PM 0
Share

On your advice, I tried using 0.99 for the x/y/z scales on the prefab's box collider, still no luck (same thing happening). Any other ideas? It's still registering a collision when transitioning from one prefab floor cube to the next.alt text

screen-shot-2015-03-16-at-11850-pm.png (66.9 kB)

2 Replies

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

Answer by Fanttum · Mar 15, 2015 at 03:53 PM

I'd try using a sphere or capsule colder instead of a box collider. (just make sure to lock rotation)

This makes it so your cube will then "roll" over any rough surface.

Comment
Add comment · Show 4 · 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 petediddy · Mar 16, 2015 at 08:28 PM 0
Share

Fanttum, tried this after your comment was received. While it helped the character not to rotate and tumble when it hits a seam between prefab cubes, it did not fix the collisions between the player and the floor prefab cubes, so it's still throwing OnCollisionEnter and Exit each time it moves to a new floor prefab cube. Any other ideas? Attached is a screenshot of player inspector settings and the console showing the OnCollisionEnter/Exits being called repeatedly as the player moves across the tiles.alt text

screen-shot-2015-03-16-at-12621-pm.png (113.7 kB)
avatar image Fanttum · Mar 17, 2015 at 09:53 PM 0
Share

Hmmmm, not sure any way to really fix that. Its got touch something... Is there a reason it shouldn't be entering the floor? $$anonymous$$aybe you could take off UseGravity and just have your Cube float slightly over everything and that might solve all your problems unless you need that for other things.

avatar image petediddy · Mar 17, 2015 at 10:13 PM 0
Share

Previously, was rotating the cube as soon as it left the floor (OnCollisionExit), although I decided to switch to a sphere for the player because of this issue. Now, with the sphere, it seems to move correctly across the floor without the unwanted bumping and rotating.

Also, I removed the OnCollisionEnter/Exit calls, and substituted a Raycast in the down direction from the sphere player to deter$$anonymous$$e if touching the floor, and this seems to be working better.

Thanks for your help!

avatar image Fanttum · Mar 20, 2015 at 01:29 AM 0
Share

Glad you got it figured out.

avatar image
0

Answer by brandonalbers1 · Mar 28, 2020 at 03:02 PM

I had the exact same problem so I applied a physics material to my object that had no friction. I hope this helps someone out!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

OnMouseDown() cube face? 1 Answer

Face detection 1 Answer

How do I add a texture to a cube (yes I know I'm a scrub)? 1 Answer

Custom Mesh UV Problem 1 Answer

Hiding faces of a cube ? 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