- Home /
global way of measuring size of game objects
I'm trying to put a primitive unity cube exactly above the shelf shown in the image (it was taken out of its model) so the equation iam using is box's position = (shelf's position.x , shelf's position.y + (shelf size in y axes /2 ) + ( box's size in y axes /2 ) , shelf's postion.z) but neither lossyscale nor local scale return the desired size.
so as shown in the image i want to measure the size of the object relative to the global 1*1 square grid so for the z axes it should return 2 and for the z axes it should return .75 .
Is your model in the correct units when you import it into Unity? Either that, or the parent of the box is not where it should be, position-wise.
telling from the inspector, z is 4 and x is 37,5. so z is twice a unit and x is 50 times a unit. I think you should get your scales right in your modelling tool. other than that, the $$anonymous$$eshFilter.$$anonymous$$esh.Bounds are probably also relevant besides the scale.
Iam very new to the whole modeling and game dev thing i made the model.in blender the cube in the picture has different dimensions in blender (75,8,200 and z axis and y axis are switched
Answer by Anupam13 · Feb 16, 2017 at 01:48 PM
Steps- 1)Fill a square grid completely with your box/rectangle so that it accurately fits into the grid. 2)Note the x,y,z scales of the box and set them as the 'scaleFactor' for corresponding directions. E.g-scalefactorX=box.transform.localscale.x. 3)Take your original box that you want take the details of.(not the one that fills the grid to find scalefacors). 4)Now divide the localScale of each axis with the respective scaleFactor, which will return the generalized scale of your box with repect to global grids. e.g- your desired output should be Vector3(box.transform.localScale.x/scalefactorX,box.transform.localScale.y/scalefactorY,box.transform.localScale.z/scalefactorZ)
P.S.- this approach will give the accurate volume and edges of simple figures like rectangle, cube, cuboids etc. but for complex shapes, you will only get the corresponding localScales of a given game object.
Your answer
Follow this Question
Related Questions
Extraction of Coordinate and Scaling it down by half. 1 Answer
scaling objects with rigidbodies 2 Answers
Scaling and performance? 0 Answers
How to move button for it not to brake on different resolutions 1 Answer
Player Car Runtime Scaling Issue 0 Answers