Misconception about how the scales work - unity3d

I am a beginner in Unity and I can't understand how the scales of GameObjects work; in the following picture I have a quad and a sprite. The quad's scale should be smaller than the sprite's scale, but in the editor when I touch them they have the same scale of 1.

Short Answer
Every object has a baseline (1, 1, 1) scale when first created. The size for a 2D sprite and 3D quad object are calculated differently for each, which is why they are not the same size in your screenshot.
Long Answer
The sprite is a 2D object and its size is based on the import settings of the sprite. The default size for sprites is 100 pixels is 1 unit.
The quad is a 3D object and its size is based on what 1 unit is in Unity. In Unity's settings, 1 unit is 1 meter, by default. So, the quad is 1 meter cubed, by default.
If you import a sprite that is 100x100, and keep the default 100 pixels is 1 unit, it should be the same size (with an orthographic camera) as the default quad size.

Related

Why is my Unity plane seemingly 10 times too big

I'm a relative Unity noob. I have a fairly simple scene. Currently in the following you will see a plane (object WorldTilemapGfx) and 2 sprites (Tile C: 0 R: 0, and Tile C: 1 R: 0).
In the following picture you see I've selected one of the sprites. Its scale is 1 x 1, and its at position 1, 0.
Now I select the other sprite.
So far the positions and sizes seem ok.
Now if I select the game object with a "plane" mesh it shows in the inspector as scale 2, 1. This is the scale I expect since it is supposed to be as wide as two of the tiles above, and as high as only 1 of them.
However its visually 10 times too big.
If I increase the X scale of one of my tiles by 10, then the relative sizes between tile and plane look ok
Also the image used for my tile is 256 x 256.
Can someone suggest what I am missing? Thanks.
See Unity Mesh Primitives
Plane
This is a flat square with edges ten units long oriented in the XZ plane of the local coordinate space. It is textured so that the whole image appears exactly once within the square. A plane is useful for most kinds of flat surface, such as floors and walls. A surface is also needed sometimes for showing images or movies in GUI and special effects. Although a plane can be used for things like this, the simpler quad primitive is often a more natural fit to the task.
whereas
Quad
The quad primitive resembles the plane but its edges are only one unit long and the surface is oriented in the XY plane of the local coordinate space. Also, a quad is divided into just two triangles whereas the plane contains two hundred. A quad is useful in cases where a scene object must be used simply as a display screen for an image or movie. Simple GUI and information displays can be implemented with quads, as can particles, sprites
and “impostor” images that substitute for solid objects viewed at a distance.
Ok.. confirmed using a Quad gave me what I expected in scale.. I now understand that the underlying plane mesh is actually 10 x 10 in size.
https://forum.unity.com/threads/really-dumb-question-scale-of-plane-compared-to-cube.33835/#:~:text=aNTeNNa%20trEE%20said%3A-,The%20plane%20is%20a%2010x10%20unit%20mesh.,a%20quick%20floor%20or%20wall.

Unity, Relative dimensions of gameobjects

