- Home /
Question by
TheNinjassin · Mar 15, 2015 at 01:46 PM ·
average
Generic List , average directional vector
Hi,
so in my game I'm creating a list of directional vectors and at certain points I need to find the average direction vector before that point. How can I find the average vector from a list?
Many Thanks, Alec.
Comment
Best Answer
Answer by raulrsd · Mar 15, 2015 at 02:22 PM
You could try something like this:
using System.Collections.Generic;
Vector3 AverageVector(List<Vector3> vectorList){
Vector3 acumulateVector = Vector3.zero;
foreach (Vector3 v in vectorList){
acumulateVector += v;
}
return acumulateVector / vectorList.Count;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613190214im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Average of Normals 1 Answer
How to get the median value of a set of data? 0 Answers
Is it possible to simplify a 3D looped curve? 0 Answers
get the average of a bunch of floats 2 Answers
Compare Vector3 3 Answers