2022-06-02 14:25:22 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class PlayerPosition : MonoBehaviour
|
|
|
|
{
|
|
|
|
public float x, y, z;
|
|
|
|
|
|
|
|
public void SavePosition()
|
|
|
|
{
|
|
|
|
x = transform.position.x;
|
|
|
|
y = transform.position.y;
|
|
|
|
z = transform.position.z;
|
|
|
|
|
2022-10-01 19:28:26 +02:00
|
|
|
PlayerPrefs.SetFloat("player.position.x", x);
|
|
|
|
PlayerPrefs.SetFloat("player.position.y", y);
|
|
|
|
PlayerPrefs.SetFloat("player.position.z", z);
|
2022-06-02 14:25:22 +02:00
|
|
|
}
|
|
|
|
|
2022-12-06 01:20:01 +01:00
|
|
|
public static Vector3 LoadPosition()
|
2022-06-02 14:25:22 +02:00
|
|
|
{
|
2022-12-06 01:20:01 +01:00
|
|
|
var x = PlayerPrefs.GetFloat("player.position.x");
|
|
|
|
var y = PlayerPrefs.GetFloat("player.position.y");
|
|
|
|
var z = PlayerPrefs.GetFloat("player.position.z");
|
2022-06-02 14:25:22 +02:00
|
|
|
|
2022-12-06 01:20:01 +01:00
|
|
|
return new Vector3(x, y, z);
|
2022-06-02 14:25:22 +02:00
|
|
|
}
|
|
|
|
|
2023-01-05 01:30:01 +01:00
|
|
|
|
|
|
|
|
2022-12-06 01:20:01 +01:00
|
|
|
/// <summary>
|
|
|
|
/// ONE BIG SHIT
|
|
|
|
///
|
|
|
|
/// First MainCharacterManager create instance with previously remembered gateway coords :)
|
|
|
|
/// After that we crate new player instance on scene
|
|
|
|
/// And finally: This script is deffaultly assigned to player soo..
|
|
|
|
/// its overwrites Player coords depending on condition in function below
|
|
|
|
/// </summary>
|
2022-06-02 14:25:22 +02:00
|
|
|
void Start()
|
|
|
|
{
|
2022-12-06 01:20:01 +01:00
|
|
|
if (OnMapAppearanceMethod.IsJustLaunched())
|
2022-06-02 14:25:22 +02:00
|
|
|
{
|
2022-12-06 01:20:01 +01:00
|
|
|
transform.position = LoadPosition();
|
|
|
|
|
|
|
|
// I really dont remember if we use this vars anywhere so I just assign new value to make sure I dont break anything :D x = transform.position.x;
|
|
|
|
x = transform.position.x;
|
|
|
|
y = transform.position.y;
|
|
|
|
z = transform.position.z;
|
2022-06-02 14:25:22 +02:00
|
|
|
}
|
|
|
|
}
|
2022-12-06 01:20:01 +01:00
|
|
|
}
|