- Home /
How to get the size of an array of object?
Hello, I work on a agar.io style of play and I do not know what to do to get all the objects and the screen by changing the camera's size. I don't know what to do. Maybe get the distance of the most far away object. Any suggestions? 'I can't give the script, sorry.'
what exactly do you mean with "all the objects"? every gameobject in the game? and what changing camera size? sorry but be more specific I don't understand what you want.
Terrible English... we can tell. But thats ok :) I am just going take a stab in the dark and guess at what you mean.
"How to get the size of an array of object?" arrayName.length;
"I do not know what to do to get all the objects and the screen by changing the cameras size" foreach(Stuff stuff in Otherstuff)
Answer by hexagonius · Jan 03, 2016 at 05:06 PM
Here you will find several formulas to calculate the frustum.
Adding all positions together and dividing them by their count gives you the center between them.
The rest ist figuring out camera position from that point and setting it's FOV.
Center the camera work perfectly! But for setting the FOV, i tried an other solution; the the distance between all object. I work too.
Answer by StuwuStudio · Jan 03, 2016 at 04:36 PM
I hate google tradution... By 'size of an array' i mean; if i have 3 objects in my array (gameobject), my camera need to get all them in the screen by changing the field of view and place the camera in center of the 3 objects.
Your answer
Follow this Question
Related Questions
Creating custom objects? 2 Answers
Iterating a GO through an array of transform positions 0 Answers
ObjectPicker Source Code? 0 Answers
Can't get more than one object. 1 Answer
Object carry in game 1 Answer