I know I did this before but most people look at newer posts and I want to hear what other people want to say.
I have a 3d game where you drag things off the world but I need a cloner that clones my object randomly from x-2 to x2 and goes faster eg: every ten seconds speed increases by original speed *1.5. The other posts did not work for me. I tried nothing but
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Clone : MonoBehaviour
{
public GameObject prefab;
public float x=2;//i dont know what x is
void Start() { StartCoroutine(Cloner()); }
float frequence = 10;
float timer = 0;
void Update()
{
if (timer > 10)
{
timer = 0; frequence = frequence / 0.5f;
}
timer += Time.deltaTime;
}
IEnumerator Cloner()
{
while (true)
{
yield return new WaitForSeconds(frequence);
Instantiate(prefab, new Vector3(Random.Range(0, 1), 0, Random.Range(0, 1)), Quaternion.identity);
Debug.Log("Work!");
}
}
}
Thanks for helping!
↧