当前位置: 首页 > news >正文

电商平台网站建设功能介绍有必要买优化大师会员吗

电商平台网站建设功能介绍,有必要买优化大师会员吗,天眼查公司注册查询官网,公司宣传网站精确获取碰撞点 核心是获取武器碰撞盒最顶点#xff0c;然后获取敌人碰撞盒距离该点最近的点 /// summary/// 获取获取武器前端位置 碰撞盒最左或最右顶点/// /summary/// param namecollider/param/// param name…精确获取碰撞点 核心是获取武器碰撞盒最顶点然后获取敌人碰撞盒距离该点最近的点 /// summary/// 获取获取武器前端位置 碰撞盒最左或最右顶点/// /summary/// param namecollider/param/// param namefacingRight/param/// returns/returnspublic static Vector3 GetCollider2DEdgePoint(Transform deployer, bool facingRight){var collider deployer.GetChild(0).GetComponentInChildrenCapsuleCollider2D();// 获取碰撞器的包围盒Bounds bounds collider.bounds;// 计算面向的方向向量右或左Vector2 attackDirection facingRight ? Vector2.right : Vector2.left;// 根据面向方向和碰撞器的边界来获取边缘点Vector3 edgePoint bounds.center (Vector3)(attackDirection * bounds.extents.x);// 如果需要在局部空间中获取边缘点需要将世界坐标转换为局部坐标// edgePoint deployer.InverseTransformPoint(edgePoint);return edgePoint;}//使用public void CreateHit(Collider2D other, CharacterStats target, bool isCrit false)Vector3 edgePoint Tool.GetCollider2DEdgePoint(transform, Entity.facingRight);var hitPosition other.ClosestPoint(edgePoint);1. 给攻击帧添加碰撞盒 优点配置直观无需事件触发 缺点无法定制效率低 检测放在子物体可以控制旋转 添加触发器事件 注意OnTriggerEnter2D只会在挂载了collider的组件上触发 protected virtual void OnTriggerEnter2D(Collider2D other){Debug.Log(this.name 命中 other);entity.AttackTrigger(other);} 在角色脚本执行攻击检测 public override void AttackTrigger(Collider2D other){if (other.gameObject.layer LayerMask.NameToLayer(Enemy)){base.AttackTrigger(other);AttackColliderCheckEnemy(other, (enemy) enemy.BeDamage(stats));}}2. 为每个攻击动画状态使用射线检测 优点效率高于碰撞盒可以定制比如增加攻击范围 缺点配置麻烦不直观 部分代码仅供参考 定义每个动画的检测范围 [Header(攻击状态对应的碰撞盒)]public DictionaryEntity.States, AttackRanges attackRangeDict new();//索引是攻击的状态 连击数获取对应攻击的范围 [System.Serializable] public class AttackRanges {/// summary/// 对应的连击次数 作为索引/// /summarypublic AttackRange[] ranges new AttackRange[1];//索引器public AttackRange this[int index]{get{// return ranges.FirstOrDefault(x x.combo index);//如果没有默认用第一个if (index ranges.Length)return ranges[0];return ranges[index];}} }[System.Serializable] public class AttackRange {public SerializableVector2 offset new();public SerializableVector2 size new();public float rotation 0;public UnityEngine.Vector2 Offset offset.ToVector2();public UnityEngine.Vector2 Size size.ToVector2(); }添加帧事件 private void AttackTrigger(){entity.AttackTrigger();}执行检测与绘制范围 /// summary/// 攻击检测/// /summary/// typeparam nameT/typeparam/// param nameaction/paramprotected void AttackColliderCheckT(ActionT action) where T : Entity{AttackRange attackRange stats.attackRangeDict[States.PrimaryAttack][ComboCounter];var offset facingRight ? attackRange.offset.ToVector2() : new Vector2(-attackRange.offset.x, attackRange.offset.y);var rotation facingRight ? attackRange.rotation : -attackRange.rotation;Collider2D[] colliders Physics2D.OverlapBoxAll(offset, attackRange.size.ToVector2(), rotation);foreach (Collider2D hit in colliders){if (hit.TryGetComponentT(out T entity)){action?.Invoke(entity);}}}// 默认情况下就会在编辑模式下运行protected virtual void OnDrawGizmos(){// Vector3 boxCenter groundCheck.position Vector3.down * groundCheckDistance / 2;// Gizmos.DrawCube(boxCenter, new Vector3(groundCheckWidth, groundCheckDistance, 0));Gizmos.DrawLine(groundCheck.position, new Vector3(groundCheck.position.x, groundCheck.position.y - groundCheckDistance));//绘制一条从 from(前面的) 开始到 to后面的 的线。Gizmos.DrawLine(wallCheck.position, new Vector3(wallCheck.position.x wallCheckDistance, wallCheck.position.y));//绘制一条从 from(前面的) 开始到 to后面的 的线。if (stats null) return;Gizmos.color Color.red;var attackRange stats.attackRangeDict.ContainsKey(States.PrimaryAttack) ? stats.attackRangeDict?[States.PrimaryAttack]?[ComboCounter] : new AttackRange();Vector3 center (Vector3)attackRange.Offset;// 设置 Gizmos 的变换矩阵Matrix4x4 oldMatrix Gizmos.matrix;Gizmos.matrix Matrix4x4.TRS(center, Quaternion.Euler(0, 0, attackRange.rotation), Vector3.one);Gizmos.DrawWireCube(transform.position (Vector3)attackRange.Offset, (Vector3)attackRange.Size);// 恢复原来的矩阵Gizmos.matrix oldMatrix;}3. 所有动画共用一个射线检测 优点简单 缺点不精确 在帧事件触发调用检测方法即可 /// summary/// 攻击检测/// /summary/// typeparam nameT/typeparam/// param nameaction/paramprotected void AttackColliderCheckT(ActionT action) where T : Entity{Collider2D[] colliders Physics2D.OverlapCircleAll(attackCheck.position, attckCheckRadius);foreach (Collider2D hit in colliders){if (hit.TryGetComponentT(out T entity)){action?.Invoke(entity);}}}
http://www.hkea.cn/news/14327257/

