• 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 /
  • Help Room /
avatar image
0
Question by kreed · Jan 30, 2018 at 12:08 PM · 2dcollisionphysicsrigidbodyplatformer

2D RigidBody slightly penetrates objects causing a bounce effect.

So I am trying to set up a simple 2D platformer. I have Box colliders on my character and walls/floors. The collision is handled, just not correctly. When you collide with a wall, the character partially penetrates that wall, then the wall forces them back out causes a bouncing effect, and I can't get the character to stop flush to a wall.

The effect is basically a vibration between the two pictures below. I also have a link to a video for further clarification.

alt text

alt text

Video of the Issue

***Note : amtToMove is a float set to 5;

 void fixedUpdate()

 {
     if(Input.GetKey("right"))
     { 
         amtToMove = Input.GetAxisRaw("Horizontal") * playerSpeed * Time.deltaTime;

         //rigidbody.AddForce(Vector3.right * amtToMove);

         rigidbody.AddForce(Vector3.right * amtToMove,ForceMode.Impulse);
     }

     if(Input.GetKey("left"))
     { 
         amtToMove = Input.GetAxisRaw("Horizontal") * playerSpeed * Time.deltaTime;
         rigidbody.AddForce(Vector3.right * amtToMove,ForceMode.Impulse);
     }

 }


I have tried moving the character using Impulses, basic forces, and using basic translation. I am also handling the movement in the FixedUpdate() function.

I appreciate any and all help.

Comment
Add comment · Show 3
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 Dakwamine · Dec 11, 2011 at 02:25 AM 0
Share

Hmm... just asking. Is it FixedUpdate() or fixedUpdate() ?

avatar image kreed · Dec 11, 2011 at 04:36 AM 0
Share

It's fixedUpdate(). I have a feeling that this means I accidentally created my own function, rather than using the one that I THOUGHT I was.

avatar image Dakwamine · Dec 11, 2011 at 01:47 PM 0
Share

I am not sure about C# syntax or features, as I always use UnityScript. But in the scripting reference, FixedUpdate() is used with an uppercase first letter like the Update(), Start(), etc.

I just do not understand why or how your fixedUpdate() is called... Unity or C# feature ? ^_^'

3 Replies

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

Answer by TruffelsAndOranges · Jun 21, 2015 at 12:16 PM

The only real solution to this problem is by lowering the Baumgarte Scale attribute in Edit -> Project Settings -> Physics2D to a very small value. With 0.0001 you will get no visual bounciness at all. I'd recommend a value that is slightly higher.

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 parth16parikh · Jan 30, 2018 at 11:32 AM 0
Share

Thanks a million! your solution was really helpful. Was stuck the whole day

avatar image glenn-dai · Aug 08, 2018 at 02:09 AM 0
Share

Thanks a lot, i got stuck at this problem for long time, even thought about writing my own 2d collision system.

avatar image henryxiu2005 · Jul 05, 2020 at 11:22 PM 0
Share

The problem just got worse for me. I set the Baumgarte Scale to the 0.0001, but now the objects just permanently intersect. For some reason, my character's jump height also increased. Is there any way to resolve this?

avatar image
1

Answer by brentstrandy · Dec 31, 2013 at 06:36 AM

Go to your PhysicsSettings2D in Edit > Project Settings > Physics 2D. There is a field called Position Iterations... Change it to a higher number (maybe 5 or more). This should stop the bouncing.

I'm posting this to help others who run into this problem... Sorry if this isn't an issue for you any longer.

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 TruffelsAndOranges · Jun 21, 2015 at 12:08 PM 0
Share

Doesn't help at all. :-/

avatar image
0

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

Better to use a circle collider?

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 TruffelsAndOranges · Jun 21, 2015 at 12:08 PM 0
Share

Circle collider vs box collider doesn't matter.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

How do I prevent stacked objects from being spoiled by collisions? 2 Answers

Why/How 2d tower of blocks collapse? 0 Answers

Rigidbody2D figits when pushed against an object. 0 Answers

Early Collision Detection 0 Answers

RigidBody becomes awake without a collision 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges