Hey All,
So I’ve got a script that spawns clouds from prefabs at random locations, I’m trying to get them so they move in a direction (as clouds do) however I can’t seem to get it to work.
public Transform cloud;
public float cloudSpeed = 1;
// Use this for initialization
void Start() {
// Spawn clouds across sky
System.Random ran = new System.Random();
int xValue = ran.Next(90, 100);
for (int y = 0; y < 7; y++) {
for (int x = 0; x < 7; x++) {
Instantiate(cloud, new Vector3(ran.Next(-280, 280), ran.Next(80, 100), ran.Next(-270, 270)), Quaternion.identity);
}
}
// Update is called once per frame
void Update () {
cloud.transform.Translate(cloud.transform.forward * cloudSpeed * Time.deltaTime);
}
If I remove “cloud.” from that second to last line ("cloud.transform.Translate(cloud.tra…) and it moved the object the script is attached to.
Any help would be greatly appreciated and apologies if this is a noob question, I’ve tried the docs too.
Thanks!