Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

First Day with Unity!

Discussion in 'Made With Unity' started by Aubrey-Falconer, Feb 13, 2008.

  1. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    I stumbled upon Unity a couple days ago, and absolutely love it! I am a web application developer, but realtime 3D applications with physics are so much more fun than web pages!

    As a testament to the power of Unity, here is what I came up with on the first day I found Unity, including learning it... I have added some minor tweaks since then, but what you see was 85% done by the time I went to bed :)

    EDIT: Many different archived versions o Mars Explorer are available to play at http://MarsXPLR.com/view-268

    Mars Explorer
    [​IMG]


    The vehicle is based off Forest Johnson's racer, with a custom paint job and significantly different physics settings.

    I am currently learning the Unity networking system, and hope to eventually have several different "teams" networked players will be able to join join - to all do battle on the martian terrain for the honor of their respective countries and monopoly of Mars' resources...

    Who can make it to the top of the volcano? :)
     
  2. 64746c

    64746c

    Joined:
    Oct 21, 2007
    Posts:
    181
    Wow, it looks great! Making the directional light a child of the car produces an interesting effect. The trail renderer looks nice too, and I liked how you could look around while in 'ride' view. Only criticism—camera is a bit jumpy on chase mode sometimes.

    Cheers
     
  3. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Thanks!

    Just smoothed the chase mode camera a bit, the RC mode camera a lot, and added a mini map.

    But can you make it to the top of the volcano?
    :)
     
  4. nickavv

    nickavv

    Joined:
    Aug 2, 2006
    Posts:
    1,801
    Awesome, especially considering that its the first thing you've made. :D

    I couldn't make it to the top of the volcano. Almost though.
     
  5. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Added a high contrast MiniMap Marker with a much more visible trail, and a new camera, with the ride camera showing the vehicle's body and the new Observe camera hiding it...

    The Volcano is surmountable - you just have to follow the correct blue path :)
     
  6. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    wow thats amazing for a first day! Beats my caped marble by a long way (though there was no terrain engine back then, grumpy old timer here :p)

    Anyway, the main path up the volcano drops off and is impossible.. You meanie!!

    I almost made it a couple times using a top seekrit sploit though. props to anyone who knows what it is.
     

    Attached Files:

  7. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Yikes! I didn't know it was possible to get going that fast! Nice picture! I'm going to have to put some bumps on the side of the volcano...

    Glad you liked the path drop off :)
    It is possible to drive all the way to the top...

    The hint is to reverse your direction before the path disappears, back down the path as far as it is safe, and then accelerate as much as possible for the slight blue patch of terrain on the slope outside of the last curve you rounded. You should be able to make it up to a ledge right above the main disappearing one. Back down it for maximum speed, and then head for the top! Try to keep to the outside as you are rounding over the edge, or you will slip all the way back down to the bottom :)

    I am thinking of placing a glider attachment or some other fun reward at the top. Possibly a huge stack of boulders you could push into the volcano, which would temporarily block it and cause a new volcano somewhere else...

    If other projects don't take over, I really hope to create a synchronized network version of this game... It would be awesome to have everyone playing tag, king of the hill, racing, and possibly even nuclear war with each other in this Martian environment :)


    Unity is so much fun! I have never before experienced a development environment in which I was so connected to the final product - instead of worrying about how to accomplish it.
     
  8. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,352
    i saw that slope to the right as you round the back of the volcano but turning around was a bit too hard for me. IMO the car physics feel a bit "lurchy" (is that a word?) but its still fun very well done for your first day!

    (@ Yoggy - don't know of any sploits but i was able to get about that high just by going near a corner of the map heading straight for it without turning)
     
  9. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,559
    That's pretty cool. I almost made the peak by following the ridge line ... close, so close.
     
  10. 1stAnd10

    1stAnd10

    Joined:
    Jan 9, 2008
    Posts:
    79
    I just took that thing off some sweet jumps.

    I don't know how you did that on your first day. My first day was spent taking 1 hour to get a Material to tile right on a plane, spending 3 hours trying to get Visual Studio 2005 to play nice in Parallels with UnityEngine.dll and then finally getting frustrated and playing WOW instead.

    Fantastic job! Where did you learn how to implement the mini map and such? Wiki posts? Searching the forum?
     
  11. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    Who can beat this:
     

    Attached Files:

  12. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    @drJones: The vehicle does get "lurchy" at high speeds, but I think it is kind of fun, and a real vehicle of that size traveling at that speed over those bumps would probably be much more lurchy. I may add a larger, heavier, less lurchy vehicle in the future...

    @1stAnd10: I should probably put a separate link to my "nostalgic" first day game, as the current link is improving with each passing day :) The first day version didn't have any of the camera switchers, pause buttons, or minimap, the particle effects weren't quite as cool, and it took me a lot longer than 4 hours. The minimap was really easy to do - I was playing around with the camera settings, and realized I could place a camera high above the map with a small ViewPortRect. I did do a lot of reading from the excellent documentation, but my favorite way to learn is just by trying things :)

    @Yoggy: Hmm - Looks like you are headed down the volcano to me... :)


    I have been working hard on a networked edition, and it is currently around 75% complete. Once I get the network driving part working, I think I will implement some rocket launching capabilities - and then we can all have a real battle!
    While developing I have run into a couple minor questions which most of you probably know offhand. If anyone could give me a point in the right direction, I would be grateful!

    -Aubrey



    Component Copying / Duplication:
    For a hypothetical example, let's say I apply a bunch of particle effects to my car GameObject, and then decide to apply them seperatley to each wheel inside the car object instead. Why can't I just copy the particle component and then paste it into each tire object? Is there another way of doing this besides adding the component to each tire from scratch and then hand typing each parameter over again?

    Filesystem Access:
    Let's say that I build an in game car editor, and want to allow people to save the changes they have made to their hard drive. Can my program access the user's filesystem, and if so, am I "sandboxed" or limited by some sort of security system?

    Global Variables:
    I don't know if this is a good practice or not, but I set up a game "controller" object to store the state of lots of important variables in my game. In PHP web development we have "superglobal" ($_SERVER) variables that are shared across objects - does Unity have the same thing, and if so would this be a better way to store my main state variables? If there was a simple way to access objects (see below), this wouldn't really be needed.

    Object Access:
    In most object oriented programming languages I have used, objects can access other objects just by their names (such as _root.child.anything or _parent.function()), but I couldn't find anything like this in Unity after scouring the manual for quite a while. To access my game controller object from other objects I finally had to use "var game : GameController;" and link it through the GUI, but this seemed like a huge pain to do for every little script I write. Is there a better way to do this?

    Undo:
    It seems that many GUI operations (such as deleting project resources and modifying script parameters) don't enter the undo trail, and this "bit" me quite a bit while learning how things worked by changing them. Am I doing something wrong, or is this on the Unity to do list, or do I need to request it? :)

    Web Rendering Settings / Performance:
    When compiling desktop applications, users are provided with a quality option when running the game. Is there some way to also tailor the quality of embedded web applications to the user's machine, or does this just happen automatically with no input needed? Also, does anyone have benchmarks comparing embedded to downloaded applications?

    Transform Required Component:
    Perfectionist that I am, it kind of bugs me that my game controller object has to have a position in space. Honestly, is there a good reason for this?
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,357
    Prefabs. :)

    With the webplayer, yes, with a standalone, no.

    There a number of ways. There are various Find commands, which you can use with GetComponent. Plus there are static variables and functions.

    It's been requested once or twice. ;)

    It doesn't happen automatically. There isn't really an equivalent, but you can provide your own menu and routines.

    It should be pretty much the same, but only in full-screen mode...otherwise it's usually limited by the browser.

    It makes it easy to see in the Hierarchy. But you actually don't have to...I always do so I can't remember the other technique....

    --Eric
     
  14. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Thanks Eric!
    Lots of good information.

    I didn't think of using prefabs as I had the particle component attached directly to my car GameObject, and duplicating the car wasn't what I wanted. I just realized that I should always create a separate GameObject for every particle emitter I want, and then I can prefab just the emitter if I need to.

    Static vars sound very useful, but I can't find anything in the docs about them, and normal javascript doesn't have them as far as I can tell. Are they in the docs somewhere?

    And finally, about 70% of the time my Network.TestConnection(); calls fail with a timeout error after a second or so. Since it also happens with the Unity example networking application, I think that it is just because I have satellite internet - which has TERRIBLE lag times. Is there some way for me to set the TestConnection() timeout a little higher? The docs didn't say anything about it.

    EDIT: The networking script I am using does have some timeouts built into it, but it seems that it is the unity network call that is actually timing out - not my script. I guess I will just keep trying things...

    -Aubrey
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,357
    Yep. In order to get the emitter, you could always duplicate the car and then get rid of everything on the duplicate except for the particle components.

    Not sure, but it's simple: if you have a script called "SomeScript" with a public variable declared like "static var someVar = 1;" then you can reference it from other scripts like "someOtherVar = SomeScript.someVar + 1;"

    There's at least one fps counter script on the wiki.

    Not sure about networking stuff...haven't done anything with that yet.

    --Eric
     
  16. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Kudos to Eric! :)

    Aside from rewriting the camera scripts, everything is now complete in the network edition except for one thing - syncing the cars...

    No matter what I try, the server host machine drives all the vehicles, and the connected client machines render the vehicles without tires. It is not a keyboard controlling linkage bug on the server machine, but seems rather to be a physics linkage - as when any of the clients cars hits a hill it slows the main server car as well. :?

    I just put a lot of work into organizing and simplifying the code, and if anyone with some experience in networking feels like taking a look at it, I would be delighted to share it with them!

    I haven't given up yet, but I am almost positive that there is just one small bug somewhere that someone with networking experience would be able to squish without trouble. If everyone is busy, I will just keep trying things :)

    Happy Coding,

    -Aubrey
     
  17. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,559
    Here's a fps counter script for you courtesy of the Unity folks ...


    Code (csharp):
    1.  
    2. // Attach this to a GUIText to make a frames/second indicator.
    3. //
    4. // It calculates frames/second over each updateInterval,
    5. // so the display does not keep changing wildly.
    6. //
    7. // It is also fairly accurate at very low FPS counts (<10).
    8. // We do this not by simply counting frames per interval, but
    9. // by accumulating FPS for each frame. This way we end up with
    10. // correct overall FPS even if the interval renders something like
    11. // 5.5 frames.
    12.  
    13. var updateInterval = 0.5;
    14.  
    15. private var accum = 0.0; // FPS accumulated over the interval
    16. private var frames = 0; // Frames drawn over the interval
    17. private var timeleft : float; // Left time for current interval
    18.  
    19. function Start()
    20. {
    21.     if( !guiText )
    22.     {
    23.         print ("FramesPerSecond needs a GUIText component!");
    24.         enabled = false;
    25.         return;
    26.     }
    27.     timeleft = updateInterval
    28. }
    29.  
    30. function Update()
    31. {
    32.     timeleft -= Time.deltaTime;
    33.     accum += Time.timeScale/Time.deltaTime;
    34.     ++frames;
    35.    
    36.     // Interval ended - update GUI text and start new interval
    37.     if( timeleft <= 0.0 )
    38.     {
    39.         // display two fractional digits (f2 format)
    40.         guiText.text = "" + (accum/frames).ToString("f2");
    41.         timeleft = updateInterval;
    42.         accum = 0.0;
    43.         frames = 0;
    44.     }
    45. }
    46.  
    47. @script RequireComponent (GUIText)
    48.  
     
  18. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    I finally gave up on implementing the networking system from scratch, and decided to gradually merge the default networking application with my game instead. I am making good progress, and hope to have something playable in a day or so!
     
  19. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    New networked version (Including cool splash screen) is up, but I still can't get the car to work...

    The "Multi Player" networked level uses the example network car, and the "Multi Crasher" level uses the mars buggy. The Multi Player level works perfectly, and the Multi Crasher level works perfectly from the server machine, but in the client machine the car tires disappear and the car can not be controlled. I am almost sure the problem is somehow related to the way the car tires animation is linked to the car in the prefab, but nothing I try seems to work. Car source code is located @ http://fun.theati.net/games/data/25/marsbuggy.unitypackage if anyone thinks they might have an idea of what is wrong.

    Testing the networking is really hard from my local setup, as my main satellite connection has such high latency that 90% of the time the network test times out before it recognizes that it works (seems to be a Unity bug), and my only other connection, an ATT AirCard, can only connect one computer to the internet at a time. (When I use internet sharing to share the AirCard connection to other computers, they can never be connected to in the game for some reason).

    I have tried everything I could think of to get two game instances running on my local computer networked to each other for testing, but I guess it is impossible as they each have to bind ports or something. I also added some functionality to the networking system to disable the master list server and attempt to connect directly to other local computers without going through the slow satellite connection, but so far haven't gotten it to work at all. It always just says "can not connect to ...".

    Soon as I get this working I am adding missile launchers, and then we can really have some fun! :D
     
  20. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    I opened a new thread for the networking issues, which can be found at: http://forum.unity3d.com/viewtopic.php?p=67398#67398

    It seems that unlike skyboxes, fog is a scene specific rendering setting which cannot be customized between cameras?
    I have been having a lot of fun with a dark fog effect, but since I can't turn off the fog for the minimap it makes it pointless - as the minimap just displays as a black block looking down at all the fog.

    It also seems like spotlights don't cast light on terrain objects?
    I would love to have headlight light cones, but the only light type that I can get to actually light up the terrain is a directional light.
    The documentation seemed very scarce on this issue. Is this a pro only feature or something?

    P.S Yoggy - I didn't realize at first that you were the one who wrote the original car script :) Thanks a bunch for releasing it!
     
  21. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    3,709
    You can setup the skybox and fog settings from a script in OnPreCull.
    I think there is a script that does that on the wiki.
     
  22. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    Yep. It's here: CameraRenderSettings
     
  23. Herabec

    Herabec

    Joined:
    Feb 24, 2008
    Posts:
    5
    Pretty fun, amazing for your first game.

    One or two things bug me though. The lack or axles. Yeah.

    And the skybox. Yes, Mars is in "space" that doesn't mean it doesn't have an atmosphere. It would be red and dusty/cloudy, so unless it is night, you wouldn't see the stars.

    The dandelion in between the large rocks in your "path" texture made me laugh.

    Great trail effect, and nice controls, though. I liked the ride mode, why did you get rid of it?
     
  24. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Thanks for the rendering settings script!
    When I didn't find anything in the docs about it, I didn't realize how easy it would be :)


    @Herabec:

    Yes - you are right about the atmosphere - but the stars look so cool! I will probably come up with some sort of compromise.

    I could model the axles easily enough, but I don't yet know enough to make them "link" to travel with the wheels - and I thought the vehicle would look better as a cartoonish buggy with no axles than a cheesy buggy with non hinged axles. I will learn a bit more about bone linkages, and probably eventually due a mechanically linked space frame for each wheel with tie rods and everything :)

    I too loved the ride mode camera, but I had to rewrite all my camera scripts to merge into the same camera for ease of implementation in a multiplayer environment. The ride mode camera was achieved via a dedicated camera with a mechanical linkage to the vehicle's body, and I haven't been able to get this working in my new all-in-one camera script. I initially experimented with a mechanical linkage that was enabled and disabled by the camera S***cher script, but couldn't get it to work. I then used some really crude and basic math to just position the camera on top of the car in space, but haven't studied quaternions enough yet to know how to add the local transform of the car to the camera position, so currently when you turn or roll the car it just spins below you in a very unrealistic way. Soon as I figure out how to get the ride mode working as well as it did before I will re-add it.
     
  25. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    New version up!

    Includes fog, atmosphere, better aligned MiniMap, more scorched vegetation, and an all around eerie "We're not on earth anymore" feel :)
    Now if I could only get spotlights to light the terrain...
     
  26. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Super cool new version up!

    Includes a high resolution galaxy and nebula laden skymap, totally customizable rendering settings for high framerates on any computer, working master server and direct connect networking ( http://forum.unity3d.com/viewtopic.php?p=67751 ), sweeping banked turns on the main martian raceway (still in progress), automatic "cookie cutter" based preference and camera remembering, and the beginnings of a new multiplayer map that will be perfect for networked tag.

    Still quite a few "rough edges" that I will be polishing as I have time.
     
  27. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Even cooler new version up! :)

    The networked edition now supports custom player names - and displays player names below players in 3D, uses collision detection to keep track of what player is "it" in tag games - and integrates this information into the messaging console, and...

    The mars exploration vehicle can now fly!
    {Press space to activate the beta quality, super cheesy, instantly appearing glider wings and switch the car into "glider" mode. Lots of physics tweaking still to be done...}
     

    Attached Files:

  28. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    Now with refined flight model and dynamically warping wings (which can be "flapped" to accelerate in air), even cooler sky and ground textures, axles for the car, slightly better volcano particle system, and much smoother terrain.
     

    Attached Files:

  29. neeraj

    neeraj

    Joined:
    Nov 16, 2009
    Posts:
    59
    hey. i have a question , first of all thanks for shearing . here comes my question how to add the Mini Map you have added in your scene. it would be better if you can reply me asap , coz i am just stuck with this prob and making my priject delay, thax in advanced. :D
     
  30. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    394
    The MiniMap is accomplished by placing a camera high above the scene and assigning it a small ViewPortRect.

    You can spice it up a bit by adding a script to make it follow your player, adding special "marker" objects on their own layer that are only rendered by the MiniMap camera, adding a "fogLayer" script to disable fog for the minimap camera as necessary, etc.

    You shouldn't "bump" very old threads. It's much better to do a search - and if you don't find your answer, start a new thread about it :)
     
  31. neeraj

    neeraj

    Joined:
    Nov 16, 2009
    Posts:
    59
    hey robur thax man for replying, but my question is i wna show my camera in mini map while it is moving, let me explain you my project.

    i have created a test walkthrough for my house and wanaa know the place and direction where i am while moving in my house. so can you just explain me the process to get this idea alive in unity 3d, thanks for your support man.
     
  32. einfopedia

    einfopedia

    Joined:
    Apr 4, 2012
    Posts:
    28
    wonderful its look a great and awesome.can you share a code of this simulation.one thing is that directional light of a car produce a excellent effect.i also want to do this.but how you ca do this in a first day.i have not complete it in a first day.brilliant struggle.