Question by
SirKruc · Feb 05, 2016 at 04:26 PM ·
errorerror messagesavesaveloaderror-message
The left-hand side of an assignment must be a variable, a property or an indexer
I looked at other threads, but could not find an answer.
The error is on line 6, 7 and 8. Could someone help me out?
using UnityEngine;
using System.Collections;
public class SaveLoad2 : MonoBehaviour {
public void SaveLocation (Vector3 pos){ //Where pos is the position of the player
PlayerPrefs.SetFloat("playerX") = pos.x;
PlayerPrefs.SetFloat("playerY") = pos.y;
PlayerPrefs.SetFloat("playerZ") = pos.z;
}
//Handles Load - Returns Vector3
public Vector3 GetLocation(){
return new Vector3(PlayerPrefs.GetFloat("playerX"), PlayerPrefs.GetFloat("playerY"),PlayerPrefs.GetFloat("playerZ"));
}
}
Comment
Best Answer
Answer by gjf · Feb 02, 2016 at 06:39 PM
your syntax is wrong - check the docs.
PlayerPrefs.SetFloat("name", value);
Such a simple answer. I should have found that myself.
Still, thanks a lot
;) the docs are a good place to start - they're usually up to date.
at least i didn't lmgtfy...