- Home /
 
               Question by 
               lancer · Aug 24, 2015 at 05:55 PM · 
                c#camerarotationgameobject  
              
 
              Align rotation when using ScreenToWorldPoint
I'm using ScreenToWorldPoint to position some gameobjects on one side of the screen. The problem is that they are not aligned corrected because the camera is rotated.

As the can see in the game view in the lower right, the cubes are off to the bottom of the screen, and they are not rotated to look at the camera.
How can I get the rotation to align with the camera?
Here is the relevant code:
 Vector3 worldPoint = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width - (Screen.width/6), 10, 10));
 GameObject temp = Instantiate (cube, worldPoint, Quaternion.identity) as GameObject;
 temp.transform.position = new Vector3(temp.transform.position.x, temp.transform.position.y-(index*offset), temp.transform.position.z);
 temp.transform.SetParent(screenParent.transform);
 
                 
                screenshot-screen.png 
                (104.8 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
help with rotation, mouse input and time.deltatime, a thirdperson script 1 Answer
Flip over an object (smooth transition) 3 Answers
Mathf.MoveTowardsAngle is not working as predicted 1 Answer
My marble (Player/Gameobject) goes through the "play board" (gameobject). Why? 1 Answer
How to rotate camera around object smoothly in fixed intervals 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                