How to split a long TArray into multiple Fvector

FVector vector =Array[i,i+2];

Should be:

FVector vector =Array[i,i+1,i+2];

I have a long TArray and I want to split into multiple FVector. Here is my Code :

 TArray<float> Array;

 Array.Init(1,1000);

 for(int32 i=0; i<Array.Num();i = i +3 ){
     FVector vector =Array[i,i+2];
     Function(vector);
 }

I get these errors:

**error: expression result unused [-Werror,-Wunused-value]
FVector vector = Array[i,i+2];

error: no viable conversion from
‘TArray FDefaultAllocator>::ElementType’ (aka
‘float’) to ‘FVector’
FVector vector = Array[i,i+2];

Any idea how to solve it?

I still get the same error.

Do you want something like:

FVector myVec = FVector(Array[i], Array[i+1], Array[i+2]);

The errors in your code are:

  1. To access the contents of an array you should provide a single index, not a comma seperated list of indexes (i.e. Array[0], not Array[0,1]
  2. You’re trying to convert a float to an FVector (i.e. you’re trying to do Fvector myVec = 2.0f). This isn’t valid, it needs to be assigned as a vector value so use a constructor as shown above).

Also note that FVector expects 3 values, not 2 as in your code (FVector2D will expect 2 values)