Search Unity

How do you make a plane/billboard look at the camera? (solved)

Discussion in 'Getting Started' started by sr3d, Oct 27, 2015.

  1. sr3d

    sr3d

    Joined:
    Oct 19, 2015
    Posts:
    78
    SOLVED - just use a quad instead of a plane (quad is a gameobject like plane)

    I have a plane with a texture on it. I want the plane to always face the camera. So If I look up and see the plane, the plane is showing me whatever texture it has on it no matter what my camera's transform. When I rotate the camera I don't want the billboard to do anything expect just face me so I can see the texture on it's plane.

    Code (csharp):
    1.  
    2. //make the plane look at the camera with the plane's vector3 forward pointing at camera
    3. transform.LookAt(lookAtThis.transform.position, Vector3.up);
    4.  
     
    Last edited: Oct 27, 2015
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Just a little tip: it looks like you've declared lookAtThis as a GameObject (or maybe a Camera?). Since you're only using the transform, you might instead declare it as Transform. This will let you drag anything with a Transform into that slot in the inspector, and reduce your code a little (you'll no longer need to call .transform on it). It also makes your intentions a bit more clear, which is always a good thing.
     
    sr3d likes this.
  3. sr3d

    sr3d

    Joined:
    Oct 19, 2015
    Posts:
    78
    Done, I made that adjustment. From now on I'll make the declares more specific :)

    Are you good at rotating things by any chance? http://forum.unity3d.com/threads/ho...no-matter-what-direction-youre-facing.364279/

    I'm trying to rotate the camera down by 45 degrees when the user hits C, the problem is the rotation always faces one direction.

    I understand how to work with transform.positions, but transform.rotation still has me stumped. I don't know how to remember a rotation, perform the rotate down by 45 degree calculation, then apply it to the transform.