Question by
michalzoufaly14 · May 07 at 05:34 PM ·
c#scripting problem
Health bar rotation on camera
Hello, I need help simplifying a script. I have a script that rotates the Health bar on the camera. Since I have a choice between two tanks at the beginning of the game (as a player) and each tank has a choice between Third personCam and sniperCam, I wrote it like this. The problem is that it doesn't work, or rather it works but badly. How could it be simplified and more importantly made functional? Thanks for the help
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Billboard : MonoBehaviour
{
public Camera camera1main;
public Camera camera2main;
public Camera camera1snipe;
public Camera camera2snipe;
public Transform cam1main;
public Transform cam2main;
public Transform cam1snipe;
public Transform cam2snipe;
void LateUpdate()
{
//main camera
if (camera1main.enabled == true)
{
transform.LookAt(transform.position + cam1main.forward);
}
else if (camera2main.enabled == true)
{
transform.LookAt(transform.position + cam2main.forward);
}
//sniper camera
if (camera1snipe.enabled == true)
{
transform.LookAt(transform.position + cam1snipe.forward);
}
else if (camera2snipe.enabled == true)
{
transform.LookAt(transform.position + cam2snipe.forward);
}
}
}
;
Comment
Your answer
Follow this Question
Related Questions
Script help player controller 0 Answers
How can I add a toggle to this FPS counter script? 1 Answer
Clones of Object Not Moving 0 Answers