Skip to content
Snippets Groups Projects
Commit bb07314c authored by Clem's avatar Clem
Browse files

bla bla bla

parent 8f2b48b9
Branches
No related tags found
No related merge requests found
/*
Clément Géraudie
/**
* Fichier : V7.cs
*
* Auteur : Clément GERAUDIE
* Date : Avril 2022
* Groupe : TP 4C
*
* Résumé du fichier :
*
* Cette classe permet de générer un terrain aléatoire et d'y ajouter un chemin aléatoire.
*
*/
using UnityEngine;
public class V7 : MonoBehaviour
......@@ -166,8 +177,6 @@ public class V7 : MonoBehaviour
// On va calculer la hauteur du point par rapport aux coordonées d'avant, et d'après
if(x+indexLargeur-1 < 0 || y+indexLargeur-1 < 0){
hauteurAvant = 0;
}
else{
hauteurAvant = terrain.terrainData.GetHeight(x+indexLargeur-1, y+indexLargeur-1);
......@@ -196,7 +205,8 @@ public class V7 : MonoBehaviour
Debug.Log("hauteur = " + hauteur);
terrain.terrainData.SetHeights(x+indexLargeur, y+indexLargeur, new float[,] { { hauteur, hauteur }});
if (indexLargeur == 3)
int obstacle = Random.Range(0, largeurDuChemin);
if (indexLargeur == obstacle)
{
cmptCubes++;
if (cmptCubes == 5)
......@@ -213,24 +223,6 @@ public class V7 : MonoBehaviour
}
}
void OnDrawGizmosSelected()
{
if(debugMode){
// On définie les paramètres de la gizmo sphere
Gizmos.color = Color.red;
if(pointsDuChemin != null)
{
float xPositionMultiplier = terrain.terrainData.size.x / heightmapWidth;
float yPositionMultiplier = terrain.terrainData.size.z / heightmapHeight;
// On va tracer une gizmo sphere sur chaque point du chemin
for(int i=0; i<nombreDePointsAGenerer; i++)
{
Gizmos.DrawSphere(new Vector3(pointsDuChemin[0, i] * xPositionMultiplier, 0, pointsDuChemin[1, i] * yPositionMultiplier), largeurDuChemin);
}
}
}
}
float[,] GenerateHeights()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment