Hey guys!
So I am trying to do something pretty simple but whenever it comes to Rotation and Unity my brain doesn’t seem to work correctly… lol
What I am trying to do in theory is very simple.
In an Awake function I am storing the players position and rotation.
var PLAYER_START : GameObject;
var player_location : Vector3;
var player_rotation : Quaternion;
function Awake()
{
player_location = PLAYER_START.gameObject.transform.position;
player_rotation = PLAYER_START.gameObject.transform.rotation;
//Check to make sure the proper values are being stored.
print("PLAYER_LOCATION: " + player_location);
print("PLAYER_ROTATION: " + player_rotation);
}
Now when the player loses I call my Reboot method which resets the gameplay elements. I then set the players position and rotation to what was stored on the Awake. For some reason the Position works great, but the Rotation is giving me issues. It prints out and appears to have stored and then assigned the proper rotation value, but upon respawn the player’s rotation is exactly where they facing when they lost. Here is the part of my Reboot method which deals with the Position and Rotation assignment.
function Reboot()
{
PLAYER_START.gameObject.transform.position = player_location;
PLAYER_START.gameObject.transform.rotation = player_rotation;
}
Like I said, the starting position is assigned perfectly and the player is back in their spawn point, but the rotation is not the starting rotation. When I print out the value of player_rotation it is being stored and assigned correctly, but for some reason it isn’t rotated upon trying again!
Thanks guys for any input! I am sure I missed something painfully obvious.