I have surface of floor like in screenshot http://prntscr.com/amqstw. If I move camera in some angle I don`t see angle floor : http://prntscr.com/amqt19. How I may resolve this problem.
That effect is due to backface culling.
In that angle (probably) the camera is inside the mesh of the floor, so the normal vectors of the cube (I presume) are facing the other way, and they get "culled" (become invisible).
You can turn it of in two ways:
By editing the mesh in your modeling software so that it becomes a
"double-sided mesh", or
By finding a shader online which, once
applied to the floor object, deactivates its backfire culling (harder
to do, without screwing up something else)
Related
I have thoses two meshes:
In my game, I put the hat on the hair at runtime:
As you can see, as expected, the hair is visible outise the hat part.
How can I achieve this in Unity (what kind of mask shader should I use?):
I've tryed to make a depth mask but it hides every meshes in my scene. I just want to hide the hair, not others meshes.
And what if I have two player having the same case? Would player mask hide player 2 hair? How can I avoid that?
What I would do:
write a C# code that gets the pivot position (bottom part of the hat) and its up vector every frame.
build a plane with these values. The up vector would be the normal vector of the plane and a plane can be defined by a point and a normal vector.
I would pass the equation of the plane to the shader (via Material.SetFloat or Material.SetVector) and evaluate if the world positions of the hair vertices are in the correct or in the wrong side of the plane.
I created 2 cylinders and put one on top of the other. Then I clicked to simulate physics and on each cylinder I added the following image blueprint, added a 50-point rotation on the z axis of each cylinder in opposite directions.
It turns out that in the simulation, when I perform, the cylinders rotate in one direction and move on the ground in the other direction. If it turns clockwise it moves left, and vice versa, and should be the other way around.
Can anyone help me solve this? It's for both cylinders to work together and I see how their simulation is accelerating with a constant rotation, but that's not what happens
If you want to simulate physics you should be applying forces to the cylinders using Add Torque in Radians or Add Torque in Degrees rather than modifying the rotation directly.
Alternatively, if you want to precisely control the cylinders, do not simulate physics. Instead, disable Simulate Physics and animate the rotation and position of the cylinders directly as you are.
I'm currently working on voxel terrain generation in Unity, and I've run into something annoying:
From certain camera angles, you can see seams between the edges of chunk meshes, as pictured below:
What I know:
This only occurs on the edge between two meshes.
This is not being caused by texture bleeding (The textures are solid colors, so I'm using a very large amount of padding when setting up the UVs).
The positions of all vertices and meshes are showing up as exact integers.
Disabling anti-aliasing almost entirely fixes this (You can still see the occasional speck along the edge).
I'm using Unity's default Standard shader.
Can someone explain what's causing this, and whether there's a way to solve this other than disabling AA?
Almost certainly the side faces are demonstrating z-buffer fighting with the top faces — precision is imperfect so along the seam of your geometry rounding errors are making the very top of the brown face of one cube seem to be closer to the camera than the very top of the green face of the next.
Ideally, don't draw the brown faces that definitely aren't visible — if a cube has a neighbour on face X then don't draw either its face X or its neighbour's adjoining face.
I have a projector component and I need to find the angle that projected texture falls at to exclude the projecting on vertical faces.
My projector is under the mouse pointer and works ok when it is over an horizontal face:
I would like the projector to switch off on vertical faces to avoid this bad effect:
If possible, I would like to do it in the shader code to avoid the vertical projected image even if the cursor is located on the corners of an horizontal face and a part "goes out" on vertical face.
I found this solution in C#:
if (Physics.Raycast(MouseRay,out hitInfo)){
if(hitInfo.normal.y>0) {
// draw
} else {
// not draw
}
}
But only it works on curved surfaces and not, for example, on the face cubes.
How can I do this properly?
Normally they would use an image on a quad using TGA transparency, which rotates itself to the face that the middle of the object is aligned to, using ray to find the vertex and making it's absolute normal.
Other ways of doing it would be quite tricky, perhaps using decals... If you did it using a shader, it would take so much time... it's a case of problem solving not being ordered in order of importance for fast development. Technically you can project a volumetric texture on top of whatever object you are using... that way you can add your barred circle projected from a point in space towards the object, as a mathematical formula, it takes a while to do, check out volumetric textures, i have written some and in your case it needs the mouse pos sent to texture and maths to add transparent zone and red zone to texture. takes all day.
It's fine to have a flat circle that flips around when you change the pointer onto a different face, it will just look like a physical card and it's much easier to code, 10 minutes instead of many hours.
Pre-info:
I'm making a 2D game in Unity which behaves like Castle Crashers, where the player can move around forwards and backwards like in a sidescroller, but also up and down, kind of like a topdown game - but it's still a 'sidescroller'.
In Unity I'm using Rigidbody2Ds and Boxcollider2Ds for physics.
However, when wanting to simulate things like dropping items, creating gibs or any other object that needs to fall to the 'floor', this gets tricky.
The objects that need to fall to the floor don't know where the floor is, so they'll fall forever.
Question
Can Boxcollider2Ds be set to collide with an individual infinite x-axis?
Object A should collide with the red axis and Object B should collide with the blue axis.
Is this possible?
You could use layers. And in project settings -> Physics2DSettings set them not to collide with each other. There is a hard limit of 32 layers and first 8 are used by system (you can still use them for this) this leaves you with 24 discreet layers - change layer of your objects when they change their position on Y axis. The gameplay might feel awful.
Use 3D physics. tilt your camera 45 degrees on X axis, set projection to ortho, and draw 2D sprites on top of invisible 3D physics objects - then you will have real 2D plane to walk and jump on.
Don't use box2d at all: write your own - simple physics library, you need it only for jumping and falling, right ?