Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class UserInfo : MonoBehaviour
- {
- public Transform target;
- Camera cam;
- public Vector3 screenPos;
- public Vector2 hpBarSize;
- public Texture2D hpBarTexture;
- void Start()
- {
- cam = GetComponent<Camera>();
- }
- void Update()
- {
- screenPos = cam.WorldToScreenPoint(target.position);
- }
- private void OnGUI()
- {
- GUI.DrawTexture(new Rect(screenPos.x - (hpBarSize.x / 2), Screen.height - screenPos.y - 70 - (hpBarSize.y / 2), hpBarSize.x, hpBarSize.y), hpBarTexture);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement