All default unity objects are black? - unity3d

This is the first time I've used Unity and I am trying to follow a basic tutorial on making a simple ball game. In the tutorial "Roll-a-ball", all of the objects appear white and you can see the shadows they make. I followed the tutorial completely, but everything I make shows up as black and I cannot differentiate the objects from each other. What is causing this and how can I fix it?

There is no camera added to your scene & also lighting.
Add the Main Camera & Directional Lighting. It will do the trick.

Related

Unity: Alternative for camera stacking/layering?

Unity 2021.3.16f1/URP 12.1.8
I've just started with Unity a few weeks ago and am still getting to grips with how everything works. So please don't assume I know everything there is to know about Unity. Treat me as a n00b. 😉
I'm building a VR game for the Quest/Quest2. I have a scene with a keypad on a wall. When the payer "clicks" it, I want the scene to go dark, and a large version of the (3D) keypad to appear with which he can then interact (enter numbers). This keypad must always stay in the middle of his view.
What I did was create a canvas, and added a black plane with 50% transparency and the large version of the keypad. I've set up the canvas as follows:
This works somewhat. It has two major disadvantages: 1) the keypad is receiving lighting from the scene while I want it to be fully lit all the time, and 2) the canvas and all its children clip through walls and objects while I always want it to be rendered in front of everything else (yes I know this will mess with your depth perception in VR, but I already have a solution for that).
So the next thing I tried, was stacking cameras. I created a second camera and set is as an overlay camera. I also set its Culling Mask to UI:
Additionally, I added the new camera to my Main Camera as a stacked camera. I changed the Culling Mask of the Main Camera to everything but UI:
This works they way I want it but at a cost: performance takes a huge hit. My frame rate actually halved. I read everywhere that this is a known problem for mobile devices (which the Quest really is).
Another solution I read about, is using RenderObjects. But I can't really find how to use this. I'm not even sure it really is a solution to what I'm trying to achieve.
So can anyone tell me how I should go about doing this? Thanks in advance!
The solution of lighting is the that you can setup the layer of your keyboard to something like "Keyboard"
And in Directional Light you can uncheck keyboard layer.
The solution of second problem is that you can change culling mask of camera on Run Time Like this:
~(1 << LayerMask.NameToLayer("Keyboard"))
renders everything except the transparent layer.
1 << LayerMask.NameToLayer("Keyboard")
renders only the transparent layer.
NOTE: You can set your own layer and check/uncheck what you want it is just a example

Unity URP Material scripting

I just started using URP in Unity for a game in progress. I'm doing a sort of sprites-in-3d thing, so I'm rendering some sprite sheets on quads. To do this, I create a Material with the sprite sheet and use tiling/offset to render the proper frame of animation by making a call like:
CombatMaterial?.SetTextureOffset("_BaseMap", new Vector2( (AnimationDefinitions[animationDefinition] % 16) * .0625f, CombatMaterial.mainTextureOffset.y));
I'm currently trying to add some feedback into my game for when characters use abilities or get hit by flickering the material. Because the base color starts at white and goes to black, that won't really work; the only other thing I seem to have available to me is emission, which looks great. Using a 0xAAAish color achieves the effect I'm looking for. I've been using the Feel Unity asset to do this, but I've also attempted using something like this:
CombatMaterial?.SetColor("_EmissionColor", Color.white);
The problem is, once I've set the _EmissionColor, the main texture offset no longer updates in game, thereby ruining all animations. If I change the texture offset manually through the inspector at runtime, animations don't work AND the _EmissionColor flickering stop working. If I mess around with the color of the _BaseMap in the inspector, _EmissionColor flickering starts working again.
Before I start diving into some unsightly color adjustments in an attempt to make this work again, I would love to know if I'm doing something that is simply unsupported by URP/Materials/whatever, or if there is some alternative to what I'm doing that's a little more straightforward.
Thank you!
After trying a bunch of random stuff, I don't have a "real" solution, but the game IS working how I want it to.
What worked for me was setting the _EmissionColor on the Material to (1,1,1). For some reason, when the _EmissionColor is set to (0,0,0) it's a black (ha) hole and won't accept future changes to the _EmissionColor. I assume this is some shader nonsense (with the base Lit Shader that URP uses) that I am clearly unfamiliar with.
Hopefully this helps anyone doing something as pointlessly against the grain as I am!

