animator for more than 1 camera
Hello My problem is that i Want to create multiplayer game like doom2 graphics style (sprite that is facing camera). So i got sprite that is doing that but the real problem is that sprite is 16 directional. heres the part of code for my billboard.
public class Billboard : MonoBehaviour {
float angle;
Animator anim;
void OnEnable(){
CameraPreRender.onPreCull += MyPreCull;
}
void onDisable(){
CameraPreRender.onPreCull -= MyPreCull;
}
void MyPreCull(){
anim = GetComponent<Animator>();
Vector3 diffrence = Camera.current.transform.position - transform.position;
transform.LookAt(transform.position - diffrence, Camera.current.transform.up);
angle = Mathf.Atan2 (diffrence.x, diffrence.z) * Mathf.Rad2Deg;
if (angle > -15 && angle < 15) {
anim.SetBool ("front", true);
} else {
anim.SetBool ("front", false);
}
if (angle < 0) {
angle += 360;
}
if (angle > 22 && angle < 45) {
anim.SetBool ("Runing22,5", true);
... it takes the direction where "monster" is facing and position of "current" camera to create angle. angle is used in animator to animate running in 16 directions. My animator works with camera that is on top of the list. Can some1 help me out a bit? sorry for my english.
Your answer
![](https://koobas.hobune.stream/wayback/20220612102524im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Sprite Animation on a 3D game 0 Answers
Weird checkerboard bug with sprites 1 Answer
Need help with my billboard shader 0 Answers
Sprites have discolored patches / color bleeding 0 Answers
Tiling Sprites and performance sprites vs. GameObjects 0 Answers