Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Endless Cylinder Tunnel

Discussion in 'Scripting' started by gregmax17, Jan 24, 2011.

  1. gregmax17

    gregmax17

    Joined:
    Jan 23, 2011
    Posts:
    186
    I am trying to accomplish a endless cylinder tunnel, for example (the 2nd image) :

    http://www.orgoquest.com/unitytest/temp.html

    How is this accomplished with Unity? PLEASE be specific in details... this is my first try at Unity.

    Thank you in advance!
     
  2. ivkoni

    ivkoni

    Joined:
    Jan 26, 2009
    Posts:
    978
    there is a tunnel runner examlpe in the iphone projects. Don't remember if it was endless. Check it out.
    Here are 2 approaches that would consider:
    1. build some tunnel parts: straight, turns, etc... and then just alternate them randomly. Say have 5 tunnel parts (as far as the player can see) and as you get out of a tunnel part remove it and add a new one. That way you control the polycount.
    2. build the tunnel with the mesh class.
    Lastly, you can combine both approaches, I guess. Build parts of the tunnel with the mesh class and combine them with the first approach.
     
  3. gregmax17

    gregmax17

    Joined:
    Jan 23, 2011
    Posts:
    186
    I can't look at the example because I am on Windows.

    I like the idea of building parts and connecting them... it will add more programming.

    What is a mesh? Does this also the model/prefeb to be flexible?
     
  4. ivkoni

    ivkoni

    Joined:
    Jan 26, 2009
    Posts:
    978
    you can look it even though you are on windows. It won't play most likely but you can still look at the scripts.
    a mesh is 3d model. (vertices, triangles, normals, colors, uvs...) In Unity you can build meshes on the fly using the Mesh class.
    There are examples of these here
    To make a tunnel from parts, you can position an empty game object at the beginning and at the end of each tunnel part to represent the end points. Then to combine the parts match the positions of the end points. You can rotate the part around an axis going along the tunnel as well (to turn up instead of right for example).
    Now, this approach would work fine, and is easy to script, but you have to model all the separate tunnel parts.
    Another problem that may arise is if you then want to 'follow' the tunnel somehow after you built it.
     
    Last edited: Jan 24, 2011
  5. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    He is refering to a mesh built on the spot, rather than a prefabricated mesh in a 3d program.

    Personally, I would prebuild one in like 3ds max, or blender and use it as sections. As Ivkoni suggests, use like 5 sections at a time. so it seems endless. Build like 4 of a curve (both ways), 4 straights maybe some dead end Y's so the player has to make a quick decision. put some ramps in it or some stuff like that so that the player can do maneuvers in it. Also add some walls in it so the player has to avoid them. It could be very cool if done right.

    The randomization also can go a little further. You could build units in singles and have nodes all around them where you place stuff. So say you have a straight section 50 meters long, and it has 30 nodes where a wall, ramp or power-up could appear at, and then you just have the code put those items at that location and rotation.

    The big advantages to using 5 sections at a time is that you have a set geometry level that you are dealing with and you can use a completely randomized layout.

    Level one is 50 sections long, 2 60, but you never have to show 60 sections, just 5. Then for the track you can loop back onto it's self and the player would never know. You just have to make it 50+ sections to win. Level 1 would have 1-2 obsticals per section, but level 20 would have 10. That would mean the player would have to have monster reflex's to get around them.... Also, you could have him control his speed where he had a certain amount of time to get from section one to section 50. so he can't just go as slow as possible and avoid everything...

    OMG i just laid out a game...
     
  6. gregmax17

    gregmax17

    Joined:
    Jan 23, 2011
    Posts:
    186
    I like the idea of modeling the tunnel in Blender/3ds max, BUT I rather know how to make the tunnel be random. After modeling about 5-10 different types of tunnels, I would assume the user would start to see the pattern... maybe?

    I appreciate the help!