Camera facing billboard !

I want a billboard to always face an object (a camera) and I see how to do it documented in several places but none seem to work for me and I can’t figure out what is wrong.

Here is my code:

{

public GameObject TargetGO;

void Start()
{
}

void Update()

{

transform.LookAt(transform.position + TargetGO.transform.rotation * Vector3.back, TargetGO.transform.rotation * Vector3.up);

}

}

So I drop another GameObject into TargetGO so I can watch the billboard orient.The billboard is always facing ‘up’ compared to the GameObject.

Tried a simple transform.lookat(TargetGO.transform.position) and this also has the billboard always point up. with billboard at 0,0,0.

What am I doing wrong???

The following script should do it, it looks like you are over complicating your LookAt perameters. when using the Transform.LookAt function, it automatically takes the transforms position into account, so you only need to provide target vector, not a relative one.

public class MyClass: MonoBehaviour 
{
    Transform MyTransform;
    Camera Cam;
	// Use this for initialization
	void Start () 
    {
        MyTransform = transform;
	}
	
	// Update is called once per frame
	void Update () 
    {
        MyTransform .LookAt(Cam.transform.position, upVector);
	}
}

Billboarding is better done in a shader than a script.

http://en.wikibooks.org/wiki/Cg_Programming/Unity/Billboards
http://en.wikibooks.org/wiki/GLSL_Programming/Unity/Billboards
http://forum.unity3d.com/threads/109111-GLSL-Animated-sprite-shader-billboard-questions