Unlike many other engines, Unity doesn’t seem to have the typical camera-oriented simple sprite, unless I’m missing something. Instead I seem to be driven toward making a particle system with one everlasting particle, cumbersome to say the least. Also, I’m looking for a means to implement a camera-oriented laser beam effect. Other engines seem to bundle such functionality into their simple sprites.
I could add this work to my long list of tasks myself, but I’m just wondering if I’m missing something. I’d rather not reinvent something already tried and tested. If Unity doesn’t have this built in, I’d appreciate any references to tried, tested efficient free code to perform this very basic graphics engine feature. I’m most interested in something that implements the laser beam.
Do you have a separate camera for the UI? If so, you can just put the effect in that view. If not, a basic “align to camera” script is pretty simple:
public class CameraFacingBillboard : MonoBehaviour
{
public Camera m_Camera;
void Start()
{
if(m_Camera.orthographic)
transform.LookAt(transform.position - m_Camera.transform.forward, m_Camera.transform.up);
else
transform.LookAt(m_Camera.transform.position, m_Camera.transform.up);
}
}
This could be placed in Update instead of Start if you wanted a billboard that constantly turned to face a moving camera (in which case I would cache some of the transforms).
Thanks, that should prove useful as a simple camera-facing billboard.
I guess I was missing something though. I just found the LineRenderer component. I wonder when they added that, must’ve come with 3.x. This will be great for making laser beams, it has all the parameters I need.
I wish there was a camera-facing billboard component built in that was just as simple and elegant, but your script will be helpful along with a plane, thanks.