Make objects randomly fall

I am making a 3D game where objects are supposed to fall randomly everywhere as the player tries to avoid them. There are 4-5 different objects and they all are supposed to disappear after 5 seconds (NOT when they fall off of the screen). I’ve hear that there is a way to use the random.range function, but am not well educated in that field.

You can destroy a GameObject with Destroy(obj, timeDelay); where ‘obj’ is the object to destroy and ‘timeDelay’ a float.

Random.range(float min, float max) returns a random float between min and max. You can use that to place your objects at random positions by changing their transform position, for example: obj.transform.position = new Vector3(Random.Range(0, 10), 10, Random.Range(0, 10)); places ‘obj’ at y = 10 and a random position where x and z are more than 0 and less than 10. You can place this in a component on the objects themselves or on the one that creates them.