Deploying to Hololens 2 - unity3d

I opened up a unity project and simply put a cube on the scene view. I then got it to deploy in Visual Studio 2019 without any errors.
When I viewed it in Hololens 2, it shows up as a blank image with no error message to be found anywhere.
Any idea as to what could be happening that would cause this?
Thank you

Since I can't add a comment yet, here's an answer that should be seen as an addition to Hernando - MSFT's answer.
Additionally to the scaling of the cube, it makes sense to position it reasonably. As already mentioned, one unit corresponds to one meter.
In the Inspectorview of the cube, Z is the distance to the camera and X and Y are the horizontal and vertical offsets.
Reasonable values for the mentioned position are X/Y/Z equal to 0/0/0.5 for example. Then the cube should be in front of you after starting the application.

Have you manipulated the cube's Scale property after adding the cube into your scene?
In MR spatial coordinate system, 1 unit = 1 meter, and the default Scale property of the new cube is "1, 1, 1". This means that the cube will be too large to completely block your view, so you can only see a blank.
We recommend that you try to manipulate the cube's Scale property to "0.1, 0.1, 0.1" for testing, if you see any different behavior, please let me know.

I think it can be
your box is too large and near the camera
or the Clear Flags of Camera is Skybox. If so, you can try to use DefaultHololens2ConfiurationProfile

Related

Unity: skinned mesh vertexbuffer output slightly different than correct results

It’s like this hip is stuck in place, with in the pictures(being at different times in the animation since I can’t upload a gif) the red wireframe is the drawing of the raw output triangles and everything else being default unity, aka the correct output
What am I doing wrong? What am I missing? This has been driving me nuts for 2-3 days now, any help is appreciated
As you do not post any code, I will try to do some guessing over what is going on. Disclamair: I actually happen to run into similar problem myself.
First, you must know that Update's of MonoBehaviour are called in random order (not neccessery random-random, but yous see the point). If you bake mesh in one component, it can still be one-frame late to the Animator component.
There are actually two solution of this case: first is to specify the order of Script Execution Order in Project Settings, while the second is to use LateUpdate instead of Update when updating mesh after skinning.
The second problem you might have run into is scale / position of skinned mesh. Even if it does not contribute at all to the animation movement it can still wreck the mesh baking collision later on.
To fix that make sure that all your SkinnedMeshRenderers objects have Local Position, Local Rotation and Local Scale set in Transform component to identity (0,0,0 for position and rotation, 1,1,1 for scale). If not - reset those values in editor. It will not change animations, but it will change mesh generator.
If both solutions does not work, please describe the problem more thoroughly.

Unity some of the object comes with wrong axis from blender fbx file

The problem I have is simple. When I export my file in a blender as fbx and import it to the unity, the objects (or part of the objects for some reason) turn into the wrong axis while it looks ok in both blender and fixes file. I looked at google for this problem. Most of them did not help me. I saw that coding might help. I found a code that can help me which is this:
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
But the problem remains because it changes all of the rotation of the road, so the right roads become wrong while wrong roads become right. Putting this in the necessary planes might work but there are so many planes and I will put more planes in the blender project in the future so it won't help me too much.
I have two options.
Write a code that changes it to the right axis if the plane/object looks at the wrong axis.
Find the right way to import it.
I don't how to do any of the time since I am a beginner. I use Unity 2019.4.33f1 and Blender 2.83. Please help me
https://drive.google.com/drive/folders/13Y-lnccTvNPWPKAT520CCM8u-7MgaXkR?usp=sharing
Thank you
EDIT: I put my blender file to the drive link as well.
EDIT2: I keep editing I know but I realize that I have another problem as well. The problem is that Unity gets my object wrong, for example, I have a half green half red object and I want both colors to be at the +y axis. It makes the red part at -y axis. Here are the pictures: https://drive.google.com/drive/folders/1ob5xdKv0nPHN3TSABHGDVA7inW8vkag6?usp=sharing
How can I fix this :'(
LAST EDIT: I found a way to solve it. I added the same object twice but one of them has a different setting. Assume that rotations are 0 0 0 (x y z respectively) and scales are 1 1 1 (x y z respectively). The second road will be different settings from the first road. Its rotation settings will be 0 0 180 and the scale will be -1 1 1. Of course, I am open to better suggestions but this is the solution I found.
SOLUTION: After a long time later, I finally found the answer. I updated this in case someone needs it later. All I had to do was calculate the normals again and the way we do is, after choosing all of the roads, Edit Mode -> Mesh -> Normals -> Recalculate Inside / Recalculate Outside
Blender uses a left handed coordinate system, where the Z axis points upwards, whereas Unity uses a right handed coordinate system, where the Y axis points upwards. There might be some extensions or packages to keep them the same, however you probably just have to rotate the model in Unity or Blender to fit your needs.

Explanation of how to calculate transforms in Unity

