Void Update not being called in this particular script

I am trying to recreate space invaders for a school project and I have been having difficultly with the void Update() not being called in this particular script. I know that script works if I do the stuff in the void Update in a new script and attach it to the same game object. I just can not figure out why it will not work within the larger script.Thanks

using UnityEngine;

public class Invaders : MonoBehaviour
{
    public Invader[] prefabs;       //Array of prefabs called invaders
    public float speed = 5f;
    public int rows = 5;
    public int columns = 11;

    private void Awake()
    {
        for (int row = 0; row < this.rows; row++)                                                    //Spacing between invaders vertically
        {
            float width  = 2.0f * (this.columns -1);                                                 //This give me the total width and height of the columns and rows based on the
            float height = 2.0f * (this.rows - 1);                                                   //spacing that is set multiplied by the row or column take away 1
            Vector3 centering = new Vector2(-width / 2, -height / 2);                                //Finding the centre of the grid pattern
            Vector3 rowPosition = new Vector3(centering.x, centering.y + (row * 2.0f), 0.0f);        //setting the row position using the centered x and y values

            for (int col = 0; col < this.columns; col++)
            {
                Invader invader = Instantiate(this.prefabs[row], this.transform);                    //spawning the Invaders from the prefabs within the row. It also stores the result of this to invader
                Vector3 position = rowPosition;
                position.x += col * 2.0f;                                                            //Spacing between the invaders horizontally
                invader.transform.localPosition = position;
            }
        }
    }

    void Start()
    {

    }

    void Update()
    {
        transform.Translate(speed * Time.deltaTime, 0, 0);  
    }
}
  1. Check if both the script is enabled and the GameObject it’s on is active in the hierarchy. Both are checkboxes you can see in the inspector. Also that the script is added to the correct GameObject.

  2. Put a Debug.Log in it to make sure you are diagnosing it correctly, that the Update is actually not called, and not just that the logic of your code is unexpectedly having no effect.

Please post general scripting problems on the Scripting forum please. The 2D forum should be used to post about 2D specific things.

I’ll move this post there.

Thanks.

So you know, it’s just called “Update”. void is just a keyword meaning that it doesn’t return anything, it’s not its name.

Here’s a useful link on how to perform debugging. This’ll help you narrow down your problem such as adding in a Debug.Log in the “Update” method as suggested above; something like Debug.Log("It's alive")