I found the code snippet below and am using it to make the sprites in my fps game always look at the camera [player] position when I move around. But not only does it make the sprites turn to face the player’s position; it makes them do so facing backwards and therefore they become completely invisible in the game (unless I stick them to a parent object and flip it 180 degrees). This happens whether I use standard sprites, sprite renderers or animations on sprites, and I can’t figure out what it is in the code that’s making them face the player backwards rather than forwards.
using UnityEngine;
public class Billboard : MonoBehaviour
{
Camera target;
void Start()
{
target = Camera.main;
}
void Update()
{
Vector3 targetPosition = new Vector3(target.transform.position.x, transform.position.y, target.transform.position.z);
transform.LookAt(targetPosition);
}
}
Does anyone know why this issue is happening and how to solve the problem so the sprites always turn to face the player but do so facing forwards by default?