最佳答案
Vector3[] GetPointsInbetween(Vector3 a, Vector3 b, float offset){
int count = (int)((b - a).magnitude / offset);
Vector3[] result = new Vector3[count];
Vector3 delta = (b - a).normalized * offset;
for (int i = 0; i < count; i++) {
result[i] = a + delta * i;
Debug.Log(result[i]);
}
return result;
}
但是.magnitude
和.normalized
是非常昂贵的操作,尽量避免在Update()
中使用它
关于c# - 沿 3d 向量查找点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36056760/