Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Jela · Jul 05, 2014 at 09:33 AM · cameracube

Put a camera inside a cube

I'm new to Unity and I'm trying to invent a game with 3d. I want to put a camera inside the cube object but how is it possible? I've read some forums and they mentioned about Normal. I don't want the camera to see the outside of the cube. I want the camera to be inside the cube, so that the only part that will be seen in my game is the inside of the cube. Is it possible? Please help me. Thank you in advance!

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jela · Jul 05, 2014 at 10:06 AM 0
Share

Im using unity. I have no idea on how to use blender. Where can I find the normals face? Is it through code or in the inspector panel? Please help me. Thank you!

avatar image tanoshimi · Jul 05, 2014 at 10:09 AM 0
Share

Unity is a game engine - you can't create or edit models in it (well, not anything more than a basic primitive). To create models to use in your game, you need a modelling program. I said Blender because it's free, but 3DS $$anonymous$$ax or $$anonymous$$aya are alternatives.

avatar image robertbu · Jul 10, 2014 at 02:28 PM 0
Share

You can use the ReverseNormals script in the Unity Wiki to reverse the normals of an object. The result will only be seen at runtime using this script.

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by fafase · Jul 05, 2014 at 09:35 AM

Just put it inside, the cube won't show since the normal you read about makes the inside of the cube not rendered.

If you really want to make sure, just increase the near clip plane value of your camera.

Sometimes you may simply want to try since it takes about 5s to figure out that inside of the cube the camera won't render it.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jela · Jul 05, 2014 at 10:19 AM 0
Share

I really want to get inside the cube. When I tried to put the camera inside, it's not working.

avatar image fafase · Jul 07, 2014 at 11:03 AM 0
Share

If you use the cube from Unity they already use backface culling, which means only one face of the cube is rendered, the outside one. Just place your camera inside of the cube, same position and see it for yourself.

avatar image
1

Answer by tanoshimi · Jul 05, 2014 at 09:36 AM

Cameras only see objects if their normals are facing them. So, if you want to be inside a cube, you need to make sure all its normals face inwards (generally they face outwards). This is easy to do in a modelling program like Blender.

Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jela · Jul 05, 2014 at 10:13 AM 0
Share

You're trying to say that I'm going to create a cube in blender then edit the normals face in blender? Then put it to unity? Am I right?

avatar image tanoshimi · Jul 05, 2014 at 10:13 AM 0
Share

Yes, exactly. And please don't post comments as answers. Post them as comments (click the "Add new comment" button to the right)

avatar image Jela · Jul 05, 2014 at 10:21 AM 0
Share

Okay. I'll try to create a cube in blender then find the normals and by the way thank you for telling me about the comment! I'm not aware that it's really different. Thank you!

avatar image Jela · Jul 05, 2014 at 11:01 AM 0
Share

Is it possible to set the size of the imported cube from blender to unity using script? Just like setting the size of the cube?

avatar image tanoshimi · Jul 05, 2014 at 11:27 AM 0
Share

Yep - just adjust the scale. https://www.dropbox.com/s/p7mdzxsjmooolxj/inwards_cube.fbx

Show more comments
avatar image
1

Answer by Kiwasi · Jul 05, 2014 at 10:46 AM

If you need a really dodgy cube and you don't want to go to blender, just build the walls of your cube out of planes. That's how my first game was built. I wouldn't suggest trying to learn Blender and Unity at the same time.

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jela · Jul 05, 2014 at 11:01 AM 0
Share

I think it's not possible, because what I'm trying to do is also to set the size of the cube, and i don't know if it's possible if I'm going to use planes.

avatar image Kiwasi · Jul 05, 2014 at 11:04 AM 0
Share

Certainly possible to resize a cube made with planes, just a bit more work. But not as much work as learning 3D modelling.

If you hang around for a while you will learn that none of my answers are impossible. Some might not be good ideas, but they are certainly all implementable.

avatar image Jela · Jul 05, 2014 at 11:09 AM 0
Share

How will it be possible? :( because I'm trying to resize the cube through a script.

avatar image Kiwasi · Jul 05, 2014 at 11:16 AM 0
Share

Its a multi step process as follows. You can figure out the details yourself.

  1. Calculate the dimensions of the cube on the new scale

  2. Scale each plane to the appropriate scale

  3. $$anonymous$$ove each plane out (or in) to the appropriate position

You can also do the same with primitive cubes if you want some thickness to your walls.

avatar image Pawscal · Jul 10, 2014 at 02:10 PM 1
Share

parent the 6 planes used to create your cube to an empty object placed at the center of the cube, scale the parent. No need to scale each faces

Show more comments
avatar image
0

Answer by Klarax · Jul 10, 2014 at 03:18 PM

According to the community scripts. And will only flip the normals when in game mode, not in editor. Worth a go

 using UnityEngine;
 using System.Collections;
  
 [RequireComponent(typeof(MeshFilter))]
 public class ReverseNormals : MonoBehaviour {
  
     void Start () {
         MeshFilter filter = GetComponent(typeof (MeshFilter)) as MeshFilter;
         if (filter != null)
         {
             Mesh mesh = filter.mesh;
  
             Vector3[] normals = mesh.normals;
             for (int i=0;i<normals.Length;i++)
                 normals[i] = -normals[i];
             mesh.normals = normals;
  
             for (int m=0;m<mesh.subMeshCount;m++)
             {
                 int[] triangles = mesh.GetTriangles(m);
                 for (int i=0;i<triangles.Length;i+=3)
                 {
                     int temp = triangles[i + 0];
                     triangles[i + 0] = triangles[i + 1];
                     triangles[i + 1] = temp;
                 }
                 mesh.SetTriangles(triangles, m);
             }
         }        
     }
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jela · Jul 12, 2014 at 06:36 AM 0
Share

I tried to put this script as a component of my gameobject cube, but nothing happened. Why? :((

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Setting a cube to be exactly size of intersecting camera view plane 1 Answer

CubeWorld Character Controller 0 Answers

How to make camera position relative to a specific target. 1 Answer

How to do perspective camera zoom? 1 Answer

Move a cube on it's edges 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges