- Home /
Spawn Rotation not Working?
Im having trouble rotation my Player spawn on Start. When I play the game it does not rotate the spawn in the correct rotation.
void Start () {
//player spawn
playerSpawn = GameObject.FindWithTag("PlayerSpawn");
playerSpawn.transform.position = new Vector3(137,6,137);
playerSpawn.transform.eulerAngles = new Vector3(0,-120,0);
//find player
player = GameObject.FindWithTag("Player");
player.transform.position = playerSpawn.transform.position;
}
I Really don't know whats happening. I figured euler would do this job but I guess im missing something or not understanding something here... Thanks!
What exactly is happening? Are you sure that the game object with the "PlayerSpawn" tag exists at the time this code is executing? Any change that there is some other game object in the scene that has this tag also and therefore the FindWithTag() is finding the wrong one?
The empty game object is tagged "PlayerSpawn". The Script above is on another gameobject called Game$$anonymous$$anager. When I hit play the Game$$anonymous$$anager moves the player spawn object to a specific spot but does not rotate it to the correct orientation.
I thought the code:
playerSpawn.transform.eulerAngles = new Vector3(0,-120,0);
would rotate the object to what I want but it doesn't. It just sits there. Ive checked to see if my update was keeping it restricted but its not.
Initially I thought that the negative value threw it off, but I did many tests, and saw that Unity converts the -120 to 240, so that's not it.
However, for all that's worth, I noticed that if the gameobject starts with a y rotation of -120, transform.eulerAngles = new Vector3(0,-120,0); will not rotate it at all, because its already facing that direction. So, if you want to see your playerSpawn actually turn to (0, -120, 0), make sure its facing towards another direction to begin with (say (0,0,0)).
Answer by abi-kr01 · Mar 21, 2014 at 05:01 AM
i think u should use
playerSpawn.transform.rotation = Quaternion.identity;
m not sure about way to use Quaternion but m sure that if u use it ur problem will be solved
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
problem after rotate an object 0 Answers
problem after rotate an object 1 Answer
Quaternion to Euler conversion singularities 0 Answers
Camera rotation behaving strangely 2 Answers