I saw some documents saying that there is no concepts of length in Unity. All you can do to determine the dimensions of the gameobjects is to use Scale.
Then how could I set the overall relative dimensions between the gameobjects?
For example, the dimension of a 1:1:1 plane is obviously different from a 1:1:1 sphere! Then how could I know what's the relative ratios between the plane and the sphere? 1 unit length of the plane is equal to how much unit of the diameter of the sphere!? Otherwise how could I know if I had set everything in the right proportion?
Well, what you say is right, but consider that objects could have a collider. And, in case of a sphere, you could obtain the radius with SphereCollider.radius.
Also, consider Bounds.extents, that's relative to the objects's bounding box.
Again, considering the Sphere, you can obtain the diameter with:
Mesh mesh = GetComponent<MeshFilter>().mesh;
Bounds bounds = mesh.bounds;
float diameter = bounds.extents.x * 2;
All GameObjects in unity have a Transform component, which determines its position, rotation and scale. Most 3D Objects also have a MeshFilter component, which contains reference to the Mesh object.
The Mesh contains the actual shape of the object, for example six faces of a cube or, faces of a sphere. Unity provides a handful of built in objects (cube, sphere, cyliner, plane, quad), but this is just a 'starter kit'. Most of those built in objects are 1 unit in size, but this is purely because the vertexes have been placed in those positions (so you need to scale by 2 to get 2units size).
But there is no limit on positinos within a mesh, you can have a tiny tiny object od a whole terrain object, and have them massively different in size despite keeping their scale at 1.
You should try to learn some 3D modelling application to create arbitrary objects.
Alternatively try and install a plugin called ProBuilder which used to be quite expensive and is nowe free (since acquired by Unity) which enabels in-editor modelling.
Scales are best kept at one, but its good to have an option to scale - this way you can re-use the spehre mesh, or the cube mesh, (less waste of memory) by having them at different scales.
In most unity applications you set the scale to some arbitrary number.
So typically 1 m = 1 unit.
All things that are 1 unit tall are 1 m tall.
If you import a mesh from a modelling program that is the wrong size, scale it to exactly one meter (use a standard 1,1,1 cube as reference). Then, stick it inside an empty game object to “convert” it into your game’s proper scale. So now if you scale the empty object’s y axis to 2, the object is now 2 meters tall.
A better solution is to keep all objects’ highest parent in the hierarchy at 1,1,1 scale. Using the 1,1,1 reference cube, scale your object to a size that looks proper. So for example if I had a model of a person I’d want it to be scaled to be roughly twice as tall as the cube. Then, drag it into an empty object of 1,1,1 scale this way, everything in your scene’s “normal” size is 1,1,1. If you want to double the size of something you’d then make it 2,2,2. In practice this is much more useful than the first option.
Now, if you change its position by 1 unit it is moving effectively by what would look like the proper 1 m also.
This process also lets you change where the “bottom” of an object is. You can change the position of the object inside the empty, making an “offset”. This is Useful for making models stand right on the ground with position y=0.

Swift: How to set size of particle effects with SCNParticleSystem?

I have simple ARKit app (using SceneKit) with cubes floating in space that I am shooting with other objects. I created .scnp file with Fire as a template and customized it to sort of look like explosion.
Everything looks good and works on collision, but my whole particle effect takes whole screen. I tried every property available on the .scnp file but the size is still enormous.
How can I set the effect area size? For example to be slighty bigger than my cubes (with width 0.1 meters).
This is how run the explosion:
let fire = SCNParticleSystem(named: "explosion.scnp", inDirectory: nil)
contactNode.addParticleSystem(fire!)
contactNode is my target cube.
The particle system property you’re looking for is particleSize. (There’s a control for setting that property in the Xcode particle system GUI editor, but I forget what it’s labeled...)
The docs for that property say:
The rendered size, in units of the scene’s world coordinate space, of the particle image.
In ARKit, scene units are the same as real-world meters. So while a particle size of, say, 10x10 might make sense in some arbitrary scene, in AR that makes each particle the size of a house. You probably want values somewhere in the scale of millimeters to centimeters (0.001 - 0.01).

Fix material with no texture?

I made a new diffused material for grass in unity5 when applied it to a somrthing small in size it has all the details of the texture grass image but when applied the same material to a much larger objects only solid color is visible with no details of the texture.
refer the down given image.
both the cube and the floor has same material.
MaterialSetting
Increase the tiling. The image will stretch to be 1 x 1 on a huge object the way you have it in your image. The higher the tile count the more the image will be repeated across the object.
Be aware the x and y values may be different to one another depending on the dimensions of the gameobject it is attached to.

How to calculate scale size of sprite object in unity

I have image of sprite having size 90 X 120 and I want to load that image in unity,
Now when I am loading that image it is look like stretch in height and width I am setting scale value of the object but It is look like not proper as I am just doing error and trial method.
can any one tell me how to calculate so the I can load proper image of sprite in scene.
means if my main camera size is 100 and type is orthographic.
and when I create sprite object below are setting which is been given to object
Texture type = Sprite
Sprite Mode = single
Pixel To units = 100
pivot = center
Max size = 1024
Format = 16 Bits
Now can any one tell me if any setting need to change or how to calculate the scale size of sprite as per above info so that sprite look good