So this is kinda related. The code below is self explanatory. Somehow, it always fails to affect one of the molecules. If there are 10 molecules, only 9 will be affected. 1 is always left out. Any idea why?

Code:
function DecreaseVolumeInEngine()
{
	VolumeChanging = 1;
	
	/*Cycle through molecules and move them all to spawn point before deleting the container.
	Otherwise, the container will shrink past the location of some molecules, leaving them
	outside*/
	var teleported = 0;
	you = ent_next(NULL);
	while(NoOfMolecules > teleported)
	{
		ENTITY* NextMolecule = you;
		you = ent_next(you);
		if(NextMolecule.skill51) //if it has a skill51, meaning its a molecule
		{
			NextMolecule.x = (SpawnPoint.x + (2000*V)) + random(100);
			NextMolecule.y = (SpawnPoint.y + (2000*V)) + random(100);
			NextMolecule.z = (SpawnPoint.z + (2000*V)) + random(100);
		}
		teleported+=1;
		wait(1);
	}
	
	ent_remove(Container);
	Container = ent_create("HollowCube.WMB", vector(0, 0, 0), ResizeTheCube);
	wait(-1);
	VolumeChanging = 0;
	wait(1);	
	
	//Center the camera behind the cube. New camera location is dependent on V (Volume of Cube)
//	camera.x -= V * 13000;
//	camera.y += V * 5000;
//	camera.z += V * 5000;
//	wait(1);
}



Last edited by rayp; 04/12/14 00:20. Reason: added code tags ... press edit to see how its done