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 Tekniko · Mar 13, 2015 at 07:26 AM · c#spritevector3

Roguelike Tutorial Expansion of Layout

Hey there, I have finished the Roguelike Tutorial on this site and I have learned a lot. Now I am trying to figure out how to expand on this game and learn even more. The first thing I wanted to do was expand the layout width and height.

My obvious first thought was to change the variables that control how many rows and columns there are.

 public int columns = 8;   //Number of columns in our game board.
 public int rows = 8;   //Number of rows in our game board.

If you take a look at the original code, the writer even commented what these two variables do. Unfortunately, changing these values has no effect. I looked throughout the rest of the code and I just can't seem to find any other way to control the board layout.

This is the last piece of code that may be helpful in answering this question.

     void BoardSetup ()
     {
     //Instantiate Board and set boardHolder to its transform.
     boardHolder = new GameObject ("Board").transform;
                 
     //Loop along x axis, starting from -1 (to fill corner) with floor or outerwall edge tiles.
     for(int x = -1; x < columns + 1; x++)
     {
     //Loop along y axis, starting from -1 to place floor or outerwall tiles.
     for(int y = -1; y < rows + 1; y++)
     {  //Choose a random tile from our array of floor tile prefabs and prepare to instantiate it.
     GameObject toInstantiate = floorTiles[Random.Range (0,floorTiles.Length)];  //Check if we current position is at board edge, if so choose a random outer wall prefab from our array of outer wall tiles.
     if(x == -1 || x == columns || y == -1 || y == rows)
     toInstantiate = outerWallTiles [Random.Range (0, outerWallTiles.Length)];  //Instantiate the GameObject instance using the prefab chosen for toInstantiate at the Vector3 corresponding to current grid position in loop, cast it to GameObject.
 GameObject instance = Instantiate (toInstantiate, new Vector3 (x, y, 0f), Quaternion.identity) as GameObject;
                         
     //Set the parent of our newly instantiated object instance to boardHolder, this is just organizational to avoid cluttering hierarchy.
    instance.transform.SetParent (boardHolder);
       }
      }
     }

By the way, tags are pointless if you can't create your own. How are tutorial, rogue, layout, and board not accepted tags?

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Mar 13, 2015 at 07:47 AM

Those are the variables that you change to alter the width and height. But they're public variables, so you set them in the inspector not in code. Highlight the GameManager prefab as shown:

alt text

And, while "tutorial" should perhaps be a tag, tags become pointless if you let people define their own - we'd just get an infinite list. You already have the ability to search the whole site for particular words, tags are designed to group questions into common categories.


roguelike.jpg (134.1 kB)
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 Tekniko · Mar 14, 2015 at 03:55 PM 0
Share

Thank you for the response. I actually figured this out yesterday but it took nearly 24 hours for this question to be posted and so I thought it was denied.

Upon expanding my board layout I realize that the board is now offset ins$$anonymous$$d of centred. How would I go about fixing this? I tried adjusting the camera location but that just made things worse.

avatar image
0

Answer by TheOneRaven · May 14, 2017 at 12:11 PM

@Tekniko Hey! I was wondering if you figured out how to re-center the offset board after altering its size. I can't seem to figure this one out :/

Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

LocalScale not working idealy 1 Answer

Instantiated Sprite is not rendering. 1 Answer

C# Transform modification. 1 Answer


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