Getting and sending a gameobjects position to another gameobject.

Hello, I want to pass the position and rotation from one game object A to another game object B (which is not destroyed on load) for storage and then pass back that value to object A when the level is loaded.

I have tried to store it as a transform.position with a vector 3 and as Transform.

how do I get the position of gameobject A

I tried
public Vector3 coordinates;
coordinates = gameobjectA.getcomponent().transform.position;

and I tried

public Transform LastPosition;
LastPosition=gameobjectA.getcomponent.Transform with no luck returned a null exception.

please ignore the typos i am writing this away a pc without monodevelop.

How would you get the position of game objectA to gameobjectsB script? is there a way to get rotation and potition? (is there a way to store transform?)

Many thanks, Dimitris.

You can hold it in a static variable so it will be persistent and hold the value even though the scenes change.

The syntax is incorrect on both lines you’ve written. It go like this;

static public Vector3 pos;
pos = a.transform.position;    //Or a.GetComponent<Transform>().position with your way