Search Unity

Rotation question - rotation relative to screen space?

Discussion in 'Scripting' started by jackmott, Jan 22, 2014.

  1. jackmott

    jackmott

    Joined:
    Jan 5, 2014
    Posts:
    167
    I've got a sphere onto which I am placing cubes with the mouse.

    I take a ray from the mouse into the world, and the point at which it hits the sphere, that is where the object goes.

    I get the normal from that hit to orient the cube so that up is properly up.

    That all works great, but as you move the cube around the sphere the rotation about the z axis starts to change relative to the screen. The cube will be nice and level at the equator but start to rotate 45 degrees as you approach the poles.

    I would like for the same edge to always face up in screen space. Is that even coherent, and if show, how do I do it?

    The image is an attempt to illustrate what I mean (this is how I want it to look)
     
  2. AngryGenius

    AngryGenius

    Joined:
    Jan 21, 2014
    Posts:
    14
    Hmmm... Perhaps
    Code (csharp):
    1.  transform.LookAt(Camera.main.transform);
    ?