c# - finding points along a vector in 3d -
i have 2 points in 3d space, , want list of points between them located "r" distance each other. how can using unity functions?
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; (int = 0; < count; i++) { result[i] = + delta * i; debug.log(result[i]); } return result; }
but .magnitude
, .normalized
expensive operations, try avoid using in update()
Comments
Post a Comment