Can I change each prefab clone for different value ?
Hello,
I am a new to Unity. I have a problem about prefab clone. I have a prefab and it have script that control its value. When I clone it and try to change its value. All my clone value have changing too.
Can I change a value of each prefab clone and don't affect to the other clone ?
This is script for my prefab.
private float minSpeed=1.0f;
private float maxSpeed=3.0f;
void Update () {
minSpeed += 0.5f;
maxSpeed += 1.0f;
//When I change minSpeed and maxSpeed. All clones are change its speed too. But I want to set a different speed for each clone.
float charSpeed = Random.Range (minSpeed, maxSpeed);
gameObject.transform.position += new Vector3 (-charSpeed * Time.deltaTime, 0.0f, 0.0f);
}
Thank you for solution.
Comment
Answer by YoungDeveloper · Sep 05, 2015 at 04:21 PM
Your instantiate from prefab, so all of your clones contains this script, so all of them are updating their own copy of min and max speed.