Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SaveLocation : MonoBehaviour {
- //position
- public float thisCharactersXposition;
- public float thisCharactersYposition;
- public float thisCharactersZposition;
- //rotation
- public float thisCharactersXrotation;
- public float thisCharactersYrotation;
- public float thisCharactersZrotation;
- public void Awake(){
- thisCharactersXposition = PlayerPrefs.GetFloat ("MyPositionX");
- thisCharactersYposition = PlayerPrefs.GetFloat ("MyPositionY");
- thisCharactersZposition = PlayerPrefs.GetFloat ("MyPositionZ");
- thisCharactersXrotation = PlayerPrefs.GetFloat ("MyRotationX");
- thisCharactersYrotation = PlayerPrefs.GetFloat ("MyRotationY");
- thisCharactersZrotation = PlayerPrefs.GetFloat ("MyRotationZ");
- }
- // Use this for initialization
- public void Start () {
- transform.position = new Vector3 (thisCharactersXposition, thisCharactersYposition, thisCharactersZposition);
- transform.rotation = Quaternion.Euler (thisCharactersXrotation, thisCharactersYrotation, thisCharactersZrotation);
- }
- // Update is called once per frame
- public void Update () {
- PlayerPrefs.SetFloat ("MyPositionX", transform.position.x);
- PlayerPrefs.SetFloat ("MyPositionY", transform.position.y);
- PlayerPrefs.SetFloat ("MyPositionZ", transform.position.z);
- PlayerPrefs.SetFloat ("MyRotationX", transform.eulerAngles.x);
- PlayerPrefs.SetFloat ("MyRotationY", transform.eulerAngles.y);
- PlayerPrefs.SetFloat ("MyRotationZ", transform.eulerAngles.z);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement