• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Sugavanas

How to generate a random terrain (like temple run) in unity ?(scripting help)

8 posts in this topic

How can i generate a running screen with different things in every level like in temple run. but i dont want it to be endless, every level there will be a end and the user can go to the next level ?

the code i have here is,

 

C#
 

     public Transform[] prefabs;

     public int tiles;


     public void GenerateLevel() {

        for(int t = 0; t < tiles; t++) {

            GameObject go = Instantiate(prefabs[Random.Range(0, prefabs.Length)]) as GameObject;


        }


    }

 

but all if the prefabs, model are being in the same place, how can i make it to go on it own position so it connects from one to another, and also when it rotates how can i make it to attach the next model after rotation.

0

Share this post


Link to post
Share on other sites

You move objects in Unity by setting their transform's position. eg:

 

go.transform.position = new Vector3(1,2,3);
 

 

To attach one model to another you set the second object's parent to be the first object. Then you can set its position relative to that one.

 

It's best if you read through all the Unity scripting guide and reference - it's long, but most of what you need is in there. The stuff about transforms is here: http://docs.unity3d.com/Documentation/Components/class-Transform.html

0

Share this post


Link to post
Share on other sites

You move objects in Unity by setting their transform's position. eg:

 

go.transform.position = new Vector3(1,2,3);
 

 

To attach one model to another you set the second object's parent to be the first object. Then you can set its position relative to that one.

 

It's best if you read through all the Unity scripting guide and reference - it's long, but most of what you need is in there. The stuff about transforms is here: http://docs.unity3d.com/Documentation/Components/class-Transform.html

 

 

ya i use the transform thing before, but i din't add the new vector3, i will try it and say about it

 

 

 

This is such a common use-case that Unity's Instantiate() method actually supports it directly (note the form of Instantiate() that takes 3 arguments).

thanks i will see it

0

Share this post


Link to post
Share on other sites

my question i show can i generate a path like temple run but i don't want it to be endless, i want it to be end it some distance, or after some tiles, and at the end it will take the user to the next level, so how do i dgenerate the prefabs in the correct order without touching each other

0

Share this post


Link to post
Share on other sites

Yes, we saw the original question, but we gave you the information on how to proceed. Instantiate each prefab at the position you want it to be in. To avoid them touching each other you need to know how wide they are, so you can position each one at least that far from the previous. Have you tried that?

1

Share this post


Link to post
Share on other sites

I recently created a similar script to generate random towers.  Each piece of the tower is 1 level.  The object's origin is 1 connecting point, I then place an empty GameObject in the prefab as another connecting point.  The script cycles through each prefab, finds the empty GameObject, and instantiates the next prefab within it.  

 

The end result is a long list of parents with their children.  The base prefab of the tower is the upper most parent and each level up the tower is a child of the last piece.  You can have the script run in a for loop to determine how many modules you want to link end-to-end to control distance.

 

I think your original question asks (correct me if I'm wrong), how do I keep my path from making 3 right turns and colliding with itself?    Have a variable track how many right or left turns were made, don't instantiate a third right turn if 2 have already been made, force a left turn module to be placed.

 

Hope this helps.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0