Possible? AI Spaceship Pathing

Hi, basically i want to put AI into my game (just movement to follow the main character until they crash into random obstacles and die, or follow a path).
Here’s a quick look at what my game looks like Screenshot by Lightshot
I use no gravity for my main character/ship, and use forward Force and sideways Force to move it >.> Is that easy to use for AI?
Also i have a theory that i can create an AI path route by using the “rail track” thing, where u make the camera follow a specific route, but i use AI instead of a camera if that makes sense? (never used it though, nor know the correct name lol).

Basically does anyone know if i’m onto something? Or can you point me into the right way for AI in spaceships (just moves forwards, doesn’t fly like an actual jet/spaceship)

Here’s my simple movement script to make it more clear what type of movement i have:

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
   
    public float yaw = 0.0f;
    public float pitch = 0.0f;
    public float roll = 0.0f;
    public float rollSpeed = 5.0f;
    public float rollAmount = 0.0f;
    public float MaxPitch = 90.0f;
    public float MinPitch = -30.0f;
    public float MaxRoll = 30.0f;

    public float RotSpeed = 25.0f;
    public float acceleration = 1.0f;
    public float maxSpeed = 60.0f;
    public Rigidbody rb;

    public float forwardForce = 2000f;

    public float sidewaysForce = 500f;
    private float curSpeed = 0.0f;




    void FixedUpdate()
    {

        rb.AddForce(0, 0, forwardForce * Time.deltaTime);

        pitch = Mathf.Clamp(pitch, MinPitch, MaxPitch);
        roll = Mathf.Clamp(roll, -MaxRoll, MaxRoll);

        transform.rotation = Quaternion.Euler(pitch, yaw, roll);
        rollAmount *= 0.9f;

        if (Input.GetKey("d"))
        {
            rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            rollAmount -= rollSpeed;
        }
        if (Input.GetKey("a"))
        {
            rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            rollAmount += rollSpeed;

        }
        if (Input.GetKey("w"))
        {
            rb.AddForce(0, sidewaysForce * Time.deltaTime, 0, ForceMode.VelocityChange);

        }
        if (Input.GetKey("s"))
        {
            rb.AddForce(0, -sidewaysForce * Time.deltaTime, 0, ForceMode.VelocityChange);

        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            rollAmount -= rollSpeed;
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            rollAmount += rollSpeed;

        }

        if (Input.GetKey(KeyCode.UpArrow))
        {
            rb.AddForce(0, sidewaysForce * Time.deltaTime, 0, ForceMode.VelocityChange);

        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            rb.AddForce(0, -sidewaysForce * Time.deltaTime, 0, ForceMode.VelocityChange);

        }

        transform.Rotate(0, 0, rollAmount * Time.deltaTime);
        transform.Translate(Vector3.forward * curSpeed);

        curSpeed += acceleration;

        if (curSpeed > maxSpeed)
            curSpeed = maxSpeed;

    }
}

I don’t know about the more complicated stuff but a simply option would be if you’ve only got the one player to have the AI do some some distance checks using if statements and then simply use transform.Translate towards the player. With regards to the ‘dogfighting’ type mechanics that they use in space sims I remember seeing a tutorial by BergZerg where he used slerp and the like to make the enemies follow the player in a curved manner.

This gives the impression that you’re in a proper dogfight, a more advanced way of doing this wouldn’t necessarily involve ‘rails’ so to speak but waypoints, you could make a list of waypoints around the player and then when the AI gets within a certain distance they simply follow those waypoints in an attack pattern against the player.

This is all stuff you have to think of though and it depends on how complex you want the AI to be, I think the waypoint thing is most likely what you’re thinking of.

Ooo, the waypoint thing sounds good yeah, thx. The game is basically about dodging obstacles in front of u, which i’d probably use waypoints to make them dodge the static objects, not entirely sure what my plan is yet tbh, whether or not i actually need AI, might just copy/paste like 6 versions of the main character and spread them out like a squadron and control them all at once lol.
Also i will check out BergZerg
+My project doesn’t even work atm xD Had a random crash, and now the project doesn’t open lol.

Since you’re talking about using AI… reinforcement learning does a good job with following objects and dodging obstacles.
Example project GitHub - mbaske/ml-dogfight: Reinforcement learning space battle demo made with Unity Machine Learning Agents