- Home /
Sprites always face the camera, Camera freely rotates
I'm trying to achieve sprite billboarding like these games:
Ragnarok Online
Disgaea
Basically the player can freely rotate, pan and zoom the camera however he wishes, and the sprites will always look the same from any angle.
I've tried simply using LookAt, but for some reason that reverses the rotation of the sprites as well. I also need the sprites to not rotate 'sideways' when the sprite is not centered on the screen. - Although that could just be because of the perspective camera - I'm not sure.
Answer by Seerix · May 27, 2014 at 12:14 PM
I use this simple script to achieve that. You can set the target to be the camera.
public class FaceTargetScript : MonoBehaviour
{
public Transform target;
void Update () {
if (target != null)
transform.rotation = target.rotation;
}
}
Edit: I was too fast in answering and ignored you requirement to prevent them to angle when they're not in the center of the screen. I'll look further into it.
Edit 2: Code updated with working example.
I actually managed to solve it, but your one line solution beats $$anonymous$$e by heaps, thanks xD
In case anyone is interested, here is the monstrosity I concocted
Vector3 oppositeCamera = transform.position - Camera.main.transform.position;
Quaternion faceCamera = Quaternion.LookRotation(oppositeCamera);
Vector3 euler = faceCamera.eulerAngles;
euler.y = 0f;
faceCamera.eulerAngles = euler;
transform.rotation = faceCamera;
Yours will probably serve your needs better though. $$anonymous$$y solution mimics the camera's viewing plane, so characters won't appear to be standing upright when viewing from high angles and that might look weird in your case.
Answer by Oris · Apr 19, 2020 at 06:23 PM
You can create a Particle and set it up to loop with static positions. By default, this particle is facing to the cam and it's extremly cheap.
Check out my Games&Assets: https://oris-romero.itch.io/