# Collsions - Objects just passing through each other

I’m halfway through my Game Production but i’m having trouble with collisions, each object (that I want to collide) has a rigidbody, isKinematic turned off, and a relative force added plus a physics material added to the mesh collider, but whenever I run the program and set it so that a certain amount of objects collide with each other, they just pass straight through each other as if the colliders weren’t there.

However my bullet script works fine when detecting that it has hit something, but I thought the Unity Engine was supposed to be able to handle this kind of stuff with world collisons without the need for extensive coding.

Here is my script so far (for the objects I want to collide)

#pragma strict

var object : GameObject;

function Start()

{

for (var i : int = 0; i < 100; i++)

``````{
var AsteroidSpeed : Vector3 = Vector3 (0,0,1);
var position : Vector3 = Random.insideUnitSphere * 500;
transform.position.x = position.x;
transform.position.y = position.y;
transform.position.z = position.z;
var rotation = Quaternion.Euler ( Random.Range (0, 360), Random.Range (0, 360), Random.Range (0, 360) );

Instantiate (object, position, rotation);
rigidbody.isKinematic = false;
rigidbody.detectCollisions = true;
rigidbody.MovePosition ( rigidbody.position + AsteroidSpeed * Time.deltaTime);
yield WaitForSeconds (0.0001);

}
``````

}

Any help would be much appreciated as I’m banging my head against the wall here

What do you expect this code to do? It actually repeat 100 times a weird sequence: generate a random point inside a sphere of radius 500 centered at (0,0,0), move its owner object to this random point, rotate it randomly, instantiate a clone of object at this position and let it alone there, then move the owner object a little in the Z direction, wait for the next frame and repeat the sequence.

If you want to generate 100 asteroids at random positions and moving to random directions, use a script like this attached to some scene object (not the asteroids!):

```var object: GameObject; // drag asteroid prefab here
var speed: float = 10; // set the asteroid speed

function Start(){
for (var i : int = 0; i < 100; i++){
// create an asteroid at random position and direction:
var position : Vector3 = Random.insideUnitSphere * 500;
var rotation = Random.rotation;
var asteroid: GameObject = Instantiate (object, position, rotation);
// set the asteroid velocity to its forward direction:
asteroid.rigidbody.velocity = asteroid.transform.forward * speed;
}
}
```