- Home /
Game Object won't match rotation of new positions transform
(sorry if the title is at all confusing) Anyway... In my game if the player falls form a platform they lose a life and get placed back at the start of the level.
Using this code-
 void OnTriggerEnter(Collider collider)
     { 
         if(collider.gameObject.name == "Player")
         {
             collider.gameObject.transform.position = levelStart.transform.position;
             LivesManager.lives -= livesValue; // Decrease Player Lives total
         }
 
     }
 
All works fine apart from I realised the player will get spawned facing whatever direction they were facing when they died. How can I make it so the player is always spawned facing the direction of the levelStart transform.
???
Answer by gameplay4all · Feb 15, 2015 at 04:37 PM
You can just set the rotation by using:
 collider.gameObject.transform.rotation = levelStart.transform.rotation;
You'd only have to rotate the levelStart object to face the proper way.
If this method isn't ideal for you game you can also just set the player rotation to a Quaternion specified in the inspector. Or use a Vector3 and Eulerangles.
Hope that helped :)
Your answer
 
 
             Follow this Question
Related Questions
make player move in direction it's facing 2 Answers
Following another object's position/rotation like parent/child relationship? 4 Answers
transform position y changes when character rotates 0 Answers
How to predict position of object before transform.translate will apply? 1 Answer
Saving System? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                