Find GameObjects Vector3

I recently worked on the save / load function. I want to save the current one Vector3after clicking the "Save" button. However, I cannot figure out how to find it GameObjects Vector3.

There are many tutorials on the Internet, but they are all in JS.

+4
source share
2 answers

A gameObject Vector3is his transform.position. Therefore, if you have a link to it, you can simply use:

Vector3 lastPosition = gameObject.transform.position;

Or, if the save script is in gameObject, it can directly reference the conversion:

Vector3 lastPosition = transform.position;

See the Unity Docs for more information .

+6
source

, , vector3, x, y, z float. , , . , : " GameObject?":)

+1

Source: https://habr.com/ru/post/1619756/


All Articles