Moving a Goomba back and fourth

Hey guys, I need help on making a first person mario game. I have been looking everywhere on how to make a Goomba (the brown mushroom enemy) move one point, then back to the original point. IE back and fourth wherever it is placed. Any ideas? I use C# by the way.:roll_eyes:

I’ve started to come up with my own code, but I am having a problem in C# that I know I can fix in US but I am learning C#. I’ve decided to use raycast so that when the Goomba’s raycast hits the wall, it will then go translate the other way. My problem is with the bool, i need the bool to become true so that i can write an if statement to get the goomba to move the other way.

using UnityEngine;
using System.Collections;

public class GoombaScript : MonoBehaviour
{
public float raycastLength;
public float goombaSpeed;
public bool hitObject = false;
void Update()
{
transform.Translate(Vector3.left * goombaSpeed * Time.deltaTime);

Vector3 left = transform.TransformDirection(Vector3.left);
if (hitObject == false Physics.Raycast(transform.position, left, raycastLength))
{
print(“HIT”);
hitObject = false;
}
}
}

if ur on windows use 3D builder and 3D viewer and shape The goomba. And if u dont kno how he looks just search up “goomba”