How to get my character to collide with objects

Hi, I’ve been working on a small project for a few days and finally got a character controller working. I’m now working on it colliding with an object, but it keeps going through the object. I’ve tried using a rigid body and a character controller from the physics components but nothing really works as expected. I only had luck with the rigid body but it would push around the object.

Preferably I would like to get the character controller working.
Here is my code so far for my charactercontroller script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MechController : MonoBehaviour {

	static Animator anim;
	public float Speed = 20.0F;
	public float rotationSpeed = 100.0F;
	CharacterController controller;
	float currentSpeed; 

	Rigidbody rbody;

	void Start()
	{
		anim = GetComponent<Animator>();
		Debug.Log (anim.name);
		rbody = GetComponent<Rigidbody> ();
		controller = GetComponent<CharacterController> ();
	}

	void Update() {

		float translation = Input.GetAxis ("Vertical") * Speed;
		float rotation = Input.GetAxis ("Horizontal") * rotationSpeed;
		translation *= Time.deltaTime;
		rotation *= Time.deltaTime;
		transform.Translate (0, 0, translation);
		transform.Rotate (0, rotation, 0);

		if(Input.GetButtonDown("Jump")) 
		{
			anim.SetTrigger("isJumping");
		}

		if(translation != 0) 
		{
			anim.SetBool("isRunning", true);

		} 
		else 
		{
			anim.SetBool ("isRunning", false);
		}
			
		Vector3 velocity = transform.forward * currentSpeed;

		controller.Move(velocity * Time.deltaTime);
		currentSpeed = new Vector2 (controller.velocity.x, controller.velocity.z).magnitude;
	}

}

Any tips or tricks would be awesome.
Thanks for your time!
-Bobby

Uee RigidBody and Box/Capsule Coliiders on both objects. Check the “is Kinematic” option in rigidbodies.

Bye!