Mesh colliders going thru each others.

I’m coding a 2d game so no gravity. I have an object which is going through the walls. I googled around and make both the wall and object mesh colliders, static, and convex but no luck.

public float speed = 1;
	public bool on = true;

	void FixedUpdate () {
		if (Input.GetKeyDown("1")) on = true;
		if (Input.GetKeyDown("2") || Input.GetKeyDown("3") || Input.GetKeyDown("4") || Input.GetKeyDown("5")) on = false;
		if (on) {gameObject.transform.Translate( new Vector3( speed * Time.deltaTime * Input.GetAxis( "Horizontal" ), speed * Time.deltaTime * Input.GetAxis( "Vertical" ), 0 ), Space.World );}
	}

I got it to work with move not with simplemove but now my object doesnt actually touch the walls. There is this weird gap between them.

CharacterController controller;
	Vector3 move = Vector3.zero;

	void Start () 
	{
		controller = GetComponent<CharacterController>();
	}
	float speed = 1;
	void Update() 
	{
		move = new Vector3(Input.GetAxis("Horizontal")*speed* Time.deltaTime, Input.GetAxis("Vertical")*speed* Time.deltaTime, 0);
		controller.Move(move);
	}

Using transform.Translate will move the object directly, ignoring any collision… for collision, you most likely should add a CHARACTER CONTROLLER to your player, then use controller.Move or controller.SimpleMove to move it.

(if you prefer to utilize physics, however, you may prefer a rigidbody instead of a character controller)

It sounds like you’re still getting used to the engine, editor and so forth; and maybe google gave you bad advice. Mesh colliders are “easy” to click on for a building model, but are a pain later on. They are officially an advanced feature.

If you like the script you have, just get rid of all the Mesh colliders. For the walls and floor, just make some cubes. They each come with 1 box collider. Once you have them the way you like, can even “check off” the renderer (seeing the cubes will help position them over your floor.)

For the Player, get rid of the MeshCollider (and rigidbody.) Just have the required CharacterController and use the little green pill that you automatically get with it.

If that still isn’t working, it will be way easier to find and ask Q’s, since that’s the most common set-up to start with.

This script its the closest I got to working but now there is this gap between the wall and player. For some reason they aren’t actually touching.

CharacterController controller;
	Vector3 move = Vector3.zero;

	void Start () 
	{
		controller = GetComponent<CharacterController>();
	}
	float speed = 1;
	void Update() 
	{
		move = new Vector3(Input.GetAxis("Horizontal")*speed* Time.deltaTime, Input.GetAxis("Vertical")*speed* Time.deltaTime, 0);
		controller.Move(move);
	}