- Home /
Instantiating glass shards(gibs) when light explodes.
I am making a horror game and I want a light that has been shorting out to suddenly break and shards (gibs) of glass fall to the ground.
How would I go about instantiating gibs in a circular pattern around the light that might give a realistic feel to glass shards falling from the light.
I was trying to randomly position the gibs around the position of the light but it's not looking well.
for(int i = 0; i< amountOfShards;i++)
{
randomNum = Random.Range(-0.5f,0.5f);
Rigidbody explodingShard;
randomPos = pos + new Vector3(randomNum, 0, randomNum);
explodingShard = Instantiate(shard, randomPos, transform.rotation) as Rigidbody;
}
Does anyone have a better method of doing this?
Here is an image of the light:
Answer by VesuvianPrime · Sep 21, 2014 at 11:16 AM
Your best approach here would be to create a new prefab and add your shards as children.
At runtime you can swap the light model for the gibs prefab and apply forces at random.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Issues with instantiated prefabs 1 Answer
How do you Instantiate a button as a child object of a canvas? 0 Answers