Record Object's Position

I was wondering how to correctly save an objects position into a variable.
I’m coding in JS, and I tried the following:

yPos = object.localPosition.y;
xPos = object.localPosition.x;
zPos = object.localPosition.z;

That didn’t work, how would I go about doing this?


objectPos = object.transform.position;

Assuming “objectPos” is a Vector3, and “object” is a GameObject.

this plug-in helps record movement of any 3d object, including avatars or complex object with multiple children… all you do is check one flag. Easy to import and use. check out the demo: GameRec unity3d asset tutorial Demo - YouTube

link in asset store; Unity Asset Store - The Best Assets for Game Making