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 RealMTG · Jan 19, 2015 at 04:05 PM · 2dphysicsrigidbody2d

2D objects gets stuck on the ground/wall?

Hi!

I just noticed in my small 2D game that the objects stop on the ground. Like I have a conveyor belt and when the cubes move on it they randomly get stuck. This also happens when they slide down next to a wall. How can I fix this?

Thanks in advance

Comment
Add comment · Show 6
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 Souk21 · Jan 19, 2015 at 04:10 PM 0
Share

Could you try to describe your problem a bit more please? I'm not sure I got it ;)

avatar image GameVortex Souk21 · Jan 19, 2015 at 04:25 PM 0
Share

Remember to post comments as actual comments and not answers (I have converted this one for you).

avatar image RealMTG Souk21 · Jan 19, 2015 at 04:26 PM 0
Share

@Souk21 Sure. So basically I have a crate object. It has a 2D box collider and a Rigidbody 2D. If I place that object next to a wall that consists of multiple sprites with box colliders, it randomly gets stuck on the wall. This also happens when I have some kind of conveyor belt. It is basically a script that applies force to a rigidbody object. While the object is moving it gets stuck. I hope that explains it better!

avatar image Souk21 · Jan 19, 2015 at 04:33 PM 0
Share

What do you mean by "stuck"? Is it stopped? Slowed down? Does it happen with a single collider for the ground? You can put all your ground sprites in an empty gameobject and apply a box collider to it, ins$$anonymous$$d of having multiple colliders

avatar image RealMTG · Jan 19, 2015 at 04:35 PM 0
Share

@Souk21 When I say it gets stuck I mean it stops. In order for it to push something needs to push it. And with the wall sprites, I can't do it like that. I need all the wall sprites to be separate. It happens randomly each time.

avatar image John_Mi · Aug 08, 2020 at 02:31 PM 0
Share

I found the solution! Please see my post below.. It's the Box collider. Thx

12 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by ajdrew81 · Aug 11, 2015 at 06:44 PM

Try using Edge colliders on your box instead. It worked great for me. Here's where I found that out http://forum.unity3d.com/threads/rigidbody-getting-stuck-on-tiled-wall.220861/

Hope this helps!

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
avatar image
1

Answer by imaginaryhuman · Mar 12, 2015 at 07:51 PM

I think it's to do with the fact that the physics engine is not 100% accurate, and that may well boil down to the fact that floating point numbers are not 100% accurate. While unity/physics is probably trying to keep the object flush to the surface, sometimes there is a tiny little bit of penetration into the surface, especially if forces are being applied or surface are moving. I believe what happens is the moving object's collider sinks into the surface just ever so slightly, enough that when it gets to the corner of a box collider (or other types also) it sort of collides against the side of that collider, and sometimes this makes the object bounce up as if it hit something, or also can make the object get stuck. It's the joins between colliders combined with slightly imprecice physics that is the problem, in my opinion. One fix I found is making your object kinematic and moving it without forces. Otherwise I guess you could program some kind of fix in a script, like OnCollisionStay2D, making sure the object is moved up a little bit if it enters the surface?

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
avatar image
1

Answer by Hanh · Aug 31, 2017 at 07:27 AM

Physics Material 2D worked for me.
- Create a Physics Meterial 2D.
- Set friction is zero
- Assign it into colliders (don't need for player)
Hope it can help you

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
avatar image
0

Answer by SnStarr · Jan 19, 2015 at 06:31 PM

Sounds similar to some prototype games where if the player jumps and force is being added to a rigid body to make the player move, and he hits a wall as long as the player is holding the arrow key down there is still being force applied and he will stick to the wall until you let go of the move key. That has to do with the force being applied to the rigid body sideways is more than the force that physics gravity can overcome. Sounds to me like every once in a while the Gravity from the Physics is too much force downwards than is being applied to the rigid body sideways causing the object to "Stop" it's not really stopping, more than it's just going downwards faster than sideways so to speak so it looks like it's not moving. Either try adding more force to the object or lower the Physics Gravity from Project Settings.

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 RealMTG · Jan 20, 2015 at 11:34 AM 1
Share

I don't think it has anything to do with the gravity. So if I just had -1 it still stops. If I would add more force it would not function as I want it to. If you are interested, here's a GIF of my crate stopping on my conveyor belt.

alt text

As you can see it just stops. It always stops on that tile too. It is not different in any way from the other tiles.

stopping block.gif (227.0 kB)
avatar image
0

Answer by alxdncn · Jul 20, 2016 at 02:27 PM

Another solution is to give the object a PhysicsMaterial2D and set the friction on it to zero. This worked for me. But depending on how you're moving this object, it might have some unintended consequences.

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
  • 1
  • 2
  • 3
  • ›

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

39 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 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

Rigidbody2d not falling once in the air 1 Answer

2D walls affect my jump height 1 Answer

Rigidbody2D freezes 1 Answer

One-way physics reaction : Objects reacting with physics to player without player being affected 2 Answers

How to move rigidbody relative to a moving object? 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