detect collider with button movement

Hi there I have 2 control systems in my project. One the general mouse look and keyboard movement. The other uses buttons to control all movement. Unfortunately the buttons override the ability to collide and stop at walls/doors etc. I thought of using raytracing but I’m unsure whether this would stop you from walking sideways through walls. Heres the code i’m using any advice would be great.

var speed : float = Time.deltaTime * 100;
if (movement==1){
 transform.Translate(0,0,speed);
 fly =0;
 }
 if (movement==2){
 transform.Translate(0,0,-speed);
  fly =0;
 }
  if (movement==3){
 transform.Translate(-speed,0,0);
  fly =0;
 }
  if (movement==4){
 transform.Translate(speed,0,0);
  fly =0;
 }

When you use .Translate() you’re most likely just moving the character to the other side of the collider, .e.g it’s like teleporting not moving. You should use a different method, e.g. if it’s a CharacterController, use .Move() or .SimpleMove().