x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to split a long TArray into multiple Fvector

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:

1.

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

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?

Product Version: UE 4.19
Tags:
more ▼

asked Jan 22 '19 at 03:14 PM in C++ Programming

avatar image

monviiva
7 1 1 6

avatar image HarryHighDef Jan 22 '19 at 03:20 PM

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

Should be:

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

avatar image monviiva Jan 23 '19 at 06:30 AM

I still get the same error.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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)

more ▼

answered Jan 23 '19 at 05:46 PM

avatar image

phil_me_up
1.1k 4 6 12

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question