using UnityEngine;
using System.Collections;
public class CloudCrafter : MonoBehaviour
{
// fields set in the Unity Inspector pane
public int numClouds = 40; // The # of clouds to make
public GameObject [] cloudPrefabs; // The prefabs for the clouds
public Vector3 cloudPosMin; // Min position of each cloud
public Vector3 cloudPosMax; // Max position of each cloud
public float cloudScaleMin = 1; // Min scale of each cloud
public float cloudScaleMax = 5; // Max scale of each cloud
public float cloudSpeedMult = 0.5f; // Adjusts speed of cloud
public bool __________________;
// fields set dynamically
public GameObject [] cloudInstances;
void Awake ()
{
// Make an array large enough to hold all the Clou_ instances
cloudInstances = new GameObject[numClouds];
// Find the CloudAnchor parent GameObject
GameObject anchor = GameObject.Find ("CloudAnchor");
// Iterate through and make Cloud_s
GameObject cloud;
for (int i = 0;i < numClouds;i++)
{
// Pick an int between 0 and cloudPrefabs.Length - 1
// Random.Range will not ever pick as high as the top number
int prefabNum = Random.Range (0, cloudPrefabs.Length);
// Make an instance
cloud = Instantiate (cloudPrefabs [prefabNum]) as GameObject;
// Position cloud
Vector3 cPos = Vector3.zero;
cPos.x = Random.Range (cloudPosMin.x, cloudPosMax.x);
cPos.y = Random.Range (cloudPosMin.y, cloudPosMax.y);
// Scale cloud
float scaleU = Random.value;
float scaleVal = Mathf.Lerp (cloudScaleMin, cloudScaleMax, scaleU);
// Smaller clouds (with smaller scaleU) should be nearer the ground
cPos.y = Mathf.Lerp (cloudPosMin.y, cPos.y, scaleU);
// Smaller clouds should be further away
cPos.z = 100 - (90 * scaleU);
// Apple these transforms to the cloud
cloud.transform.position = cPos;
cloud.transform.localScale = Vector3.one * scaleVal;
// Make cloud a child of the anchor
cloud.transform.parent = anchor.transform;
// Add the cloud to cloudInstances
cloudInstances *= cloud;*
-
}*
- }*
}
The code is a bit long. Can someone explain what does Mathf.lerp mean??? Thanks, Im new to c#.