Question by
martn00 · Apr 06, 2017 at 07:09 PM ·
rotationeuleranglesfps controller
Every time when I tried to change my rotation of my FPS Controller, it changed back right away back! How can I fix this...
What do I need to change so my FPS Controller won't reset all the time? This is a part of my script on which I'm trying for changing the rotation (English bad):
if (GameObject.FindGameObjectWithTag("placeMeBack") != null){
//playerLL is a int from the PlayerPrefs
playerLL = PlayerPrefs.GetInt("checkpoint");
//Hier reset ik de player naar zijn laatste checkpoint
player = GameObject.Find("Player");
player.tag = "Player";
float x, y, z, ry, rx, rz;
//location[] is a array with gameobjects
x = location[playerLL].transform.position.x;
y = location[playerLL].transform.position.y;
z = location[playerLL].transform.position.z;
ry = location[playerLL].transform.rotation.eulerAngles.y;
rx = location[playerLL].transform.rotation.eulerAngles.x;
rz = location[playerLL].transform.rotation.eulerAngles.z;
player.transform.eulerAngles = new Vector3(rx, ry, rz);
player.transform.position = new Vector3(x, y, z);
}
Comment