duck

unity 3d finding average position of many objects

Jul 13th, 2011
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.28 KB | None | 0 0
  1. private Vector3 AverageSeatPosition()
  2. {
  3.     Vector3 avgPos = Vector3.zero;
  4.     if (seats.Count > 0) {
  5.         foreach (Seat _seat in seats)
  6.         {
  7.             avgPos += _seat.transform.position;
  8.         }    
  9.         avgPos /= seats.Count;
  10.     }    
  11.     return avgPos;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment