stop vehicle from moving through walls

I have this simple auto acceleration ship movement script for my racing game (it’s in javascript)

var movementSpeed = 80;
     var rotationSpeed : float = 100.0;

     function Update () {
       transform.position += transform.forward * Time.deltaTime * movementSpeed;

         var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
         
         rotation *= Time.deltaTime;
         
     
         transform.Rotate (0, rotation, 0);
     }

but because of the way it’s set up it’s causing the player’s ship to phase through walls even if I have a collider and rigibody attached to it, how can I fix this?

@EliteHedgehog56

You shouldn’t directly change the transform.position of a GameObject for movement as this may cause it to stop colliding. You should use transform.Translate or Rigidbody.AddRelativeForce and Rigidbody.AddForce for the majority of your movements.

Also not entirely sure you know what Time.deltaTime is and why it’s used if you aren’t doing the correct movement. Time.deltaTime is the time in seconds it took to complete the previous frame and essentially turns the script into "Move this many units per second.

The Rigidbody being Kinematic could also cause this issue with collision.