- Home /
2D Character gets stuck while crossing 2 plane tiles
Hello everyone, today I started noticing that my character was a bit shaky on the Y axis while running on a simple plane (series of square tiles), and I checked in the inspector at runtime and I actually found out some slight variations on the Y of the transform. I have a box collider for the top and a circle for the feet, so I tried to remove the circle and add another box for the lower part. The Y movement finally stopped, HOWEVER now the character randomly gets stuck when crossing two adjacent tiles. Not quite randomly, I noticed it happens sometimes when I change direction, it must be a combination of position (relative to the end of the tile) and character velocity that triggers this. It really makes no sense to me, since the tiles have a dimension of 1 in unity, and their collider is also 1x1, plus I placed the tiles perfectly one next to each other using vertex snapping, and at integer positions just to make sure unity wasn't doing some rounding error, so the character should slide with no problem. Both character and tile materials have 0 friction and bounciness. Also they have rigidbodies, with fixed angle, and the tiles are also set to Is Kinematic. I spent the whole morning doing tests changing parameters with no luck, I even doubled the tiles collider size (so they overlap), and the player still gets stuck at the boundary. Basically when it gets stuck, even if I press D the animation runs but the caracter doesn't move, to move it again in that direction I have to step back first. Here's the code for the movement, very simple:
float move = Input.GetAxis ("Horizontal");
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
Sorry for the wall of text but I wanted to give you as much information as possible. Thank you in advance.
I just wanted to say that I found out that it is a known problem http://forum.unity3d.com/threads/195940-Sliding-2D-Rigidbody-catches-on-box-collider-corners-and-quot-jumps-quot Any idea if they fixed it someway with Unity 4.3 or if anyone found a workaround?
I heard they are currently mainly focusing on 2D so I guess your best bet is to try latest version if that's fixed, ALSO make sure you make a backup especially for 2D project because IT could happen something won't work, ...
But that densest mean that it won't.
I updated to the latest version, the problem is still there unfortunately. I did some other tests on a playground project with just a row of tiles and one on top as a player, I found out that if you increase the scale of the items, the box collider does no longer get stuck. The circle collider still gets some fluctuations on the Y axis, but because of the scale they get quite negligible it seems. So the question now is if the scale increases exponentially the computational weight. I would say so, but maybe if you use gameobject all pretty much of the same size, unity is smart enough to optimize... Who knows, doing another search on the subject!
I have the same issue. I am currently using 4.5.4f1. Is there any workaround?
EDIT: $$anonymous$$y solution was now -> Change the Box Colliders to Circle Colliders.
Your answer
Follow this Question
Related Questions
Swapping Horizontal Input for Mobile 0 Answers
UnityException: Input Axis Horizontal is not setup. 1 Answer
Horizontally scrolling across children having grid layout and parent having horizontal layout 0 Answers
Why isn't this input working? 1 Answer
How can my character move horizontally with Rigidbody.MovePosition? 3 Answers