Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 The_Icaruz · Jun 08, 2018 at 06:00 AM · unity 2dtilemaptiles

"Random" Rule Tile

Hello everybody, at the moment I'm making a 2D Platformer with Unity 2017 and work with Tilemaps and Ruletiles.

To my question : I know I can make Rule Tiles but is it possible to set up a Rule Tile and define varieties of lets say the straigth Ground Tile?

To clarify, when I'm drawing a "straight Ground Tile" line with my Rule Tile is it possible to say there are three different "straight Ground Tiles" wich the Rule Tile should randomly pick from so I have a little variety of my Layout to break the monotony of my Level.

I hope you understand my question and could help me with my problem.

Thanks in advance.

Edit : I'm using the 2d-extras asset and want to use the rule tile and the random tile function at the same time.

Comment
Add comment · Show 4
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 Harinezumi · Jun 08, 2018 at 12:23 PM 0
Share

Check out the 2d-extras for Tile$$anonymous$$aps made by Unity. It includes a Random rule tile, I think that's what you want. I haven't used it, so don't know how it works, but check out this tutorial from Unity, they explain how to use it starting from about 0:50.

avatar image The_Icaruz Harinezumi · Jun 08, 2018 at 12:25 PM 0
Share

I use the 2d-extras but my question is if i can use the rule tile with the function of the rule tile and random tile function.

avatar image Harinezumi The_Icaruz · Jun 08, 2018 at 12:36 PM 0
Share

Sorry, I haven't used tilemaps myself, so I don't know. I just thought you wanted the RandomTile.

avatar image DearUnityPleaseAddSerializableDictionaries · Apr 13, 2019 at 12:28 AM 0
Share

Hey did you manage to make it? I really wanted one as well. $$anonymous$$aybe we can make it together on GitHub.

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by tormentoarmagedoom · Jun 08, 2018 at 11:12 AM

I see the word "Random" in the title, but there is not in the text.. I understand, you have 3 flat tiles, and want to select only one of them each time in a random way.

Then, you only need to create an array with all 3 tiles. and select one at random

Create an array, called FlatTilesArray

 public GameObject[] FlatTilesArray = new GameObject[3];

Assign the tiles in the inspector, and now, you just need to use Random.Range to select one.

 SelectedTile = FlatTilesArray[Random.Range(0,FlatTilesArray.Lenght);

Every time will pick one at random from index 0 to index 2

Bye!!

Comment
Add comment · Show 2 · 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 The_Icaruz · Jun 08, 2018 at 12:13 PM 0
Share

Okay I see what you are saying but I'm not sure if I can change the script from the 2d extras asset that easy. At the moment I can't try it, but as soon as I'm home I will change the script and try if this works.

Thank you for your help.

Edit: I changed the text so there is the word random in my question. ^^

avatar image FrickinSilly · Mar 12, 2021 at 04:03 PM 0
Share

This answer merely describes how to pick randomly from an array in C# and does not answer the OP's question. Why is it marked "Best Answer?"

The question was correctly answered below by btouellette

avatar image
7

Answer by btouellette · Feb 13, 2020 at 06:16 AM

On a RuleTile for a specific Sprite you can change Output from Single to Random and it will allow you to define a list of variant tiles that will be randomly chosen between.

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 Olleluk · Aug 18, 2020 at 04:25 PM 0
Share

Thank you man, this really helped me with my top down game, now I can randomise the grass tiles.

avatar image
1

Answer by raiszoliver · Apr 08, 2021 at 04:36 PM

There is an option called Random in the Rule Tile's inspector, in the Output dropdown list. I suppose that's what you meant. Also, there's a brush called Random brush to randomly place (static) tiles.

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

91 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

TileMap won't show up in 2d object in heirarchy. 0 Answers

My character is floating. How do I fix this? 1 Answer

How would I instantiate rooms made of a ruletile as part of a rogue-like random level generation system and have the ruletile affected by the other spawned rooms rule tiles? 0 Answers

How can I get the world position of a Tile? 2 Answers

[Solved] Isometric Rule Tiles not Following Guidelines. 0 Answers


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