Jump to content

  • Log In with Google      Sign In   
  • Create Account


Unity 3D Cube Vs Plane...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 Dan Violet Sagmiller   Members   -  Reputation: 890

Like
0Likes
Like

Posted 03 January 2013 - 01:43 PM

In Unity3D 4, in a C# Script, I'm creating a tiled floor. (a bunch of cubes with textures set) and sizes set to Vector3.One. The grid works. The problem is that I am using Cubes. I don't want to use cubes. not when I only need 1 face of the cube. I tried switching my code to use GameObject.CreatePrimitive(PrimitiveType.Plane); instead of GameObject.CreatePrimitive(PrimitiveType.Cube); but then nothing shows up. I also set the plane size to Vector3(1,1,0). Is there something else I need to configure with a plane? I presume that is essentially just a single rectangular face.

Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


Sponsor:

#2 superman3275   Crossbones+   -  Reputation: 1964

Like
2Likes
Like

Posted 03 January 2013 - 03:20 PM

Try the Unity forums. Also, your plane is tiny.

 

Why are we talking about aerial vehicles! :)!


I'm a game programmer and computer science ninja ph34r.png!

Here's Breakout:
Breakout!

Want to ask about Python and / or Pygame? What about HTML5 / CSS3 / JavaScript? What about C++ and / or SFML 2 (and 1.6)? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

Superman3275@Gmail.com

or Personal-Message me on here smile.png!


#3 AverageJoeSSU   Members   -  Reputation: 505

Like
2Likes
Like

Posted 03 January 2013 - 03:30 PM

Make sure your gameobject is facing the camera, planes wont get rendered from the back unlike a cube.


------------------------------

redwoodpixel.com


#4 uglybdavis   Members   -  Reputation: 806

Like
0Likes
Like

Posted 03 January 2013 - 03:31 PM

Plane size should be Vector3.one.

 

x goes left to right, y goes up and down, z goes forward and back

So you have your z axis scaled to 0, the object wont show up.

 

Go to game object > create other > plane to make a new one in your scene, select it and set it's z scale to 0, see what happens.


Edited by uglybdavis, 03 January 2013 - 03:32 PM.


#5 DrEvil   Members   -  Reputation: 1075

Like
1Likes
Like

Posted 03 January 2013 - 04:32 PM

Any reason why you aren't generating a mesh from script and using a mesh collider to create a more optimal collision representation on 1 object? Using a bunch of box or plane objects will likely be slow and problematic for collision, depending on your usage.

#6 Dan Violet Sagmiller   Members   -  Reputation: 890

Like
0Likes
Like

Posted 04 January 2013 - 02:01 PM

Make sure your gameobject is facing the camera, planes wont get rendered from the back unlike a cube

 

DUH!!!  I was facing the bottom of the board!  Which also explains why I was editing the negative Z order Vertices to get my ripple effects to work. 

 

I'm not at home to try it, but I think this is exactly the issue and can't wait to shift the camera's location.  This will be so much easier on management.

 

 

 

Plane size should be Vector3.one.
x goes left to right, y goes up and down, z goes forward and back

I'm pretty sure that Z goes up and down in Unity, and X/Y are still used for Cartesian/WENS directions.  A plane being just a face, without sides, I would have presumed a height of 0 would have worked fine.  However, I had tried it on .One, and ended up with the same results.  But I presume at this point that I was just looking at the wrong side of the plane.

 

 

 

Any reason why you aren't generating a mesh from script and using a mesh collider to create a more optimal collision representation on 1 object? Using a bunch of box or plane objects will likely be slow and problematic for collision, depending on your usage.

 

