I'm very beginner in Unity so please forgive if, this questions isn't so hard to answer:)
So, I have a text on a Canvas in the editor, it is okay, it's showing well on Scene editor and In Game as well.
But, when I added two Sprites, which going to be the player and the enemy, the positions of these sprites are behave a bit weird.
The text position is: x: -293 y: 195, when I'm modifying the position of the text it works fine.
When I add the sprites to x:0 y:0 and x:1 y:1, in the scene editor they appear in the left bottom corner, but when I check in the game, they placed in the middle of the screen.
My question is why the coordinates and the positions are so different on Scene (grey) and on Game (blue) ?
Because initialized render mode of Canvas in Unity is "ScreenSpace - Overlay". So it is shown on too big area in scene. If you want to work only in view field of camera, in inspector just change render mode of Canvas to "ScreenSpace-Camera" and drag your MainCamera to RenderCamera in inspector. Even if you use ScreenSpace-Camera, coordinate system of RectTransform (UI Objects transform) is different than Transform (Normal game objects transform)
in this view, if you get closer to the left-down corner of your scene, you will see your main camera area and Sprites that are in correct positions.
I hope this helps.
Related
hierarchy
2d sprite
panel UI
in game
Fist make sure your canvas' Render Mode is not set to Screen Space - Overlay.
If it is, then switch it to Screen Space - Camera and then change its Render Camera property to point to your main camera.
You can then use the following canvas' properties to control where it appears in relation to other sprites (which appears on top of which), the same way you control any other 2D Sprite:
Sorting Layer
Order in Layer
Also worth noting that 2D Sprites with same Sorting Layer and Order in Layer will use the distance to the camera to decide which one appears on top of which, and the same is true for the canvas:
If your canvas' Render Mode is set to Screen Space - Camera, it will always be positioned in front of your camera and you need to use its Plane Distance property in order to position it correctly.
If your canvas' Render Mode is set to World Space, you can position it freely in the world in the same way you position any other sprite.
First of all the hierarchy window in unity is completely irrelevant when its about positioning.
In Unity everything is 3D, even if you switch to 2D perspective.
So in your case you still have your camera, your sprite and your canvas in a 3D Dimension.
To set your sprite in front of the canvas you only need to increase the positioning stats (seen in your "panel UI" screenshot) at least slightly closer to your camera than the canvas is.
In Unity3d, I'm trying to make a simple metaball effect using multiple sprites of a blurred round, and those sprites move randomly.
Thus I'd like the shader to perform a pixel color change from the rendering of all the sprites all together and not one by one.
Here is an example :
The picture on the left shows four sprites with the blurred sprite ; the picture on the right is the result of the shader.
And I have no clue of how to do this.
If I understand your question correctly, what you can do is
Create a new RenderTexture
Move these sprites off-screen, out of the main camera's view.
Point a new orthographic camera at all of the sprites that you've moved off-screen and set this camera's Target Texture field (in the Inspector view) to the render texture. This will save whatever the camera is seeing to that texture.
From here you can render that texture onto the surface of another game object (maybe a Quad?)
Attach a custom shader material to that quad that takes the render texture as input.
Perform whatever operations you wish to the render texture within this shader
Position this quad object in front of your main camera so that the final result gets rendered to screen
Does this make sense?
I'm using a google cardboard camera (GVRMAIN) and it is placed in the center of my gameobject when i build it it goes up. It is now in different position from the game view in unity. Help me guys please
Maybe your scene gets scaled up or down on the device and the gameobject moves its position from to original position in the unity editor. So if the camera is attached to the center of this gameobject it also changes positions.
You should attach the camera to a gameobject thats always staying on the same position regardless of the current aspect ratio.
I'm facing a problem in my scene i drop a object ball in hierarchy and arrange its position in center. But it's not showing that ball in Scene and Game tab it only shows its circle collider radius like this:
But when I untick and then tick again back to a component sprite renderer then it's show that object in Scene and Game tab like this:
Check your material. Possibly this material have selected not-existed shader.
Check Sorting layer. It must be higher than background Sorting layer
I am using Vuforia and Unity to do AR. So far I have gone through the ImageTarget example, and am able to see the teapot using my Samsung Galaxy S4. I've also managed to overlay some UI elements on the screen.
Now, I'm trying to place a persistent 3d object (capsule for example) in the world.
However, when I place a capsule say, next to the teapot, I see only a white screen when I start the android app.
Why is this so? How can I resolve this?
My scene hierachy is like this
ARCamera
Directional Light
ImageTargetChips
ImageTargetStones
Canvas <-- for UI overlay
EventSystem
Capsule <-- adding this into the world causes screen to turn white
Even if I shift Capsule to under ARCamera, I only see white when I start up the app.
Thanks.
You have to learn about the Unity hierarchy. Everything, i.e., 3D objects, image, audio, etc., i.e content associated to specific image target must be Hierarchically child of ImageTarget.
Here, you need to put your 3DObject (Capsule) inside the image target (Stones/Chips).
Like
> +ARCamera
>
> -ImageTargetChips
>
> Teapot
> Capsule
And then adjust the position & Scale of capsule (3D Object)
Your 3D object must be in a camera view:
eg. Position of camera: x:0 y:0 z:0
Position of image target: x:0 y:0 z:-60
Here, Z axis is "Depth"