NavMesh.SamplePosition 采样位置 How to get a random point on NavMesh?
来源:互联网 发布:美国歌手prince 知乎 编辑:程序博客网 时间:2024/05/01 08:02
转自: http://wiki.ceeger.com/script/unityengine/classes/navmesh/navmesh.sampleposition
转自: http://answers.unity3d.com/questions/475066/how-to-get-a-random-point-on-navmesh.html
I generated a random point with in a unit sphere and multiplied it by the max distance I wanted my agents to walk:
Vector3 randomDirection = Random.insideUnitSphere * walkRadius;
I then added my agents current position to this vector and used the NavMesh.SamplePosition function to find the close position on the NavMesh:
randomDirection += transform.position; NavMeshHit hit; NavMesh.SamplePosition(randomDirection, out hit, walkRadius, 1); Vector3 finalPosition = hit.position;
I then used final postion as the destination for my agent.
Hope this helps!
0 0
- NavMesh.SamplePosition 采样位置 How to get a random point on NavMesh?
- "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
- How to get to the point quickly?
- raycast navmesh
- Unity:Navmesh
- Unity Navmesh
- Unity-NavMesh
- How to get a stack trace on Windows zz
- the diary of how to get a random word within a file
- 【BUG】 "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
- "SetDestination" can only be called on an active agent that has been placed on a NavMesh. 解决办法
- Move can only be called on an active agent that has been placed a Navmesh的解决办法
- how to get a polygon
- How to get a solution?
- Find closest point on a Linestring to another point
- Unity关于 "Move" can only be called on an active agent that has been placed on a NavMesh.问题的解决办法
- Unity中BUG:SetDestination can only be called on an active agent that has been placed on a navmesh 的处理
- How to get sudo on Your ubuntu
- [HNOI2002] 公交车路线
- HDU2095find your present (2)
- 关于js框架react——mvc框架么?
- hdu 5976 Detachment 逆元+二分+数学
- 进程与线程
- NavMesh.SamplePosition 采样位置 How to get a random point on NavMesh?
- 基本数据类型
- POJ1502MPI Maelstrom 【Dijkstra】
- 初次接触Android Studio发现并解决的一些问题
- CodeForces 304A Pythagorean Theorem II 【基础】【暴力】
- 前端工程师面试题
- 主板知识详解:支持内存类型
- 关于Object被Destroy之后,该Object的原引用==null的问题
- 求n!中某个因子个数【模板】