- Home /
How do I explode multiple clones out of an object?
How do I explode multiple clones out of an object?
I have an asteroid which when killed I want to create multiple smaller clones of itself.
for (int i = 0; i < 3; i++) {
Transform clone = Instantiate(transform, transform.position, Quaternion.identity) as Transform;
Vector3 scale = transform.localScale;
scale.x /= 2;
scale.y /= 2;
scale.z /= 2;
clone.localScale = scale;
}
But because they are rigid bodies they just fly out from each other. How can I instantiate them so the explode out in a uniform pattern?
Answer by GrKl · Jan 03, 2014 at 11:11 AM
I think you should not instantiate them all at the exact same location as they are rigid bodies add a random Vector3 to their position for that
then you should add a force to get them to move away from the original transform.position of the first asteroid
Your answer
Follow this Question
Related Questions
Instantiate(this.gameObject) causing crash 2 Answers
Deleting an instance 2 Answers
How do I properly duplicate an object in a editor script? 3 Answers
I dont want "(clone)" but how to change? 2 Answers
MemberWiseClone Protected?!? 1 Answer