- Home /
 
               Question by 
               alexkaskasoli · Dec 14, 2013 at 06:18 AM · 
                cameradirection  
              
 
              Is character facing in the direction of camera?
How could I check if the character is facing in the direction of the camera or away from it?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by robertbu · Dec 14, 2013 at 06:22 AM
This answer will depend on how you define facing and away and the orientation of the camera with respect to the player's ground plane, and whether the ground is flat. If you are just looking for within a 180 degrees:
 var dot = Vector3.Dot(transform.forward, Camera.main.transform.forward);
 
 if (dot <= 0.0) {
     Debug.Log("The character is facing the camera");
 }
 else {
     Debug.Log("The character is facing away from the camera");
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                