J'ai un code pour les tracets des boules que je tire, et j'aimerai savoir comment changer la couleur a chaque tire , ou alors a chaque boules qui apparait, j'ai essayer avec le Color.Lerp mais ceci n'est qu"'un gradiant, et je cherche vraiment que chacun des boules soit different:
Code : Tout sélectionner
Vector3[] array = new Vector3[this.path.count * 2u];
Vector2[] array2 = new Vector2[this.path.count * 2u];
Color[] array3 = new Color[this.path.count * 2u];
int[] array4 = new int[(this.path.count - 1u) * 6u];
float timeStamp = this.path.points[0].timeStamp;
float num3 = this.path.points[(int)((uint)((UIntPtr)(this.path.count - 1u)))].timeStamp - this.path.points[0].timeStamp;
float num4 = 1f / num3;
Color color = new Color(1f, 1f, 1f, 0f);
int num5 = 0;
while ((long)num5 < (long)((ulong)this.path.count))
{
PathPoint pathPoint = this.path.points[num5];
float num6 = pathPoint.timeStamp - timeStamp;
float num7 = num6 * num4;
Vector3 vector;
if (num5 == 0)
{
vector = pathPoint.position - this.path.points[num5 + 1].position;
}
else
{
vector = this.path.points[num5 - 1].position - pathPoint.position;
}
Vector3 a = new Vector3(-vector.z, 0f, vector.x);
a.Normalize();
Vector3 a2 = a * Mathf.Sin(pathPoint.timeStamp * 100f) * 0.025f;
array[num5 * 2] = pathPoint.position + a * this.size * 0.5f + a2 * this.waveRatio;
array[num5 * 2 + 1] = pathPoint.position + -a * this.size * 0.5f + a2 * this.waveRatio;
Color color2;
if (num5 == 0 || (long)num5 == (long)((ulong)(this.path.count - 1u)) || num2 > num6 + num)
{
color2 = color;
}
else if (num2 > num6)
{
color2 = new Color(1f, 1f, 1f, 1f - (num2 - num6) / num);
}
else
{
color2 = Color.white;
}
array3[num5 * 2] = color2;
array3[num5 * 2 + 1] = color2;
array2[num5 * 2] = new Vector2(num7 * this.uvScale, 0f);
array2[num5 * 2 + 1] = new Vector2(num7 * this.uvScale, 1f);
if (num5 > 0 && !pathPoint.split)
{
array4[(num5 - 1) * 6] = num5 * 2 - 2;
array4[(num5 - 1) * 6 + 1] = num5 * 2 - 1;
array4[(num5 - 1) * 6 + 2] = num5 * 2;
array4[(num5 - 1) * 6 + 3] = num5 * 2 + 1;
array4[(num5 - 1) * 6 + 4] = num5 * 2;
array4[(num5 - 1) * 6 + 5] = num5 * 2 - 1;
}
num5++;
}
Mesh mesh = base.GetComponent<MeshFilter>().mesh;
mesh.Clear();
mesh.vertices = array;
mesh.uv = array2;
mesh.colors = array3;
mesh.triangles = array4;
}
Merci d'avance