Hey guys, I want to save the players x, y, and z every time the player saves the game.
so pseudo code wise:
if(player presses x)
gameControl.spawnpoint = players.transform.position;
//when the game loads in the start function it will
playerSpawnPoint = gameControl.spawnpoint
public class GameControl : MonoBehaviour {
//spawn point
public const PLAYER_SPWAN_POINT = "Player Spawn Point";//game object name that player spawns from at start of level
public Vector3 spawnPoint;
//the top class is what I have as a set up
//so lets presume I have a class called "SpawnPoint" script saved to the player how will i be able to take its position and save it into gameControl.spawnpoint;
Sorry if that sounds naive, I know how to do it with like a 2D game, such as Action Script 3, but it seems difficult to implement in a 3D game.
I dont understand, you have everything you would need in that script(though not written correctly). player.transform.position will give you a Vector3 of that players position in the world.
savedSpawnPoint = player.transform.position;
Are you asking how you would update the players position from a stored Vector3?
If you are trying to store the player position FROM the player INTO another script containing the “playersPos” variable, you need to set the variable to public, not private
no, you can always ‘this’, but:
‘this’ refers to the script body in which the ‘this’ is written
if you have
public class GameControl : MonoBehaviour {
....
this.anythingHere
}
then the ‘this’ refers to the GameControl. Since monobehaviours have a transform property, you can call this.transform to get the transform of the gameObject attatched