Returns the mean (average) of up to 16 real value arguments.


mean(val1, val2, ... val15);

Argument Description
val0 ... val15 The values to compare.

Returns: Real


This function works by adding up all the input values and then dividing them by their own number. So, mean(2, 6, 9, 32) returns 12.25 as 2+6+9+32=49 and 49/4=12.25.


xmiddle = mean(obj_player1.x, obj_player2.x, obj_player3.x);
ymiddle = mean(obj_player1.y, obj_player2.y, obj_player3.y);

This will set xmiddle and ymiddle to the x and y coordinates of the average of the coordinates of three player objects, obj_player1, obj_player2 and obj_player3. You could, for instance, use this to keep the game camera focused on all three players instead of just one.

Back: Real Number Functions
Next: median
© Copyright YoYo Games Ltd. 2015 All Rights Reserved