I’ve been working on this script for 3 days and am finally asking for assistance. I’ve managed to save Int’s using PlayerPrefs, but can’t get my positioning right. I’ve used answers found here and the script reference to put this together.
I’d like assistance rewriting this, and adding vector3 to save and load for my character.
Here’s the parts of the script throwing errors:
//-----Players Position----------
var PlayerX : float;
var PlayerY : float;
var PlayerZ : float;
var PlayerPosition : Transform;
var player : GameObject;
function Update(){
//=======Setting Player position for save====
PlayerX =(PlayerPosition.transform.position.x);
PlayerY =(PlayerPosition.transform.position.y);
PlayerZ =(PlayerPosition.transform.position.z);
}
//saving playerPrefs
function saveAttributes()
{
PlayerPrefs.SetFloat("PlayerX");
PlayerPrefs.SetFloat("PlayerY");
PlayerPrefs.SetFloat("PlayerZ");
}
function loadstuff () {
PlayerX = PlayerPrefs.GetFloat("PlayerX");
PlayerY = PlayerPrefs.GetFloat("PlayerY");
PlayerZ = PlayerPrefs.GetFloat("PlayerZ");
PlayerPosition.transform.position.x = ("PlayerX");
PlayerPosition.transform.position.y = ("PlayerY");
PlayerPosition.transform.position.z = ("PlayerZ");
player.transform.position = ("PlayerPosition");
}
Here are the errors:
BCE0017: The best overload for the method ‘UnityEngine.PlayerPrefs.SetFloat(String, float)’ is not compatible with the argument list ‘(String)’.
BCE0022: Cannot convert ‘String’ to ‘float’.
I wouldn’t mind converting this to use arrayPrefs, but I need help writing it versus a link to the script reference, or wiki. I’ve managed to learn from veiwing examples here on Answers this much through a diligent search and try method.
Any assistance would be most appreciated, thank you.