Each tile can be different, and the game is still managed (primarily) in a 2D x/y overhead grid, like Star Craft.  Since I'm using potentially different textures for every block, (and these can change during game play) I'm presuming I need separate faces for each.  (also, I'm using the vertices to generate a height map, which keeps changing during the game play, i.e. explosions leave craters, etc...)

 

If I am not mistaken, in Unity, a plane is just a single rectangular face, where as a cube is 6 planes with the vertices lined up to make a cube.

 

I would be more than happy to find out otherwise, and find out that I can simple add a primitive rectagular face, but for now, Plane is the closes thing to a primitive face I can see./

 

Thanks for all your help.


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#7 Dan Violet Sagmiller   Members   -  Reputation: 890

Like
0Likes
Like

Posted 04 January 2013 - 02:04 PM


Using a bunch of box or plane objects will likely be slow and problematic for collision, depending on your usage.

 

True, but this will be for an RTS, with a relatively isolated perspective on the battle field.  I'll need to look into what a mesh collider is though.  I have not worked with one yet.


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#8 Dan Violet Sagmiller   Members   -  Reputation: 890

Like
0Likes
Like

Posted 04 January 2013 - 02:37 PM


Any reason why you aren't generating a mesh from script and using a mesh collider to create a more optimal collision representation on 1 object?

 

Because I didn't know how,m particulary, I had never even looked at it before.  Fortunately I found a good example, and I will be switching my code to use this now. :)

 

http://blog.nobel-joergensen.com/2010/12/25/procedural-generated-mesh-in-unity/


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#9 Dan Violet Sagmiller   Members   -  Reputation: 890

Like
0Likes
Like

Posted 05 January 2013 - 07:37 PM

I looked up Collider Meshes, and found that it creates just a single GameObject, I.e. 1 texture for the whole thing.  This doesn't work for my needs.  

 

I'm not sure what I was doing wrong with a plane, but it wasn't a good option any way, since a plane is actually broken into about 200 triangles (10x10 grid, each of 2 triangles). A cube is built from 6 sides with 2 triangles each, which actually costs less performance.  However, I figured out how to recreate the mesh, by rebuilding it with only 2 triangles, and then apply the textures, normals and bounds.  

 

Anyway, I resolved it.  Also, part of my problem was the position, I had everything positioned upside down.  could have worked, but would have been confusing to maintain over time.

 

Thanks.


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#10 DrEvil   Members   -  Reputation: 1075

Like
0Likes
Like

Posted 06 January 2013 - 01:15 AM

I would texture atlas your tiles and just use the right texture coordinates. Then you get the dynamic stuff with the best performance. If your game is simple/small enough just stick to what's easiest to work with. If the map is large though that technique will be slow for rendering(lots of draw calls) and collision

#11 Dan Violet Sagmiller   Members   -  Reputation: 890

Like
0Likes
Like

Posted 06 January 2013 - 01:45 PM

would texture atlas your tiles and just use the right texture coordinates.

 

I just looked up a texture atlas, and perhaps I miss understood it, or if there are special features in Unity 3D for it, but I have an issue it doesn't resolve.

 

The tiles will need to change.  for instance, an explosion happens over grass, and there will no longer be grass, just charred dirt and gravel.   I'll need to change out what these tiles are, on a regular basis in Real-Time.  

 

Also, I don't actually need to do 3D collision detection here.   Because my code contains a 2D array for a height map (managed), I can just apply the units position on the height map to define what Z level they are at.  I can reserve collision detection for explosions, moving elements and buildings, but the ground can be fictitious in the physics sense.  Rendering will still be quick because I'm using low polygon counts, and the area of visibility will be quite small.  (maybe 100x100 tiles typically.)


Edited by hpdvs2, 06 January 2013 - 01:47 PM.

Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#12 DrEvil   Members   -  Reputation: 1075

Like
0Likes
Like

Posted 06 January 2013 - 04:27 PM

Fair enough. 100x100 tiles is not an insignificant number of draw calls. You should be able to dynamically change the texture coordinates in the mesh to account for dynamic changes in tiles all while keeping. I'm not sure what the break even point is with regards to draw calls versus dynamically changing the texture coords. Keep it in mind though if you run into performance issues. If this is a simple game for pc might not make enough of a difference. If you are targeting mobile it might be significant.

#13 DrEvil   Members   -  Reputation: 1075

Like
0Likes
Like

Posted 06 January 2013 - 04:32 PM

*While all keeping a single mesh and draw call, and texture atlas.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS