Bullet billboarding

So, this is a rather hard to describe problem, but I figure it’ll make sense once I write it out.

Basically, I’m creating a prefab for the bullet projectiles in my game–not particle effects, just flat planes textured to look like some kind of a tracer round coming out of a gun, looking rather nice so far. However, the planes need to billboard slightly so that they will be visible even at somewhat skewed angles. Essentially, I need it billboarded on its local X axis, not the world X axis, so that it appears to be moving straight towards its target.

My character controller prefab does not allow the camera to rotate on its Z axis, but instead the character controller itself does the rotation (and the camera controls up and down looking–see the default FPS Controller prefab in the standard assets and you’ll understand what I mean). As a result, standard LookAt style billboarding doesn’t seem to work properly. For example, I have an adapted version of this script from the wiki to work on the X axis instead of the Y axis:

using UnityEngine;
using System.Collections;
 
 public class LookAtCameraXOnly : MonoBehaviour
 {
    public Camera cameraToLookAt;
 
    void Update()
    {
        Vector3 v = cameraToLookAt.transform.position - transform.position;
        v.x = v.z = 0.0f;
        transform.rotation = Quaternion.LookRotation(cameraToLookAt.transform.position - v) * Quaternion.AngleAxis(90, Vector3.up);
    }
 }

but because of the way of my character controller being set up, the billboarding does not work properly. I need a way to ensure that I get the desired effect (X axis billboarding) while maintaining my current character controller setup.

Any ideas?

I think this is what you want.