- Home /
Issue while walking on multiple box collider 2D
Hi !
I've been making a terraria-like game this afternoon where the level is make of blocks and I've encounter an issue when my player start to hit a certain speed, or when he change his direction, like in this video I made (start at 0:30).
I think the player's collider (a sphere) and a block's collider (a cube) are blocking each other but I don't understand why it happen so randomly, since all the blocks are at the exact some Y position, it should be a perfectly flat floor.
Here's the player controller I've been using :
using UnityEngine;
using System.Collections;
public class Player_Controller : MonoBehaviour {
public float speed;
private Rigidbody2D rb;
void Start(){
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate (){
float moveHorizontal = Input.GetAxis ("Horizontal");
rb.velocity = new Vector2 (speed*moveHorizontal,rb.velocity.y);
}
}
And here's some details :
The player
A cube
The scene
Thanks for your answer !
ps : Sorry if there is any misspell, english is not my primary language :)
Answer by MelvMay · Dec 09, 2015 at 08:18 AM
Their positions don't matter, they do not form a continuous surface. Use the EdgeCollider2D for this.
Here's a good description of the issue: Ghost Vertices.
Note that we're working on a solution where you can merge colliders automatically to form a single continuous collider that obviously would have a continuous surface.
Your answer
![](https://koobas.hobune.stream/wayback/20220612051831im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Simplest way to deaccelerate a Rigidbody2D object 1 Answer
My player is unexplainably destroyed when collides with a collider 0 Answers
2D Physics Problem? 1 Answer
Player Knockback Without Physics 0 Answers
How would I prevent ghost vertices? 2 Answers