method not working(help?)

i have a 2d game with unity 2021.1 and I’m trying to summon multiple prefabs for a boss attack. here is the code:

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

public class Boss : MonoBehaviour
{
    [SerializeField] Rigidbody2D myRigidbody;
    [SerializeField] Animator myAnimator;
    [SerializeField] float jumpDelay;
    [SerializeField] float jumpHeight;
    [SerializeField] GameObject minion;
    [SerializeField] int maxMinionSpawn;
    playerMovement player;

    void Start()
    {
        spawnMinions();
    }

    void OnCollisionEnter2D(Collision2D other)
    {
        myAnimator.SetBool("hasLanded", true);
        myAnimator.SetBool("isJumping", false);
        Invoke("jump", jumpDelay);
    }

    void jump()
    {
        myAnimator.SetBool("hasLanded", false);
        myAnimator.SetBool("isJumping", true);
        myRigidbody.velocity = new Vector2 (Random.Range(-5, 5), jumpHeight);
    }

    void spawnMinions()
    {
        int minionCount = Random.Range(1, maxMinionSpawn);
        for (int i = 0; i > minionCount; i++)
        {
            Debug.Log("i have summoned my minions, you jerk!");
            Instantiate(minion, transform.position, transform.rotation);
        }
    }
}

and I tried to use it in a Start() method, and it didn’t call the method. I know it’s error free because there are no error messages and how else am i to start the project anyways but please help?

I believe you want i < minionCount

1 Like