How can I make a cube hollow on the inside?

In general I wanted to make it in unity3d but I saw that in tutorials, they made it in blender.
This is what I did in unity:
I want to make this high cube hollow on the inside, and make a small door so that I will be able to walk inside the cube. Later on, I want to somehow add stairs but the problem now is how to make it hollow on the inside.
I saw in some places the suggestion to use blender so I tried this tutorial in blender:
Blender
But got stuck there after I checked the Add Mesh Extra Objects and clicked on Save User Settings. I tried then to click on the bottom on Add > Mesh but then I don't have Extra Objects. I have Extras objects like in the tutorial video.
Anyone my main goal is to make the high cube hollow on the inside with a small door on the bottom so I will be able to walk inside.
From what I know Unity3D has no 3DModelling by default (maybe there is something for that in store), so you need to use Blender or some other program (for example Maya). There is https://blender.stackexchange.com/ where you can ask same question (since it is not really unity3d related)
Maybe this will be helpful : https://blender.stackexchange.com/questions/5849/how-do-i-create-a-solid-object-cube
Overall what you could do, but it is not the est way - you can build a everything out of boxes yourself in Unity3D
Try use to boolean modifier. Take a look this tutorial:
Blender 2.6 Tutorial 26 - Boolean Modifier

Textures to Object in Unity / Vuforia

I'm trying to do some Augmented Reality in Unity using the Vuforia plugin. I've managed to get everything working (I'm using a 3d model of a car), only the position of the car relative to the marker is wrong when I come to preview it (click the 'Play button at the top and watch through the computer's camera - is 'preview' the right name for this?).
It should be sitting on the the marker in the center, but instead it's floating above the marker and off to the side by quite a bit. The positioning is definitely right in the program itself, so I'm not sure why this isn't reflected in the preview.
Also: at the moment the car is simply an untextured grey object. I realise the textures are included in a subfolder, however I can't drag the entire car's folder (including the Textures subfolder) into the ImageTarget, only the .3ds file itself. Does anyone know how to apply the original textures to the car?
Thanks so much for your help in advance!
Ben
Well, to start answering your question about the drifting away part, you've probably got a Rigidbody attached to your Car? Well, if that's the case, then Go to the Inspector where the Rigidbody is and you'll see constraints.
To avoid it floating off, you might want to check Freeze Positions for whichever direction it needs. Probably Y axis.
Now, I'm not entirely sure if you're using Vector.AddForce to move your objects, but if you are then just check if your car can move if you've put all constraints on.
If you can't then in your code trying using Object.Rigidbody.SetActive(true) when you need it to start moving, and Object.Rigidbody.SetActive(false) when its done.
On the other hand, if you aren't using Vector.AddForce() then remove Rigidbody component if you've used it.
As for the material. If you've got the material in your folder that you've downloaded then just drag and drop it into Assets. Now sometimes your car may be one solid mesh, but some times it may be multiple meshes. So which ever the case. Drag the material from your Assets onto the Hierarchy panel over your car mesh/meshes and it should turn into that color.
Hope it helps. :)

Shadows going through objects

I'm new to Lighting in 3D. Just started working with Unity3D. I was creating a sample for myself to test shadows and there is a problem.
As you can see that i have created two simple walls with two cubes. Also I have setup a directional light. Let's go the backside of the walls to view the problem
Technically the front wall should be blocking the shadow of the back wall. But it is not. I have painted a read line to show that where the shadow of front wall is overlapping the shadow of the other, meaning going all the was through the wall. Why is that happening. Help please...
set your shader to DIFFUSE. i have the same problem and solved this. my spotlight is passing thor
that is interesting indeed, i have used unity3d for 5 plus years and never seen or noticed this. however, this might seem like a weird request, could you set the ground and the two cubes to bumped diffuse and make sure the cubes are touching the ground.
Since the shader that is used might allow shadows to pass, secondly, could you go to player settings and check if you are using forward of differed rendering, since their lighting techniques are very different they might have different results.
but all in all, best guess is that the shader you are using allows shadows to pass.