Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

player position after scene load

Discussion in 'Scripting' started by chemsoun, May 5, 2015.

  1. chemsoun

    chemsoun

    Joined:
    Apr 9, 2015
    Posts:
    49
    hi everyone, i've been having problems with positionning a player between scenes, what i have now is a player in the correct position but not in the correct direction , i want rotate the player after the second scene is loaded. i've been tryng a lot of solutions but it seems no one gives the proper result. that i should someone suggested that i should use Quaternion.SetLookRotation , well i have no idea how that works instead i've used transform.LookAt
    but it still doesn't work

    Code (CSharp):
    1. void OnLevelWasLoaded(int level){
    2.    
    3.         if (level == 2) {
    4.        
    5.             Debug.Log ("level 2 ");
    6.  
    7.  
    8.             Debug.Log("y : " + GameObject.Find("young").transform.rotation.y);// displays  y : 1
    9.  
    10.             Vector3 vect = new Vector3(0,2,0);
    11.             transform.LookAt(vect);
    12.  
    13.             Debug.Log("y : " + GameObject.Find("young").transform.rotation.y);//  displays y : -0.6
    14.  
    15.  
    16.  
    17.        
    18.         }
    19.    
    20.    
    21.    
    22.     }
     
  2. hamsterbytedev

    hamsterbytedev

    Joined:
    Dec 9, 2014
    Posts:
    353
    Just set your transform.rotation to Quaternion.Euler(new Vector3(0, yAngle, 0));