Hello All,
I’m experiencing a strange behavior from a script :
tempPlanetMesh.GetComponent<Transform> ().localPosition = new Vector3 (PlayerPrefs.GetFloat ("PlanetMesh" + SaveSunNb + planetn + "posX"), 0, PlayerPrefs.GetFloat ("PlanetMesh" + SaveSunNb + planetn + "posZ"));
Debug.Log(PlayerPrefs.GetFloat ("PlanetMesh" + SaveSunNb + planetn + "posX"));
Debug.Log(tempPlanetMesh.GetComponent<Transform> ().localPosition);
The script is executed when a key is pressed.
Each time the script is executed, the Debug.Log show the correct value of PlayerPrefs.GetFloat (“PlanetMesh” + SaveSunNb + planetn + “posX”), for example 4000.
and the values of tempPlanetMesh.GetComponent ().localPosition shown in the second Debug.Log are ok (4000,0,whatever).
However, the position of tempPlanetMesh is not set as it should and stays equal to (0,0,0) in the inspector.
Even stranger, this seems to occurs randomly as sometimes it works just well.
I really don’t know why the same script doesn’t always give the same results. And why the localPosition is not always applied to the object transform.
Can you help me with this ?
Thank you !