我有一个222行和3列的数组。 222应表示我产生的球体数量和3列x,y和z位置。
现在我想以正弦波方式移动最后一个球体(球体222),我喜欢其他球体占据这个位置。换句话说
Y(221)= Y(222)
t = t-1
这意味着我需要访问222 for x,y和for z而
x应为:
//
float functionXvalue = 221 * scaleInputRange / 222;
if (animate) {
functionXvalue += Time.time * animSpeed;
应该是:
//
float ComputeFunction(float x)
{
return Mathf.Sin(x);
}
和z: 零
如何访问数组中的值并进行这些计算?
编辑: 到目前为止,我有这个:
// Update is called once per frame (ORIGINAL)
void Update()
{
//int initialpos = 10;
//create an array with 3 columns (x,y,z) and numberOfPoints rows
//Vector3[] arrayPosSpheres=new Vector3[(int)(20/(sizeSphere*overlay))];
for (int j = 0; j < 221; j++) {
for (int p = 0; p < 3; p++) {
arrayPosSpheres [j] [p] = arrayPosSpheres [j + 1] [p + 1];
}
}
//
float functionXvalue = 221 * scaleInputRange / 222;
if (animate) {
functionXvalue += Time.time * animSpeed;
}
arrayPosSpheres [221] [0] = functionXvalue;
arrayPosSpheres [221] [1] = ComputeFunction (functionXvalue) * scaleResult;
arrayPosSpheres [221] [2] = 0;
for (int m = 221; m = 0; m--) {
for (int q = 0; q < 3; q++) {
// access of x,y and z values of sphere 221
plotPoints [m].transform.position = arrayPosSpheres [m] [q];
}
}
float ComputeFunction (float x)
{
return Mathf.Sin(x);
}
}
但我有很多错误......
Assets / Scripts / SineWaveSpheres.cs(135,33):错误CS0022:错误的索引数1' inside [], expected
2'
Assets / Scripts / SineWaveSpheres.cs(156,17):错误CS0029:无法隐式转换类型int' to
bool'