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


GML Code Example

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.


GML Code Example

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.

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here