Unity3D.AI(人工智能)
1024路漫漫
hi,很高兴认识你。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
根据物理公式在Unity中实现抛物线运动.2
上一篇文章,确实是模拟了抛物线运动,但是并不能很好的控制。比如一种应用场景,指定地面上的目标点,让炮弹根据抛物线轨迹准确的落到目标点上。要实现这个需求,需要两个已知条件,仰角的角度,炮弹飞行的时间。1.算出和目标点的距离,因为水平方向是匀速运动,已知飞行时间,可以算出水平方向的速度。 dir = (targetPos - transform.position).normalized; transform.LookAt(targetPos); float dis = Vector原创 2021-12-30 15:10:34 · 3646 阅读 · 2 评论 -
根据物理公式在Unity中实现抛物线运动.1
说明下应用场景已知炮台的仰角是30度,在仰角方向的速度是10m/s, 实现抛物线运动。物体的抛物线运动,可以将仰角方向的速度分解成水平方向和垂直方向。已知仰角方向的速度,和角度,可以根据三角函数可以计算出水平方向的速度和垂直方向的速度。在水平方向的速度是匀速运动,而在垂直方向是重力加速度的自由落体运动。具体实现如下:1.分解仰角方向的的速度为x方向和y方向 volocityY = Mathf.Sin(Mathf.Deg2Rad * angle) * volocity; voloc原创 2021-12-30 14:59:11 · 3962 阅读 · 0 评论 -
使用Quaternion.AngleAxis和Quaternion.Euler实现目标点绕某点旋转
target 是目标点Vector3org 是自身点Vector3-45f是旋转的角度Vector3.up是绕y轴Vector3 pos = Quaternion.AngleAxis(-45f, Vector3.up) * (target - org) + org;也可以是Vector3 pos = Quaternion.Euler(0f, -45f, 0f) * (target - org) + org;Quaternion.Euler 和Quaternion.Angle.原创 2021-09-05 14:20:53 · 1831 阅读 · 0 评论 -
Unity Physics.OverlapCapsule的使用
Unity Physics.OverlapCapsule这个函数判定胶囊中有多少碰撞体。Collider[] OverlapCapsule(Vector3 point0, Vector3 point1, float radius, int layerMask);第1,2个参数是胶囊的底部和顶部球心坐标。这里有个坑,传入的时候不是获取的CapsuleCollider自己的中心和CapsuleCollider的高度的运算。因为CapsuleCollider.center是本地坐标。我在使用时用的用的原创 2021-08-25 10:44:42 · 3358 阅读 · 0 评论 -
Unity碰撞和碰撞检测
带碰撞效果用OnCollisionXXOnCollisionEnter(Collision col)OnCollisionStay(Collision col)OnCollisionExit(Collision col)发生碰撞的条件:主动方必须有Rigidbody,发生碰撞的两个游戏对象必须有Collider,被动方对于RigidBody可又不可无,参数是表示被动方。所谓带碰撞效果是指有物理效果,比如碰了要发生位移之类的。只是检测用OnTriggerXXOnTriggerEnt原创 2021-08-24 07:42:42 · 1498 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.Variable Synchronizer(变量同步)
Behavior Tree (BT)的变量Variable是用于Tree和Task之间通讯的重要手段。Variable Synchronizer主要是用于非Behavior Tree和Behavior Tree之间通讯的一种方式。帮助文档中有一个例子主要用于动画和Behavior Tree之间的通讯。表示了一个很重要的思想“并不推荐将动画同步去达到BT控制动画的目的,而是用使用同步那些能控制动画的变量”。可以推广下,类似的还有,比如说用于碰撞检测,并不是要把碰撞组件拿去同步,但可以去同步碰撞的结果。原创 2021-08-23 17:26:36 · 840 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.Decorator装饰5
The task guard task is similar to a semaphore in multithreaded programming. The task guard task is there to ensure a limited resource is not being overused.For example, you may place a task guard above a task that plays an animation. Elsewhere within your.原创 2021-06-08 07:13:44 · 438 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.Decorator装饰4
Interrupt中断The interrupt task will stop all child tasks from running if it is interrupted. The interruption can be triggered by the perform interruption task. The interrupt task will keep running its child until this interruption is called. If no interru原创 2021-06-03 06:43:34 · 659 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.Decorator装饰3
Parent Tasks Parent Tasks are the composite and decorator tasks within the behavior tree. While the ParentTask API has no equivalent API to Unity’s MonoBehaviour class, it is still pretty easy to determine what each method is used for. // The ma...原创 2021-06-03 06:19:01 · 505 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.Decorator装饰2
ReturnFailureThe return failure task will always return failure except when the child task is running.在原创 2021-06-02 07:05:26 · 417 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.Decorator装饰1
ParParent Tasks are the composite and decorator tasks within the behavior tree. While theParentTask API has no equivalent API to Unity’s MonoBehaviour class, it is still pretty easyto determine what each method is used for.// The maximum number of ch原创 2021-06-02 06:46:27 · 469 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.组合(Composits)的AbortType理解
Composits有个中断参数,AbortType四个值,AbortType.None很好理解,就是没有中断。Lower Priority中断低优先级要想清楚这个意思,先得明白低优先级是什么,在这里低优先级是在节点右边的节点。这个行为树启动前,Sequece的AbortType被设置成None,C_Test的c被设置成false,这样C_Test返回失败,父节点Sequence也返回失败,那么Selector只有去执行Idle运行后也就是Log并没执行到。那假设有这样一种情况,在I原创 2021-05-15 19:20:42 · 1401 阅读 · 0 评论 -
Unity行为树插件Behavior Tree Designer记录.Movement的CanSeeObject
意如其名,这个做为一个行为树的判定行为节点,判定目标是否能被行为树的“主人”看见。之所以写因为这个Conditional很实用,官网帮助文档上作为范例来写。但很遗憾,先后再两个两个地方看到官方的两个bug。第一个地方在官网的pdf文档和官网的在线文档中https://opsive.com/support/documentation/behavior-designer/writing-a-new-conditional-task/这两地方都有一个CanSeeObject的简化版本。我只摘抄bug的部分原创 2021-05-15 16:35:44 · 1046 阅读 · 0 评论 -
Unity2D寻路插件Navigation2D Pathfinding简介和修改
调研了下,大概有两个插件可以用于Unity2D:1.PolyNav - 2D Pathfinding2.Navigation2D Pathfinding 当然,这些插件包括unity自带的Navmesh,还有那个著名的A start pathfind 插件,都是只用于客户端,不能用于服务器。根据AssetStore上的介绍,前者比较早,从unity5就支持...原创 2019-03-02 10:20:03 · 11705 阅读 · 5 评论 -
Obstacle Avoiddance之世界空间的坐标转局部空间坐标推导
根据《游戏人工智能编程案例精粹》第三章中中方法描述,整个算法中需要将世界空间的点转到局部空间。比如场景中有若干障碍物,但并不是每一个都需要检查,也就是先要筛选。这个筛选过程中过滤掉“后面”的障碍物是很重要的环节。所谓“后面”是相对的,是根据朝向来判断的。比如我现在正前方5米有一个障碍物,这个正前方是我移动的方形。那这个障碍物是应该要被检查的。如果我现在转向180度,移动方向就完全背对...原创 2019-02-20 00:22:21 · 736 阅读 · 0 评论 -
已知两点和切线如何确定圆心和半径长度
如图,已知点A,B,以及过B的切线。如果求的过AB的圆。1.确定圆心O(1)连接A,B, 在其二分之一处做垂线(2)过B做垂直于切线(3)两条垂线的交点就是圆心2.计算圆的半径根据图,实际是求三角形OBC的斜边OB长度。C是AB的中点(1)A,B已知,角a也就已知了。并且CB=AB/2(2)CB/OB=sin(c) =>OB= CB/sin(c)(3)...原创 2019-02-23 08:49:55 · 17876 阅读 · 5 评论
分享