Why can I see the inside of a room as soon as I cross it, in Unity? - unity3d

I am currently working on a 3d game in Unity, and I am working on the level design using ProBuilder. I basically created a huge cube which I "flipped normal", and a second one way smaller
which, as the other one, I flipped normal, but as soon as I crossed it while turning backward I could weirdly see through the small cube, which makes it feel unfinished. How could I fix this issue?

Normally in 3d games triangles can only be seen from one side. Usually this is not a problem because walls have some thickness. Since you clearly have paper thin walls made of only one layer of triangles this is exactly the result you should expect.
In short add the other side to your walls. The simples way is to duplicate the existing triangles and flipping them. Walls will still be paper thin of course. Later you should probably make them thicker.

Related

Drawing continuous lines on Xcode/Unity

I am making a app which draws continuous lines like a snake using Unity and SKSpriteKit (Obj-C) in Xcode (I’m making 2 versions of the same app in both):
http://i.stack.imgur.com/qA1zk.png
http://i.stack.imgur.com/484kj.png
http:// i.stack.imgur.com/QTEkC.png (Apologies for the image posts. I can't post an image/more than 2 links)
If you’ve ever heard of a game called Curve Fever, what I’m doing here is quite similar to it. I’m controlling the direction of the end of the line with the arrowkeys, whilst the end of the line automatically moves forward every frame creating an image like the one above.
However, from the 3 screenshots above, it is quite obvious that my program isn’t very efficient - every frame, I add a circle sprite to the SKScene in the place where my moving sprite is, which is why, after a while, there are over 1000 nodes on the screen, and the energy impact/memory/cpu is very high… Not ideal.
So now I’m looking for better ways of drawing the line on the screen without drawing thousands of nodes.
A while ago, a friend talked to me about how he made a similar app in GameMaker (which I have no knowledge of how to use). When I asked him how he rendered the line, he said he created something called a “surface”, and when anything moved on that surface, the old position of the sprite would still stay there - which would create lines if a circle moved across the surface.
He was rather vague about this, and I tried to do some research later, but with no success. I couldn’t find anything relevant about continuous lines, surfaces and GameMaker, Xcode or Unity.
If someone could come up with a solution like my friend was talking about, for Xcode/Unity - preferably both (or if someone could tell me what he was talking about for GameMaker), then I’d be grateful, as this would optimise my game and reduce the severe lags I get after around 30 seconds.
Also, I’d be grateful if anyone could suggest alternative solutions to this, too.
I'm using GameMaker but I have no knowledge of Xcode or Unity. I can't help you directly but I can explain GameMaker surfaces.
Surfaces in GM are objects where you can draw on instead of directly drawing on the screen. Later you can draw the surface to the screen. The main advantage of it is that you can store a surface and for example draw it again in another tick, while the screen is redrawn in every tick, or that you can change it over time.
Surfaces are basically just bitmaps where you draw on. That means it wouldn't be hard to do the same in any other environment. Most other libraries/APIs call it canvas.
In your example you would draw one circle to the bitmap in each tick and then draw the whole bitmap to the screen.
A related topic is destructible terrain as it is discussed here: https://gamedev.stackexchange.com/questions/6721/implementing-a-2d-destructible-landscape-like-worms

Unity3D: How to make effect that cut avatar into pieces

I'm new to Unity3D, after several official tutorials I got some basic understanding about Unity3D. Now I would like to have fun with making my game.
I would like to have a sword cut an avatar into pieces. Like the game "Fruit Ninja", cutting fruit into pieces.
The specific effect I want: the cutting should be according to sword-cutting-angle, in other words, the breaking-pieces effect should vary according to every cut, that feels real.
My thought: since Avatar is made by Mesh Filter, if I cut the avatar by waist, into two pieces(upper body, lower body), I should use code to make two Mesh Filter to hold the two pieces.
I'm not expecting very detailed code, that could be a lot. I'm just wondering if I could get a clue about how to make this effect. Because I think "cutting avatar into piece" should be a general effect in game.
Thank you in advance :)
It's not easy as you may think...
Here you can get one approach to the solution:
it clones the object, finds a plane based on user variables, and flattens all the points on the other side of the plane onto it, then repeats this with the clone and the other side of the plane.
Other approach could come from using shaders, search for "cut away view shader".
I hope I have given you the start kick

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.

Breaking up a sprite in cocos2d

I'm making a 2D plane fighting game for the iPhone in cocos2d. I'm trying to make it so when you shoot an enemy plane, it breaks into a couple of separated pieces that will fall out of sight. What is generally the best practice for breaking one sprite up into many? should I create new images for each separate piece, or treat the initial image like a sprite sheet, and make a new sprite from segments?
Please look at this tutorial
It makes a grid of points then moves the internal (not-edge) ones around randomly a bit so it's not all perfect triangles. Then each update it moves/rotates the triangles separately--then draws them all at once.
You treat the whole thing as a sprite, so can run any of the usual actions on it. This example uses CCMoveBy to move the whole group down off the bottom.

How do I create a floor for a game?

I'm attempting to build a Lunar Lander style game on the iPhone. I've got Cocos2D and I'm going to use Box2D. I'm wondering what the best way is to build the floor for the game. I need to be able to create both the visual aspect of the floor and the data for the physics engine.
Oh, did I mention I'm terrible at graphics editing?
I haven't used Box2D before (but I have used other 2D physics engines), so I can give you a general answer but not a Box2D-specific answer. You can easily just use a single static (stationary) Box if you want a flat plane as the floor. If you want a more complicated lunar surface (lots of craters, the sea of tranquility, whatever), you can construct it by creating a variety of different physics objects - boxes will almost always do the trick. You just want to make sure that all your boxes are static. If you do that, they won't move at all (which you don't want, of course) and they can overlap without and problems (to simulate a single surface).
Making an image to match your collision data is also easy. Effectively what you need to do is just draw a single image that more or less matches where you placed boxes. Leave any spots that don't have boxes transparent in your image. Then draw it at the bottom of the screen. No problem.
The method I ended up going with (you can see from my other questions) is to dynamically create the floor at runtime and then draw it to the screen.