See through Walls and Culling

Hi there.
First of all, thanks for this great Product and for giving it to me for free. I really appreciate that.

Now on with my Problem:
I have created a model of a room and a floor in Milkshape and exported it as 3dsMax-File. Then I imported it into Unity. Worked fine so far. The Model was created by creating plane, then extruding it to positive y. Then I duplicated the Top and mirrored it to the bottom and moved it up. Then I have reverted all Vertices. So you can’t see out from inside. But I can look into the Building from the Outside. How do I disable backface-culling fir this Object?
The other Problem is that I can see through the tiny walls. The blue stuff on the right is ok, thats the entrance, but the blue stuff on the left side is seeing through the Wall. I have added a Mesh-Collider to each Wall and the floor. How can I prevent this? I am using an FPS-Camera.
Hence this screen:
http://img23.imageshack.us/img23/1723/unity.png

And I have seen someone editing a level pretty fast in a Video. How can I do this like him? I could not figure it out :(.
http://www.unitytutorials.com/video/70/beginning-1-of-4
Thanks for your help.
rya.

ps.: Is there no lower price for the pro pc-engine as 1k Euro? Would love an indie-pricing model with restrictions in selling-price and stuff like that.

Perhaps some have overseen my question :).

Any way to post an image with a little more detail showing what you are describing? Maybe it’s just me but it’s hard to wrap my head around what it is you’re asking about based on that image.

Thanks for your reply and my apologies if my description does not point out my problem clear enough. So I have created more screenshots and I hope that they will make my problem more understable.

So, I create a plane in Milkshape:
http://img20.imageshack.us/img20/9795/milk1t.png

Then I extrude the Edges by a Factor of 18 to the y-coordinate:
http://img69.imageshack.us/img69/7409/milk2.png

Now I have still the Top of this Box selected. So I duplicate it and I mirror this to the bottom with a method of Milkshape:
http://img69.imageshack.us/img69/1099/milk3.png

Now I move this mirrored piece up to close the box and weld the vertices together so that there is no space. Since they are exactly beneath each other, it does not cause any funky effects and the quad is smooth:
http://img69.imageshack.us/img69/6784/milk4.png

Here you can see the camera inside the Box. You can’t see any solid mesh, because the backfaces are facing to the inside of the box:
http://img254.imageshack.us/img254/1442/milk5.png

Now I just reverse the Vertex Order and you cannot see to the outside any more:
http://img94.imageshack.us/img94/8946/milk6.png

The next step is to export this as .3ds-File from Milkshape and then I import it by drag&drop to the assets of Unity. There I select the Option “Generate Colliders” which makes me able to walk inside the Box using the provided FirstPersonCamera. This is how looks inside Unity, I have added some Lightning for you:
http://img692.imageshack.us/img692/5945/milk7.png

So now this is the whole way how I create my levels, I found this method in a Tutorial and it looked good. Now, if you walk around in the scene, you do not fall outside the box or so, everything is fine. But if you run against the Wall, you can see the outside, meaning the blue background of Unity. Thats what the previous Screenshot shows. And since this is a huge glitch, I want to remove it. I have uploaded the Model for you in 3ds-Format:

Now, with all Vertices showing to the inside, you can look inside the “building” if you are outside of it. The walls are simply missing. Well not missing, they are culled I think. Can I disable or reverse culling if the player stands outside the building?

I hope this detailed explanation made it clearer for you to understand my Problem. Thanks for your help.
regards

BY THE POWER OF THOR, THANK YOU!!! :shock:

As for the culling issue, there have been a whole bunch of threads on that topic over the past several years about that. I recommend searching “backface”. The easy answer is, if you want optimum performance, then duplicate the faces in Milkshape and flip their normals.

I’m waiting to download your .3ds file. In the future, please just upload the file into the forum. Waiting is totally boring! :frowning:

I opened your file, and saw that you did, in fact, not weld the vertices. There are two objects instead of one.

By just having the .3ds file, I can’t see why you’d have the “seeing through the wall” issue. How are you getting around the scene? Did you add a FPS Walker script? Can you give us a .unitypackage or project folder instead?

Thanks for yor reply and sorry for inconvinience.
Hmm, maybe I forgot to Weld the Vertes by this Model because I was making Screens. However, I do not think that this affects or causes the Problem. I have done a minimal sample of my problem and hope you can help me.

Uhm, I do not know how this can happen… When I import the Model to Unity, there are all Objects 2 Times: As Wireframe (I suppose?) and as an entry with a blue box in front of it. But you will see yourself.

Open the project and run against a wall. Then you will see the outside. If not, then its perhaps my Gfx-Card. It is an HD4890.

Download:

I am sorry, the forums did not let me upload my file… it always said “No post mode specified”. I hope it is not too much asked to download it from there.
regards

I can’t get that file until several hours from now unless you can upload the file to the forum. Try zipping or 7zip-ing the project or unitypackage and uploading that.

General Error
Tried to upload empty file

But the file is not empty… :?
Tried it as unitypackage, 7zip, zip and rar. Nothing worked. Sorry.
regards

Okay! I was emailed the file. Here’s your problem:

Your camera’s near clip plane is way too large.

I figured that was your issue, but I didn’t want to make that call based on the original screenshot, which confused me.

Thanks a lot. Set the clipping plane to 0.3 and I cannot look through any walls anymore.
Perhaps anybode has a good hint how to come up with a good value? Or is this okay?
regards

This code gets you the highest “safe” value possible, so that you will never see through anything close to you, as long it has a good collider. The character controller will block things from getting any closer. In practice, you might be able to set the value just slightly higher, because you generally don’t have colliders intersecting all the way into the character controller’s skin width. But this would be such a small difference that I wouldn’t even bother, especially since you’d run the risk of seeing through objects when you’re moving very quickly.

Now, as it is, your camera is not located far enough into the top of your character controller, so you could potentially look through ceilings, given this code. You can solve that problem by moving the camera further in. In your current project, you can do this by setting the camera transform’s y value to .6. (You just need to have it be below the hemisphere at the top of the character controller capsule).

Use this script by attaching it to the camera, and dragging the game object called First Person Controller onto the controller variable slot. And keep in mind that it won’t work if you move the camera off-center to the character controller. Let me know if you need help adjusting the script if you do make that change.

using UnityEngine;

public class CalculateMaxNearClipPlane : MonoBehaviour {


public CharacterController controller;

void Start ()
{
	Vector3 scale = controller.transform.localScale;
	camera.nearClipPlane = controller.radius * Mathf.Max(scale.x, scale.z) *
		Quaternion.Dot
		(
			Quaternion.Euler
			(
				-camera.fieldOfView,
				// We have to calculate the horizontal field of view.
				-2 * Mathf.Rad2Deg * 
					Mathf.Atan
					(
						Mathf.Tan(camera.fieldOfView * .5F * Mathf.Deg2Rad) 
						* camera.aspect
					),
				0
			),
			Quaternion.identity
		);
}
	

}

222813–8070–$calculatemaxnearclipplane_616.cs (572 Bytes)

Thanks a lot Jesse :slight_smile:
regards