x


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.

more ▼

asked Dec 11 '11 at 01:42 AM

kreed gravatar image

kreed
1 5 6 7

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

Dec 11 '11 at 02:25 AM Dakwamine

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.

Dec 11 '11 at 04:36 AM kreed

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 ? ^_^'

Dec 11 '11 at 01:47 PM Dakwamine
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You could check your Physics Settings in Edit > Project Settings > Physics. Min Penetration For Penalty or Solver Iteration Count can correct your problem. More precisions are in the Reference Manual.

If not sufficient, you could use greater object scales as this problem will be less visible at higher scales.

more ▼

answered Dec 11 '11 at 04:21 AM

Dakwamine gravatar image

Dakwamine
534 4 7 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2483
x1865
x1783
x1033
x185

asked: Dec 11 '11 at 01:42 AM

Seen: 1476 times

Last Updated: Dec 11 '11 at 01:47 PM