Search Unity

Level1 to Level 2

Discussion in 'General Discussion' started by AaronC, Apr 25, 2006.

  1. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    I have learned that as most vram cards are 32mb, A level should contain less than 32mb worth of assets. Does Unity indie have the functions of:"You have reached the end of this level" and some simple way of progressing on to the next"level"? I notice during building the game an option box allows multiple scenes to be added. Can anyone tell me how to get from level 1 to level 2?
     
  2. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    http://otee.dk/Documentation/ScriptReference/Application.html#LoadLevel

    ... you can btw. have more than 32Mb of assets in a level. Not everything in a scene is held in VRAM at once. Things are allocated and deallocated by Unity on the fly. Also some (actually most) things aren't stored in VRAM at all. The VRAM is mostly used up by textures and the framebuffer and other graphics-card stuff.... err... or something like that.
     
  3. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Cool is there any technical tricks to getting more data into a scene without overloading? I guess reducing the camera's draw distance is going to be one thing. Is the script for impostoring models with sprites available anywhere? If so can someone tell me how to use it?

    Will swap blood for code
     
  4. Mr. Animator

    Mr. Animator

    Joined:
    Oct 2, 2005
    Posts:
    193
    I don't know if I'd say "most" video cards have 32 megs of VRAM. Its true that keeping your system requirements low makes your potential audience that much wider (not everyone upgrades their video card every year) but you could get 64 meg cards five years ago without breaking the bank.

    Of course if you're running a 32meg card then that's probably what you should author for :)
     
  5. thijske

    thijske

    Joined:
    Jan 13, 2006
    Posts:
    15
    Targos,

    Unity uses OpenGL to take care of its communications requirements with 3d hardware. Although OpenGL does support some commands to indicate a preference for which textures should be loaded natively (i.e. in vram) and which should be stored in main memory, it generally just pushes as many textures to vram as it can and then starts to resort to main memory. Unity, in other words, doesn't really have a say in which texture will reside in vram and which doesn't. This is a *good* thing; suppose your Unity program is running in windowed mode, you wouldn't want your program to write to the vram used by OSX, would you? So, don't worry too much about how much memory each level will take up in vram. Just test your programs on 32 mb vram machines in windowed mode. If they run fine, you'll be okay (regardless of where OpenGL decided to store your textures). Developing on the lowest spec-ed machine you want to support is a good idea anyway.

    Best,
    Thijs
     
  6. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Hey thanks everybody. Would it be more accurate to say that whatever is in the Draw Distance,ie, what can be seen in any given frame, is stored in Vram?and the other stuff is standing by to be drawn?
    I cant help but feel that it would be prudent to strip down my textures before importing them. And compress my audio. With audio I should be using the Ogg Vorbis codec shouldnt I? Keeping it mono so I can make it directional...?
    On the audio note, is there a way to make things emit a sound when my player capsule bumps into them? If so then the Collision aspect could become a trigger for other things like triggering animations huh? Is this straightforward or hell difficult?
     
  7. Mr. Animator

    Mr. Animator

    Joined:
    Oct 2, 2005
    Posts:
    193
  8. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    The VRAM usage basically is like this:

    In order for a texture or a mesh to be rendered, it has to be stored in VRAM. So when its time to render a mesh, it (and any texture is may use) is copied in there. If there is not enough room in VRAM, the stuff that was used the longest time ago is thrown out.

    As for textures, you should NEVER reduce the size of you psd files (or flatten layers). Unity flattens on import. In the texture import settings you can also have unity reduce the size. This does NOT alter your psd file, which is kept at full res - ready for using at a larger size in the next game you make.

    You can also tell unity to reduce all textures at runtime. This effectively reduces VRAM usage by a factor 4. This means you can have textures at high res just tell unity to skip the highest level. Download GooBall and play with the GFX settings to see this in action.

    You are right about the audio files. Just remember to keep the uncompressed ones around.
     
  9. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    Could there be a way to calculate how much vram is actually used for different tasks like textures, AA and so on and show this information in unity?
     
  10. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Theoretically, yes... The numbers it gives you would not really tell you all that much though... OS can eat up VRAM as well, so you can't count on a 32MB card actually giving your game 32MB. That's why most games on PCs let you choose the texture res, where console games don't
     
  11. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    Hmm if i could read some stats about what kind of ressources my application eats that would be helpful to get a nice overview and where i should maybe optimize or what a specific feature would costs me without using the calculator

    A little bit like in flash where you also get some stats after publishing or when publishing sw3d modells from max out. I also still like the ide-ressource-viewer in virtools, as it shows you for instance bottlenecks in the code with one view.
     
  12. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    So I guess the best way to approach this is to load up heaps of stuff and if it doesnt work, pull stuff out. The animation school I go to has been generating .mb files for 4 years and this is the first year we've had a game engine, so I might just pile a heap of random stuff in and see what happens...Thanks for your input you guys, keep it up
     
  13. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Ok so up untill now I've been modding the fps playground to the point of removing and replacing everything except the first person controller. I guess that my game once completed will have the unneccessary elements of the demo still in the project so have been trying to start a project from scratch. When I do so, I import a terrain mesh with collider, and drop in the first person controller. The problem is the controller lacks a lot of features that the demo has>the shooting ball ability, movement etc
    Can anyone please tell me in real simple terms how to make a controller as good as the one in the demo?
    Step by step so I fully get it? Thanks
     
  14. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Hmmm Finally got to try those tips like load level and on collision enter, but I'm not a programmer...It just doesnt make any sense to me. What am I supposed to do with this data? I think Ill just wait for some tutorials for dummies :?
     
  15. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The scripting tutorial.pdf next to Unity explains how to load levels.
     
  16. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Joachim, or someone who has the patience to help me...
    Regarding the load level scripting functions...
    I would really like to nail this one. When I look at scripts, I see a bunch of brackets, sometimes on different lines, and I see stuff that must obviously be code, and then I often see descriptions that releate to the code. So If I copy and paste some code, what do I need to consider? ie If I want to Put a "Run" command in, does it need to be here:

    {
    {
    {Run)
    )
    )
    Does it matter how many brakets/spaces there are?and are the brackets the"Boundaries "Of the code?
    Q2 Should I be deleting all the descriptive stuff in order to get the script to work? Ive tried a few Scripts from the wiki but I just dont have the noodles to get them typed up and presented to the unity engine so they will work...
    If I can knock over at least 1 simple example, I may be able to figure it out.Thanks
     
  17. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Hey Targos, I strongly recommend you buy a book on javascript or check out the many tutorial sites and learn the basic syntax before you try to code. It will be very frustrating learning from scratch by trying random things.

    You don't need to learn the web classes and all that of course, just the code syntax. Learn what comments are and the tags for them, how to use variables, functions, simple math, etc. Once you do that you will understand everything a lot more and wont hit as many brick walls.

    HTH,
    -Jeremy
     
  18. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Also, I just read that you were wanting to load a level on collision so here is a little snippet for you to do that. Create a new javascript...script and paste this code in by itself.

    Code (csharp):
    1.  
    2. function OnCollisionEnter()
    3. {
    4.   Application.LoadLevel("myLevel");
    5. }
    6.  
    -Jeremy
     
  19. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Hi Jeremy, Itried to follow your instructions, but just got this:

    Can't add script behaviour NewBehaviourScript. The script needs to derive from MonoBehaviour!
    Any Tips?
    (Itried to drag the script onto a cylinder)
     
  20. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    You created a C# script. You need to create a new javascript script. Then you paste that code in.

    -Jeremy
     
  21. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Yeah I tried that Jeremy, I think Unity's crapped out again. we have to reinstall it regularly. Its a bit dissappointing really.
    So it didnt work.In fact none of the scripts seem to work today. Its pretty fragile, often It cant build real basic scenes.
    Im not sure if I have the patience today...or tomorrow...anymore...GRRRR
     
  22. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Man, get access to another machine! That must be extremely frustrating. :eek:

    -Jeremy
     
  23. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Targos, this happens to me too once in awhile when trying to use new scripts that I copy into my current project. Try just restarting Unity and see if it will attach the script then. Re-installing all the time shouldn't be necessary.