# ' Rigidbody ' Short Question

Hi guys…,
How can I save a rigidbody ’ Local Z ’ direction in a variable ? is the following right ?

``````var sphereRight = rigidbody.AddForce(transform.right * 5);
``````

AddForce does not return any values… so that set (=) won’t do anything.

What do you mean by “‘Local Z’ direction”?

You can save the velocity.

I want save Object 1 face direction in a variable to use it for changing Object 2 direction, to make Object1 and Object2 look at the same direction

Details:
There is a scene contains a Cube inside a Sphere, I use the following code to Roll the Sphere, all I need make the cube Always face toward sphere roll direction

Sphere Roll Code:

``````private var _GameManager : GameObject;
var movement 			 : Vector3;
var moveSpeed 			 : float 		 = 6.0f;

function Start()
{

}

function Update ()
{
var forward : Vector3 = Camera.main.transform.TransformDirection(Vector3.forward);
forward.y = 0;
forward = forward.normalized;

var forwardForce : Vector3 = forward * Input.GetAxis("Vertical") * moveSpeed;

var right   : Vector3 = Camera.main.transform.TransformDirection(Vector3.right);
right.y = 0;
right = right.normalized;

var rightForce : Vector3 = right * Input.GetAxis("Horizontal") * moveSpeed;
}
``````

get the forward value off the transform

``````var forwardCache = targ.transform.forward;
``````

that’s the ‘facing’ direction

ok, how to assign it to other object

well if you want to set it on something else… you don’t just set the forward. Because what’s the up (and subsequently right)?

In that case you want the rotation.

``````var orientation = targ1.transform.rotation;
targ2.transform.rotation = orientation;
``````