dontdestroyonload and vector3

So here’s a quick question. Supposing each terrain of my scene exists in the same vector3, can I use dontdestroyonload to not only have my gameobject persist into the next scene, but to also exist in its current vector3?

Thanks
-Richard

Yes

Excellent. Is there documentation on this task, specifically? I’m assuming I would have to get the parent object’s current vector3 information?

Thanks
-Richard

If you just call

DontDestroyOnLoad(gameObject);

In your Awake() function, it will carry over to the next scene in the same position it already is.

Regards,

-Lincoln Green

I think you have a general misconception about GameObject, Vector3 and Transform.

GameObject is basically a container which contains other things.

The Transform contains the position, rotation, scale and other relevant data of that game object. Everygame object also must have a transform (it’s added by default).

A Vector3 is only a three-dimensional vector which contains x, y and z values for either rotation, position or scale. It’s a complex datatype if you want see it that way.

You can only make gameobjects to be not destroyed on scene load. Everything inside it will not be destoryed neither (components like transform, Collider etc.).

i.e.

gameObject.transform.position = new Vector3(1,2,3); // set the position of the transform
gameObject.transform.rotation.eulerAngles = new Vector3(0,90,0); // set rotation in euler angles, as rotations is normally saved as Quaterion
gameObject.transform.scale = new Vector3(1,1,1); // set scale

as you see, all three of them use Vector3, but they do different thing. The first does position, second does rotation and the third does scale.