I am getting started with Unity and am just trying to get my head around the units. What are these units? It seems they are their own 'quantity' and to treat 2 units as 2 times the value of 1 unit.
Anyway - I am trying to workout how to optimally calculate transforms to objects sit exactly where I want them to.
In my scene I have a terrain and a cylinder as so:
As you can see my cylinder is floating. I want the cylinder to sit perfectly on top of the terrain.
My terrain is at the following transform: 0,0,0 and scale 0,0,0 (not sure how to tell it's dimensions yet).
My cylinder is part of a new object, as so:
My FirstPersonPlayer is at transform: 85.9,2.165,51.8 and scale 1,1,1. My Cylinder is at 'localposition' 0,0,0 and local scale 1.2,1.8,1.2
Now - the transform of FirstPersonPlayer on the y axis appears to be what I need to correct.
Currently it is set to 2.165 and is floating a bit above the terrain.
Through manually shifting it, around 1.85 looks about right - but I want to know how to calculate that, rather than doing a finger in the air 'that looks about right'.
Can anyone help me? (Before you suggest using gravity etc , I actually am, but don't want the player falling as soon as they start, however slight that may look or feel.
Many thanks,
As per #Nikola Dimitroff the answer is:
You don't have to compute anything, hold Shift + Control and drag the object. Every game engine ever made calls this "Snap to Ground"
I appreciate and agree with the other comments.

Weird Lines 3D Unity

I'm working on a project, using unity 5.4.
In this projects blocks are stacked next to eachother.
However there appear some annoying weird lines. Also on android these
line occur more often than on PC.
For illustration purposes I added an image and video.
Please zoom in on the picture to see, the line I'm speaking of, clearly.
Could anyone please provide a solution to get red of this nuissance.
Thanks in advance.
Literature:
Block alignment code snippet:
for (int x = 0; x < xSize; x++)
for (int z = 0; z < zSize; z++)
{
Vector3 pos = new Vector3(x, -layerDepth, z);
InstantiateBlock(pos);
}
Video link: https://youtu.be/5wN1Wn51d_Y
You have object seams!
This occurs when there is a physical or perceived gap between objects.
There are multiple causes for this.
1. Floating Point Imprecision
This could be because you are setting the position of the cubes to int's but they have floating point dimensions. The symptom for this is usually no white seams when the camera is close to the objects, and then they gradually appear as you get further away due to floating point imprecision. More.
Most of these blocks appear to line up exactly, from most camera positions. But from the occasional unfortunate position, the exact value for A's position plus its vertex at (0.5,0.5,-0.5) might be slightly different to object B's position plus its vertex at (-0.5,0.5,-0.5) . The result is that Unity shows a tiny gap, within which you can see the shadowed side of cube A.
If you consider the following on paper 3 == 1/3 * 3 this is mathematically correct, however using floats, 1/3 == 0.333333... and subsequently 3 * 0.333333... == 0.999999... BINGO! random gap between objects!
So how to solve? Use floats to calculate the positions of your objects. new vector3(1,1,1); should be new vector3(1f,1f,1f); - for example. For further reading on this try this SOP.
2. Texture Wrap-mode
If you are using textures on your objects, try changing the Wrap-Mode of your texture from wrap to clamp, or try upping the texture padding.
3. Shadow Acne - (Lighting and Shadow artifacts)
This is the arbitrary patterns of pixels in shadow when they should really be lit or NOT lit.
To prevent shadow acne, a Bias value can be added to the distance in the shadow map to ensure that pixels on the borderline definitely pass the comparison as they should, or to ensure that while rendering into the shadow map. source.
In Unity... go to your light source and then increase the Shadow Type > shadow Bias I would suggest doubling the default value of 0.05 and then continue so until fixed. You don't want to crank this value to max because...
Do not set the Bias value too high, because areas around a shadow near the GameObject casting it are sometimes falsely illuminated. This results in a disconnected shadow, making the GameObject look as if it is flying above the ground.
Are you using different blocks that you put against eachother? Your problem sounds like the blocks are not completely against eachother which causes you to see the side of the next block (this explains the camera Y changing: you might see the side better from higher up). That side will have different lighting and appear as a different/lighter colour. To check if this is the problem, try overlapping them slightly manually in the editor and see if the problem still occurs.
Making the blocks kinematic solves that. The issue is the rigid bodies bumping up against one another.

.dae model disappears when approaching

When I move towards my .dae imported model, it disappears. I'm not "inside" the mesh yet, visibly at least, so I don't know what the deal is.
It looks like your object is closer than the scene-view camera's "Near Clip Plane", and is not being rendered as a result. The default editor "near clip plane" distance is around 0.3 units, so it shouldn't normally interfere with your objects.
Check that your object scale is correct. If your object is very small, the scene camera's near clip plane will seem much farther in comparison, and will appear to clip objects more aggressively.
You can create a default "Cube" primitive to check the size of your objects. Cubes are 1 unit in all dimensions by default, and most of the time it's a good idea to roughly map one unit to a real-world scale of 1 meter. If your object is considerably smaller than the cube, you may want to try scaling them up and seeing if that helps.
F key is a shortcut key that will automatically zoom and focus to an object. Select the GameObject and press F. This problem should be gone.
If the problem is still there, select the Camera and change the Clipping Planes Near to 0.3 and Far to 50000. You can mess with these values until Object stops disappearing. Although, pressing F should solve it.