Initial commit

Basic plant generation and lifecycle implemented.
This commit is contained in:
2025-08-06 21:04:49 -07:00
parent 7c2cb4242f
commit 3a909fda70
94 changed files with 8592 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 38166df52fd8da047ab0e315ea28f767
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6bb4d993508c61c4e837e5ba33bc683a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

@@ -0,0 +1,130 @@
fileFormatVersion: 2
guid: d2f419117b124db4d99c72a8f22cad44
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 459 KiB

+130
View File
@@ -0,0 +1,130 @@
fileFormatVersion: 2
guid: bba241c3ea31a44499709c726e59b655
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
+96
View File
@@ -0,0 +1,96 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8704148140120826694
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 958940264986333582}
m_Layer: 0
m_Name: Bush
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &958940264986333582
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8704148140120826694}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3839943562410999596}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &3657064933162703047
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 958940264986333582}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -90
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
propertyPath: m_Name
value: stylized bush
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
--- !u!4 &3839943562410999596 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
m_PrefabInstance: {fileID: 3657064933162703047}
m_PrefabAsset: {fileID: 0}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f89e947d8ef527b4a939de047e8e2817
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,107 @@
fileFormatVersion: 2
guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7
ModelImporter:
serializedVersion: 22200
internalIDToNameTable: []
externalObjects: {}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1bc84950781f7264491a8886c8f96056
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,48 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4454294744824292065
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3972681746881930118}
- component: {fileID: 1392466578619433816}
m_Layer: 0
m_Name: PlantPrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3972681746881930118
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4454294744824292065}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1392466578619433816
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4454294744824292065}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78a4559363f05014eb7e00692e5865b6, type: 3}
m_Name:
m_EditorClassIdentifier:
plantModels:
- {fileID: 919132149155446097, guid: e3d2efed8d0c55a4ca5bfa35b9f6c6c7, type: 3}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 20d627f37ea26f346bf0c20e82a4152a
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 429b4c8a929dcbc4cba767dae2e1429a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+28
View File
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using UnityEngine;
public class Core : MonoBehaviour
{
[SerializeField] public NutrientController nutrientCont;
[SerializeField] public PlantController plantCont;
[SerializeField] public Terrain ground;
public static Core instance;
private void Awake()
{
instance = this;
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6cd62492e09975242bf83bc1a18d458d
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5452b02ced2e98e4ca75c1ec896ae274
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using UnityEngine;
public class AnimalController : MonoBehaviour
{
[SerializeField] List<_IAnimal> animalPrefabs;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 57bdcc6b5435f73478e14cc53eacec2f
@@ -0,0 +1,10 @@
using UnityEngine;
public class AnimalRabbit : _IAnimal
{
[SerializeField] GameObject visualPrefab;
public AnimalRabbit()
{
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7307a57df8e8a93418bff241ef45a13d
@@ -0,0 +1,41 @@
using UnityEngine;
public class _IAnimal : MonoBehaviour
{
[SerializeField] GameObject model;
// Inherent values
public int foodChainPlacement;
public int gender;
public float speed;
public float sightDist;
public float weightHunger;
public float weightBreed;
// Current values for need of each
public float health;
public float breed;
Collider sightSphere;
void Start()
{
}
void FixedUpdate()
{
}
public void Eat()
{
}
public void Breed()
{
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1d547cd47e0ec2545925c3496ddd02fa
@@ -0,0 +1,43 @@
using UnityEngine;
public class NutrientController : MonoBehaviour
{
private float[,] nutrientMap;
[SerializeField, Range(10, 100)] int sizeX;
[SerializeField, Range(10, 100)] int sizeY;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
nutrientMap = new float[sizeX, sizeY];
for(int r = 0; r < sizeX; r ++)
{
for(int c = 0; c < sizeY; c++)
{
nutrientMap[r, c] = 1;
}
}
}
// Update is called once per frame
void Update()
{
}
public float GetNutrients(float x, float y)
{
int locX = Mathf.FloorToInt(x * sizeX);
int locY = Mathf.FloorToInt(y * sizeY);
return nutrientMap[locX, locY];
}
public void UseNutrients(float x, float y, float used)
{
int locX = Mathf.FloorToInt(x * sizeX);
int locY = Mathf.FloorToInt(y * sizeY);
nutrientMap[locX, locY] -= used;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 881bafe4bc0f5d747a4fa68fb5fc9126
+59
View File
@@ -0,0 +1,59 @@
using UnityEngine;
using System.Collections.Generic;
public class Plant : MonoBehaviour
{
private float healthMax;
private float healthCurrent;
private float nutrientNeed;
private float growthRate;
public bool isAlive;
private GameObject visualPrefab;
public GameObject visual;
public void SetVisual(GameObject visualPrefab)
{
this.visualPrefab = visualPrefab;
}
public void SetValues(float healthMax, float nutrientNeed, float growthRate)
{
this.healthMax = healthMax;
this.nutrientNeed = nutrientNeed;
this.growthRate = growthRate;
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
private void Start()
{
visual = Instantiate(visualPrefab, transform);
healthCurrent = healthMax;
isAlive = true;
}
// Update is called once per frame
void Update()
{
Terrain terrain = Core.instance.ground;
NutrientController nutrientCont = Core.instance.nutrientCont;
float x = transform.position.x / terrain.terrainData.size.x;
float y = transform.position.y / terrain.terrainData.size.y;
float nutrientsAvailable = nutrientCont.GetNutrients(x, y);
if(nutrientNeed > nutrientsAvailable)
{
healthCurrent -= Time.deltaTime * (0.1f * healthMax);
}
else
{
visual.transform.localScale += visual.transform.localScale * (growthRate * Time.deltaTime);
nutrientCont.UseNutrients(x, y, (nutrientNeed * Time.deltaTime));
}
if (healthCurrent <= 0)
{
isAlive = false;
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 78a4559363f05014eb7e00692e5865b6
@@ -0,0 +1,53 @@
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class PlantController : MonoBehaviour
{
[SerializeField] GameObject plantPrefab;
[SerializeField] List<GameObject> plantModels;
List<GameObject> plants;
float xBound;
float zBound;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
plants = new List<GameObject>();
Terrain terrain = Core.instance.ground;
xBound = terrain.GetComponent<Terrain>().terrainData.size.x;
zBound = terrain.GetComponent<Terrain>().terrainData.size.z;
for (int i = 0; i < 100; i++)
{
GameObject newPlant = Instantiate(plantPrefab, transform);
newPlant.GetComponent<Plant>().SetVisual(plantModels[Random.Range(0, plantModels.Count - 1)]);
newPlant.GetComponent<Plant>().SetValues(Random.Range(10f, 100f), Random.Range(0f, 0.5f), Random.Range(0f, 0.5f));
float x = Random.Range(0, xBound);
float z = Random.Range(0, zBound);
float y = terrain.SampleHeight(new Vector3(x, 0, z));
Vector3 normal = terrain.terrainData.GetInterpolatedNormal(x / xBound, z / zBound);
newPlant.transform.LookAt(normal);
newPlant.transform.Rotate(new Vector3(90, 0, 0));
Vector3 newPlantPos = new Vector3(x, y, z);
newPlant.transform.position = newPlantPos;
plants.Add(newPlant);
}
}
// Update is called once per frame
void Update()
{
for(int i = 0; i < plants.Count; i ++)
{
GameObject currentPlant = plants[i];
Plant plantI = currentPlant.GetComponent<Plant>();
if(!plantI.isAlive)
{
currentPlant.SetActive(false);
plants.Remove(currentPlant);
Destroy(currentPlant);
i--;
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c9529d38afda2d141bd48565721ab95f