- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
请观看此短片以了解问题所在。一旦有大约 23 个字符,它们就会开始向不同的方向移动。请帮助我,我正在尽我最大的努力搜索了好几天并尝试了不同的寻路方法,但都没有成功。
http://screencast.com/t/sUx9O0I9GQ
我的设置是一个网格,角色有一个带有默认配置组件的 AIPath。肯定是可以的,因为我在压测视频里看到了:https://www.youtube.com/watch?v=htoen7x3LuQ
这行代码导致了问题:
seeker.StartPath (transform.position,target.transform.position, OnPathComplete);
完整的上下文
public void Start () {
InvokeRepeating ("searchPath", 1.0f, 1.0f);
searchPath ();
}
public void searchPath() {
GameObject target = GameObject.Find ("Target");
seeker = GetComponent<Seeker>();
controller = GetComponent<CharacterController>();
//Start a new path to the targetPosition, return the result to the OnPathComplete function
seeker.StartPath (transform.position,target.transform.position, OnPathComplete);
}
public void OnPathComplete (Path p) {
Debug.Log ("Yay, we got a path back. Did it have an error? "+p.error);
if (!p.error) {
path = p;
//Reset the waypoint counter
currentWaypoint = 0;
}
}
public void Update () {
if (path == null) {
//We have no path to move after yet
return;
}
if (currentWaypoint >= path.vectorPath.Count) {
Debug.Log ("End Of Path Reached");
Destroy(gameObject);
return;
}
//Direction to the next waypoint
Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized;
dir *= speed * Time.deltaTime;
controller.SimpleMove (dir);
//Check if we are close enough to the next waypoint
//If we are, proceed to follow the next waypoint
if (Vector3.Distance (transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) {
currentWaypoint++;
return;
}
}
正如标题所说,这是 Aron Granberg 的寻路项目 http://arongranberg.com/astar/
谢谢
最佳答案
我得到了 A* 寻路项目的作者 Aron 的回复。
Hi
This is due to a high load on the pathfinding system. An agent might request a path when it is at some point, but since it takes some time for the path to be calculated, the agent will have moved when it gets the result back. The AIPath script tries to fix this (assuming the closestOnPathCheck field is enabled) but it cannot do it at all times. The solution is to reduce the load on the pathfinding system and the game. First, make sure you have multithreading enabled (A* Inspector -> Settings), also it is probably a good idea to turn off Show Graphs for larger graphs since drawing that is pretty slow and will reduce the fps significantly. You can also increase the pickNextWaypointDistance and the forwardLook fields on the AIPath script, that will reduce the chance of this happening.
添加光线转换修改器将进一步提高性能。免费版仅支持一个线程,专业版最多支持 8 个线程。
关于unity3d - Unity A* 寻路项目 : Repath makes the character move to the opposite direction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34008700/
我正在尝试提供即时转码的视频。不幸的是,这意味着寻求不起作用。我假设这是因为浏览器不知道视频有多长,因此无法正确显示搜索栏。 有谁知道是否可以对视频的时长进行硬编码? 我想到的另一个选择可能是创建我自
我是一名优秀的程序员,十分优秀!