how to fix my player from phasing through walls

I have set all of my colliders to not trigger and all of them are set. my player goes through them and if you stop in the wall it just pushes you out almost like it doesn’t update in time.

use FixedUpdate()

that might fix it

Based on the details added in the comments, the problem lies in the difference between using Transform.position for movement and applying movement that will be properly handled by physics interactions.

Before jumping into a simple “Here’s how to fix it”, however, let’s first look at why this doesn’t work in its current form.

void Update()
{
	transform.position += movementInput * Time.deltaTime;
}

While this will make the character move in the direction that input is provided, it won’t affect their “physical” presence in the physics engine(s). This is because the rendered 3D model (or 2D texture/sprite) and their Collision data are not the same thing. While moving the GameObject around using Transform.position &#42does&#42 move their Collider around, it doesn’t send messages to it, nor does it occur with proper timing.

Physics simulations in Unity occur independently from the framerate for consistency, in FixedUpdate() (default 50fps) rather than in Update() (Each rendered frame). A Rigidbody (or Rigidbody2D) component will allow a GameObject to properly interact with the Colliders on other GameObjects.

With that in mind, there are numerous ways to move around using a Rigidbody.

The most standard “correct” way is to AddForce() to the GameObject:

Rigidbody rb; // or Rigidbody2D

void Start()
{
	rb = GetComponent<Rigidbody>();
}

void FixedUpdate()
{
	// For player movement, we'll want to ignore mass
	// Apply directional movement each frame based on provided input
	// Apply special forces (i.e. jump) once at a time
	
	// 3D
	rb.AddForce(v3MovementInput, ForceMode.Acceleration);
	if(jumpInput)
	{
		rb.AddForce(v3JumpInput, ForceMode.VelocityChange);
		jumpInput = false;
	}
	
	// 2D
	rb2D.AddForce(v2MovementInput * rb2D.mass, ForceMode2D.Force);
	if(jumpInput)
	{
		rb2D.AddForce(v2JumpInput * rb2D.mass, ForceMode2D.Impulse);
		jumpInput = false;
	}
}

This applies forces which affect the Rigidbody’s Velocity. On that note, the velocity can also be set directly, with less-believable results.

Additionally, a Rigidbody (typically a kinematic one) can be moved using Rigidbody.MovePosition() instead. This is effectively equivalent to using Transform.position, but will always attempt to resolve physics interactions in the process. To apply it to your example would look about like this:

Rigidbody2D rb;
void Start()
{
	rb = GetComponent<Rigidbody2D>();
}

void Update()
{
	movement = Vector2.right * Input.GetAxis("Horizontal");
}

void FixedUpdate()
{
	// Because you're modifying position directly, you still
	// want to multiply by Time.deltaTime
	// Fortunately, Time.deltaTime is automatically converted
	// to Time.fixedDeltaTime in FixedUpdate()
	rb.MovePosition(transform.position + movement * Time.deltaTime * speed);
}