
I created a very simple project to reproduce this problem. I can’t understand what was happening, it seems like a bug to me, but I’m not sure. I created this script, so the player can jump infinity times, and at a certain height, when the player falls, the collision with tilemap collider 2D is ignored, with or without composite. I try to use composite because I thought he was passing between the squares, but with composite, it’s even worse, the player ignores in lower height.
This project has 2 tilemaps, 1 with composite, and another without. The white is with, and the blue is without. The tilemap without composite is a simple tilemap with Tilemap Collider 2D. To create a tilemap with composite, I also added a Tilemap Collider 2D, but I set Used By Composite, and I add a Composite Collider 2D, which automatically adds a Rigidbody 2D on tilemap, so I set this Rigidbody 2D as Kinematic.
My PlayerController script:
using UnityEngine;
using UnityEngine.SceneManagement;
public class PlayerController : MonoBehaviour
{
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
Walk();
Jump();
Restart();
}
void Walk()
{
float horizontalMovement = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(horizontalMovement * 10, rb.velocity.y);
}
void Jump()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(new Vector2(0, 30f), ForceMode2D.Impulse);
}
}
void Restart()
{
if (Input.GetKeyDown(KeyCode.R))
{
SceneManager.LoadScene("SampleScene");
}
}
}
Besides that, the gravity scale on player Rigidbody2D is 10, but I don’t think this can be a reason for that.
I post this project on GitHub, which you can see here.