{
// souls Random.range(1,4) !!!
Instantiate(souls,transform.position,transform.rotation);
// souls = prefab object with collider and rigidbody.
}
when i kill my enemy, his soul drop down as orbit or ball, good thing. This soul should not effect from the physic around it. like if something hit it, it moves. how to do this ?
What components do the souls have? Sounds like you have given them a collider and a rigidbody. Not sure if the rigidbody is needed though as that will make it use physics. so if possible remove that. For the collider you could set it to a trigger so that other objects pass through it.
So, they should react to physics (in this case gravity) but not be able to be touched by other objects. In that case use collision layers
Pseudo code:
var amount = Random.Range(1, 4);
int count = 0;
while(count < amount);
{
Instantiate(blah blah);
count++;
}
As a warning btw, Random.Range(int, int) is different from Random.Range(float, float). For the int version the max (second param) is exclusive where in the float version it is inclusive. Using above sample:
Random.Range(1, 4) → return 1-3
Random.Range(1f, 4f) → return 1-4