public SceneObjectData GetOrCreateSceneObject(string uid, string scene)
        {
            SceneObjectData sobj = GetSceneObject(uid);

            if (sobj != null && sobj.scene == scene)
            {
                return(sobj);
            }

            if (!string.IsNullOrEmpty(uid))
            {
                SceneObjectData nobj = new SceneObjectData();
                nobj.uid           = uid;
                nobj.scene         = scene;
                scene_objects[uid] = nobj;
                return(nobj);
            }
            return(null);
        }
        void Start()
        {
            if (!was_spawned && PlayerData.Get().IsObjectRemoved(GetUID()))
            {
                Destroy(gameObject);
                return;
            }

            //Set current position
            SceneObjectData sobj = PlayerData.Get().GetSceneObject(GetUID());

            if (sobj != null && sobj.scene == SceneNav.GetCurrentScene())
            {
                transform.position = sobj.pos;
                transform.rotation = sobj.rot;
            }

            DetectGrounded(); //Check grounded
        }
        public void SetCharacterPosition(string uid, string scene, Vector3 pos, Quaternion rot)
        {
            TrainedCharacterData cdata = GetCharacter(uid);

            if (cdata != null)
            {
                cdata.scene = scene;
                cdata.pos   = pos;
                cdata.rot   = rot;
            }
            else
            {
                //Characters that were not spawned are saved as scene objects
                SceneObjectData sobj = GetOrCreateSceneObject(uid, scene);
                if (sobj != null)
                {
                    sobj.pos = pos;
                    sobj.rot = rot;
                }
            }
        }