- Home /
Tilegrid platformer collision
Hello,
I'm experimenting with unity for a tilebased 2d platformer. The level is build out of an array of ints, where each int represents a cube with a box collider (the tiles). The boxes are perfectly alligned next to eachother. Both the tiles and player's position is locked on the Z axis, and the rotation on all axis.
However, when the player walks over a horizontal set of tiles he suddenly jumps up at some points. It's as if he "trips" over one of the boxes, even though they should just behave as one big box collider. This problem does not occur when I use one big collider.
You can view a very simple sample here. https://www.dropbox.com/s/jxupnw2ivsc1mih/platformer.swf
The first section is one big box collider, the crates are seperate box colliders. To reproduce the problem, stand on one end of the crates and single tap A or D to move to the other side.
Here is the character control code just to be sure
using UnityEngine;
using System.Collections;
public class Ball_Script : MonoBehaviour {
// Use this for initialization
void Start ()
{
print("started this shit");
}
// Update is called once per frame
void Update ()
{
Vector3 velocity = rigidbody.velocity;
if (Input.GetKey(KeyCode.A))
{
rigidbody.velocity = new Vector3(-10, velocity.y, velocity.z);
}
if (Input.GetKey(KeyCode.D))
{
//rigidbody.velocity = new Vector3(10, velocity.y, velocity.z);
}
if(Input.GetKeyDown(KeyCode.W))
{
rigidbody.velocity = new Vector3(velocity.x, 5, velocity.z);
print("woop");
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613073608im_/https://answers.unity.com/themes/thub/images/avi.jpg)