Voici le codes, que j'ai un tout petit peu modifier. Pourrais-tu s'il te plait y jeter un oeil est me dire se que tu en pense.
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemsSpawn : MonoBehaviour
{
#region Variable
//Public
//Private
[SerializeField] private float minX = 0.0f;
[SerializeField] private float maxX = 0.0f;
[SerializeField] private int minItemsToSpawn = 1;
[SerializeField] private int maxItemsToSpawn = 6;
[SerializeField] private GameObject[] items; // potential array of hazards
//[SerializeField] private float timeBetweenSpawns = 0.0f;
[SerializeField] private float timeRandomMin = 0.0f; // Temps minimum entre chaque Spawn
[SerializeField] private float timeRandomMax = 0.0f; // Temps maximum entre chaque Spawn
private bool canSpawn = false;
private float timeBetweenSpawns = 5.0f; // Temps entre les spawn
private int qteItemsToSpawn = 0; // QTE => Quantité, Quantité de projectile à apparaitre.
private int itemToSpawn = 0;
private int itemSpawnCap = 8;
#endregion
#region UnityFunction
// Start is called before the first frame update
void Start()
{
canSpawn = true; //Temp start
}
// Update is called once per frame
void Update()
{
if (canSpawn == true)
{
StartCoroutine("GenerateItems");
}
}
private IEnumerator GenerateItems()
{
canSpawn = false;
timeBetweenSpawns = Random.value * timeRandomMin + timeRandomMax;
qteItemsToSpawn = Random.Range(minItemsToSpawn, maxItemsToSpawn); //Testing Values
yield return new WaitForSeconds(Random.value * timeBetweenSpawns + 2.0f);
for (int i = 0; i < qteItemsToSpawn; i++)
{
Vector3 spawnPos = new Vector3(Random.Range(minX, maxX), Random.Range(8.5f, 12.0f), 0.0f); // Generate a spawnPosition the Hazard
Instantiate(items[itemToSpawn], spawnPos, Quaternion.identity); // Spawn the Hazard
}
canSpawn = true;
}
#endregion
}
Code : Tout sélectionner
Destroy(Instantiate(projectilesParticlesToon.gameObject, transform.position, projectilesParticlesToon.transform.rotation), projectilesParticlesToon.startLifetime);
Code : Tout sélectionner
Gravité Code Description Projet Fichier Ligne Source État de la suppression
Avertissement CS0618 'ParticleSystem.startLifetime' est obsolète : 'startLifetime property is deprecated. Use main.startLifetime or main.startLifetimeMultiplier instead.' Assembly-CSharp H:\Interface\Unity 3D\Project\Cube 3D News\Assets\Data\Scripts\ProjectilesCollision.cs 34 IntelliSense Actif
Enfin pour finir;
Voici le résultat en video qu'en penses-tu ??
Il faudrait que je fasse la même chose mais pour les projectiles maintenant.
https://www.youtube.com/watch?v=05u6lpv4zcs
Serait-il possible de garder le sujet ouvert en en non résolu s'il vous plait, ça évitera de faire encore des tonnes de sujets qui se rapproche surtout si c'est pour le même projet.
Merci encore et toujours pour ton aide qui est vraiment précieuse !