Unity3D——RPG人物头顶血条跟随

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wang_lvril/article/details/80711689
  1. 创建血条UI;
  2. 创建角色物体,挂载脚本;
  3. 获得角色位置坐标,转化为屏幕坐标。
     Vector3 pt = Camera.main.WorldToScreenPoint(new Vector3(this.transform.position.x, this.transform.position.y + 1, this.transform.position.z));
  4. 设置UI坐标,屏幕坐标转化为世界坐标
    bloodUI.transform.position = UICamera.FindCameraForLayer(bloodUI.layer).GetComponent<Camera>().ScreenToWorldPoint(new Vector3(pt.x, pt.y, 1));

猜你喜欢

转载自blog.csdn.net/wang_lvril/article/details/80711689
今日推荐