2D Tilemap Collisions

So I’m having trouble with 2D Tilemap collisions. My game is going to be a top down 2D RPG. In my game I have a player, which is currently just a sprite that can move up, down, left, and right. I also have a small map that I have been working on with my tileset. However, I have been having trouble adding colliders to the walls so that the players can’t walk through them. I tried putting the walls on a separate grid and adding a tileset collider to just that grid, but it isn’t working. My player does have rigidbody2d and tile map collider 2d on him so I’m not sure why it isn’t working. I tried a polygon collider before where I had to outline the walls by hand. This was very inefficient but also led to a lot of glitches when my player collided with the wall, so I would really appreciate it if someone could give me some advice here. To clarify, I want my player to be able to move through some of the tiles (grass, paths, etc.) but not be able to move through the wall tiles. Thanks in advanced to anyone who can help.

So i am going to assume you know how to set up a tile (if not unity tutorial). I think what you are looking for is the Composite Collider 2D, simply put this component takes all the colliders in child(?) and makes them into 1 solid/connected. Here is a Unity talk where he sets up the Colliders for his tilemap. This should solve the problem i think you have(small gaps between 2Dbox colliders).

Now depending how experienced you are with unity, your problem might be alot more basic. If this dosent fix your issue, you need to give us a little bit more information, are you just walking up against the wall and just slipping past ? Are you 100% sure your collider setting are correct ?


After reading your comment with some new info i can add a couple more things.

I’m not slipping through the walls, but if I run into them at certain angles like at corners it will flip my character sideways or upside down and completely change the orientation of the game.
As mentioned by Austin-Gregory in the comments, if you look at the Rigidbody2D component you can restrict Rotations on Axis. This goes back to my settings suggestion(should have been more clear i ment in componants).
I’m pretty sure there’s something wrong with my player movement code
Is there anywhere I can find a more stable player movement script for top down rpgs

	// Use this for initialization
	void Start () 
	{
		Character = this.GetComponent<Rigidbody2D>();
	}
	
	// Update is called once per frame
	void FixedUpdate () 
	{
		DirectionX = Input.GetAxisRaw("Horizontal");
		DirectionY = Input.GetAxisRaw("Vertical");
		Character.velocity = new Vector2(DirectionX * Speed, DirectionY * Speed);
		//Debug.Log(DirectionX +" " + DirectionY);
	}

Here is some code that works with Rigidbody2D put it on you character.


The thing is @nickmakesgames the root if your problems i think is in understanding the basics.
You need to take this 1 step at a time, I suggest starting with colliders and rigidbodies and then move on to tilemaps. Because in the end we might solve 1 problem right now, but in the future your gonna have a very simple problem again and trying to debug these types of problems takes more time then its worth especially if the OP dosent take the time to learn the basics. i dont want to discourage you from asking questions, a good question is hard to formulate that is why i say take it 1 step at a time.