- Home /
Unity2D collision problem
Hi, i am making a 2D platform game. In this game there are some boxes that are in the air (they are side by side). Each of this boxes has its own box collider 2D.
When my character (with his box collider2D) jumps on the boxes there isn't any problem. The problem apperars when the character tries to move on the boxes.. Because sometimes he can't go on.. I think that this is based on the boxes' colliders...
Have you got somo solutions or something else ? :)
If you need any further information, ask me :)
Thank you so much:)
I have a solution, but i don't know if it is good..
I can create an Empty GameObject and make the boxes( without the box collider) as its children. And the put the collider in the gameobjecct and adapt to the boxes :)
It works but i don't know if there is a better way
If i try to walk on the boxes, the character stops moving...
Can you please show the code you have written for character movement?
float h = Input.GetAxis("Horizontal"); anim.SetFloat("Speed", $$anonymous$$athf.Abs(h));
if(h rigidbody2D.velocity.x < maxSpeed) rigidbody2D.AddForce(Vector2.right h * moveForce);
if($$anonymous$$athf.Abs(rigidbody2D.velocity.x) > maxSpeed)
rigidbody2D.velocity = new Vector2($$anonymous$$athf.Sign(rigidbody2D.velocity.x) * maxSpeed, rigidbody2D.velocity.y);
Answer by bhartu · Jul 01, 2014 at 01:29 PM
you can put circle collider2D and give physics2D material with low friction. it should work.
is too big circle.. there is something like capsule in 2d ?
Oh, c'mon, you can add several colliders. Look that 2D-tutorial, man.
I tried to use a circle collider but the problem persists...
Answer by incorrect · Jul 01, 2014 at 11:22 AM
my character (with his box collider2D)
Just open the example 2D-project provided by Unity and look how it is done. It should have circle collider, btw.
@aled96, I've noticed. But for some reason circle collider is used for characters. Try looking 2D-tutorial. ;)
Answer by timvanderweijde · Jul 01, 2014 at 08:27 PM
The rigidbody2D component of the boxes should probably be set to "Is kinematic" is true. (checkbox) Otherwise other forces like gravity will effect the position of your boxes.
I quess there will me a really small edge where your characters stops.