Spawn with incorrect direction. some of the time

so, unknown complexity, i think performance, and target is kind of a bs subject for this, as i don’t think it technically matters. I have a distinct issue, and i’m going to try to give all the relevant info for it, so here it goes.

quick description: when I begin play, i have a number of enemies that are to spawn after a certain amount of time, which works fine. I had this problem before, and changing my update of time.deltatime into fixed update solved it, but i’m not using that for this one. when they spawn, they are instantiated to spawn in a specific direction, specifically spawner point 1’s direction. some of them in the order start not doing that.

Edit: Maybe the question was too implied, so here it is: why is it doing this, and/or does anyone know how to solve it?

whytheaf

that shows what i mean, sometimes it’s one, sometimes every other one.

all relevant code (that i’m aware of):

spawners at the bottom

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class NWaveWaypoints : MonoBehaviour
{
    public GameObject[] ships;
    public Transform[] spawnerPoints;
    public int counter;
    float spawnStart;
    float spawnTimer = 0.5f;
    // Start is called before the first frame update
    void Start()
    {

    }

    private void OnEnable()
    {
        counter = 0;
        spawnStart = Time.time;

    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (Time.time > spawnStart)
        {
            if (counter < ships.Length)
            {
                GameObject clone = Instantiate(ships[counter], spawnerPoints[0].transform.position, spawnerPoints[0].transform.rotation);//, spawnerPoints[0].transform.position, Quaternion.Euler(0, 0, 0));
                //clone.transform.position = spawnerPoints[0].transform.position;
                //clone.transform.rotation = spawnerPoints[0].transform.rotation;
                clone.GetComponent<Path1>().waypoints = spawnerPoints;
                clone.GetComponent<Path1>().rotspeed = 3f;
                clone.GetComponent<Path1>().speed = 1.13f;
                clone.GetComponent<Path1>().AssignWayPoints();
                spawnStart = Time.time + spawnTimer;
                counter++;
            }
        }
        if (counter >= ships.Length)
        {
            gameObject.SetActive(false);
        }
    }
}

the spawners on top

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class WaypointSpawns : MonoBehaviour
{
    public GameObject[] ships;
    public Transform[] spawnerPoints;
    public int counter;
    float spawnStart;
    float spawnTimer = 0.5f;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    private void OnEnable()
    {
        counter = 0;
        spawnStart = Time.time;

    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (Time.time > spawnStart) {
            if (counter < ships.Length)
            {
                GameObject clone = Instantiate(ships[counter], spawnerPoints[0].transform.position, spawnerPoints[0].transform.rotation);
                //clone.transform.position = spawnerPoints[0].transform.position;
                //clone.transform.rotation = spawnerPoints[0].transform.rotation;
                clone.GetComponent<Path1>().rotspeed = 1.75f;
                clone.GetComponent<Path1>().waypoints = spawnerPoints;
                clone.GetComponent<Path1>().AssignWayPoints();
                spawnStart = Time.time + spawnTimer;
                counter++;
            }
        }
        if (counter >= ships.Length) {
            gameObject.SetActive(false);
        }
    }
}

enemy ship

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

public class Path1 : MonoBehaviour
{
    public Transform[] waypoints;
    [SerializeField] Vector3[] points;
    public int currentWP = 0;
    public Vector3 wpTarget;
    public Rigidbody rb;
    public float speed;
    public float rotspeed = 1f;
    float waypointDistance = 0.5f;
    // Start is called before the first frame update
    void Start()
    {
        
    }
    public void AssignWayPoints()
    {
        points = new Vector3[waypoints.Length];
        for (int i = 0; i < waypoints.Length; i++)
        {
            points[i] = waypoints[i].transform.position;
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (points.Length > 0)
        {
            // i need current wp to be a number form 0 to length -1
            wpTarget = points[currentWP];
            Debug.Log(currentWP);
            if (Vector3.Distance(transform.position, wpTarget) < waypointDistance)
            {
                if (currentWP == waypoints.Length - 1)
                {
                }
                else
                {
                    currentWP++;
                }
            }
            TurnTowardWayPoint();
        }
    }
    void FixedUpdate()
    {
        rb.velocity = transform.forward * speed;
    }
    void TurnTowardWayPoint()
    {
        if (wpTarget - transform.position != Vector3.zero)
        {
            Quaternion lookatWP = Quaternion.LookRotation(wpTarget - transform.position);
            transform.rotation = Quaternion.Slerp(transform.rotation, lookatWP, rotspeed * Time.deltaTime);  
        }
    }
}

now, i say this is all the relevant code, because i’m reasonably sure after checking multiple times that these are the only actual scripts running in the scene.

i can see no reason that any of the ships should spawn in any direction except what the first spawn points direction is, and for reference to that…

small edit: there appears to be some small lag spike when one spawns off angle, but only in editor, no spike in a build.