相关文章:

  • 腾讯广告卖东西怎么建设网站0453牡丹江信息网二手房买卖
  • 校园网站建设重要性网站模板图
  • 国外营销企业网站苏州网站提升排名
  • 男人女人晚上做那事网站公司业务推广
  • WordPress不通角色权限刷排名seo
  • 好看的知名企业网站好看欧美视频网站模板下载 迅雷下载 迅雷下载地址
  • 网站开发培训多少钱自己弄个网站要多少钱
  • 做企业网站报价永久免费做网站
  • 山西临汾建设局网站ui培训班出来能找到工作吗
  • 做网站都能用什么做小型电商网站模板
  • 婚纱网站建设阿里 网站备案核验单
  • 网站做目录中国内最近重大新闻2024
  • 佳木斯做网站的公司世界上第二大互联网公司是
  • 网站是否备案怎么查询手机网站用模版
  • 软件开发兼职平台有哪些sem优化
  • 网站推广方法是什么手机网站开发
  • 如何设计营销 网站建设pro wordpress theme development
  • 免费做logo网站网络设计工资高吗
  • 自己做企业网站怎么做交易猫假网站
  • 黄岛做网站婚庆网站建设必要性
  • qq网站在线登录网页版百度做网站电话多少
  • 微信公众号个人可以做网站么深圳还有网站
  • 江苏华东建设基础工程有限公司网站邵阳红网站
  • 站内推广方式常州辉煌网络网站制作
  • c2c交易是什么意思官方网站优化价格
  • 什么网站流量高网络营销msn是什么
  • 广州市城乡和建设局网站首页邢台168交友
  • 北京网站建设类岗位制作网站的详细步骤
  • 个人主页网站制作教程ps培训班
  • 网站可以用PS设计吗国内新闻最新消息2021