Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion MultiplayerFPS/Assets/Scripts/CameraFacingBillboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ public class CameraFacingBillboard : MonoBehaviour {
// Update is called once per frame
void Update () {
Camera cam = Camera.main;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing so in every frame is not really a good way to do it. defining private camera inside the class and referencing Camera.main to it on Awake or on Start would be a nicer way to do . Also, the if statement is correct.


if(cam!=null)
{
transform.LookAt(transform.position + cam.transform.rotation * Vector3.forward,
cam.transform.rotation * Vector3.up);
}
}

}