Im misunderstanding arrays.

basic question:

How can I use arrays, to keep gameobjects, and then another array for the rigidbody.velocity of those gameobjects, and then use that second array to ‘restore’ the rigidbody velocity after returning from pause(doing rigidbody.sleep() then wakeup() )?

UPDATE:

ok here is where im at now.

Here is my new code:

void Update()
{
guiText.text = ("testbool: ") + GameLogicScript.TestBool; // well time for debugging…

// find player
player = GameObject.FindGameObjectWithTag("Player");
asteroids = GameObject.FindGameObjectsWithTag("Asteroid");
savedAsteroidVelocity = new Vector3[asteroids.Length];

// save player velocity and position if were pausing
if(GameLogicScript.GamePaused)
{
	// avoid nullref by checking that player is not dead or something...
	if(player != null)
	{
		// save player if we havent yet
		if(!saved)
		{
			savedPlayerVelocity = player.rigidbody.velocity;
			saved = true;
			loaded = false;
			player.rigidbody.Sleep(); // sleep my precious...
		}
						
		// Save asteroids if we havent yet
		if(!asteroidSaved)
		{
			for(int i = 0; i < asteroids.Length; i++)
			{
				asteroidSaved = true;
				savedAsteroidVelocity _= asteroids*.rigidbody.velocity;*_

* asteroidLoaded = false;*
_ asteroids*.rigidbody.Sleep();
WrappingEnabled = false;
GameLogicScript.SwitchCamPause();
}
}
}
}*_

* // if game not paused anymore load velocity’s and position’s*
* if(!GameLogicScript.GamePaused)*
* {*
* // dont worry about player if were not out of wave 0*
* if(GameLogicScript.wave > 0)*
* {*
* if(player != null)*
* {*
* if(!loaded)*
* {*
* player.rigidbody.WakeUp();*
* player.rigidbody.velocity = savedPlayerVelocity;*
* //player.transform.position = savedPlayerPos;*
* saved = false;*
* loaded = true;*
* }*
* }*

* if(!asteroidLoaded)*
* {*
* for(int i = 0; i < asteroids.Length; i++)*
* {*
* asteroidLoaded = true;*
_ asteroids*.rigidbody.WakeUp();
asteroids.rigidbody.velocity = Vector3.left; //savedAsteroidVelocity;
// savedAsteroidPosition = asteroid.rigidbody.position;
asteroidSaved = false;
}
}
}
WrappingEnabled = true;
}
}*

Now what is going wrong this time, is the “asteroids” aka “enemyObjects” before…
they are getting ALL the same velocity on resume…they dont take back the unique velocity they had before (random directions) and instead all float off in the exact same direction…
you know, reading this now that I posted it, seems like rechecking saved asteroid velocity every frame…does that reset the like…yaknow…velocity??? hmm
I have made serious progress thanks entirely to hijinxbassist! thanks a ton! Hopefully you can see some flaws in what im doing…
PS the asteroids array is gameobjects, and the savedasteroidvelocity array is vector3’s_

Ok, so here is what the code will resemble (sry, i type unity-javascript)

public var enemyObjects:Rigidbody[];
public var savedAsteroidVelocity:Vector3[];
public var timeScale:float;
public var paused:boolean;

function Start()
{
    enemyObjects=GameObject.FindGameObjectsWithTag("Asteroid")as Rigidbody[];
    savedAsteroidVelocity=new Vector3[enemyObjects.Length];
}
function Update()
{
    if(Input.GetButtonUp("p"))
    {
        if(paused)Time.timeScale=timeScale;
        else
        {
            timeScale=Time.timeScale;
            Time.timeScale=0;
        }
    }
    if(Time.timeScale==0)
    {
        if(!paused)
        {
            paused=true;
            for(var i:int=0;i<enemyObjects.Length;i++)
            {
                savedAsteroidVelocity _= enemyObjects*.velocity;*_

}
}
}
else if(paused)
{
paused=false;
for(var i:int=0;i<enemyObjects.Length;i++)
{
enemyObjects_.velocity=savedAsteroidVelocity*;
}
}
}*

This will pause the game when the button “p” is released. If the game is already paused, it will reset the time scale. This code relies on
1) Game is paused using Time.timeScale
2) No new asteroids are added while playing (After Start() is called)_