Freezing an object and keeping it's velocity

Consider the following: I have a cube, which has a function called Freeze. It sets the cube rigidbody to kinematic, and when called again, it unfreezes said cube. I was trying to implement a way for the cube, after being “unfrozen”, re-adding it’s speed from BEFORE it was frozen, to give and idea of it being frozen in space-time. However, the code I wrote does not work. Is there a way to do this?

Code I used (C#):

void Freeze() {

	if (isSelected) {  
		if (!rb.isKinematic) {
			retainedSpeed = rb.velocity;
			print (retainedSpeed);
			rb.isKinematic = true;
			cubeMesh.materials [1].SetColor("_EmissionColor", freezeColor);
		} else if (rb.isKinematic) {
			rb.isKinematic = false;
			rb.AddForce (retainedSpeed);
			cubeMesh.materials [1].SetColor ("_EmissionColor", defaultColor);

		}
	}
}

Force and velocity are two different things - what you’re going to want to do is replace rb.AddForce (retainedSpeed); with rb.velocity = retainedSpeed;

Force causes acceleration, which changes velocity OVER TIME whereas setting the velocity directly changes velocity instantly.