This question was
closed Jan 15, 2019 at 11:41 AM by
tormentoarmagedoom for the following reason:
The question is answered, right answer was accepted
Question by
craftingtycoon · Jan 15, 2019 at 11:36 AM ·
instantiateprefabs
How to edit new clone properties?
Hello!
I need to instantiate different objects, but all of them will not be identical. Some variables in the scripts need to be different. I need to have 1 diferent prefab for each configuration? or there is a method to edit them?
Thankyou guys!
Comment
Best Answer
Answer by tormentoarmagedoom · Jan 15, 2019 at 11:39 AM
Good day.
I supose you know how to use Instantiate()
So now, you only need to assign a variable before instantiate to edit anythig from it like any other object
GameObject NewObject = Instantiate (Prefab, Position, Rotation);
Now this new object is stored in NewObject variable, so you can do anything to it like any other object
NewObject.GetComponent<YourScript>().YourVariable=valueYouWant;
or move, destroy, change, paint.. anything...
NewObject.transform.position = Vector3.zero();
Good luck! Bye!