Player wont collide with wall

The player wont collide with wall when it goes forward. It just go through the wall. We have a script that makes the player go forward and we want the player collide with the object

void Update () {
		
transform.position += new Vector3(0,0,.308f);
	
	}
}

Obviously transform.position is going to make the object go through the wall. Any Suggestions will help. I am a beginner in scripting.

This is how I approached the problem. I gave the object a rigidbody, with gravity set to true, isKinematic set to false.

Yes, but then to still have control of the object without it wobbling, rotating and sliding around, I modified the velocity like so :

rigidbody.velocity = Vector3( 0, rigidbody.velocity.y, 0 );

with this line, gravity still works , but when I use

transform.position += transform.forward * speed * Time.deltaTime;

the object collides with other colliders (that are not triggers!), and also runs up and down the slopes of a 3D terrain without going through the hillsides. Try it out =]