Billboard rotate along arbitrary axis

Hello everyone,

The billboard function is to point towards a location using its Y axis (ex: a direction).
I’m trying to create a billboard that rotates along this arbitrary axis, but always facing the camera.

I have some code that is working in some cases, but i still need a little help to make it fully work.

void BillboardAxis(Vector3 axis)
{
		// create the look vector: pos -> camPos
		Vector3	look	= cam.transform.position - transform.position;
		look.Normalize();
		
		// billboard about the direction vector
		Vector3	up    = axis;
		Vector3	right	= Vector3.Cross(cam.transform.up,look);
		
		// watch out when the look vector is almost equal to the up vector the right
		// vector gets close to zeroed, normalize it
		right.Normalize();
		
		// the billboard won't actually face the direction of the look vector we
		// created earlier, that was just used as a tempory vector to create the
		// right vector so we could calculate the correct look vector from that.
		look = Vector3.Cross(right, up);

		transform.right = right;
		transform.up = up;
		transform.forward = look;

	}

Best Regards.

I got it working :slight_smile:
No need to reply.

Many Thanks.