Question by
DiegoBittencourt · Aug 25, 2015 at 02:49 PM ·
sizechangeclonecreate
Create a clone and change his size
Hello, I'm working in a 2D game and what I'm trying to do is very simple I guess, but I can't solve by myself: "When the player click in a object, create a clone and put the clone at X, Y and change his size. AND if the player click on the other object (a green background) destroy the clone."
Can someone help me on this, please? Thanks for your attention!
Comment
Best Answer
Answer by SuperRaed · Aug 25, 2015 at 07:28 PM
I see you need at least 2 scripts one for each object the original and the clone
original would have void OnMouseDown(){// called when the object is clicked on
Instantiate ( a GameObject variable, a Vector3 for position , Quaternion.identity );
}
as for the clone use the same method but this time call Destroy()
void OnMouseDown(){
Destroy(gameObject);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612001320im_/https://answers.unity.com/themes/thub/images/avi.jpg)