首页 > 其他 > 详细

屏幕空间伤害弹字,根据攻击角度调整弹字方向。

时间:2021-02-06 15:52:43      阅读:24      评论:0      收藏:0      [点我收藏+]
        Vector3 screen= Camera.main.WorldToScreenPoint(transform.position+Vector3.up*0.2f);
            GameObject gameObject = GameObject.Instantiate(damageText);
            TMP_Text text = gameObject.GetComponentInChildren<TMP_Text>();
            text.text = "-" + ((int)damage).ToString();
            //Destroy(gameObject, 1f);
            Transform textTrans = gameObject.transform.GetChild(0);
            screen.z = 0;
            textTrans.position = screen;
            Vector3 dir = collision.transform.position - transform.position;
            dir.Normalize();
            float d= Vector3.Dot(collision.transform.parent.right,dir);
            Vector3 temp = new Vector3(-d*Screen.width*0.5f,Random.Range(0.5f, 1f)*Screen.height*0.5f,0);
            (textTrans as RectTransform).DOLocalMove(temp, 0.8f).SetEase(Ease.OutBack);
            text.DOFade(0, 0.5f).SetEase(Ease.OutCirc).SetDelay(0.3f);
            textTrans.DOScale(1.5f,0.8f).SetEase(Ease.OutCirc);

技术分享图片技术分享图片

 

 弹字方向为怪物在角色的相对方向。

 

屏幕空间伤害弹字,根据攻击角度调整弹字方向。

原文:https://www.cnblogs.com/DazeJiang/p/14381379.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!