I’ve been trying to make my own save and load features for my game. I got everything working until the last few lines
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity;
using System.Security.Cryptography;
public class Player : MonoBehaviour
{
public void SavePlayer ()
{
SaveSystem.SavePlayer(this);
// Debug.Log("SaveSYstem");
}
public void LoadPlayer()
{
PlayerData data = SaveSystem.LoadPlayer();
Debug.Log($"LoadingSystem {data.position[0]}, {data.position[1]}, {data.position[2]}");
Vector3 position;
position.x = data.position[0];
position.y = data.position[1];
position.z = data.position[2];
transform.position = position;
}
}
I’ve tried looking up solutions online but could not find any.
i have this connect to my player and have buttons that when pressed load the SavePlayer() and LoadPlayer()
the save player works but when i try to hit my load button it doesn’t move my player. I expected it to move my player and it doesn’t work. I check and it loads the saved position too.
Maybe? Depends on the code. I assure you if you DebugLog the position right after you change it in this script it will have been changed. Something else is overwriting it later.
i commented my movment script out and tried it out and that save and load feature worked!
now how do i add it back without overwriting the load Player()
It tells you what you’re doing wrong in that you’re assigning something to Transform.position.x when you cannot. Maybe you should state what you want but also do it on your own thread; the above thread has nothing to do with your problem.